lib/xz/xz_dec_test.c
Source file repositories/reference/linux-study-clean/lib/xz/xz_dec_test.c
File Facts
- System
- Linux kernel
- Corpus path
lib/xz/xz_dec_test.c- Extension
.c- Size
- 5072 bytes
- Lines
- 215
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/fs.hlinux/uaccess.hlinux/crc32.hlinux/xz.h
Detected Declarations
function xz_dec_test_openfunction xz_dec_test_releasefunction xz_dec_test_writefunction xz_dec_test_initfunction xz_dec_test_exitmodule init xz_dec_test_init
Annotated Snippet
static const struct file_operations fileops = {
.owner = THIS_MODULE,
.open = &xz_dec_test_open,
.release = &xz_dec_test_release,
.write = &xz_dec_test_write
};
state = xz_dec_init(XZ_PREALLOC, DICT_MAX);
if (state == NULL)
return -ENOMEM;
device_major = register_chrdev(0, DEVICE_NAME, &fileops);
if (device_major < 0) {
xz_dec_end(state);
return device_major;
}
printk(KERN_INFO DEVICE_NAME ": module loaded\n");
printk(KERN_INFO DEVICE_NAME ": Create a device node with "
"'mknod " DEVICE_NAME " c %d 0' and write .xz files "
"to it.\n", device_major);
return 0;
}
static void __exit xz_dec_test_exit(void)
{
unregister_chrdev(device_major, DEVICE_NAME);
xz_dec_end(state);
printk(KERN_INFO DEVICE_NAME ": module unloaded\n");
}
module_init(xz_dec_test_init);
module_exit(xz_dec_test_exit);
MODULE_DESCRIPTION("XZ decompressor tester");
MODULE_VERSION("1.0");
MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org>");
MODULE_LICENSE("Dual BSD/GPL");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/fs.h`, `linux/uaccess.h`, `linux/crc32.h`, `linux/xz.h`.
- Detected declarations: `function xz_dec_test_open`, `function xz_dec_test_release`, `function xz_dec_test_write`, `function xz_dec_test_init`, `function xz_dec_test_exit`, `module init xz_dec_test_init`.
- Atlas domain: Kernel Services / lib.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.