Page 1 of 1

Storing files in a file system

Posted: Wed Jul 11, 2007 12:31 am
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?

Posted: Wed Jul 11, 2007 12:59 am
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

Posted: Thu Jul 12, 2007 12:36 am
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.