fs/afs/proc.c
Source file repositories/reference/linux-study-clean/fs/afs/proc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/afs/proc.c- Extension
.c- Size
- 18966 bytes
- Lines
- 787
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/module.hlinux/proc_fs.hlinux/seq_file.hlinux/sched.hlinux/uaccess.hinternal.h
Detected Declarations
struct afs_vl_seq_net_privatefunction afs_proc_cells_showfunction afs_proc_cells_stopfunction afs_proc_cells_writefunction afs_proc_addr_prefs_showfunction afs_proc_rootcell_showfunction afs_proc_rootcell_writefunction afs_proc_cell_volumes_showfunction afs_proc_cell_volumes_stopfunction afs_proc_cell_vlservers_showfunction afs_proc_cell_vlservers_stopfunction afs_proc_servers_showfunction afs_proc_servers_stopfunction afs_proc_sysname_showfunction afs_proc_sysname_stopfunction afs_proc_sysname_writefunction afs_put_sysnamesfunction afs_proc_stats_showfunction afs_proc_cell_setupfunction afs_proc_cell_removefunction afs_proc_initfunction afs_proc_cleanup
Annotated Snippet
struct afs_vl_seq_net_private {
struct seq_net_private seq; /* Must be first */
struct afs_vlserver_list *vllist;
};
static inline struct afs_net *afs_seq2net(struct seq_file *m)
{
return afs_net(seq_file_net(m));
}
static inline struct afs_net *afs_seq2net_single(struct seq_file *m)
{
return afs_net(seq_file_single_net(m));
}
/*
* Display the list of cells known to the namespace.
*/
static int afs_proc_cells_show(struct seq_file *m, void *v)
{
struct afs_vlserver_list *vllist;
struct afs_cell *cell;
if (v == SEQ_START_TOKEN) {
/* display header on line 1 */
seq_puts(m, "USE ACT TTL SV ST NAME\n");
return 0;
}
cell = list_entry(v, struct afs_cell, proc_link);
vllist = rcu_dereference(cell->vl_servers);
/* display one cell per line on subsequent lines */
seq_printf(m, "%3u %3u %6lld %2u %2u %s\n",
refcount_read(&cell->ref),
atomic_read(&cell->active),
cell->dns_expiry - ktime_get_real_seconds(),
vllist ? vllist->nr_servers : 0,
cell->state,
cell->name);
return 0;
}
static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
__acquires(rcu)
{
rcu_read_lock();
return seq_hlist_start_head_rcu(&afs_seq2net(m)->proc_cells, *_pos);
}
static void *afs_proc_cells_next(struct seq_file *m, void *v, loff_t *pos)
{
return seq_hlist_next_rcu(v, &afs_seq2net(m)->proc_cells, pos);
}
static void afs_proc_cells_stop(struct seq_file *m, void *v)
__releases(rcu)
{
rcu_read_unlock();
}
static const struct seq_operations afs_proc_cells_ops = {
.start = afs_proc_cells_start,
.next = afs_proc_cells_next,
.stop = afs_proc_cells_stop,
.show = afs_proc_cells_show,
};
/*
* handle writes to /proc/fs/afs/cells
* - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
*/
static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
{
struct seq_file *m = file->private_data;
struct afs_net *net = afs_seq2net(m);
char *name, *args;
int ret;
/* trim to first NL */
name = memchr(buf, '\n', size);
if (name)
*name = 0;
/* split into command, name and argslist */
name = strchr(buf, ' ');
if (!name)
goto inval;
do {
*name++ = 0;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `linux/sched.h`, `linux/uaccess.h`, `internal.h`.
- Detected declarations: `struct afs_vl_seq_net_private`, `function afs_proc_cells_show`, `function afs_proc_cells_stop`, `function afs_proc_cells_write`, `function afs_proc_addr_prefs_show`, `function afs_proc_rootcell_show`, `function afs_proc_rootcell_write`, `function afs_proc_cell_volumes_show`, `function afs_proc_cell_volumes_stop`, `function afs_proc_cell_vlservers_show`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.