fs/configfs/inode.c
Source file repositories/reference/linux-study-clean/fs/configfs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/configfs/inode.c- Extension
.c- Size
- 4827 bytes
- Lines
- 195
- 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.
- 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/namei.hlinux/backing-dev.hlinux/capability.hlinux/sched.hlinux/lockdep.hlinux/slab.hlinux/configfs.hconfigfs_internal.h
Detected Declarations
function configfs_setattrfunction set_default_inode_attrfunction set_inode_attrfunction configfs_set_inode_lock_classfunction configfs_set_inode_lock_classfunction configfs_get_name
Annotated Snippet
if (sd->s_iattr) {
/* sysfs_dirent has non-default attributes
* get them for the new inode from persistent copy
* in sysfs_dirent
*/
set_inode_attr(inode, sd->s_iattr);
} else
set_default_inode_attr(inode, mode);
}
return inode;
}
#ifdef CONFIG_LOCKDEP
static void configfs_set_inode_lock_class(struct configfs_dirent *sd,
struct inode *inode)
{
int depth = sd->s_depth;
if (depth > 0) {
if (depth <= ARRAY_SIZE(default_group_class)) {
lockdep_set_class(&inode->i_rwsem,
&default_group_class[depth - 1]);
} else {
/*
* In practice the maximum level of locking depth is
* already reached. Just inform about possible reasons.
*/
pr_info("Too many levels of inodes for the locking correctness validator.\n");
pr_info("Spurious warnings may appear.\n");
}
}
}
#else /* CONFIG_LOCKDEP */
static void configfs_set_inode_lock_class(struct configfs_dirent *sd,
struct inode *inode)
{
}
#endif /* CONFIG_LOCKDEP */
struct inode *configfs_create(struct dentry *dentry, umode_t mode)
{
struct inode *inode = NULL;
struct configfs_dirent *sd;
if (!dentry)
return ERR_PTR(-ENOENT);
if (d_really_is_positive(dentry))
return ERR_PTR(-EEXIST);
sd = dentry->d_fsdata;
inode = configfs_new_inode(mode, sd, dentry->d_sb);
if (!inode)
return ERR_PTR(-ENOMEM);
configfs_set_inode_lock_class(sd, inode);
return inode;
}
/*
* Get the name for corresponding element represented by the given configfs_dirent
*/
const unsigned char * configfs_get_name(struct configfs_dirent *sd)
{
struct configfs_attribute *attr;
BUG_ON(!sd || !sd->s_element);
/* These always have a dentry, so use that */
if (sd->s_type & (CONFIGFS_DIR | CONFIGFS_ITEM_LINK))
return sd->s_dentry->d_name.name;
if (sd->s_type & (CONFIGFS_ITEM_ATTR | CONFIGFS_ITEM_BIN_ATTR)) {
attr = sd->s_element;
return attr->ca_name;
}
return NULL;
}
Annotation
- Immediate include surface: `linux/pagemap.h`, `linux/namei.h`, `linux/backing-dev.h`, `linux/capability.h`, `linux/sched.h`, `linux/lockdep.h`, `linux/slab.h`, `linux/configfs.h`.
- Detected declarations: `function configfs_setattr`, `function set_default_inode_attr`, `function set_inode_attr`, `function configfs_set_inode_lock_class`, `function configfs_set_inode_lock_class`, `function configfs_get_name`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.