AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
initramfs.c File Reference

initramfs: the root filesystem from the RAM disk the boot loader loaded. More...

#include <core/system.h>
#include <core/string.h>
#include <core/panic.h>
#include <mm/mm.h>
#include <dev/ramdev.h>
#include <fs/vfs.h>
#include <fs/initramfs.h>
#include <fs/devfs.h>
#include <fs/posix.h>
#include <aquila/errno.h>
#include <ds/queue.h>
#include <boot/boot.h>

Go to the source code of this file.

Functions

int initramfs_archiver_register (struct fs *fs)
 Registers a filesystem that can make a root from a RAM disk archive.
int load_ramdisk (module_t *module)
 Mounts the RAM disk as the root filesystem.

Variables

static struct vnode * rd_dev = NULL
static struct queue * archivers = QUEUE_NEW()

Detailed Description

initramfs: the root filesystem from the RAM disk the boot loader loaded.

The RAM disk is an archive; each archiver (cpiofs, the only one) is asked in turn to make a filesystem from it, and the first that can becomes the root.

Definition in file initramfs.c.

Function Documentation

◆ initramfs_archiver_register()

int initramfs_archiver_register ( struct fs * fs)

Registers a filesystem that can make a root from a RAM disk archive.

Parameters
fsthe filesystem, whose load operation reads the archive
Returns
0, or -ENOMEM

Definition at line 32 of file initramfs.c.

References archivers, initramfs_archiver_register(), fs::name, and printk().

Referenced by cpio_init(), and initramfs_archiver_register().

◆ load_ramdisk()

int load_ramdisk ( module_t * module)

Mounts the RAM disk as the root filesystem.

The kernel can't go on without a root: if no archiver can read the RAM disk, it panics.

Parameters
modulethe boot loader's module that holds the RAM disk
Returns
what mounting the root returns

Definition at line 49 of file initramfs.c.

References archivers, DEV, devfs, vnode::fs, kmalloc(), fs::load, load_ramdisk(), M_ZERO, vnode::mode, NULL, panic, printk(), queue_for, rd_dev, rd_size, vnode::rdev, vnode::size, and vfs_mount_root().

Referenced by kmain(), and load_ramdisk().

Variable Documentation

◆ archivers

struct queue* archivers = QUEUE_NEW()
static

Definition at line 24 of file initramfs.c.

Referenced by initramfs_archiver_register(), and load_ramdisk().

◆ rd_dev

struct vnode* rd_dev = NULL
static

Definition at line 23 of file initramfs.c.

Referenced by load_ramdisk().