fat32 only partially working

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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post 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!
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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. ;)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post 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.

?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post 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?
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post by supagu »

hrmm i thought the first data cluster was cluster 2, 0 and 1 were reserved....
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post by supagu »

i havent got around to creating files yet, im just trying to make a valid directory
User avatar
pulsar
Member
Member
Posts: 49
Joined: Wed Nov 22, 2006 1:01 am
Location: chennai

Post 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.
everyone here are best programmers ( not yet not yet)
supagu
Member
Member
Posts: 46
Joined: Sat Apr 07, 2007 1:24 am

Post by supagu »

i have added the . and .. directorys
i guess i should proably try to get files working first
Post Reply