OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: FUSE filesystem?
PostPosted: Thu Nov 11, 2021 6:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
zap8600 wrote:
What I could do is make a disk image, make a FUSE driver, open the image with the driver, make a file, close the image, and open the image in a hex editor. Then I could look at the file and, if I ever get disk access working, implement my own way to read files.

FUSE is just an API that allows userspace filesystem drivers to talk to the Linux (and BSD?) kernel VFS. If you're designing a new filesystem for your OS, you won't be able to get away from writing both a filesystem driver and a VFS.

It might be a good idea to write your filesystem for Linux using libfuse first, so you can test your filesystem code and design outside of your OS.

zap8600 wrote:
If there is a way to make files with inodes without needing disk access, I would like to know. That would be much appreciated.

You probably want a RAM drive. Making one is pretty simple: allocate some memory, and pretend the contents of that memory are on a disk. When your filesystem driver asks to read or write a block, you read or write from that allocated memory instead of from a hard drive.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 9:00 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. I think I'm starting to understand. Sooo.. how do I use the RAM disk? I have my own bootloader, so I can't load it with GRUB. Also, how would I make a filesystem with libfuse? I've looked at it before. Do I use the passthrough examples? Would I be able to create my own file structures? If I could get answers, that would be much appreciated.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 10:17 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
zap8600 wrote:
Sooo.. how do I use the RAM disk? I have my own bootloader, so I can't load it with GRUB.

Load the disk image somewhere in memory, then tell your kernel where it was loaded.

zap8600 wrote:
Also, how would I make a filesystem with libfuse? I've looked at it before. Do I use the passthrough examples? Would I be able to create my own file structures?

I think the passthrough examples do a pretty good job of showing off the libfuse API. There's also documentation for each of the callbacks, if you look around a bit. You'll decide how to turn the libfuse callbacks into reading and writing structures on the disk, so you can design your own structures. When you design your structures, keep in mind that disks are block devices: you can only read or write whole blocks, not individual bytes. The two most common block sizes are 512 bytes and 4096 bytes.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 10:24 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. So what you're telling me is that if I use libfuse, I can r/w to the disk without disk drivers? Sorry if I'm not properly understanding.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 11:36 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
zap8600 wrote:
So what you're telling me is that if I use libfuse, I can r/w to the disk without disk drivers?

No. If you use libfuse, you can use Linux to read/write the disk. Linux has disk drivers.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 12:14 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. So basically, I can go through the Linux kernel code and grab the code? If so, then what file am I looking for? Does it use inb and outb (or something similar) to r/w to the disk?


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 12:39 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
No, I was suggesting that you use libfuse to test your filesystem in Linux before trying to make it work in your OS. You would still need to write your own disk drivers for your OS.

(If you really wanted to, you could copy Linux code as long as you follow the license, but that's not what I'm suggesting here.)


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 2:08 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. Now I think I understand. So first, I make my filesystem. Then I test it in Linux. After that, I try to add disk access to my OS. Then I test the disk access (probably by making a .bin file, adding data to it with a hex editor, adding it to the OS image, running it in QEMU, and trying to read that data) and see if it works. But first, I have some questions. First, can I change the structure of a file? I want it to start out simple, probably as a flat filesystem, and as I continue developing my OS, I'll make it more advanced. Second, what functions does my filesystem need just to work? I think it only needs readdir and getattr.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 2:42 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
zap8600 wrote:
First, can I change the structure of a file? I want it to start out simple, probably as a flat filesystem, and as I continue developing my OS, I'll make it more advanced.

It's your filesystem, you can change it however you like.

zap8600 wrote:
Second, what functions does my filesystem need just to work? I think it only needs readdir and getattr.

As far as libfuse is concerned, you don't need any functions, so pick whichever ones sound useful. I think those two are enough to navigate (sub)directories, but you won't be able to read any files!


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 6:08 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. What I meant in my first question, is if it possible to change the structure of a file, and if so, then how?


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 6:20 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
I don't understand the question. What structure are you talking about?


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 10:47 pm 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. If I remember correctly, it is something like this:
Code:
struct FILE {
    char name;
    int uid;
    int size;
    int type;
}

It basically defines the parameters of a file. You would probably have to make some of them uint32 and some of them unsigned. This is the simplest structure I could come up with.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Fri Nov 12, 2021 11:53 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
I still don't understand. Where is this structure used?


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Mon Nov 15, 2021 9:15 am 
Offline
Member
Member

Joined: Tue Nov 02, 2021 11:26 am
Posts: 195
Hi. I believe it is in the fuse_common.h file.


Top
 Profile  
 
 Post subject: Re: FUSE filesystem?
PostPosted: Mon Nov 15, 2021 10:45 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
That file is part of the libfuse API. If you change any of the structures in it, your code won't be compatible with libfuse anymore.

If you're designing your own API, you can define whatever structures you like.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 77 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group