FAT32 file system - Adding and removing files.

S

superhac007

Hi,

I am looking for information on how to add and remove files from a
fat32 file system. Specifically the pseudo mechanics not actual
code. I have some idea, but I'm not sure if this is the optimum way.

For adding I am assuming the following steps:

1) add the file entry to the directory. Do I find the first available
entry (0x00) or can I replace a deleted directory entry (0xE5)?

2) Find an available cluster in the FAT Table. Do I search for the
first available entry location that is set to 0x00000000?

3) Break up the file data among clusters and update the FAT entries,
and set starting cluster of file.

for deleting:

1) set the filename length to 0xE5. Then do I reset the clusters that
make up that file to (0x00000000)?

Thanks,

Steve
 
S

Seebs

Hi,

I am looking for information on how to add and remove files from a
fat32 file system. Specifically the pseudo mechanics not actual
code. I have some idea, but I'm not sure if this is the optimum way.

You might try a DOS or Windows newsgroup, as this has entirely to do with
a filesystem. You could write this code in any language you wanted, and
it would be essentially the same.

-s
 
S

superhac007

 I am looking for information on how to add and remove files from a
fat32 file system.  Specifically the pseudo mechanics not actual
code.  I have some idea, but I'm not sure if this is the optimum way.

[...]

I would recommend using fopen() and remove().

lol... ;)

This is a from scratch parser. As in I am parsing the disk raw. I've
got the boot sector parsed, fat table parsed, and can navigate the
directories, but I am looking for the proper way to add and remove
files. I can't seem to find any examples on the web.

Steve
 
C

Chris M. Thomasson

Seebs said:
You might try a DOS or Windows newsgroup, as this has entirely to do with
a filesystem. You could write this code in any language you wanted, and
it would be essentially the same.

How would you react to the following statement:


You cannot create low-level algorithm X in any language you wanted to, C/C++
aside of course!!!!!:


http://groups.google.com/group/comp.lang.c/msg/d8ae596a08b7afd9


without resorting to unsafe coding practices wrt said languages
safe-guards...






;^)
 
S

superhac007

Seems unlikely that people here would know, but I could recommend the
Linux kernel source as a reference:

http://lxr.linux.no/linux+v2.6.31/f.../lxr.linux.no/linux+v2.6.31/fs/fat/dir.c#L984

But, to be honest, I don't know a thing about it.

-Beej

Thanks Beej. That was exactly what I was looking for. For some
reason I never thought of looking at the Linux modules for FAT, even
though I'm working on Linux!! It appears that I was pretty close with
my assumptions on first glance.

I'm with you before I started this project I never looked at how file
systems worked. Its an obscure topic, and most people would just use
ready made drivers. I learned quite a bit so far, and now have a
great appreciation for the role it fulfills.


Thanks again,

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top