implementing a filesystem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
crasha

implementing a filesystem

Post by crasha »

At the moment I'm looking at a load of tutorials on implementing a filesystem but I still don't know two main things:
1. How do I write a driver (C or Assembly)?
2. Do I have to use A: B: C: D: etc. for drive identification? or could i use the drive number in DL like 00: 01: 02: etc.?

If anyone knows of a sample driver I could study or any good tutorials please let me know :)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:implementing a filesystem

Post by Candy »

crasha wrote: At the moment I'm looking at a load of tutorials on implementing a filesystem but I still don't know two main things:
1. How do I write a driver (C or Assembly)?
2. Do I have to use A: B: C: D: etc. for drive identification? or could i use the drive number in DL like 00: 01: 02: etc.?

If anyone knows of a sample driver I could study or any good tutorials please let me know :)
Seeing the way you asked the second question makes me wonder if you ever tried an operating system that was not created or compatible with Microsoft operating systems. If not, please do try one of them and determine what at least can be done differently.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:implementing a filesystem

Post by Pype.Clicker »

crasha wrote: At the moment I'm looking at a load of tutorials on implementing a filesystem but I still don't know two main things:
1. How do I write a driver (C or Assembly)?
using a text editor...

More seriously, be more specific. What kind of "driver" do you want to write, here ? a floppy driver? an ATA hard-disk driver ? a FAT32 driver (that's not actually a driver, but who knows ...)

I'd suggest you go to OSRC (see .:QuickLinkz:.) and grab documentation about device programming. Writing a driver means that you have to know
- how the device should be programmed
- how the system expect the driver to interact (see Tim Robinson's doc for an example)
2. Do I have to use A: B: C: D: etc. for drive identification? or could i use the drive number in DL like 00: 01: 02: etc.?
Please give more informations about the environment (e.g. *where* are you ? real mode ? protected mode ? booting ? in an existing OS ?)

If you're in your own OS, you can use any kind of stuff you like to identify the disk/partition you're using ...
aladdin

Re:implementing a filesystem

Post by aladdin »

Do you want to implement your own filesystem or write a driver for an existing one ?
-Writing your own filesystem is not really a good idea (in my opinion) since it will make your OS not compatible with others, but if you want to do that, i suggest to you to read other FS specifications to determine what are your needs.

-Now if you want to write a driver for an existing filesystem , you can find lot of documentation over the web (heared about google ? ;) )

-If you only want to write the hardware driver (for I/Ooperations), it will depend on what driver you want to build (as Pype said) , but you will use both C and ASM (or ASM only if you want).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:implementing a filesystem

Post by Pype.Clicker »

aladdin wrote: but you will use both C and ASM (or ASM only if you want).
Or C only if you have already a library for in's and out's and a framework for registering interrupts ;)
crasha

Re:implementing a filesystem

Post by crasha »

Candy wrote:
crasha wrote: At the moment I'm looking at a load of tutorials on implementing a filesystem but I still don't know two main things:
1. How do I write a driver (C or Assembly)?
2. Do I have to use A: B: C: D: etc. for drive identification? or could i use the drive number in DL like 00: 01: 02: etc.?

If anyone knows of a sample driver I could study or any good tutorials please let me know :)
Seeing the way you asked the second question makes me wonder if you ever tried an operating system that was not created or compatible with Microsoft operating systems. If not, please do try one of them and determine what at least can be done differently.
I have (linux). It uses things like / and /usr/local/bin and things like that, but I always (for some reason) thought that was something to do with the linux filesystems. Also, most BIOS's use strings like "A: then D: then C:" and things like that. I just wasn't sure.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:implementing a filesystem

Post by Candy »

crasha wrote: I have (linux). It uses things like / and /usr/local/bin and things like that, but I always (for some reason) thought that was something to do with the linux filesystems. Also, most BIOS's use strings like "A: then D: then C:" and things like that. I just wasn't sure.
Linux and unix in general use the /-system because they chose to. Nobody forces you to do anything. OS development is like being in the middle of a desert. You can do anything you want and until you get close to society, nobody will care. Plus, it's a hell of a lot of work to get anything noticeable done.

Also, nobody cares whether you conform to the European railway system width or the Spanish one for instance. You can conform to something completely different if you like, but don't expect trains from the other countries to run on them.

Translated back from the metaphor, Windows uses A:, B: and D: etc. because they understand what that means. Even if the system is ambiguous, flawed and nonscalable, it's still clear that A: is not a cdrom drive and that C: is not a floppy drive. For people who use Windows this is obvious and the only way to do something.

The BIOS manufacturers only cared about the Windows users (being their intended audience, you can't really blame them) and chose the name those people use for it rather than how it's actually called. You know the first name and like it. You don't know the second. Why should you be forced to learn it?

As for the unix people, they were there before the Windows people (by about a decade, give or take a few years). Microsoft themselves sold a unix clone for a while until they gave up and started the windows project.

Your own choice? You have all the freedom in the world. You can call them devices, harddisks, apparati, schijven, whatever you prefer. Divide them up in any way you like. There's a big space out there (usually about 2^38 bits) on your disk that are not known to you yet. Figure out what others intend to say and make your own mark (but make sure not to obliterate theirs, as it will make them unstable). You are entirely fully free in your choices. You can do WHATEVER YOU WANT, in whatever way you want to, by doing whatever you like. You have total freedom.



If you've come here to ask us to tell you what to do, that's one thing we can't do. We cannot decide for you what to do. We can help you decide for yourself what you want though. Do you want to appeal to windows-users? If so, try something that looks like A:. Do you want to appeal to linux users? If so, make something similar to the /-system. Do you not care about them but just want the "best" system? Then consider how you want to access your data, not how you at this moment access it.

Good luck and know that we will be here to help you.
mystran

Re:implementing a filesystem

Post by mystran »

Even modern Windows (any NT based) only use A:/C:/D: because they are familiar to a lot of people. Internally it's a single device tree, although somewhat different from Unix. But Windows can actually mount filesystems into directories too, in which case the result is even more like Unix.

So even in case of Windows, what the user sees is just a painting covering the real thing.
crasha

Re:implementing a filesystem

Post by crasha »

Oooo I understand now thanks! :)
0mni

Re:implementing a filesystem

Post by 0mni »

I was reading the thread now, and who.

is this ppl dislike the A:\ C:\ D:\ because its used by win
or because of the structure?

where is the big advantage of the nix /- system
i think its not like we create A: C: D: just for the dumb
user who dont understand the device tree or something like this, in my opinion its simple to understand and does its job.

not all invention of win are bad things.

as for me i would name my devicecs also in this pattern
not exactly A C D but separete the discs rather then mount them to folders, it gives a clear view of the hardware in your comp, maybe not if you create 20 partitions of your 200Gb HDD.(keep it simple yet usable) both styles have their good sides (well NOT the symboli liks but this is another story :) ) . the win style separets the disks like they are avalible as hardware and the logic is more understandeble.

still. its only my though on this toppic

0mni.
Curufir

Re:implementing a filesystem

Post by Curufir »

Well the reason I don't like it is it gives no indication of what the media is.

Is D: a partition? a cdrom drive? a usb stick?

Whereas if you mount a device like Unix the names tend to make a bit more sense. /media/cdrom seems more obvious than D: to me.

That doesn't mean someone else might think completely the opposite way. Go with what's comfortable.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:implementing a filesystem

Post by Brendan »

Hi,

Just though I'd show how an OS can be different from both Windows and *nix...

I have 2 file system types, "legacy" (iso9660, DOS/FAT, etc) and native (my own). Legacy file systems all look like directories within '/' that have names starting with '#' followed by it's hardware details - for e.g. "/#fd0" is a legacy file system on the first floppy disk and "/#hda" may be a CD-ROM.

For native file systems they are all mounted at '/' and super-imposed on top of each other. The file "/foo/bar.txt" could be on any device. This means that if one partition gets full the OS can shift files to a different partition without effecting anything, or the same file can be on several hard disks at the same time (redundancy & better performance when file data can be read from several devices at once). Another benefit is that a user can add another drive, format it and forget about it (no need to copy files, mount it, adjust any scripts to point to new directories, etc).

This fixes the "out of space" problem with both *nix and windows, but it makes it slower to find a file because you need to check all native file systems rather than just one. I use caching to reduce the effect of this though. Another problem is when the user wants to remove or re-format a drive - in this case the filesystem is marked as "deprecated" and the OS removes all files from it in the background (the user should only remove/re-format the drive after this has completed).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply