Page 1 of 1
Writing a filesystem
Posted: Wed Oct 14, 2009 5:32 pm
by jeremy6996
I've found several tutorials on writing a virtual file system, but I'd rather build a disk file system, and I can't find any on it. I still don't understand the purpose of a Virtual File System over a Disk File System, and I was wondering if you can help me understand. Thank you.
Re: Writing a filesystem
Posted: Wed Oct 14, 2009 5:57 pm
by gravaera
Hi:
The VFS is what the kernel interacts with. The intricacies of the various filesystems on different devices attached to the system are hidden from the kernel, and userspace and drivers.
How so? The VFS is filesystem independent. It presents all mounted devices as one tree root. Calls to open up a USB flash driver mounted in the virtual filesystem at /media/usbf001 are given to the VFS.
The VFS has information on each node in the FS tree, and it 'knows' which device this node correlates to. The VFS driver has the implementation details for translating a call to a particular node of the VFA to its local FS driver; However you do device<->FS relationships in your kernel is an implementation detail, and any other information you need can be found on the internet;
Coincidentally, this article on Wikipedia (
http://en.wikipedia.org/wiki/Virtual_file_system) was the first result on google for 'Virtual File System' and the third for 'VFS'.
You may also find it amusing to know that the wiki has an article giving the basics on VFS generation, and some comprehensive links at the bottom. (
http://wiki.osdev.org/VFS).
-All the best,
gravaera
Re: Writing a filesystem
Posted: Wed Oct 14, 2009 9:51 pm
by Firestryke31
The VFS is an in-memory representation of the disk file system(s), a kind of cache if you will. Most (if not all) implementations extend this by allowing you to hook in several partitions (and even disks, or if you're really far along across the network too) as part of one big file system, typically using mount points. They make it possible by not only storing info about the file, but info about how to manipulate it as well (I think function pointers to driver syscalls is common). This makes it, from a user-space application's point of view, just as easy to access a file on an NTFS partition across the network as it is to access a file on an ZFS on a local partition.
The VFS is usually built and added to when the various data sources are mounted, mostly at boot.
Basically, VFS == abstraction layer.
Re: Writing a filesystem
Posted: Fri Oct 16, 2009 10:32 pm
by jeremy6996
Ah, I see, that makes much more sense. Thanks to both of you.