VFS theory
Posted: Tue Jul 28, 2009 7:29 am
Hello
I'm currently implementing filesystem stuff, including devfs, vfs, and fat12. But I'm uncertain whether I've have done it the right way, or the most efficient way. My filesystem stuff is currently working like this:
Filesystems is registered in VFS with name and functions for file operations, so when a file operation is requested, it goes through the following steps.
1. An application calls the VFS for a file operation, e.g. open()
2. The VFS figures out which mountpoint the file belongs to.
3. The VFS redirects the operation to the appropriate filesystem driver.
4. The filesystem processes the request and returns its data to VFS.
5. VFS returns to the application.
I guess this is the right (or most widely used) approach for file operations?
But further more, my on-disk filesystems (like fat12) access the hardware though /dev/fd0. This means, that a file operation goes though all the following steps (it's a little tricky sketched up, but '->' means call to function and '<-' means return to function).
So, I've 6 function calls that all returns to the previous function, and to me this seems like overkill?
PART II
My FAT12 driver stores the current directory in a structure in the driver. This means that every time a file operation is required, the driver most likely has to change directory, because the calls comes from different applications with different working directories. This means that there is a lot of directory changing all the time. Is the a normal way of working with filesystem, or should I store data for the current directory for each open file?
I'm a little confused about how I implement VFS in the most efficent way, and I cannot really find anything about how the VFS is created in a smart way
I'm currently implementing filesystem stuff, including devfs, vfs, and fat12. But I'm uncertain whether I've have done it the right way, or the most efficient way. My filesystem stuff is currently working like this:
Filesystems is registered in VFS with name and functions for file operations, so when a file operation is requested, it goes through the following steps.
1. An application calls the VFS for a file operation, e.g. open()
2. The VFS figures out which mountpoint the file belongs to.
3. The VFS redirects the operation to the appropriate filesystem driver.
4. The filesystem processes the request and returns its data to VFS.
5. VFS returns to the application.
I guess this is the right (or most widely used) approach for file operations?
But further more, my on-disk filesystems (like fat12) access the hardware though /dev/fd0. This means, that a file operation goes though all the following steps (it's a little tricky sketched up, but '->' means call to function and '<-' means return to function).
Code: Select all
Application -> VFS -> FAT12 -> VFS -> DEVFS -> FLOPPY DRIVER <- DEVFS <- VFS <- FAT12 <- VFS <- Application
PART II
My FAT12 driver stores the current directory in a structure in the driver. This means that every time a file operation is required, the driver most likely has to change directory, because the calls comes from different applications with different working directories. This means that there is a lot of directory changing all the time. Is the a normal way of working with filesystem, or should I store data for the current directory for each open file?
I'm a little confused about how I implement VFS in the most efficent way, and I cannot really find anything about how the VFS is created in a smart way