Page 1 of 1

Help needed for "File Systems"

Posted: Tue Jan 27, 2004 12:00 am
by the_creator
I have developed a bootloader and a kernel, both written in ASM (nasm Syntax)
and I cant seem to figure out how to implement a file system... As of now my Os has a simple command-line like interface and can input commands for the kernel to execute, but I resides in memory!!!, and my OS has no concept of files...
-(for lack of better terms), how would I be able to create a "file system" where I could create and delete files and information off of a hard drive or any storage media for that matter,I just cant seem to figure out how to do this, any help, pls

RE:Help needed for

Posted: Wed Jan 28, 2004 12:00 am
by bubach
the most simple way of doing this is to take (if you boot from a floppy) FAT12. Some searches for FAT12 +os dev should get you some info..

/ Christoffer

RE:Help needed for

Posted: Wed Jan 28, 2004 12:00 am
by Karig
Well, a floppy or hard disk stores everything in sectors. If you talk to the hardware (or even use the BIOS), you load sectors, not files. A file system is basically a database that tells your code what sectors to load in order to load a file. A directory is a special kind of file that contains records; each record gives the name, size, and location of a particular file, and usually such things as the date the file was last modified and the filetype.

A file system covers a pool of sectors (either all the sectors on a floppy, or all the sectors in a partition on a hard disk). Whenever you write a new file to the file system, the file system has to determine which sectors to overwrite in order to store the file. You could just go through a list of free sectors (also stored on the disk) and pick the first sectors that are listed as free, or you could do something more sophisticated, such as look for a group of free sectors large enough to hold the file but as close together on the disk as possible (so the file can be loaded faster, with fewer seeks [meaning movement of the read arm across the surface of the disk]). When you delete a file, you make the sectors that contained that file available for reuse.

Note that sectors are 512 bytes long. Sometimes sectors are grouped into clusters, and the file system will read and write only whole clusters -- so that more is read in or written out at a time, for better performance.

I hope this gives you a little bit of understanding, but you still need to do some research. Google is your friend :) and look for link pages on this and other OS development sites, for stuff to read about file systems in general, about FAT (FAT12/FAT16/FAT32), about ext2, ext3, ReiserFS, and so on.

RE:Help needed for

Posted: Fri Jan 30, 2004 12:00 am
by pepito
Hello:

I am working into the File System of my OS too.

I recommend you to choose some File System already exist instead of design one.
Then you just need to create the services necessary to access to it.

I choose FAT and I take the basic routines from a bootloader that can load a kernel file form a FAT12 volume, I have not the original code but there are many similar files at the web (search using the keywords FAT12.ASM).

You can get information about File Systems at:

http://osdev.neopages.net/docs.php?cat=13&sort=1
http://www.nondot.org/sabre/os/articles/FileSystems/

I hope it can be useful to you!

pepito