fs/ext4/namei.c
Source file repositories/reference/linux-study-clean/fs/ext4/namei.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/namei.c- Extension
.c- Size
- 113654 bytes
- Lines
- 4250
- 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/pagemap.hlinux/time.hlinux/fcntl.hlinux/stat.hlinux/string.hlinux/quotaops.hlinux/buffer_head.hlinux/bio.hlinux/iversion.hlinux/unicode.hext4.hext4_jbd2.hxattr.hacl.htrace/events/ext4.h
Detected Declarations
struct fake_direntstruct dx_countlimitstruct dx_entrystruct dx_rootstruct dx_root_infostruct dx_nodestruct dx_framestruct dx_map_entrystruct dx_tailstruct statsstruct ext4_renamentfunction Copyrightfunction ext4_initialize_dirent_tailfunction ext4_dirblock_csumfunction __warn_no_space_for_csumfunction ext4_dirblock_csum_verifyfunction ext4_dirblock_csum_setfunction ext4_handle_dirty_dirblockfunction ext4_dx_csumfunction ext4_dx_csum_verifyfunction EXT4_BLOCK_SIZEfunction ext4_dx_csum_setfunction EXT4_BLOCK_SIZEfunction ext4_handle_dirty_dx_nodefunction ext4_next_entryfunction dx_get_blockfunction dx_set_blockfunction dx_get_hashfunction dx_set_hashfunction dx_get_countfunction dx_get_limitfunction dx_set_countfunction dx_set_limitfunction dx_root_limitfunction dx_node_limitfunction dx_show_indexfunction dx_show_leaffunction dx_show_entriesfunction htree_rep_invariant_checkfunction htree_rep_invariant_checkfunction dx_releasefunction ext4_htree_next_blockfunction htree_dirblock_to_treefunction ext4_htree_fill_treefunction search_dirblockfunction dx_make_mapfunction dx_sort_mapfunction dx_insert_block
Annotated Snippet
struct dx_tail {
u32 dt_reserved;
__le32 dt_checksum; /* crc32c(uuid+inum+dirblock) */
};
static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
struct ext4_filename *fname,
struct ext4_dir_entry_2 **res_dir);
static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
struct inode *dir, struct inode *inode);
/* checksumming functions */
void ext4_initialize_dirent_tail(struct buffer_head *bh,
unsigned int blocksize)
{
struct ext4_dir_entry_tail *t = EXT4_DIRENT_TAIL(bh->b_data, blocksize);
memset(t, 0, sizeof(struct ext4_dir_entry_tail));
t->det_rec_len = ext4_rec_len_to_disk(
sizeof(struct ext4_dir_entry_tail), blocksize);
t->det_reserved_ft = EXT4_FT_DIR_CSUM;
}
/* Walk through a dirent block to find a checksum "dirent" at the tail */
static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
struct buffer_head *bh)
{
struct ext4_dir_entry_tail *t;
int blocksize = EXT4_BLOCK_SIZE(inode->i_sb);
#ifdef PARANOID
struct ext4_dir_entry *d, *top;
d = (struct ext4_dir_entry *)bh->b_data;
top = (struct ext4_dir_entry *)(bh->b_data +
(blocksize - sizeof(struct ext4_dir_entry_tail)));
while (d < top && ext4_rec_len_from_disk(d->rec_len, blocksize))
d = (struct ext4_dir_entry *)(((void *)d) +
ext4_rec_len_from_disk(d->rec_len, blocksize));
if (d != top)
return NULL;
t = (struct ext4_dir_entry_tail *)d;
#else
t = EXT4_DIRENT_TAIL(bh->b_data, EXT4_BLOCK_SIZE(inode->i_sb));
#endif
if (t->det_reserved_zero1 ||
(ext4_rec_len_from_disk(t->det_rec_len, blocksize) !=
sizeof(struct ext4_dir_entry_tail)) ||
t->det_reserved_zero2 ||
t->det_reserved_ft != EXT4_FT_DIR_CSUM)
return NULL;
return t;
}
static __le32 ext4_dirblock_csum(struct inode *inode, void *dirent, int size)
{
struct ext4_inode_info *ei = EXT4_I(inode);
__u32 csum;
csum = ext4_chksum(ei->i_csum_seed, (__u8 *)dirent, size);
return cpu_to_le32(csum);
}
#define warn_no_space_for_csum(inode) \
__warn_no_space_for_csum((inode), __func__, __LINE__)
static void __warn_no_space_for_csum(struct inode *inode, const char *func,
unsigned int line)
{
__ext4_warning_inode(inode, func, line,
"No space for directory leaf checksum. Please run e2fsck -D.");
}
int ext4_dirblock_csum_verify(struct inode *inode, struct buffer_head *bh)
{
struct ext4_dir_entry_tail *t;
if (!ext4_has_feature_metadata_csum(inode->i_sb))
return 1;
t = get_dirent_tail(inode, bh);
if (!t) {
warn_no_space_for_csum(inode);
return 0;
}
Annotation
- Immediate include surface: `linux/fs.h`, `linux/pagemap.h`, `linux/time.h`, `linux/fcntl.h`, `linux/stat.h`, `linux/string.h`, `linux/quotaops.h`, `linux/buffer_head.h`.
- Detected declarations: `struct fake_dirent`, `struct dx_countlimit`, `struct dx_entry`, `struct dx_root`, `struct dx_root_info`, `struct dx_node`, `struct dx_frame`, `struct dx_map_entry`, `struct dx_tail`, `struct stats`.
- 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.