hello everyone,
once u start writing your kernel and then think of implementing a file system can anybody help me how to do it ?
Say if we did a logical file system using link lists how do we read the file allocation tables from a floppy (fat12) disk and enter file descriptor into our logical file system ?
please correct me if i am wrong.
(do we have to write our own device driver to read sectord from floppy)
please reply
bye
sriko
[email protected]
Logical File System and after..
Re:Logical File System and after..
The way I do it is by writing file system drivers to act as an interface between the kernel and the physical storage device -- effectively plugins which talk to the hard disk and expose files to the kernel.
Each file system driver is a set of functions (parse, lookup file, create file, open directory, list directory, etc.) which returns information in a set format. Initially, the root directory is represented by a virtual directory, which stores the structure in memory. You can't create files in virtual directories, but you can create other directories. These are stored in memory in a tree structure: there is one directory at the top (the root), which can contain as many subdirectories as it needs, in a linked list. Each subdirectory can contain other subdirectories, and so on.
Each directory in each file system is given a unique ID, made up of a pointer to the file system driver that contains it and an ID; IDs are assigned by individual file system drivers. To support different file systems on disk, my kernel maintains a list of mount points. When a file name is given to the kernel it scans along it, looking for slashes (/) like this:
node = root;
while (!end_of_string)
{
if (find_mount_point(node, &mount_point))
node = mount_point;
find_next_slash();
node->fs->parse(this_component, &node);
advance_to_next_slash();
}
At each stage, it looks for the current node ID in the list of mount points; if it's found a match, it redirects to that mount point and continues the parse.
Each file system driver is a set of functions (parse, lookup file, create file, open directory, list directory, etc.) which returns information in a set format. Initially, the root directory is represented by a virtual directory, which stores the structure in memory. You can't create files in virtual directories, but you can create other directories. These are stored in memory in a tree structure: there is one directory at the top (the root), which can contain as many subdirectories as it needs, in a linked list. Each subdirectory can contain other subdirectories, and so on.
Each directory in each file system is given a unique ID, made up of a pointer to the file system driver that contains it and an ID; IDs are assigned by individual file system drivers. To support different file systems on disk, my kernel maintains a list of mount points. When a file name is given to the kernel it scans along it, looking for slashes (/) like this:
node = root;
while (!end_of_string)
{
if (find_mount_point(node, &mount_point))
node = mount_point;
find_next_slash();
node->fs->parse(this_component, &node);
advance_to_next_slash();
}
At each stage, it looks for the current node ID in the list of mount points; if it's found a match, it redirects to that mount point and continues the parse.
Re:Logical File System and after..
ok, sir that was good onformation.But coming to device drivers, suppose i want to load the files from the floppy into my logical directory structure how do i do it, that is how do i access the file descriptors in the file allocation table in the floppy,
If i am not wrong bios interrupts can't do this, we can't use dos interrupts , so we hav to use device drivers which handle this system calls for open , write etc.
But do WE hav to write these device drivers ourselves ?
(till now what i hav done written a boot sector which load the kernel into memory.i hav written kernel in c.i hav just written a small command interpreter which at present handles 2 -4 silly commands.Am i going in the right direction? pleaz guide me.
If yes how?
thanx for the early reply.
bye
[email protected]
If i am not wrong bios interrupts can't do this, we can't use dos interrupts , so we hav to use device drivers which handle this system calls for open , write etc.
But do WE hav to write these device drivers ourselves ?
(till now what i hav done written a boot sector which load the kernel into memory.i hav written kernel in c.i hav just written a small command interpreter which at present handles 2 -4 silly commands.Am i going in the right direction? pleaz guide me.
If yes how?
thanx for the early reply.
bye
[email protected]
Re:Logical File System and after..
Yes... writing device drivers is a large and essential part of any operating system. In order to read files from a FAT-formatted floppy disk, you will need to write a floppy driver and a FAT file system driver. Try looking at http://www.nondot.org/sabre/os/ for details on the floppy disk controller and FAT file system.sriko wrote:If i am not wrong bios interrupts can't do this, we can't use dos interrupts , so we hav to use device drivers which handle this system calls for open , write etc.
But do WE hav to write these device drivers ourselves ?
Yes, that's the right way to go about things: start with a basic operating environment (your shell) and add things as you need them.(till now what i hav done written a boot sector which load the kernel into memory.i hav written kernel in c.i hav just written a small command interpreter which at present handles 2 -4 silly commands.Am i going in the right direction?
Re:Logical File System and after..
Sir , thanx again for all your replies
:-\)i am wondering where to start from , and how to write a device driver for a disk read/write.kindly guide me.
)Also i tried to read the sector 19 on disk(using dos interrupts ofcourse) and display filenames in root directory using a structure and i did it. But kindly let me know how do i run through a file chain and display all files(say DIR command).
???)can we access FAT ? if so how(is it by reading 2 sector on disk?)
kindly reply
bye
sriko
:-\)i am wondering where to start from , and how to write a device driver for a disk read/write.kindly guide me.
)Also i tried to read the sector 19 on disk(using dos interrupts ofcourse) and display filenames in root directory using a structure and i did it. But kindly let me know how do i run through a file chain and display all files(say DIR command).
???)can we access FAT ? if so how(is it by reading 2 sector on disk?)
kindly reply
bye
sriko