fs/coda/inode.c
Source file repositories/reference/linux-study-clean/fs/coda/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/coda/inode.c- Extension
.c- Size
- 8876 bytes
- Lines
- 403
- 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.
- 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/module.hlinux/kernel.hlinux/mm.hlinux/string.hlinux/stat.hlinux/errno.hlinux/unistd.hlinux/mutex.hlinux/spinlock.hlinux/file.hlinux/vfs.hlinux/slab.hlinux/pid_namespace.hlinux/uaccess.hlinux/fs.hlinux/fs_context.hlinux/fs_parser.hlinux/vmalloc.hlinux/coda.hcoda_psdev.hcoda_linux.hcoda_cache.hcoda_int.h
Detected Declarations
struct coda_fs_contextfunction coda_free_inodefunction init_oncefunction coda_init_inodecachefunction coda_destroy_inodecachefunction coda_reconfigurefunction coda_set_idxfunction coda_parse_fdfunction coda_parse_paramfunction coda_parse_monolithicfunction coda_fill_superfunction coda_put_superfunction coda_evict_inodefunction coda_getattrfunction coda_setattrfunction coda_statfsfunction coda_get_treefunction coda_free_fcfunction coda_init_fs_context
Annotated Snippet
struct coda_fs_context {
int idx;
};
enum {
Opt_fd,
};
static const struct fs_parameter_spec coda_param_specs[] = {
fsparam_fd ("fd", Opt_fd),
{}
};
static int coda_set_idx(struct fs_context *fc, struct file *file)
{
struct coda_fs_context *ctx = fc->fs_private;
struct inode *inode;
int idx;
inode = file_inode(file);
if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
return invalf(fc, "coda: Not coda psdev");
}
idx = iminor(inode);
if (idx < 0 || idx >= MAX_CODADEVS)
return invalf(fc, "coda: Bad minor number");
ctx->idx = idx;
return 0;
}
static int coda_parse_fd(struct fs_context *fc, struct fs_parameter *param,
struct fs_parse_result *result)
{
struct file *file;
int err;
if (param->type == fs_value_is_file) {
file = param->file;
param->file = NULL;
} else {
file = fget(result->uint_32);
}
if (!file)
return -EBADF;
err = coda_set_idx(fc, file);
fput(file);
return err;
}
static int coda_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct fs_parse_result result;
int opt;
opt = fs_parse(fc, coda_param_specs, param, &result);
if (opt < 0)
return opt;
switch (opt) {
case Opt_fd:
return coda_parse_fd(fc, param, &result);
}
return 0;
}
/*
* Parse coda's binary mount data form. We ignore any errors and go with index
* 0 if we get one for backward compatibility.
*/
static int coda_parse_monolithic(struct fs_context *fc, void *_data)
{
struct file *file;
struct coda_mount_data *data = _data;
if (!data)
return invalf(fc, "coda: Bad mount data");
if (data->version != CODA_MOUNT_VERSION)
return invalf(fc, "coda: Bad mount version");
file = fget(data->fd);
if (file) {
coda_set_idx(fc, file);
fput(file);
}
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/mm.h`, `linux/string.h`, `linux/stat.h`, `linux/errno.h`, `linux/unistd.h`, `linux/mutex.h`.
- Detected declarations: `struct coda_fs_context`, `function coda_free_inode`, `function init_once`, `function coda_init_inodecache`, `function coda_destroy_inodecache`, `function coda_reconfigure`, `function coda_set_idx`, `function coda_parse_fd`, `function coda_parse_param`, `function coda_parse_monolithic`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.