Filesystem mounting
Posted: Fri Nov 18, 2011 1:25 pm
Hey, been gone for a while. I found that the mix in coding style from different tutorials made debugging a pain in the butt, so I decided to go back and start from scratch with my OS. I had originally named my kernel "SimpleKernel" since I didn't plan on going very far. I have since renamed it "NSSKernel" or "Not So Simple Kernel" since I've realized how even a tiny kernel is definitely not simple lol. Like I said, I rewrote my entire kernel from scratch. I now have a higher half (linked at 0xC0000000) kernel with basic TTY support similar to that of Linux. I have completely redesigned my paging interface, and have written a completely new scheduler. I have multitasking up and running, and am now moving on to an abstract filesystem design (I'm planning on linking my INITRD to the abstract filesystem so I can test loading executable's without dealing with filesystems and devices).
I am following the Unix style paths with mounting/umounting on arbitrary directories. I currently have a very basic fs_node structure with the readdir, finddir, open, close, etc... function pointers, and two pointers to these nodes in each task. One for the root filesystem, and one for the current working directory. I am trying to decide how I'm going to handle mounting, and I've come up with this structure:
where "src" is the directory/device node that was mounted at "dst"
(P.S. yes, I'm using the linux list_head implementation for lists. It is so nice, I couldn't resist
)
I first put a list of these in each task, but then I realized that would be a bad idea, since one process could mount without the rest of the system knowing
so I decided that a global mount_point list was needed.
with this design, each time a path was referenced, you would have to check each directory against the mount_point list to see if it was mounted somewhere else. If it was, swap your pointer with the mount_point::src. Like this:
and check_mounts() would either return the same pointer, or a pointer to a different directory node which was mounted to "dir". The only problem is that this would need to be done for every directory in every path that is parsed. :/ (granted on my machine there are only 6 things actually mounted, 7 or 8 sometimes, but still).
My question: would this be a good design? If not, do you have an idea for a better design?
I am following the Unix style paths with mounting/umounting on arbitrary directories. I currently have a very basic fs_node structure with the readdir, finddir, open, close, etc... function pointers, and two pointers to these nodes in each task. One for the root filesystem, and one for the current working directory. I am trying to decide how I'm going to handle mounting, and I've come up with this structure:
Code: Select all
struct mount_point
{
struct fs_node* src; // Mount source
struct fs_node* dst; // Mount point
u32 flags; // Mount flags
struct list_head* link; // Link to the next mount point
};
(P.S. yes, I'm using the linux list_head implementation for lists. It is so nice, I couldn't resist

I first put a list of these in each task, but then I realized that would be a bad idea, since one process could mount without the rest of the system knowing

with this design, each time a path was referenced, you would have to check each directory against the mount_point list to see if it was mounted somewhere else. If it was, swap your pointer with the mount_point::src. Like this:
Code: Select all
dir = check_mounts(dir);
My question: would this be a good design? If not, do you have an idea for a better design?