fs/proc/namespaces.c
Source file repositories/reference/linux-study-clean/fs/proc/namespaces.c
File Facts
- System
- Linux kernel
- Corpus path
fs/proc/namespaces.c- Extension
.c- Size
- 4668 bytes
- Lines
- 195
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/proc_fs.hlinux/nsproxy.hlinux/ptrace.hlinux/namei.hlinux/file.hlinux/utsname.hnet/net_namespace.hlinux/ipc_namespace.hlinux/pid_namespace.hlinux/user_namespace.hinternal.h
Detected Declarations
function proc_ns_readlinkfunction proc_ns_dir_readdir
Annotated Snippet
const struct file_operations proc_ns_dir_operations = {
.read = generic_read_dir,
.iterate_shared = proc_ns_dir_readdir,
.llseek = generic_file_llseek,
};
static struct dentry *proc_ns_dir_lookup(struct inode *dir,
struct dentry *dentry, unsigned int flags)
{
struct task_struct *task = get_proc_task(dir);
const struct proc_ns_operations *const *entry, *const *last;
unsigned int len = dentry->d_name.len;
struct dentry *res = ERR_PTR(-ENOENT);
if (!task)
goto out_no_task;
last = &ns_entries[ARRAY_SIZE(ns_entries)];
for (entry = ns_entries; entry < last; entry++) {
if (strlen((*entry)->name) != len)
continue;
if (!memcmp(dentry->d_name.name, (*entry)->name, len))
break;
}
if (entry == last)
goto out;
res = proc_ns_instantiate(dentry, task, *entry);
out:
put_task_struct(task);
out_no_task:
return res;
}
const struct inode_operations proc_ns_dir_inode_operations = {
.lookup = proc_ns_dir_lookup,
.getattr = pid_getattr,
.setattr = proc_nochmod_setattr,
};
Annotation
- Immediate include surface: `linux/proc_fs.h`, `linux/nsproxy.h`, `linux/ptrace.h`, `linux/namei.h`, `linux/file.h`, `linux/utsname.h`, `net/net_namespace.h`, `linux/ipc_namespace.h`.
- Detected declarations: `function proc_ns_readlink`, `function proc_ns_dir_readdir`.
- 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.