fs/ecryptfs/miscdev.c
Source file repositories/reference/linux-study-clean/fs/ecryptfs/miscdev.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ecryptfs/miscdev.c- Extension
.c- Size
- 14398 bytes
- Lines
- 499
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/hash.hlinux/random.hlinux/miscdevice.hlinux/overflow.hlinux/poll.hlinux/slab.hlinux/wait.hlinux/module.hecryptfs_kernel.h
Detected Declarations
function ecryptfs_miscdev_pollfunction ecryptfs_miscdev_openfunction ecryptfs_miscdev_releasefunction ecryptfs_send_miscdevfunction ecryptfs_miscdev_readfunction ecryptfs_miscdev_responsefunction ecryptfs_miscdev_writefunction ecryptfs_init_ecryptfs_miscdevfunction ecryptfs_destroy_ecryptfs_miscdev
Annotated Snippet
static const struct file_operations ecryptfs_miscdev_fops = {
.owner = THIS_MODULE,
.open = ecryptfs_miscdev_open,
.poll = ecryptfs_miscdev_poll,
.read = ecryptfs_miscdev_read,
.write = ecryptfs_miscdev_write,
.release = ecryptfs_miscdev_release,
.llseek = noop_llseek,
};
static struct miscdevice ecryptfs_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "ecryptfs",
.fops = &ecryptfs_miscdev_fops
};
/**
* ecryptfs_init_ecryptfs_miscdev
*
* Messages sent to the userspace daemon from the kernel are placed on
* a queue associated with the daemon. The next read against the
* miscdev handle by that daemon will return the oldest message placed
* on the message queue for the daemon.
*
* Returns zero on success; non-zero otherwise
*/
int __init ecryptfs_init_ecryptfs_miscdev(void)
{
int rc;
atomic_set(&ecryptfs_num_miscdev_opens, 0);
rc = misc_register(&ecryptfs_miscdev);
if (rc)
printk(KERN_ERR "%s: Failed to register miscellaneous device "
"for communications with userspace daemons; rc = [%d]\n",
__func__, rc);
return rc;
}
/**
* ecryptfs_destroy_ecryptfs_miscdev
*
* All of the daemons must be exorcised prior to calling this
* function.
*/
void ecryptfs_destroy_ecryptfs_miscdev(void)
{
BUG_ON(atomic_read(&ecryptfs_num_miscdev_opens) != 0);
misc_deregister(&ecryptfs_miscdev);
}
Annotation
- Immediate include surface: `linux/fs.h`, `linux/hash.h`, `linux/random.h`, `linux/miscdevice.h`, `linux/overflow.h`, `linux/poll.h`, `linux/slab.h`, `linux/wait.h`.
- Detected declarations: `function ecryptfs_miscdev_poll`, `function ecryptfs_miscdev_open`, `function ecryptfs_miscdev_release`, `function ecryptfs_send_miscdev`, `function ecryptfs_miscdev_read`, `function ecryptfs_miscdev_response`, `function ecryptfs_miscdev_write`, `function ecryptfs_init_ecryptfs_miscdev`, `function ecryptfs_destroy_ecryptfs_miscdev`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.