fs/ntfs3/index.c
Source file repositories/reference/linux-study-clean/fs/ntfs3/index.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs3/index.c- Extension
.c- Size
- 58857 bytes
- Lines
- 2753
- 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/blkdev.hlinux/buffer_head.hlinux/fs.hlinux/kernel.hdebug.hntfs.hntfs_fs.h
Detected Declarations
struct bmp_buffunction cmp_fnamesfunction cmp_uintfunction cmp_sdhfunction cmp_uintsfunction get_cmp_funcfunction bmp_buf_getfunction bmp_buf_putfunction indx_mark_usedfunction indx_mark_freefunction functionfunction scan_for_freefunction indx_find_freefunction scan_for_usedfunction indx_used_bitfunction index_hdr_checkfunction index_buf_checkfunction fnd_clearfunction fnd_pushfunction fnd_is_emptyfunction indx_clearfunction indx_initfunction offsetoffunction indx_writefunction indx_read_rafunction indx_findfunction indx_find_sortfunction indx_find_rawfunction indx_create_allocatefunction indx_add_allocatefunction indx_insert_into_rootfunction mi_resize_attrfunction indx_insert_into_bufferfunction indx_insert_entryfunction indx_shrinkfunction indx_free_childrenfunction indx_get_entry_to_replacefunction indx_delete_entryfunction indx_update_dup
Annotated Snippet
struct bmp_buf {
struct ATTRIB *b;
struct mft_inode *mi;
struct buffer_head *bh;
ulong *buf;
size_t bit;
u32 nbits;
u64 new_valid;
};
static int bmp_buf_get(struct ntfs_index *indx, struct ntfs_inode *ni,
size_t bit, struct bmp_buf *bbuf)
{
struct ATTRIB *b;
size_t data_size, valid_size, vbo, off = bit >> 3;
struct ntfs_sb_info *sbi = ni->mi.sbi;
CLST vcn = off >> sbi->cluster_bits;
struct ATTR_LIST_ENTRY *le = NULL;
struct buffer_head *bh;
struct super_block *sb;
u32 blocksize;
const struct INDEX_NAMES *in = &s_index_names[indx->type];
bbuf->bh = NULL;
b = ni_find_attr(ni, NULL, &le, ATTR_BITMAP, in->name, in->name_len,
&vcn, &bbuf->mi);
bbuf->b = b;
if (!b)
return -EINVAL;
if (!b->non_res) {
data_size = le32_to_cpu(b->res.data_size);
if (off >= data_size)
return -EINVAL;
bbuf->buf = (ulong *)resident_data(b);
bbuf->bit = 0;
bbuf->nbits = data_size * 8;
return 0;
}
data_size = le64_to_cpu(b->nres.data_size);
if (WARN_ON(off >= data_size)) {
/* Looks like filesystem error. */
return -EINVAL;
}
valid_size = le64_to_cpu(b->nres.valid_size);
bh = ntfs_bread_run(sbi, &indx->bitmap_run, off);
if (!bh)
return -EIO;
if (IS_ERR(bh))
return PTR_ERR(bh);
bbuf->bh = bh;
wait_on_buffer(bh);
lock_buffer(bh);
sb = sbi->sb;
blocksize = sb->s_blocksize;
vbo = off & ~(size_t)sbi->block_mask;
bbuf->new_valid = vbo + blocksize;
if (bbuf->new_valid <= valid_size)
bbuf->new_valid = 0;
else if (bbuf->new_valid > data_size)
bbuf->new_valid = data_size;
if (vbo >= valid_size) {
memset(bh->b_data, 0, blocksize);
} else if (vbo + blocksize > valid_size) {
u32 voff = valid_size & sbi->block_mask;
memset(bh->b_data + voff, 0, blocksize - voff);
}
bbuf->buf = (ulong *)bh->b_data;
bbuf->bit = 8 * (off & ~(size_t)sbi->block_mask);
bbuf->nbits = 8 * blocksize;
return 0;
}
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/buffer_head.h`, `linux/fs.h`, `linux/kernel.h`, `debug.h`, `ntfs.h`, `ntfs_fs.h`.
- Detected declarations: `struct bmp_buf`, `function cmp_fnames`, `function cmp_uint`, `function cmp_sdh`, `function cmp_uints`, `function get_cmp_func`, `function bmp_buf_get`, `function bmp_buf_put`, `function indx_mark_used`, `function indx_mark_free`.
- 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.