include/linux/seq_file.h
Source file repositories/reference/linux-study-clean/include/linux/seq_file.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/seq_file.h- Extension
.h- Size
- 10427 bytes
- Lines
- 336
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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/types.hlinux/string.hlinux/string_helpers.hlinux/bug.hlinux/mutex.hlinux/nodemask.hlinux/fs.hlinux/cred.h
Detected Declarations
struct seq_operationsstruct seq_filestruct seq_operationsfunction seq_has_overflowedfunction seq_get_buffunction seq_commitfunction seq_setwidthfunction seq_putsfunction seq_escape_strfunction seq_has_overflowedfunction seq_show_option
Annotated Snippet
static const struct file_operations __name ## _fops = { \
.owner = THIS_MODULE, \
.open = __name ## _open, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = seq_release, \
}
#define DEFINE_SHOW_ATTRIBUTE(__name) \
static int __name ## _open(struct inode *inode, struct file *file) \
{ \
return single_open(file, __name ## _show, inode->i_private); \
} \
\
static const struct file_operations __name ## _fops = { \
.owner = THIS_MODULE, \
.open = __name ## _open, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = single_release, \
}
#define DEFINE_SHOW_STORE_ATTRIBUTE(__name) \
static int __name ## _open(struct inode *inode, struct file *file) \
{ \
return single_open(file, __name ## _show, inode->i_private); \
} \
\
static const struct file_operations __name ## _fops = { \
.owner = THIS_MODULE, \
.open = __name ## _open, \
.read = seq_read, \
.write = __name ## _write, \
.llseek = seq_lseek, \
.release = single_release, \
}
#define DEFINE_PROC_SHOW_ATTRIBUTE(__name) \
static int __name ## _open(struct inode *inode, struct file *file) \
{ \
return single_open(file, __name ## _show, pde_data(inode)); \
} \
\
static const struct proc_ops __name ## _proc_ops = { \
.proc_open = __name ## _open, \
.proc_read = seq_read, \
.proc_lseek = seq_lseek, \
.proc_release = single_release, \
}
static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
{
#ifdef CONFIG_USER_NS
return seq->file->f_cred->user_ns;
#else
extern struct user_namespace init_user_ns;
return &init_user_ns;
#endif
}
/**
* seq_show_options - display mount options with appropriate escapes.
* @m: the seq_file handle
* @name: the mount option name
* @value: the mount option name's value, can be NULL
*/
static inline void seq_show_option(struct seq_file *m, const char *name,
const char *value)
{
seq_putc(m, ',');
seq_escape(m, name, ",= \t\n\\");
if (value) {
seq_putc(m, '=');
seq_escape(m, value, ", \t\n\\");
}
}
/**
* seq_show_option_n - display mount options with appropriate escapes
* where @value must be a specific length (i.e.
* not NUL-terminated).
* @m: the seq_file handle
* @name: the mount option name
* @value: the mount option name's value, cannot be NULL
* @length: the exact length of @value to display, must be constant expression
*
* This is a macro since this uses "length" to define the size of the
* stack buffer.
*/
#define seq_show_option_n(m, name, value, length) { \
Annotation
- Immediate include surface: `linux/types.h`, `linux/string.h`, `linux/string_helpers.h`, `linux/bug.h`, `linux/mutex.h`, `linux/nodemask.h`, `linux/fs.h`, `linux/cred.h`.
- Detected declarations: `struct seq_operations`, `struct seq_file`, `struct seq_operations`, `function seq_has_overflowed`, `function seq_get_buf`, `function seq_commit`, `function seq_setwidth`, `function seq_puts`, `function seq_escape_str`, `function seq_has_overflowed`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.