File system implementation

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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

File system implementation

Post by GLneo »

hi all, I've been looking at different OS's trying to understand there file system structure, I think AMOS is the easiest to understand ( I think you just register a calltable with the FS handler then it calls read t a filesystem depending on what you read ) but how do you know what is on with file system: /mnt/hda1/ <- FAT , but if you read from: /mnt/hda2 <- ext2 but how will it know what FS is which ( how will you detect file systems ), also what does mount do in a FS, does it just place a device somewhere on the root tree? I'm just really confused, could someone go thought what is needed to make a file system handler?

thx!
User avatar
omin0us
Member
Member
Posts: 49
Joined: Tue Oct 17, 2006 6:53 pm
Location: Los Angeles, CA
Contact:

Post by omin0us »

It took be a while to wrap my head around the whole idea of using a vfs and filesystems too back when i wrote mine. :]
Basically, you have a virtual filesystem of virtual nodes (vnodes). In my os, it does not autodetect the FS, (although, i'd like to add support for fingerprinting a filesystem on a given device automatically). In mine, you specify what OS you'd like to mount it as, and based on various structures, you can determine of that device contains the filesystem specified. Mounting basically just says, "when you hit this point of the path, start reading this device using this FS to find files".
http://ominos.sourceforge.net - my kernel
#ominos @ irc.freenode.net
http://dtors.ath.cx - my blog
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

omin0us wrote:In my os, it does not autodetect the FS, (although, i'd like to add support for fingerprinting a filesystem on a given device automatically).
Linux actually auto-detects (or at least used to) by asking each driver for a super block until one of them succeeds. So as long as every driver checks that there's a right type of filesystem before giving a superblock, you'll have auto-detection by brute-force. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
Franchie
Posts: 11
Joined: Tue Apr 17, 2007 5:34 am

Post by Franchie »

mystran wrote:So as long as every driver checks that there's a right type of filesystem before giving a superblock, you'll have auto-detection by brute-force. :)
Is there any other way?
Mine currently just verifies the 'magic' number in the superblock structure. But then again, I only have a handful of filesystems to test it on...
User avatar
omin0us
Member
Member
Posts: 49
Joined: Tue Oct 17, 2006 6:53 pm
Location: Los Angeles, CA
Contact:

Post by omin0us »

Franchie wrote:Is there any other way?
Mine currently just verifies the 'magic' number in the superblock structure. But then again, I only have a handful of filesystems to test it on...
This was basically going to be my plan. :] I dont really know of any other way. But that way should be fine, as you can fingerprint a FS based on certain values that you know should be in its superblock or ranges of values.
http://ominos.sourceforge.net - my kernel
#ominos @ irc.freenode.net
http://dtors.ath.cx - my blog
Post Reply