flat assembler
Message board for the users of flat assembler.

Index > OS Construction > file system

Goto page 1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
I have a big problem

i need to write my own file system but
i'm lost in the diversity of choises
first:
i don't know if
A) the primary directory will be in boot sector (in place of partition table) or B) only a pointer to first directory sector
i don't know if
A) files names will be in the pointers tables sectors or
B) in separates sectors
i don't know if
A) the procedures in boot sector will be the same than in kernel or
B) no procedures in boot sector
i don't know how many stages for the file system
1 2 or 3 ???
for me the first stage is to show a global occupation of the directory, the second to contain files pointers, the third to contain files names
i don't know how to write pointers

A) in CHS dword form
B) in LBA form
C) in other form

i am lost in the choises you see

so you can help me by reply your preferences
and don't speak about using existing file systems
Post 03 Oct 2007, 09:26
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
something very interresting is possible in fasm
org 100h
;org 7C00h
call programm
ret
org 0
dd labelle
db 'blalallkdjfhdkjqfhdjkfhezkafds;qn'
labelle:
db 'kldsncklnd,;:sqncnakljfdfqs'
db 'Erfdsjsd,,:'

align 512
org 0
dd otherlabel
db 'dsd'
otherlabel db 'fdfhlkjfljlkzef',0

with org xxxx
it is possible to write a multisector structure
No???
Post 09 Oct 2007, 00:20
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
edfed: Have you consired obtaining a book of OS theory? Os theory books might help you to find some answers concerning file system design.

regards,
Mac2004
Post 09 Oct 2007, 16:39
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
i don't need this kind of book
the "bibliotheque" is full of books like this

i need .txt .pdf .doc .asm .inc .com .hlp files and nothing else

thank you

what about dma programming
what about udma programming
what about i/o disk programming
what about pic pit int programming?

and the floppy disk how can i really control that?
and not in theory
and you? you probably have a little idea about file system?
i need technical documents with exact indications about the norm
and the HARDWARE
Post 09 Oct 2007, 16:46
View user's profile Send private message Visit poster's website Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Post 09 Oct 2007, 18:22
View user's profile Send private message Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav
Overexcitement, unsound english knowledge, lack of understanding of the topic - you can choose any two of that. ( Smile )

edfed wrote:
i need .txt .pdf .doc .asm .inc .com .hlp files and nothing else

i need technical documents with exact indications about the norm
and the HARDWARE


Filesystems HOWTO:
http://www.opennet.ru/docs/HOWTO/Filesystems-HOWTO.html

Linux Kernel 2.4 Internals:
http://www.moses.uklinux.net/patches/lki.html

Operating System resource center:
http://www.nondot.org/sabre/os/articles

Cottontail OS Development Library:
http://www.osdever.net/cottontail/
Post 09 Oct 2007, 18:23
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
yes thank you very much
i've found the most of documents links on fasm.net
thank you

i'll use it like it would be
to make a fuckin os

thanks again
Post 10 Oct 2007, 00:43
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
Quote:

and you? you probably have a little idea about file system?


Personally I have written a file system of my own using Fasm so I know what it takes to design and write such a thing.

By searching a little bit of theory you actually speed up the designing process. Fewer questions to ask and more understanding of the subject.
A good file system is not a trivial task to do.
Post 10 Oct 2007, 17:11
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Mac2004 wrote:

Personally I have written a file system of my own using Fasm so I know what it takes to design and write such a thing.
Writing only from my own perspective, I would welcome a few sentences from you, or even a couple of paragraphs, highlighting the mistakes to avoid, or the method used, to create one's own file system. I think this is an important topic....The more you are willing to share, the better, in my opinion.
Smile
Post 10 Oct 2007, 18:37
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
the first step of the creation of my os is the file system
i need it very simple and the nearest possible of the ┬ÁP memory management
the problem with 512 bytes sectors is that there is no 512 byte paging
why???
ask to intel
i decide to build the file system with a tree level coding for files

0 ) the root entry is one of x?(depend on user) in the boot sector

1st) the pointer table in the parent folder or a root entry
2nd) an allocation table to show the different zones of the file
3rd) the different zones of the files to load directly in file memory

nb the folders are files too
all is file
a single sector too is a file
and to economise memory a single sector will take place in only one sector
how?
the file size dword is less or equal 512 bytes?
so the sector is directly taken from the index

how to show the global disk occupation?
with a field like in unix
this field is pointed by the 'field' entry on boot sector
it's a system entry, user canot acces (ring 3 ???)

and the boot entry is the root of the boot process folder and development tools

evolution of this kind of file system is possible
compatibility with others file system is NULL
there is no partition table and no bios parameter block

and now i stop speaking
i'll work


Description:
Download
Filename: dirtables.inc
Filesize: 914 Bytes
Downloaded: 163 Time(s)



Last edited by edfed on 10 Oct 2007, 23:11; edited 2 times in total
Post 10 Oct 2007, 22:36
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Why do you need to write a filesystem? For a school class? What are the requirements, etc?

Or do you just want to do it as a hobby project?
Post 10 Oct 2007, 23:00
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
because i have a little hobby project
Post 10 Oct 2007, 23:09
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
tom tobias: Thanx for asking Smile I'am happy to share my thoughts. I will try to explain my ideas briefly.

To say it simple:

1) Files/folders have a header of 512bytes. First 256 bytes are reserved for the file/folder name and the rest are reserved for other data. Folders are basically linked lists of start sectors pointing to subfiles/subfolders. Files and folders are independent of their parent folders. (meaning that the subfiles/subfolders could be recovered in case of parent folder destruction (at least in theory). Presuming that subfile/subfolder sectors are intact one just needs to do sector by sector disk read to recover the file/folder.)

2) All other functions can written to produce basic file system services based on this simple
idea.

3) When basic FS services are there one just needs to write actual ramdisk, floppy, ATA etc. implementations of the file system.

4) It's written from scratch and fully by using Fasm.



How I tested the code:
-- -----------------------
Personally I have tested my file system through ramdisk. I used ramdrive routines to test the first implementation of the file system.
Doing so helped me to see whether there are serious bugs present in the file system code or not.
I think basic ramdisk routines are rather easy to write. Especially when compared to writing a floppy or ATA driver. Smile

Of course routines like printing strings, numbers, sectors in hex and ascii are very essential. (I guess this is very obvious Smile)

regards,
Mac2004
Post 11 Oct 2007, 04:01
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Thank you very much, well done. May I ask a few fundamental questions? I apologize in advance, if some of these questions seem utterly banal. I have no experience creating a file system, but it is something in which I have great interest.
Mac2004 wrote:

Files/folders have a header of 512bytes. First 256 bytes are reserved for the file/folder name ...
I am curious to learn why you chose this dimension, rather than some other size. I would have thought that a name could as easily be limited to 32 characters, for example. Do you store the length of the file, or the date/time when last accessed, in the remaining 256 bytes of the header?
Mac2004 wrote:
Folders are basically linked lists of start sectors pointing to subfiles/subfolders.
Where do you manage the current location, i.e. the next place to write data on the hard disk, without overwriting existing data? How do you rewrite the starting address and length of the new data in the parent directory? What happens to obsolete data? Once the data is "deleted", do you simply change the pointer, leaving the data where it is, or do you write zeros to all locations? Do you have a method to compress (i.e. recover) former space, now "empty"?
Mac2004 wrote:

Have you consired obtaining a book of OS theory? Os theory books might help you to find some answers concerning file system design.
Which book do you recommend, for addressing these kind of fundamental questions?
Mac2004 wrote:

Personally I have tested my file system through ramdisk.
I would profit from a bit more detailed explanation. Do you use a debugger to examine dram after simulating the hard disk operations by writing to memory?
fudder wrote:

Why do you need to write a filesystem?
but, then, which alternate file system would you suggest? For me, FAT offers far too much complexity, in addition to various copyright problems; as for the others, such as those described by Artlav (Thanks, great links!!!), is there one or another that you would propose as a general purpose, inelegant, straightforward, "simple" file system? I need a plain vanilla file system which assumes single user access, but, what I have seen, is, rather, file systems looking to the world of terabyte storage, with emphasis on "security features" of absolutely no use to me. I am, as you know too well, about four, or perhaps, five decades, behind the times.
Smile
Post 11 Oct 2007, 10:10
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel
@Mac2004:
Quote:
I think basic ramdisk routines are rather easy to write. Especially when compared to writing a floppy or ATA driver.

Could you give more information on the way you implemented ramdisk support like what functions did you implement?

@tom tobias:
Quote:
For me, FAT offers far too much complexity, in addition to various copyright problems

FAT is probably one of the easiest to implement I can think of (ok the LFN support is twisted, but still). There are easier-to-implement file systems like BFS but they are far too primitive to be used as general purpose FS. Then you have the other - far more complex - FS used (natively or not) in the Unix/BSD family and Linux. I think some day I will implement something like UFS or FFS... in a distant future.
Post 11 Oct 2007, 15:38
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
@ManOfSteel: You need to implement basic read/write sector routines. The sector size is 512bytes (usually). Reading/writing ramdisk is just normal memory copying. Smile.
Formatting is a special case of writing and so on...
That's what I meant by saying "easier than writing floppy or ATA driver". There's no need to access io ports to accomplish read/write sector routines.


@tom tobias: Your are ok to ask. Smile

Quote:

I am curious to learn why you chose this dimension, rather than some other size. I would have thought that a name could as easily be limited to 32 characters, for example. Do you store the length of the file, or the date/time when last accessed, in the remaining 256 bytes of the header?

512bytes comes from the fact that sector size is normally 512bytes. I think disks as linear arrays of sectors.

Personally I prefer having an option for long file names. I have been in situations where having 32 chars for a file name wouldn't been enough.

The header size is planned to occupy one sector on a disk. I think it's easy access the file/folder that way. You only need to read header sector (=1 sector) from the disk in order access a file/folder.

Yes, the remaining 256 bytes of the header do contain similar data you mentioned .


Quote:
Where do you manage the current location, i.e. the next place to write data on the hard disk, without overwriting existing data? How do you rewrite the starting address and length of the new data in the parent directory? What happens to obsolete data? Once the data is "deleted", do you simply change the pointer, leaving the data where it is, or do you write zeros to all locations? Do you have a method to compress (i.e. recover) former space, now "empty"?


I use a bit table where one bit indicates the status of a sector. So one byte can hold the info for 8 sectors. Using the table allows me to find free space from a disk, recover "empty" space and so on..

"Deleted" data can handled 3 ways: 1) by freeing bits from the bit table and clearing the file header.
2) moving the file to "recycle bin", an area of sectors reserved for recycling
3) erasing the file by overwriting all of the sectors and freeing the bits from the bit table..

Quote:
Which book do you recommend, for addressing these kind of fundamental questions?


Personally I own a copy of Operating Systems: internals and Design Principles by William Stallings. It is an excellent book in my opinion. I think there are others as well, but I haven't had chance see them.

Quote:
I would profit from a bit more detailed explanation. Do you use a debugger to examine dram after simulating the hard disk operations by writing to memory?


I wrote a routine that prints one sector (512bytes) contents on screen both in hex and in ascii. By using the routine I can check whats really happening in memory.
It's a little bit like having a "poor man's disk editor" Smile

regards,
Mac2004
Post 11 Oct 2007, 20:07
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
mac2004
can you show us a disk image of your file system
or a structure diagram?

i have a very good idea

write comments and/or file name in folder
and file name in the first sector of the file chain
Post 11 Oct 2007, 21:35
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
Quote:

or a structure diagram?


Here's a short illlustration:

-parent folder containing the start sector (=header) of a subfile/subfolder

*Let's load the header sector from disk to memory.

*Now we have both the name and the rest of the subfile/subfolder
info loaded in memory:
-------------------------------------------------------------------------
name string (256 bytes)
FileID/FolderID (arbitrary constants to show that this a valid file/folder header )
actual file size
size in sectors
created date&time
modified date&time
accessed date&time
(and so on,,)

The actual file/folder starts right after the header sector.


Quote:

and file name in the first sector of the file chain


I think my solution is like that you proposed..


regards
Mac2004
Post 12 Oct 2007, 03:00
View user's profile Send private message Reply with quote
Hayden



Joined: 06 Oct 2005
Posts: 132
Hayden
A Garbage collector file system is probably a good 1st free file system to code. each file/directory has a header and data space. the header links files and directories forwards and back and tracks free/used space. As files are deleted they're marked as free. When a new file is written the algo starts at the root and searches the linked list for a big enough space, while doing this you could be doing a semi defag on the fly ect... blah blah...

nb. you could also interlink diretories ect.. ie: a perticular directory may be reached via several different paths starting from the root.

_________________
New User.. Hayden McKay.
Post 12 Oct 2007, 09:00
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
quote:
name string (256 bytes)
FileID/FolderID (arbitrary constants to show that this a valid file/folder header )
actual file size
size in sectors
created date&time
modified date&time
accessed date&time
(and so on,,)
/quote:


i add a feature
a zone table
to show the differents fragments of the file, if fragmented
only two parameters, zone chs,lba or else, zone size (bytes)


the fat chain will start in header just afer file name
in my opignion file name mustn't reserve 256 bytes
but must be possible to be more than 1 sector

so i out a dword at the begining that index the begining of the zone map
the last dword in a fat chain sector is the @ of following sector

so it becomes fully modular
and if file name is short, i onfy use the place it needs
and if it's long it can be on severals sectors
because file names can be very long ( contain comments into or web links and extra features )

this is to improve the fast of the file system exploration

and i want a file name in the parent folder
Post 12 Oct 2007, 09:50
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3, 4  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.