Writing a filesystem

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.
Post Reply
jeremy6996
Posts: 10
Joined: Mon Sep 28, 2009 11:06 am

Writing a filesystem

Post 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.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Writing a filesystem

Post 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
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: Writing a filesystem

Post 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.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
jeremy6996
Posts: 10
Joined: Mon Sep 28, 2009 11:06 am

Re: Writing a filesystem

Post by jeremy6996 »

Ah, I see, that makes much more sense. Thanks to both of you.
Post Reply