fs/ntfs3/attrib.c
Source file repositories/reference/linux-study-clean/fs/ntfs3/attrib.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs3/attrib.c- Extension
.c- Size
- 62718 bytes
- Lines
- 2777
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/slab.hlinux/kernel.hdebug.hntfs.hntfs_fs.h
Detected Declarations
function Copyrightfunction attr_load_runsfunction run_deallocate_exfunction attr_allocate_clustersfunction lockedfunction attr_set_size_resfunction attr_set_size_exfunction attr_data_get_blockfunction attr_data_get_block_lockedfunction clusterfunction attr_data_write_residentfunction attr_load_runs_vcnfunction attr_load_runs_rangefunction attr_wof_frame_infofunction attr_is_frame_compressedfunction attr_allocate_framefunction attr_collapse_rangefunction attr_punch_holefunction attr_insert_rangefunction attr_force_nonresident
Annotated Snippet
if (!clen) {
err = -EINVAL;
goto out;
}
if (lcn != SPARSE_LCN) {
if (sbi) {
/* mark bitmap range [lcn + clen) as free and trim clusters. */
mark_as_free_ex(sbi, lcn, clen, trim);
if (run_da) {
CLST da_len;
if (!run_remove_range(run_da, vcn, clen,
&da_len)) {
err = -ENOMEM;
goto failed;
}
ntfs_sub_da(sbi, da_len);
}
}
dn += clen;
}
len -= clen;
if (!len)
break;
vcn_next = vcn + clen;
if (!run_get_entry(run, ++idx, &vcn, &lcn, &clen) ||
vcn != vcn_next) {
/* Save memory - don't load entire run. */
goto failed;
}
}
out:
if (done)
*done += dn;
return err;
}
/*
* attr_allocate_clusters - Find free space, mark it as used and store in @run.
*/
int attr_allocate_clusters(struct ntfs_sb_info *sbi, struct runs_tree *run,
struct runs_tree *run_da, CLST vcn, CLST lcn,
CLST len, CLST *pre_alloc, enum ALLOCATE_OPT opt,
CLST *alen, const size_t fr, CLST *new_lcn,
CLST *new_len)
{
int err;
CLST flen, vcn0 = vcn, pre = pre_alloc ? *pre_alloc : 0;
size_t cnt = run->count;
for (;;) {
err = ntfs_look_for_free_space(sbi, lcn, len + pre, &lcn, &flen,
opt);
if (err == -ENOSPC && pre) {
pre = 0;
if (pre_alloc)
*pre_alloc = 0;
continue;
}
if (err == -ENOSPC && new_len && vcn - vcn0) {
/* Keep already allocated clusters. */
*alen = vcn - vcn0;
return 0;
}
if (err)
goto out;
if (vcn == vcn0) {
/* Return the first fragment. */
if (new_lcn)
*new_lcn = lcn;
if (new_len)
*new_len = flen;
}
/* Add new fragment into run storage. */
if (!run_add_entry(run, vcn, lcn, flen, opt & ALLOCATE_MFT)) {
undo_alloc:
/* Undo last 'ntfs_look_for_free_space' */
mark_as_free_ex(sbi, lcn, len, false);
err = -ENOMEM;
goto out;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/slab.h`, `linux/kernel.h`, `debug.h`, `ntfs.h`, `ntfs_fs.h`.
- Detected declarations: `function Copyright`, `function attr_load_runs`, `function run_deallocate_ex`, `function attr_allocate_clusters`, `function locked`, `function attr_set_size_res`, `function attr_set_size_ex`, `function attr_data_get_block`, `function attr_data_get_block_locked`, `function cluster`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.