include/linux/kernfs.h
Source file repositories/reference/linux-study-clean/include/linux/kernfs.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/kernfs.h- Extension
.h- Size
- 20650 bytes
- Lines
- 655
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/list.hlinux/mutex.hlinux/idr.hlinux/lockdep.hlinux/rbtree.hlinux/atomic.hlinux/bug.hlinux/types.hlinux/uidgid.hlinux/wait.hlinux/rwsem.hlinux/cache.h
Detected Declarations
struct filestruct dentrystruct iattrstruct ns_commonstruct seq_filestruct vm_area_structstruct vm_operations_structstruct super_blockstruct file_system_typestruct poll_table_structstruct fs_contextstruct kernfs_fs_contextstruct kernfs_open_nodestruct kernfs_iattrsstruct kernfs_global_locksstruct kernfs_elem_dirstruct kernfs_elem_symlinkstruct kernfs_elem_attrstruct kernfs_nodestruct kernfs_syscall_opsstruct kernfs_open_filestruct kernfs_opsstruct kernfs_fs_contextenum kernfs_node_typeenum kernfs_node_flagenum kernfs_root_flagfunction kernfs_typefunction kernfs_id_inofunction kernfs_id_genfunction kernfs_inofunction kernfs_genfunction kernfs_enable_nsfunction kernfs_ns_enabledfunction kernfs_typefunction kernfs_enable_nsfunction kernfs_namefunction kernfs_path_from_nodefunction pr_cont_kernfs_namefunction kernfs_find_and_get_nsfunction kernfs_walk_and_get_nsfunction kernfs_getfunction kernfs_get_inodefunction kernfs_create_rootfunction kernfs_destroy_rootfunction kernfs_create_dir_nsfunction __kernfs_create_filefunction kernfs_create_linkfunction kernfs_activate
Annotated Snippet
struct kernfs_global_locks {
struct mutex node_mutex[NR_KERNFS_LOCKS];
};
enum kernfs_node_type {
KERNFS_DIR = 0x0001,
KERNFS_FILE = 0x0002,
KERNFS_LINK = 0x0004,
};
#define KERNFS_TYPE_MASK 0x000f
#define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
enum kernfs_node_flag {
KERNFS_ACTIVATED = 0x0010,
KERNFS_NS = 0x0020,
KERNFS_HAS_SEQ_SHOW = 0x0040,
KERNFS_HAS_MMAP = 0x0080,
KERNFS_LOCKDEP = 0x0100,
KERNFS_HIDDEN = 0x0200,
KERNFS_SUICIDAL = 0x0400,
KERNFS_SUICIDED = 0x0800,
KERNFS_EMPTY_DIR = 0x1000,
KERNFS_HAS_RELEASE = 0x2000,
KERNFS_REMOVING = 0x4000,
};
/* @flags for kernfs_create_root() */
enum kernfs_root_flag {
/*
* kernfs_nodes are created in the deactivated state and invisible.
* They require explicit kernfs_activate() to become visible. This
* can be used to make related nodes become visible atomically
* after all nodes are created successfully.
*/
KERNFS_ROOT_CREATE_DEACTIVATED = 0x0001,
/*
* For regular files, if the opener has CAP_DAC_OVERRIDE, open(2)
* succeeds regardless of the RW permissions. sysfs had an extra
* layer of enforcement where open(2) fails with -EACCES regardless
* of CAP_DAC_OVERRIDE if the permission doesn't have the
* respective read or write access at all (none of S_IRUGO or
* S_IWUGO) or the respective operation isn't implemented. The
* following flag enables that behavior.
*/
KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK = 0x0002,
/*
* The filesystem supports exportfs operation, so userspace can use
* fhandle to access nodes of the fs.
*/
KERNFS_ROOT_SUPPORT_EXPORTOP = 0x0004,
/*
* Support user xattrs to be written to nodes rooted at this root.
*/
KERNFS_ROOT_SUPPORT_USER_XATTR = 0x0008,
/*
* Renames must not change the parent node.
*/
KERNFS_ROOT_INVARIANT_PARENT = 0x0010,
};
/* type-specific structures for kernfs_node union members */
struct kernfs_elem_dir {
unsigned long subdirs;
/* children rbtree starts here and goes through kn->rb */
struct rb_root children;
/*
* The kernfs hierarchy this directory belongs to. This fits
* better directly in kernfs_node but is here to save space.
*/
struct kernfs_root *root;
/*
* Monotonic revision counter, used to identify if a directory
* node has changed during negative dentry revalidation.
*/
unsigned long rev;
};
struct kernfs_elem_symlink {
struct kernfs_node *target_kn;
};
struct kernfs_elem_attr {
const struct kernfs_ops *ops;
struct kernfs_open_node __rcu *open;
Annotation
- Immediate include surface: `linux/err.h`, `linux/list.h`, `linux/mutex.h`, `linux/idr.h`, `linux/lockdep.h`, `linux/rbtree.h`, `linux/atomic.h`, `linux/bug.h`.
- Detected declarations: `struct file`, `struct dentry`, `struct iattr`, `struct ns_common`, `struct seq_file`, `struct vm_area_struct`, `struct vm_operations_struct`, `struct super_block`, `struct file_system_type`, `struct poll_table_struct`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.