Page 2 of 2

Posted: Mon Apr 23, 2007 3:02 pm
by pcmattman
That's EOF - means the root directory only takes up one cluster of space.

You need to read the sector that the entry points to (offset in FAT + start of data area). Each of the entries in the root directory are 32-byte structures pointing to a file.

Try to find Microsoft's FAT doc. It's sort of useful, given the fact that FAT is a Microsoft abomination. 80% of my FAT driver comes from that document.

Posted: Tue Apr 24, 2007 8:22 am
by supagu
okay problem has been solved, i had a major flaw in my understanding of how this was working. The fat entry was the first 32bits of each cluster, but its like a table before the data area!

Posted: Tue Apr 24, 2007 11:18 am
by mystran
supagu wrote:okay problem has been solved, i had a major flaw in my understanding of how this was working. The fat entry was the first 32bits of each cluster, but its like a table before the data area!
That's quite possibly the only sane design decision in the whole filesystem. ;)

Posted: Sat Apr 28, 2007 7:03 pm
by supagu
okay i've run in to a bit of another problem, how to determine is a directory is valid.

I've got a fat32 filesystem set up by windows 98, when i deleted some files/directories my OS is still showing that they exist (but thier name is corrupt)

in the MS fat32 doco it says the first later of dirname (dirname[0]) determines if a file/directory is valid or not. But in my case it doesnt.

?

Posted: Sun Apr 29, 2007 10:01 am
by frank
if the first character in a file or directory name is 0xe5 then that file or directory has been deleted and is no longer valid.

Posted: Sun Apr 29, 2007 11:54 am
by mystran
frank wrote:if the first character in a file or directory name is 0xe5 then that file or directory has been deleted and is no longer valid.
Also, if you see 0x05, you should translate it into 0xE5, since 0xE5 is a valid character in a filename, but it's number is reserved for encoding deleted entries.

Posted: Sat May 05, 2007 2:07 am
by supagu
okay, i can make directoys and they show up in windows 3.11 and windows 98, how ever they wont let open the file saying it has already been removed.
Also trying to delete the folder fails.

the onlything that looks different in the directory strucutres is the cluster number (ive even tried ripping the modified/created dates/time out of an existing win98 directory)

my folders are being created around cluster 2, 3, 4 etc... while the clusternumber from win98 apears to be random and much higher so im wondering if it doesnt like this?

Posted: Sat May 05, 2007 8:47 pm
by pcmattman
You have to create the clusters for a new file/folder at the first free FAT entry (ie. 0x0000). If you don't Windows will complain. Also, a file with no data in it has a cluster entry of 0. As soon as you write data to it, it becomes whatever free cluster there is.

Posted: Sun May 06, 2007 5:29 am
by supagu
hrmm i thought the first data cluster was cluster 2, 0 and 1 were reserved....

Posted: Sun May 06, 2007 5:12 pm
by pcmattman
I meant the value at an arbitary entry in the FAT table. For instance, cluster entry 30 might be 0x0000, means you don't need to go any further (there is never another entry after a null).

What I also meant was that the value in the 'cluster' field of the directory entry is always 0 if there is no data in the file. As soon as data is put into the file, the cluster entry is changed back to the proper value.

I know, because I wrote 'create file' functions that worked. I just couldn't get my write functions to work (mainly because I couldn't figure out how to allocate more space for the file in the FAT).

Read the Microsoft FAT docs. Everything you need is there. Believe me, that's where I wrote my driver from. A hex editor also helps.

Posted: Mon May 07, 2007 12:07 am
by supagu
i havent got around to creating files yet, im just trying to make a valid directory

Posted: Mon May 07, 2007 2:22 am
by pulsar
You said you haven't started creating files that means, you are not creating dot entries and dotdot entries in the directory. I like to know whether you have already played with Fat12. If so then playing with fat32 entries also easy.

Posted: Wed May 09, 2007 4:46 am
by supagu
i have added the . and .. directorys
i guess i should proably try to get files working first