fs/adfs/dir.c
Source file repositories/reference/linux-study-clean/fs/adfs/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/adfs/dir.c- Extension
.c- Size
- 9756 bytes
- Lines
- 459
- 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.
- 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/hex.hlinux/slab.hadfs.h
Detected Declarations
function adfs_dir_copyfromfunction adfs_dir_copytofunction __adfs_dir_cleanupfunction adfs_dir_relsefunction adfs_dir_forgetfunction adfs_dir_read_buffersfunction adfs_dir_readfunction adfs_dir_read_inodefunction adfs_dir_mark_dirtyfunction adfs_dir_syncfunction adfs_object_fixupfunction adfs_iteratefunction adfs_dir_updatefunction adfs_tolowerfunction __adfs_comparefunction adfs_dir_lookup_bynamefunction adfs_hashfunction adfs_comparefunction adfs_lookup
Annotated Snippet
const struct file_operations adfs_dir_operations = {
.read = generic_read_dir,
.llseek = generic_file_llseek,
.iterate_shared = adfs_iterate,
.fsync = simple_fsync,
};
static int
adfs_hash(const struct dentry *parent, struct qstr *qstr)
{
const unsigned char *name;
unsigned long hash;
u32 len;
if (qstr->len > ADFS_SB(parent->d_sb)->s_namelen)
return -ENAMETOOLONG;
len = qstr->len;
name = qstr->name;
hash = init_name_hash(parent);
while (len--)
hash = partial_name_hash(adfs_tolower(*name++), hash);
qstr->hash = end_name_hash(hash);
return 0;
}
/*
* Compare two names, taking note of the name length
* requirements of the underlying filesystem.
*/
static int adfs_compare(const struct dentry *dentry, unsigned int len,
const char *str, const struct qstr *qstr)
{
return __adfs_compare(qstr->name, qstr->len, str, len);
}
const struct dentry_operations adfs_dentry_operations = {
.d_hash = adfs_hash,
.d_compare = adfs_compare,
};
static struct dentry *
adfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
{
struct inode *inode = NULL;
struct object_info obj;
int error;
error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj);
if (error == 0) {
/*
* This only returns NULL if get_empty_inode
* fails.
*/
inode = adfs_iget(dir->i_sb, &obj);
if (!inode)
inode = ERR_PTR(-EACCES);
} else if (error != -ENOENT) {
inode = ERR_PTR(error);
}
return d_splice_alias(inode, dentry);
}
/*
* directories can handle most operations...
*/
const struct inode_operations adfs_dir_inode_operations = {
.lookup = adfs_lookup,
.setattr = adfs_setattr,
};
Annotation
- Immediate include surface: `linux/hex.h`, `linux/slab.h`, `adfs.h`.
- Detected declarations: `function adfs_dir_copyfrom`, `function adfs_dir_copyto`, `function __adfs_dir_cleanup`, `function adfs_dir_relse`, `function adfs_dir_forget`, `function adfs_dir_read_buffers`, `function adfs_dir_read`, `function adfs_dir_read_inode`, `function adfs_dir_mark_dirty`, `function adfs_dir_sync`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.