fs/fuse/cuse.c
Source file repositories/reference/linux-study-clean/fs/fuse/cuse.c
File Facts
- System
- Linux kernel
- Corpus path
fs/fuse/cuse.c- Extension
.c- Size
- 16474 bytes
- Lines
- 664
- 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/fuse.hlinux/cdev.hlinux/device.hlinux/file.hlinux/fs.hlinux/kdev_t.hlinux/kthread.hlinux/list.hlinux/magic.hlinux/miscdevice.hlinux/mutex.hlinux/slab.hlinux/stat.hlinux/module.hlinux/uio.hlinux/user_namespace.hdev.hfuse_i.hfuse_dev_i.h
Detected Declarations
struct cuse_connstruct cuse_devinfostruct cuse_init_argsfunction cuse_read_iterfunction cuse_write_iterfunction cuse_openfunction cuse_releasefunction cuse_file_ioctlfunction cuse_file_compat_ioctlfunction cuse_parse_onefunction cuse_parse_devinfofunction cuse_gendev_releasefunction cuse_process_init_replyfunction cuse_send_initfunction cuse_fc_releasefunction cuse_channel_openfunction cuse_channel_releasefunction cuse_class_waiting_showfunction cuse_class_abort_storefunction cuse_initfunction cuse_exitmodule init cuse_init
Annotated Snippet
static const struct file_operations cuse_frontend_fops = {
.owner = THIS_MODULE,
.read_iter = cuse_read_iter,
.write_iter = cuse_write_iter,
.open = cuse_open,
.release = cuse_release,
.unlocked_ioctl = cuse_file_ioctl,
.compat_ioctl = cuse_file_compat_ioctl,
.poll = fuse_file_poll,
.llseek = noop_llseek,
};
/**************************************************************************
* CUSE channel initialization and destruction
*/
struct cuse_devinfo {
const char *name;
};
/**
* cuse_parse_one - parse one key=value pair
* @pp: i/o parameter for the current position
* @end: points to one past the end of the packed string
* @keyp: out parameter for key
* @valp: out parameter for value
*
* *@pp points to packed strings - "key0=val0\0key1=val1\0" which ends
* at @end - 1. This function parses one pair and set *@keyp to the
* start of the key and *@valp to the start of the value. Note that
* the original string is modified such that the key string is
* terminated with '\0'. *@pp is updated to point to the next string.
*
* RETURNS:
* 1 on successful parse, 0 on EOF, -errno on failure.
*/
static int cuse_parse_one(char **pp, char *end, char **keyp, char **valp)
{
char *p = *pp;
char *key, *val;
while (p < end && *p == '\0')
p++;
if (p == end)
return 0;
if (end[-1] != '\0') {
pr_err("info not properly terminated\n");
return -EINVAL;
}
key = val = p;
p += strlen(p);
if (valp) {
strsep(&val, "=");
if (!val)
val = key + strlen(key);
key = strstrip(key);
val = strstrip(val);
} else
key = strstrip(key);
if (!strlen(key)) {
pr_err("zero length info key specified\n");
return -EINVAL;
}
*pp = p;
*keyp = key;
if (valp)
*valp = val;
return 1;
}
/**
* cuse_parse_devinfo - parse device info
* @p: device info string
* @len: length of device info string
* @devinfo: out parameter for parsed device info
*
* Parse @p to extract device info and store it into @devinfo. String
* pointed to by @p is modified by parsing and @devinfo points into
* them, so @p shouldn't be freed while @devinfo is in use.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
Annotation
- Immediate include surface: `linux/fuse.h`, `linux/cdev.h`, `linux/device.h`, `linux/file.h`, `linux/fs.h`, `linux/kdev_t.h`, `linux/kthread.h`, `linux/list.h`.
- Detected declarations: `struct cuse_conn`, `struct cuse_devinfo`, `struct cuse_init_args`, `function cuse_read_iter`, `function cuse_write_iter`, `function cuse_open`, `function cuse_release`, `function cuse_file_ioctl`, `function cuse_file_compat_ioctl`, `function cuse_parse_one`.
- 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.