Friday, January 8, 2010

Adding new filesystem to Inferno

I have uploaded the codebase that I will be using on google-code at
http://code.google.com/p/inferno-rtasks/.
Feel free to download and play with it.

My next objective is to add new synthetic file-system similar to /net or /prog to Inferno. Here is the approach that helped me.


First step was to find out where are most of the synthetic fie-systems are residing.
The location was emu/port/. New synthetic filesystem was created by copying
emu/port/devcmd.c with new name emu/port/devtask.c. This file has
one structure Dev cmddevtab at bottom of the file which needs modifications.
I modified this structure as follows

Dev cmddevtab = {
'C',
"cmd",

cmdinit,

Above structure was modified as

Dev taskdevtab = {
'T',
"task",

cmdinit,


You also need to tell compilation process for including this file into compilation path.
This can be done by modifying emu/Linux/emu file which is configuration file
controlling what all should be included in emu image. This file has sections for
dev, lib, link, mod, port, code, init and root. As my addition is supposed to be
synthetic filesystem, I added following line to the dev section of this file.

task


With this modification, you can recompile the kernel and execute the new image.
To test if this new filesystem is present, you can use following command

; ls '#T'
#T/cmd

The output #T/cmd proves that this file-system is in kernel.


Now, lets concentrate on auto mounting this synthetic filesystem at boot time.
This involves few more steps.

First, we need place to mount this filesystem. Lets edit emu/Linux/emu
again. This time, we add following line in root section.

/task /

Refer other entries for the syntax expected in this field. This will create a
placeholder directory /task were we can mount out filesystem.

Next step is to modify initialization script so that it will actually mount synthetic filesystem.
The initialization script can be found at appl/cmd/emuinit.b.
Locate the init() function which is responsible for initial binding of the
filesystem with their mount-points. Add following line to this function after
other filesystems are mounted using similar calls.

sys-bind ("#T", "/task", sys->MBEFORE) ;


I repeated the same modification in appl/cmd/brasil.b as in few cases brasil.b is used
as initialization script.

After this, you should be able to recompile the kernel and test using following command
within inferno.

; ls /task
/task/cmd

Here, the output /task/cmd shows that our filesystem is properly attached to the
root filesystem :-)

No comments:

Post a Comment