Filesystem Driver
Posted: Thu Jan 17, 2008 6:51 am
How would you go about writing a driver for a custom filesystem under Linux?
Code: Select all
; ——————————————————————————————————————————————————
; typedef STRUCT FDDTEntry{
; QWORD EntryParentIndexInFDDT;
; QWORD EntryLinkIndexInFDDT;
; QWORD EntryRelativeClusterIndexOnDisk;
; QWORD EntrySizeInBytes;
; QWORD EntrySizeOnDiskInClusters;
; DWORD EntryType;
; DWORD Attributes;
; DWORD CreationTime;
; DWORD CreationDate;
; DWORD ModificationTime;
; DWORD ModificationDate;
; DWORD LastAccessTime;
; DWORD LastAccessDate;
; DWORD CreatorID;
; DWORD CreatorGroupID;
; DWORD[44] Reserved;
; BYTE[256] EntryNameInUTF8;
; }
; ——————————————————————————————————————————————————
I think the OP's question is not how to write a file system driver for his OS, but how to write a file system driver for Linux, so he can access the file system from his OS, in Linux. Unfortunately, I have very little experience with that. That said, check out FUSE. Google is your friend in this case, as no doubt many implementations of a FUSE driver can be found.XCHG wrote:I'm on Windows but I hope this will help. First I laid out the basic structure of the file system. You have to have a sound understanding of your goals and what you want to pull off with your file system in the future since changing it will change many things in your operating system.
This is the route I'm going actually. It lacks some power in that it's hard to write such a program to integrate with things like drag and drop files (I'm not even bothering, just run the program and choose what to do to the image). On the other hand, it is arguably much simpler to do it this way, and if the program dies it won't take the host OS down with it. A driver is much more difficult to debug anyway.crazygray1 wrote:Instead I may write a prog to work with disk images formatted to my file system.
It's also more portable and easier to install.Telgin wrote:This is the route I'm going actually. It lacks some power in that it's hard to write such a program to integrate with things like drag and drop files (I'm not even bothering, just run the program and choose what to do to the image). On the other hand, it is arguably much simpler to do it this way, and if the program dies it won't take the host OS down with it. A driver is much more difficult to debug anyway.crazygray1 wrote:Instead I may write a prog to work with disk images formatted to my file system.
FUSE only supports a handful of operating systems... It would be far easier to make a portable utility in C.iammisc wrote:FUSE is probably better than writing a new app. It has the same benefits as a disk image app except that the filesystem will be able to do the same things that all linux file systems do. Even if the driver crashes, it won't take the kernel down with it because it is running in userspace. I wrote a simple driver for a pseudo-filesystem in FUSE for SQLite and it wasn't too hard. Writing it for a custom filesystem would only be a little harder. The FUSE API is pretty easy to work with. You also don't need to implement everything, just enough to do what you want. For example, I only implemented, readdir, read, and stat at first and then worried about writing later.
Yup, if it follows standards and doesn't use any APIs you can just copy and compile. Command line apps are simple to port.Alboin wrote:It's also more portable and easier to install.Telgin wrote:This is the route I'm going actually. It lacks some power in that it's hard to write such a program to integrate with things like drag and drop files (I'm not even bothering, just run the program and choose what to do to the image). On the other hand, it is arguably much simpler to do it this way, and if the program dies it won't take the host OS down with it. A driver is much more difficult to debug anyway.crazygray1 wrote:Instead I may write a prog to work with disk images formatted to my file system.
Then again, the OP specifically asked for a Linux solution.Brynet-Inc wrote:FUSE only supports a handful of operating systems... It would be far easier to make a portable utility in C.