fs/exfat/dir.c
Source file repositories/reference/linux-study-clean/fs/exfat/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/exfat/dir.c- Extension
.c- Size
- 33897 bytes
- Lines
- 1376
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/slab.hlinux/compat.hlinux/bio.hlinux/buffer_head.hlinux/filelock.hexfat_raw.hexfat_fs.h
Detected Declarations
enum exfat_validate_dentry_modefunction Copyrightfunction exfat_get_uniname_from_ext_entryfunction exfat_readdirfunction exfat_init_namebuffunction exfat_alloc_namebuffunction exfat_free_namebuffunction exfat_iteratefunction positionfunction exfat_alloc_new_dirfunction exfat_calc_num_entriesfunction exfat_get_entry_typefunction exfat_set_entry_typefunction exfat_init_stream_entryfunction exfat_init_name_entryfunction exfat_init_dir_entryfunction exfat_free_benign_secondary_clustersfunction exfat_init_ext_entryfunction exfat_remove_entriesfunction exfat_update_dir_chksumfunction exfat_put_dentry_setfunction exfat_find_locationfunction exfat_validate_entryfunction exfat_get_dentry_setfunction exfat_get_dentry_setfunction exfat_validate_empty_dentry_setfunction exfat_get_empty_dentry_setfunction exfat_reset_empty_hintfunction exfat_set_empty_hintfunction exfat_find_dir_entryfunction exfat_count_dir_entriesfunction exfat_get_volume_label_dentryfunction exfat_read_volume_labelfunction exfat_write_volume_label
Annotated Snippet
const struct file_operations exfat_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.iterate_shared = shared_exfat_iterate,
.unlocked_ioctl = exfat_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = exfat_compat_ioctl,
#endif
.fsync = exfat_file_fsync,
.setlease = generic_setlease,
};
int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu)
{
int ret;
exfat_chain_set(clu, EXFAT_EOF_CLUSTER, 0, ALLOC_NO_FAT_CHAIN);
ret = exfat_alloc_cluster(inode, 1, clu, IS_DIRSYNC(inode), false);
if (ret)
return ret;
return exfat_zeroed_cluster(inode, clu->dir);
}
int exfat_calc_num_entries(struct exfat_uni_name *p_uniname)
{
int len;
len = p_uniname->name_len;
if (len == 0)
return -EINVAL;
/* 1 file entry + 1 stream entry + name entries */
return ES_ENTRY_NUM(len);
}
unsigned int exfat_get_entry_type(struct exfat_dentry *ep)
{
if (ep->type == EXFAT_UNUSED)
return TYPE_UNUSED;
if (IS_EXFAT_DELETED(ep->type))
return TYPE_DELETED;
if (ep->type == EXFAT_INVAL)
return TYPE_INVALID;
if (IS_EXFAT_CRITICAL_PRI(ep->type)) {
if (ep->type == EXFAT_BITMAP)
return TYPE_BITMAP;
if (ep->type == EXFAT_UPCASE)
return TYPE_UPCASE;
if (ep->type == EXFAT_VOLUME)
return TYPE_VOLUME;
if (ep->type == EXFAT_FILE) {
if (le16_to_cpu(ep->dentry.file.attr) & EXFAT_ATTR_SUBDIR)
return TYPE_DIR;
return TYPE_FILE;
}
return TYPE_CRITICAL_PRI;
}
if (IS_EXFAT_BENIGN_PRI(ep->type)) {
if (ep->type == EXFAT_GUID)
return TYPE_GUID;
if (ep->type == EXFAT_PADDING)
return TYPE_PADDING;
if (ep->type == EXFAT_ACLTAB)
return TYPE_ACLTAB;
return TYPE_BENIGN_PRI;
}
if (IS_EXFAT_CRITICAL_SEC(ep->type)) {
if (ep->type == EXFAT_STREAM)
return TYPE_STREAM;
if (ep->type == EXFAT_NAME)
return TYPE_EXTEND;
if (ep->type == EXFAT_ACL)
return TYPE_ACL;
return TYPE_CRITICAL_SEC;
}
if (ep->type == EXFAT_VENDOR_EXT)
return TYPE_VENDOR_EXT;
if (ep->type == EXFAT_VENDOR_ALLOC)
return TYPE_VENDOR_ALLOC;
return TYPE_BENIGN_SEC;
}
static void exfat_set_entry_type(struct exfat_dentry *ep, unsigned int type)
{
if (type == TYPE_UNUSED) {
ep->type = EXFAT_UNUSED;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/compat.h`, `linux/bio.h`, `linux/buffer_head.h`, `linux/filelock.h`, `exfat_raw.h`, `exfat_fs.h`.
- Detected declarations: `enum exfat_validate_dentry_mode`, `function Copyright`, `function exfat_get_uniname_from_ext_entry`, `function exfat_readdir`, `function exfat_init_namebuf`, `function exfat_alloc_namebuf`, `function exfat_free_namebuf`, `function exfat_iterate`, `function position`, `function exfat_alloc_new_dir`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.