fs/configfs/dir.c
Source file repositories/reference/linux-study-clean/fs/configfs/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/configfs/dir.c- Extension
.c- Size
- 52146 bytes
- Lines
- 1981
- 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.
- 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/fs.hlinux/fsnotify.hlinux/mount.hlinux/module.hlinux/slab.hlinux/err.hlinux/configfs.hconfigfs_internal.h
Detected Declarations
function configfs_d_iputfunction inodesfunction configfs_set_dir_dirent_depthfunction configfs_adjust_dir_dirent_depth_before_populatefunction configfs_adjust_dir_dirent_depth_after_populatefunction configfs_init_dirent_depthfunction put_fragmentfunction configfs_dirent_existsfunction configfs_make_direntfunction configfs_remove_direntfunction configfs_dir_set_readyfunction configfs_create_dirfunction configfs_dirent_is_readyfunction configfs_create_linkfunction configfs_rmdirfunction configfs_lookupfunction rmdirfunction configfs_detach_rollbackfunction list_for_each_entry_continuefunction detach_attrsfunction populate_attrsfunction detach_groupsfunction mkdirfunction populate_groupsfunction list_for_each_entryfunction configfs_remove_default_groupsfunction list_for_each_entry_safefunction unlink_objfunction link_objfunction unlink_groupfunction link_groupfunction configfs_detach_itemfunction configfs_attach_itemfunction configfs_detach_groupfunction configfs_attach_groupfunction client_disconnect_notifyfunction make_itemfunction configfs_dump_onefunction configfs_dumpfunction list_for_each_entryfunction configfs_depend_itemfunction list_for_each_entryfunction configfs_do_depend_itemfunction configfs_find_subsys_dentryfunction configfs_depend_itemfunction configfs_depend_itemfunction configfs_depend_item_unlockedfunction configfs_rmdir
Annotated Snippet
const struct file_operations configfs_dir_operations = {
.open = configfs_dir_open,
.release = configfs_dir_close,
.llseek = configfs_dir_lseek,
.read = generic_read_dir,
.iterate_shared = configfs_readdir,
};
/**
* configfs_register_group - creates a parent-child relation between two groups
* @parent_group: parent group
* @group: child group
*
* link groups, creates dentry for the child and attaches it to the
* parent dentry.
*
* Return: 0 on success, negative errno code on error
*/
int configfs_register_group(struct config_group *parent_group,
struct config_group *group)
{
struct configfs_subsystem *subsys = parent_group->cg_subsys;
struct dentry *parent;
struct configfs_fragment *frag;
int ret;
frag = new_fragment();
if (!frag)
return -ENOMEM;
mutex_lock(&subsys->su_mutex);
link_group(parent_group, group);
mutex_unlock(&subsys->su_mutex);
parent = parent_group->cg_item.ci_dentry;
inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
ret = create_default_group(parent, group, frag);
if (ret)
goto err_out;
spin_lock(&configfs_dirent_lock);
configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata);
spin_unlock(&configfs_dirent_lock);
inode_unlock(d_inode(parent));
put_fragment(frag);
return 0;
err_out:
inode_unlock(d_inode(parent));
mutex_lock(&subsys->su_mutex);
unlink_group(group);
mutex_unlock(&subsys->su_mutex);
put_fragment(frag);
return ret;
}
EXPORT_SYMBOL(configfs_register_group);
/**
* configfs_unregister_group() - unregisters a child group from its parent
* @group: parent group to be unregistered
*
* Undoes configfs_register_group()
*/
void configfs_unregister_group(struct config_group *group)
{
struct configfs_subsystem *subsys = group->cg_subsys;
struct dentry *dentry = dget(group->cg_item.ci_dentry);
struct dentry *parent = group->cg_item.ci_parent->ci_dentry;
struct configfs_dirent *sd = dentry->d_fsdata;
struct configfs_fragment *frag = sd->s_frag;
down_write(&frag->frag_sem);
frag->frag_dead = true;
up_write(&frag->frag_sem);
inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
spin_lock(&configfs_dirent_lock);
configfs_detach_prep(sd, NULL);
spin_unlock(&configfs_dirent_lock);
configfs_detach_group(dentry);
d_inode(dentry)->i_flags |= S_DEAD;
dont_mount(dentry);
d_drop(dentry);
fsnotify_rmdir(d_inode(parent), dentry);
inode_unlock(d_inode(parent));
dput(dentry);
mutex_lock(&subsys->su_mutex);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/fsnotify.h`, `linux/mount.h`, `linux/module.h`, `linux/slab.h`, `linux/err.h`, `linux/configfs.h`, `configfs_internal.h`.
- Detected declarations: `function configfs_d_iput`, `function inodes`, `function configfs_set_dir_dirent_depth`, `function configfs_adjust_dir_dirent_depth_before_populate`, `function configfs_adjust_dir_dirent_depth_after_populate`, `function configfs_init_dirent_depth`, `function put_fragment`, `function configfs_dirent_exists`, `function configfs_make_dirent`, `function configfs_remove_dirent`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.