Storing files in a file system

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
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Storing files in a file system

Post by XCHG »

Suppose you have an index area for your file system where you store information related to all entries in the data block such as files, directories and etc. Now suppose you have this directory:

bin/directory1/

and you create a file called "file1.txt" under that directory. Now you want to store the information pertaining to "file1.txt" in the index area of your file system. How will you determine (in the file's information) to what directory it belongs? will you provide an index to the index area pertaining to its parent directory? a kind of an identifier? XOR the name of the parent and store it as a byte there? what will you do?
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

In Ext2/3 this problem does not arise - in most file systems the file table/index/whatever is stored in tree form. So parents have pointers to their children but not vice versa. [EDIT: excluding special directory entries "../"]

So as I understand it, you have header information for a file "file.txt", but you want to work out what directory heirarchy it belongs to. However, this does give rise to the question "How did you manage to get the header information for this file anyway without recursing through the directory heirarchy?". If you just searched through all the inodes for a header with filename "file.txt" you have problems, because there could be many hundreds of files with that name in different directories.

To solve the problem, just traverse the directory tree every time you need a file.

Sorry for the broken English - it's early in the morning :P (And unfortunately I am English so I really don't have an excuse... :( )

JamesM
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

Thank you James. I have a block called the "FDDT" that is a short form of File and Directory Descriptor Table. FDDT is kind of like a File Allocation Table with major differences of course. Each entry in the FDDT can point to a file/directory/etc. Now if for example, "file1.txt" is the 3rd entry and "directory1" is the first entry, I thought of setting the 'ParentIndex" of "file1.txt" to 0x00000000 for the first entry in the FDDT. I still don't know if this approach is effective or not.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Post Reply