Questions about file handling

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Questions about file handling

Post by brain »

Here's how I do it, there are multiple drivers that implement FS_FileSystem structs and call attach_filesystem to add them to the list.

http://brainbox.cc/repository/trunk/six ... lesystem.c

you can also see the related header file:

http://brainbox.cc/repository/trunk/six ... lesystem.h
tobbebia
Posts: 17
Joined: Fri Feb 19, 2010 1:49 pm
Location: Sweden

Re: Questions about file handling

Post by tobbebia »

bluemoon wrote:Don't mix volumes with mount table, they can be isolated.

Think about this, you have a list of volume objects, which can do this thing:
FILE_NODE file;
volume->open(&file, "/abc.txt");

Now, the mount mechanism is merely hash mapping.

Code: Select all

vfs_mount_add("/", vol[0]);
vfs_mount_add("/foo/", vol[1]);
When open a file

Code: Select all

vfs_open(/foo/abc.txt");
This resolve into vol[1] and pass "/abc.txt" to it.
But what if I do readdir on "/". Then it wont list foo as a dir.
My GitHub account: http://github.com/tobbebia
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Questions about file handling

Post by bluemoon »

One way to workaround that is to enforce a directory present before mounting. Just like any unix.

ps. I see nothing wrong by not showing /foo if it does not exist on the volume. It's just a metter of policy and user experience.
tobbebia
Posts: 17
Joined: Fri Feb 19, 2010 1:49 pm
Location: Sweden

Re: Questions about file handling

Post by tobbebia »

bluemoon wrote:One way to workaround that is to enforce a directory present before mounting. Just like any unix.

ps. I see nothing wrong by not showing /foo if it does not exist on the volume. It's just a metter of policy and user experience.
Thanks for your informing replies! As I'm not a very experienced linux user I didn't know about that. So basically I should make an initrd filesystem and create those folder: "/dev, /dev/hdd0, /dev/usb" etc?
My GitHub account: http://github.com/tobbebia
Post Reply