fs/dlm/debug_fs.c
Source file repositories/reference/linux-study-clean/fs/dlm/debug_fs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/dlm/debug_fs.c- Extension
.c- Size
- 19796 bytes
- Lines
- 826
- 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.
- 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/pagemap.hlinux/seq_file.hlinux/init.hlinux/ctype.hlinux/debugfs.hlinux/slab.hdlm_internal.hmidcomms.hlock.hast.h
Detected Declarations
function print_format1_lockfunction print_format1function print_format2_lockfunction print_format2function list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction print_format3_lockfunction print_format3function list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction print_format4function table_seq_showfunction table_seq_stopfunction table_open1function table_open2function table_write2function table_open3function table_open4function waiters_readfunction list_for_each_entryfunction waiters_writefunction dlm_delete_debug_filefunction dlm_state_showfunction dlm_flags_showfunction dlm_send_queue_cnt_showfunction dlm_version_showfunction dlm_rawmsg_writefunction dlm_delete_debug_comms_filefunction dlm_create_debug_filefunction dlm_register_debugfsfunction dlm_unregister_debugfs
Annotated Snippet
static const struct file_operations format1_fops;
static const struct file_operations format2_fops;
static const struct file_operations format3_fops;
static const struct file_operations format4_fops;
static int table_open1(struct inode *inode, struct file *file)
{
struct seq_file *seq;
int ret;
ret = seq_open(file, &format1_seq_ops);
if (ret)
return ret;
seq = file->private_data;
seq->private = inode->i_private; /* the dlm_ls */
return 0;
}
static int table_open2(struct inode *inode, struct file *file)
{
struct seq_file *seq;
int ret;
ret = seq_open(file, &format2_seq_ops);
if (ret)
return ret;
seq = file->private_data;
seq->private = inode->i_private; /* the dlm_ls */
return 0;
}
static ssize_t table_write2(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
struct seq_file *seq = file->private_data;
int n, len, lkb_nodeid, lkb_status, error;
char name[DLM_RESNAME_MAXLEN + 1] = {};
struct dlm_ls *ls = seq->private;
unsigned int lkb_flags;
char buf[256] = {};
uint32_t lkb_id;
if (copy_from_user(buf, user_buf,
min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT;
n = sscanf(buf, "%x %" __stringify(DLM_RESNAME_MAXLEN) "s %x %d %d",
&lkb_id, name, &lkb_flags, &lkb_nodeid, &lkb_status);
if (n != 5)
return -EINVAL;
len = strnlen(name, DLM_RESNAME_MAXLEN);
error = dlm_debug_add_lkb(ls, lkb_id, name, len, lkb_flags,
lkb_nodeid, lkb_status);
if (error)
return error;
return count;
}
static int table_open3(struct inode *inode, struct file *file)
{
struct seq_file *seq;
int ret;
ret = seq_open(file, &format3_seq_ops);
if (ret)
return ret;
seq = file->private_data;
seq->private = inode->i_private; /* the dlm_ls */
return 0;
}
static int table_open4(struct inode *inode, struct file *file)
{
struct seq_file *seq;
int ret;
ret = seq_open(file, &format4_seq_ops);
if (ret)
return ret;
seq = file->private_data;
seq->private = inode->i_private; /* the dlm_ls */
return 0;
}
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/seq_file.h`, `linux/init.h`, `linux/ctype.h`, `linux/debugfs.h`, `linux/slab.h`, `dlm_internal.h`, `midcomms.h`.
- Detected declarations: `function print_format1_lock`, `function print_format1`, `function print_format2_lock`, `function print_format2`, `function list_for_each_entry`, `function list_for_each_entry`, `function list_for_each_entry`, `function print_format3_lock`, `function print_format3`, `function list_for_each_entry`.
- 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.