init/do_mounts_rd.c
Source file repositories/reference/linux-study-clean/init/do_mounts_rd.c
File Facts
- System
- Linux kernel
- Corpus path
init/do_mounts_rd.c- Extension
.c- Size
- 7570 bytes
- Lines
- 316
- Domain
- Core OS
- Bucket
- Boot And Init
- 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.
- 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/kernel.hlinux/fs.hlinux/minix_fs.hlinux/ext2_fs.hlinux/romfs_fs.huapi/linux/cramfs_fs.hlinux/initrd.hlinux/string.hlinux/string_choices.hlinux/slab.hdo_mounts.h../fs/squashfs/squashfs_fs.hlinux/decompress/generic.h
Detected Declarations
function ramdisk_start_setupfunction identify_ramdisk_imagefunction nr_blocksfunction rd_load_imagefunction compr_fillfunction compr_flushfunction errorfunction crd_load
Annotated Snippet
if (i && (i % devblocks == 0)) {
pr_cont("done disk #1.\n");
rotate = 0;
fput(in_file);
break;
}
kernel_read(in_file, buf, BLOCK_SIZE, &in_pos);
kernel_write(out_file, buf, BLOCK_SIZE, &out_pos);
if (!IS_ENABLED(CONFIG_S390) && !(i % 16)) {
pr_cont("%c\b", rotator[rotate & 0x3]);
rotate++;
}
}
pr_cont("done.\n");
successful_load:
res = 1;
done:
fput(in_file);
noclose_input:
fput(out_file);
out:
kfree(buf);
init_unlink("/dev/ram");
return res;
}
static int exit_code;
static int decompress_error;
static long __init compr_fill(void *buf, unsigned long len)
{
long r = kernel_read(in_file, buf, len, &in_pos);
if (r < 0)
printk(KERN_ERR "RAMDISK: error while reading compressed data");
else if (r == 0)
printk(KERN_ERR "RAMDISK: EOF while reading compressed data");
return r;
}
static long __init compr_flush(void *window, unsigned long outcnt)
{
long written = kernel_write(out_file, window, outcnt, &out_pos);
if (written != outcnt) {
if (decompress_error == 0)
printk(KERN_ERR
"RAMDISK: incomplete write (%ld != %ld)\n",
written, outcnt);
decompress_error = 1;
return -1;
}
return outcnt;
}
static void __init error(char *x)
{
printk(KERN_ERR "%s\n", x);
exit_code = 1;
decompress_error = 1;
}
static int __init crd_load(decompress_fn deco)
{
int result;
if (!deco) {
pr_emerg("Invalid ramdisk decompression routine. "
"Select appropriate config option.\n");
panic("Could not decompress initial ramdisk image.");
}
result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error);
if (decompress_error)
result = 1;
return result;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/fs.h`, `linux/minix_fs.h`, `linux/ext2_fs.h`, `linux/romfs_fs.h`, `uapi/linux/cramfs_fs.h`, `linux/initrd.h`, `linux/string.h`.
- Detected declarations: `function ramdisk_start_setup`, `function identify_ramdisk_image`, `function nr_blocks`, `function rd_load_image`, `function compr_fill`, `function compr_flush`, `function error`, `function crd_load`.
- Atlas domain: Core OS / Boot And Init.
- Implementation status: source implementation candidate.
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.