How to implement a filesystem
EXT2 help
Hello, now that I found how bad FAT is, in the sense of using up to much space on a floppy, I have moved on to EXT2.
My problem: I don't know where to start. If anyone has a tutorial, guide, etc. on the EXT2 fs that would be great. Thanks!!
My problem: I don't know where to start. If anyone has a tutorial, guide, etc. on the EXT2 fs that would be great. Thanks!!
Re: EXT2 help
The wiki article on ext2 is pretty good. Wikipedia's article on ext2 has a helpful diagram explaining how indirect blocks work. I found this article, which the wiki article was based on, a useful complement to the wiki as well.
Re: EXT2 help
Thanks for the reply, but I am afraid I was looking for more of a "How to read sectors", etc. kind of tutorial.
-
- Member
- Posts: 283
- Joined: Mon Jan 03, 2011 6:58 pm
Re: EXT2 help
See linux source code.wxwsk8er wrote:Thanks for the reply, but I am afraid I was looking for more of a "How to read sectors", etc. kind of tutorial.
- Monk
P.S. See http://wiki.osdev.org/Beginner_Mistakes ... al_on...3F
Re: How to implement a filesystem
Please actually read the wiki and search the web. If you wish to know about floppies, you can for instance read http://wiki.osdev.org/Floppy_Disk_Controller.
Don't disguise your real question "How do I read a floppy or a harddisk?" as "How do I read a file from a filesystem?". The filesystem is an abstraction higher and it's pretty trivial to make a simple filesystem. It's the block device driver that's tricky as it involves hardware specifics rather than imagination.
Don't disguise your real question "How do I read a floppy or a harddisk?" as "How do I read a file from a filesystem?". The filesystem is an abstraction higher and it's pretty trivial to make a simple filesystem. It's the block device driver that's tricky as it involves hardware specifics rather than imagination.
Re: EXT2 help
That's easy - you read the sectors in exactly the same way that you would for a FAT filesystem.wxwsk8er wrote:Thanks for the reply, but I am afraid I was looking for more of a "How to read sectors", etc. kind of tutorial.
Re: How to implement a filesystem
Not to mention that, IMO, ext2 is a fair bit more complex than FAT32. If you can't understand FAT, don't dig yourself into a hole by starting on ext.
[nx] kernel: http://github.com/zhiayang/nx
Re: How to implement a filesystem
IMO it's easier. Same complexity in terms of looking up files, less legacy warts.ext2 is a fair bit more complex than FAT32
Re: How to implement a filesystem
Ok, so I have looked (not copyied) at a few other peoples driver code, but I don't see any interrupts called, bytes written, etc. of how they would comunicate to the disc.
Thats more what I was asking. Thanks for all the replys
Thats more what I was asking. Thanks for all the replys
Re: How to implement a filesystem
Which code exactly? Depending on who's code you read, there can be a few ways of 'communicating' with a hard disk drive (not floppy, i don't know about that)wxwsk8er wrote:Ok, so I have looked (not copyied) at a few other peoples driver code, but I don't see any interrupts called, bytes written, etc. of how they would comunicate to the disc.
Thats more what I was asking. Thanks for all the replys
1. ATA PIO with polling -- while loop checking the ATA disk until it's done
2. ATA PIO with interrupts -- use interrupts to tell you when the disk is done.
3. DMA (interrupts only) -- mostly async, don't need to wait -- send data, disk says 'okay i'll do it', then sends an interrupt when it's done -- transfers much more than one sector at a time.
If you're in protected mode (you should be), none of the three methods will have anything resembling 'int $0xYY', unlike real mode code where you call the BIOS.
Also:
Eh perhaps, I was thrown off because I only had a long PDF to work with and not a convenient wikipedia article :pCandy wrote: IMO it's easier. Same complexity in terms of looking up files, less legacy warts.
[nx] kernel: http://github.com/zhiayang/nx
Re: How to implement a filesystem
I just picked up a little. But what about yours? How do you communicate with the disk?
Re: How to implement a filesystem
Well, in very simple terms, I
1. Send the appropriate commands to the IDE controller to check that it is ready. Repeat until the controller indicates that it is ready.
2. Send the appropriate commands to ask it to read a sector from the disk.
3. Continue with other stuff. When the controller has read the sector from the disk and is ready to transfer them it will send an interrupt.
4. The interrupt handler for that interrupt then reads the bytes from the controller and copies them to a disk buffer.
5. Once everything is read the interrupt routine exits and we are ready to go again.
That's just a rough outline. There are, of course, a few more details to be filled in. It's really not that different to the keyboard handler.
1. Send the appropriate commands to the IDE controller to check that it is ready. Repeat until the controller indicates that it is ready.
2. Send the appropriate commands to ask it to read a sector from the disk.
3. Continue with other stuff. When the controller has read the sector from the disk and is ready to transfer them it will send an interrupt.
4. The interrupt handler for that interrupt then reads the bytes from the controller and copies them to a disk buffer.
5. Once everything is read the interrupt routine exits and we are ready to go again.
That's just a rough outline. There are, of course, a few more details to be filled in. It's really not that different to the keyboard handler.
Re: How to implement a filesystem
Ok, what about to read clusters/sectors? How do you do that?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: How to implement a filesystem
Ok, after seeing the same question for the umpteenth time, I'm going to lock this as plain old spam.
We're not here to spoonfeed you. There is no tutorial. There is more than enough sample code and other reference material being pointed out for you. You are simply wasting everyone's time by not spending any effort, and breaking various written and unwritten rules of conduct.
What you have heard should be three times sufficient to write your own implementation, so that's what you are going to do first now.
We're not here to spoonfeed you. There is no tutorial. There is more than enough sample code and other reference material being pointed out for you. You are simply wasting everyone's time by not spending any effort, and breaking various written and unwritten rules of conduct.
What you have heard should be three times sufficient to write your own implementation, so that's what you are going to do first now.