StuBS
|
On a disk with Minix V3 the following is written one after the other
struct Minix_Super_Block
in minix/minix.h
struct Minix_Disk_Inode
in minix/minix.h
mkfs.minix
from Linux, blocks are 1024 bytes in size.struct Minix_Dirent
in minix/minix.h
.On a Linux host:
$ dd if=/dev/zero of=~/file.img bs=1MiB count=1 $ mkfs.minix -3 ~/file.img # optional --inodes <number> 352 inodes 1024 blocks Firstdatazone=26 (26) Zonesize=1024 Maxsize=2147483647
As root on Linux host:
$ losetup --find --show ~/file.img $ mount /dev/loop0 /mnt/tmp # Now create files etc $ umount /dev/loop0 $ losetup --detach /dev/loop0
Since root access is not always available (e.g. in the Lab), there is a command line application that allows direct access to the image using FTP-like commands
$ cd tool $ make $ fstool ~/file.img # Now edit files etc. # "help" for further information
Enables writing from OOStuBS to the image so that this data can then be read later in e.g. Linux.
In common.mk
at QEMU
add -drive file=./test_imgs/minix_sample_data.img,format=raw
. Then the image - if it is the only one - is the master on the first port. Then, it is sufficient to write the following in the app.
#include "fs/harddisk.h" Harddisk harddisk; int error = VFS::mount("minix", &harddisk, "");
If you want to use a different port, you must add e.g. -drive file=./test_imgs/minix_sample_data.img,format=raw,bus=1,unit=1
to QEMU
(see man qemu
). Accordingly, use Harddisk harddisk(secondary_bus_slave);
in the app. All other supported ports can be found in enum Drive
under harddisk.h
.
The initial ramdisk does not allow writing. Pass the file system image as initrd via QEMUINITRD
.
In the app:
#include "memory/multiboot.h" external void *multiboot_addr; multiboot_info_t *mb_info = (multiboot_info_t*)multiboot_addr; if (mb_info->mods_count <= 0) { GuardedScheduler::exit(); } multiboot_module_t *mod = (multiboot_module_t*)mb_info->mods_addr; void *initrd = (void *)mod->mod_start; size_t initrdsize = ((size_t)mod->mod_end) - ((size_t)mod->mod_start); Ramdisk ramdisk(initrd, initrdsize); int error = VFS::mount("minix", &ramdisk, "");
Does not allow writing. To create a header file so that the image can then be used via a variable, proceed as follows:
xxd -i minix_mkfs.img > minix_img.h
In the app:
#include "minix_img.h" #include "fs/ramdisk.h" static Ramdisk ramdisk(test_imgs_minix_sample_data_img, test_imgs_minix_sample_data_img_len); int error = VFS::mount("minix", &ramdisk, "");
The Virtual File System (VFS for short) offers some folder and file operations. For example, operations such as VFS::open(...)
, VFS::lseek(...)
or VFS::stat(...)
can be found there. More detailed descriptions of the methods can be found in the comments of vfs.h
.