mb2mfs – Multiboot2-Module File System

The Multiboot2-Module file system provides Multiboot2 modules as files.

This file system is implemented in

This filesystem provides multiboot2 modules as files.

General Information

Using the Multiboot2 boot protocol, one can specify modules to be loaded into memory during boot. The module’s name – as specified, e.g., in grub.cfg – serves as the file’s absolute path name inside the file system.

Example snippet for grub.cfg:

menuentry "tomOSii" {
        multiboot2 /boot/tomOSii.bin
        module2 /boot/sbin/init/init.bin /sbin/init
        boot
}

In the above snippet, the kernel image is loaded from /boot/tomOSii.bin on the boot volume. A single module is loaded from /boot/sbin/init/init.bin on the boot volume into memory. The name /sbin/init is assigned to the module. This name serves as the path to the respective file provided by the Multiboot2-Module file system. The file’s content is identical to the content of /boot/sbin/init/init.bin. If mb2mfs is mounted to /, then the file is available as /sbin/init.

Initialization

The file system driver is initialized by calling

void fs_mb2mfs_init(void)

Initialize the multiboot2-module filesystem.

Register the multiboot2-module filesystem to the filesystem core.

^ Back to top.

Mounting the File System

A Multiboot2-module file system is mounted by calling the mount operation via the mount system call.

For this file system to work, users will have to provide a pointer to the Multiboot2 info struct as mount data.

The mount operation is implemented in

static inode_t *__fs_mb2mfs_mount(file_system_t *fs, int flags, const char *device, void *data)

Mount the file system.

Parameters:
  • fs – The file system to be mounted

  • flags – The mount flags – have to be MS_NOT_YET_IMPLEMENTED

  • device – The device the file system lives on – unused here

  • data – Additional data – unused here

^ Back to top.

Looking Up a File

A file, i.e., a multiboot2 module, is looked up by using the lookup operation:

static inode_t *__fs_mb2mfs_lookup(inode_t *dir, const char *name, unsigned int flags)

Look up an inode for a path /p name.

Parameters:
  • dir – The inode representing the file system root

  • name – The full path of the file to be looked up

  • flags – unused

Returns:

the inode, on success

Returns:

NULL, on failure

^ Back to top.

Opening a File

A file, i.e., a multiboot2 module, is opened by using the open operation:

static int __fs_mb2mfs_fops_open(inode_t *inode, file_t *file)

Open a multiboot2 module as a file.

There is nothing to be done here. The required steps are already handelled by sys_open.

Returns:

0

^ Back to top.

Closing a File

A file, i.e., a multiboot2 module, is closed by using the open operation:

static int __fs_mb2mfs_fops_close(inode_t *inode, file_t *file)

Close a multiboot2 module as a file.

There is nothing to be done here. The required steps are already handelled by sys_close.

Returns:

0

^ Back to top.

Reading from a File

Reading from a file, i.e., a multiboot2 module, is facilitated by the read operation:

static ssize_t __fs_mb2mfs_fops_read(file_t *file, char *buffer, size_t buffer_size, size_t *offset)

Read from a multiboot2 module.

Parameters:
  • file – The file to read from

  • buffer – The buffer to read into

  • buffer_size – The size of the buffer / the number of bytes to read

  • offset – Pointer to the offset specifying where to start reading

Returns:

The number of bytes read, on success. May be less than buffer_size.

Returns:

0, if reading while already at the end of the file.

^ Back to top.