Page 3 of 3

Re: How to implement a filesystem

Posted: Tue Jul 29, 2014 6:06 am
by iansjack

EXT2 help

Posted: Sun Aug 03, 2014 6:08 pm
by deleted
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!!

Re: EXT2 help

Posted: Sun Aug 03, 2014 7:04 pm
by madanra
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

Posted: Sun Aug 03, 2014 7:51 pm
by deleted
Thanks for the reply, but I am afraid I was looking for more of a "How to read sectors", etc. kind of tutorial.

Re: EXT2 help

Posted: Sun Aug 03, 2014 8:43 pm
by FallenAvatar
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.
See linux source code.

- Monk

P.S. See http://wiki.osdev.org/Beginner_Mistakes ... al_on...3F

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 4:14 am
by sortie
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.

Re: EXT2 help

Posted: Mon Aug 04, 2014 4:35 am
by iansjack
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.
That's easy - you read the sectors in exactly the same way that you would for a FAT filesystem.

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 5:51 am
by zhiayang
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.

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 6:05 am
by Candy
ext2 is a fair bit more complex than FAT32
IMO it's easier. Same complexity in terms of looking up files, less legacy warts.

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 6:15 am
by deleted
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 :D

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 6:21 am
by zhiayang
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 :D
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)
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:
Candy wrote: IMO it's easier. Same complexity in terms of looking up files, less legacy warts.
Eh perhaps, I was thrown off because I only had a long PDF to work with and not a convenient wikipedia article :p

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 6:40 am
by deleted
I just picked up a little. But what about yours? How do you communicate with the disk?

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 9:15 am
by iansjack
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.

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 10:22 am
by deleted
Ok, what about to read clusters/sectors? How do you do that?

Re: How to implement a filesystem

Posted: Mon Aug 04, 2014 10:39 am
by Combuster
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.