fs/autofs/root.c
Source file repositories/reference/linux-study-clean/fs/autofs/root.c
File Facts
- System
- Linux kernel
- Corpus path
fs/autofs/root.c- Extension
.c- Size
- 24917 bytes
- Lines
- 932
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/compat.hlinux/string.hautofs_i.h
Detected Declarations
function autofs_del_activefunction autofs_dir_openfunction autofs_dentry_releasefunction autofs_mount_waitfunction do_expire_waitfunction unhashedfunction path_is_mountpointfunction autofs_d_managefunction autofs_dir_permissionfunction autofs_dir_symlinkfunction autofs_dir_rmdirfunction autofs_set_leaf_automount_flagsfunction autofs_clear_leaf_automount_flagsfunction autofs_dir_rmdirfunction autofs_compat_get_set_timeoutfunction autofs_get_set_timeoutfunction autofs_get_protoverfunction autofs_get_protosubverfunction autofs_ask_umountfunction is_autofs_dentryfunction ioctlfunction autofs_root_ioctlfunction autofs_root_compat_ioctl
Annotated Snippet
const struct file_operations autofs_root_operations = {
.open = dcache_dir_open,
.release = dcache_dir_close,
.read = generic_read_dir,
.iterate_shared = dcache_readdir,
.llseek = dcache_dir_lseek,
.unlocked_ioctl = autofs_root_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = autofs_root_compat_ioctl,
#endif
};
const struct file_operations autofs_dir_operations = {
.open = autofs_dir_open,
.release = dcache_dir_close,
.read = generic_read_dir,
.iterate_shared = dcache_readdir,
.llseek = dcache_dir_lseek,
};
const struct inode_operations autofs_dir_inode_operations = {
.lookup = autofs_lookup,
.permission = autofs_dir_permission,
.unlink = autofs_dir_unlink,
.symlink = autofs_dir_symlink,
.mkdir = autofs_dir_mkdir,
.rmdir = autofs_dir_rmdir,
};
const struct dentry_operations autofs_dentry_operations = {
.d_automount = autofs_d_automount,
.d_manage = autofs_d_manage,
.d_release = autofs_dentry_release,
};
static void autofs_del_active(struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
struct autofs_info *ino;
ino = autofs_dentry_ino(dentry);
spin_lock(&sbi->lookup_lock);
list_del_init(&ino->active);
spin_unlock(&sbi->lookup_lock);
}
static int autofs_dir_open(struct inode *inode, struct file *file)
{
struct dentry *dentry = file->f_path.dentry;
struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
struct autofs_info *ino = autofs_dentry_ino(dentry);
pr_debug("file=%p dentry=%p %pd\n", file, dentry, dentry);
if (autofs_oz_mode(sbi))
goto out;
/*
* An empty directory in an autofs file system is always a
* mount point. The daemon must have failed to mount this
* during lookup so it doesn't exist. This can happen, for
* example, if user space returns an incorrect status for a
* mount request. Otherwise we're doing a readdir on the
* autofs file system so just let the libfs routines handle
* it.
*/
spin_lock(&sbi->lookup_lock);
if (!path_is_mountpoint(&file->f_path) && autofs_empty(ino)) {
spin_unlock(&sbi->lookup_lock);
return -ENOENT;
}
spin_unlock(&sbi->lookup_lock);
out:
return dcache_dir_open(inode, file);
}
static void autofs_dentry_release(struct dentry *de)
{
struct autofs_info *ino = autofs_dentry_ino(de);
struct autofs_sb_info *sbi = autofs_sbi(de->d_sb);
pr_debug("releasing %p\n", de);
if (!ino)
return;
if (sbi) {
spin_lock(&sbi->lookup_lock);
if (!list_empty(&ino->active))
Annotation
- Immediate include surface: `linux/capability.h`, `linux/compat.h`, `linux/string.h`, `autofs_i.h`.
- Detected declarations: `function autofs_del_active`, `function autofs_dir_open`, `function autofs_dentry_release`, `function autofs_mount_wait`, `function do_expire_wait`, `function unhashed`, `function path_is_mountpoint`, `function autofs_d_manage`, `function autofs_dir_permission`, `function autofs_dir_symlink`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.