fs/afs/dir.c
Source file repositories/reference/linux-study-clean/fs/afs/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/afs/dir.c- Extension
.c- Size
- 60952 bytes
- Lines
- 2231
- 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/kernel.hlinux/fs.hlinux/namei.hlinux/pagemap.hlinux/swap.hlinux/ctype.hlinux/sched.hlinux/iversion.hlinux/iov_iter.hlinux/task_io_accounting_ops.hinternal.hafs_fs.hxdr_fs.h
Detected Declarations
struct afs_lookup_one_cookiestruct afs_lookup_cookiestruct afs_dir_iteration_ctxfunction afs_dir_unuse_cookiefunction afs_dir_dump_stepfunction afs_dir_dumpfunction afs_dir_check_blockfunction afs_dir_check_stepfunction afs_dir_checkfunction afs_dir_openfunction afs_do_read_singlefunction afs_read_singlefunction afs_read_dirfunction test_bitfunction afs_dir_iterate_blockfunction afs_dir_iterate_stepfunction afs_dir_iterate_contentsfunction afs_dir_iteratefunction afs_readdirfunction afs_lookup_one_filldirfunction afs_do_lookup_onefunction afs_lookup_filldirfunction afs_do_lookup_successfunction afs_server_supports_ibulkfunction afs_d_revalidate_rcufunction afs_d_revalidatefunction unhashedfunction afs_d_iputfunction afs_d_releasefunction afs_check_for_remote_deletionfunction afs_vnode_new_inodefunction afs_create_successfunction afs_create_edit_dirfunction afs_create_putfunction afs_dir_remove_subdirfunction afs_rmdir_successfunction afs_rmdir_edit_dirfunction afs_rmdir_putfunction afs_rmdirfunction afs_dir_remove_linkfunction afs_unlink_successfunction afs_unlink_edit_dirfunction afs_unlink_putfunction afs_unlinkfunction afs_createfunction afs_link_successfunction afs_link_putfunction afs_link
Annotated Snippet
const struct file_operations afs_dir_file_operations = {
.open = afs_dir_open,
.release = afs_release,
.iterate_shared = afs_readdir,
.lock = afs_lock,
.llseek = generic_file_llseek,
};
const struct inode_operations afs_dir_inode_operations = {
.create = afs_create,
.lookup = afs_lookup,
.link = afs_link,
.unlink = afs_unlink,
.symlink = afs_symlink,
.mkdir = afs_mkdir,
.rmdir = afs_rmdir,
.rename = afs_rename,
.permission = afs_permission,
.getattr = afs_getattr,
.setattr = afs_setattr,
};
const struct address_space_operations afs_dir_aops = {
.writepages = afs_dir_writepages,
};
const struct dentry_operations afs_fs_dentry_operations = {
.d_revalidate = afs_d_revalidate,
.d_delete = afs_d_delete,
.d_release = afs_d_release,
.d_automount = afs_d_automount,
.d_iput = afs_d_iput,
};
struct afs_lookup_one_cookie {
struct dir_context ctx;
struct qstr name;
bool found;
struct afs_fid fid;
};
struct afs_lookup_cookie {
struct dir_context ctx;
struct qstr name;
unsigned short nr_fids;
struct afs_fid fids[50];
};
static void afs_dir_unuse_cookie(struct afs_vnode *dvnode, int ret)
{
if (ret == 0) {
struct afs_vnode_cache_aux aux;
loff_t i_size = i_size_read(&dvnode->netfs.inode);
afs_set_cache_aux(dvnode, &aux);
fscache_unuse_cookie(afs_vnode_cache(dvnode), &aux, &i_size);
} else {
fscache_unuse_cookie(afs_vnode_cache(dvnode), NULL, NULL);
}
}
/*
* Iterate through a kmapped directory segment, dumping a summary of
* the contents.
*/
static size_t afs_dir_dump_step(void *iter_base, size_t progress, size_t len,
void *priv, void *priv2)
{
do {
union afs_xdr_dir_block *block = iter_base;
pr_warn("[%05zx] %32phN\n", progress, block);
iter_base += AFS_DIR_BLOCK_SIZE;
progress += AFS_DIR_BLOCK_SIZE;
len -= AFS_DIR_BLOCK_SIZE;
} while (len > 0);
return len;
}
/*
* Dump the contents of a directory.
*/
static void afs_dir_dump(struct afs_vnode *dvnode)
{
struct iov_iter iter;
unsigned long long i_size = i_size_read(&dvnode->netfs.inode);
pr_warn("DIR %llx:%llx is=%llx\n",
dvnode->fid.vid, dvnode->fid.vnode, i_size);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/fs.h`, `linux/namei.h`, `linux/pagemap.h`, `linux/swap.h`, `linux/ctype.h`, `linux/sched.h`, `linux/iversion.h`.
- Detected declarations: `struct afs_lookup_one_cookie`, `struct afs_lookup_cookie`, `struct afs_dir_iteration_ctx`, `function afs_dir_unuse_cookie`, `function afs_dir_dump_step`, `function afs_dir_dump`, `function afs_dir_check_block`, `function afs_dir_check_step`, `function afs_dir_check`, `function afs_dir_open`.
- 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.