Page 1 of 1
File system implementation
Posted: Thu Apr 19, 2007 9:24 am
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!
Posted: Thu Apr 19, 2007 9:45 am
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".
Posted: Thu Apr 19, 2007 3:22 pm
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.
Posted: Thu Apr 19, 2007 3:50 pm
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...
Posted: Thu Apr 19, 2007 4:13 pm
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.