fs/configfs/file.c
Source file repositories/reference/linux-study-clean/fs/configfs/file.c
File Facts
- System
- Linux kernel
- Corpus path
fs/configfs/file.c- Extension
.c- Size
- 12175 bytes
- Lines
- 482
- 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/module.hlinux/slab.hlinux/mutex.hlinux/vmalloc.hlinux/uaccess.hlinux/uio.hlinux/configfs.hconfigfs_internal.h
Detected Declarations
struct configfs_bufferfunction fill_read_bufferfunction configfs_read_iterfunction configfs_bin_read_iterfunction fill_write_bufferfunction flush_write_bufferfunction configfs_write_iterfunction configfs_bin_write_iterfunction __configfs_open_filefunction configfs_releasefunction configfs_open_filefunction configfs_open_bin_filefunction configfs_release_bin_filefunction configfs_create_filefunction configfs_create_bin_file
Annotated Snippet
const struct file_operations configfs_file_operations = {
.read_iter = configfs_read_iter,
.write_iter = configfs_write_iter,
.llseek = generic_file_llseek,
.open = configfs_open_file,
.release = configfs_release,
};
const struct file_operations configfs_bin_file_operations = {
.read_iter = configfs_bin_read_iter,
.write_iter = configfs_bin_write_iter,
.llseek = NULL, /* bin file is not seekable */
.open = configfs_open_bin_file,
.release = configfs_release_bin_file,
};
/**
* configfs_create_file - create an attribute file for an item.
* @item: item we're creating for.
* @attr: atrribute descriptor.
*/
int configfs_create_file(struct config_item * item, const struct configfs_attribute * attr)
{
struct dentry *dir = item->ci_dentry;
struct configfs_dirent *parent_sd = dir->d_fsdata;
umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG;
int error = 0;
inode_lock_nested(d_inode(dir), I_MUTEX_NORMAL);
error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode,
CONFIGFS_ITEM_ATTR, parent_sd->s_frag);
inode_unlock(d_inode(dir));
return error;
}
/**
* configfs_create_bin_file - create a binary attribute file for an item.
* @item: item we're creating for.
* @bin_attr: atrribute descriptor.
*/
int configfs_create_bin_file(struct config_item *item,
const struct configfs_bin_attribute *bin_attr)
{
struct dentry *dir = item->ci_dentry;
struct configfs_dirent *parent_sd = dir->d_fsdata;
umode_t mode = (bin_attr->cb_attr.ca_mode & S_IALLUGO) | S_IFREG;
int error = 0;
inode_lock_nested(dir->d_inode, I_MUTEX_NORMAL);
error = configfs_make_dirent(parent_sd, NULL, (void *) bin_attr, mode,
CONFIGFS_ITEM_BIN_ATTR, parent_sd->s_frag);
inode_unlock(dir->d_inode);
return error;
}
Annotation
- Immediate include surface: `linux/fs.h`, `linux/module.h`, `linux/slab.h`, `linux/mutex.h`, `linux/vmalloc.h`, `linux/uaccess.h`, `linux/uio.h`, `linux/configfs.h`.
- Detected declarations: `struct configfs_buffer`, `function fill_read_buffer`, `function configfs_read_iter`, `function configfs_bin_read_iter`, `function fill_write_buffer`, `function flush_write_buffer`, `function configfs_write_iter`, `function configfs_bin_write_iter`, `function __configfs_open_file`, `function configfs_release`.
- 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.