FAT32 file system - Adding and removing files.

FAT32 file system - Adding and removing files.

Post by superhac00 » Sat, 19 Sep 2009 05:36:21


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
 
 
 

FAT32 file system - Adding and removing files.

Post by Seeb » Sat, 19 Sep 2009 06:01:36


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
--
Copyright 2009, all wrongs reversed. Peter Seebach / XXXX@XXXXX.COM
http://www.yqcomputer.com/ ;-- lawsuits, religion, and funny pictures
http://www.yqcomputer.com/ (Scientology) <-- get educated!

 
 
 

FAT32 file system - Adding and removing files.

Post by superhac00 » Sat, 19 Sep 2009 06:13:38


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
 
 
 

FAT32 file system - Adding and removing files.

Post by Beej Jorge » Sat, 19 Sep 2009 08:39:51


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

http://www.yqcomputer.com/ +v2.6.31/fs/fat/dir.c#L1230
http://www.yqcomputer.com/ +v2.6.31/fs/fat/dir.c#L984

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

-Beej
 
 
 

FAT32 file system - Adding and removing files.

Post by Paul » Sat, 19 Sep 2009 20:51:33


...

You could try looking at application notes, or device driver libraries,
for embedded processors that have USB mass storage device drivers.
There should/may be one that implements a proper FAT system.

An example of this would be the STM32 USB device library (mass
storage device example), although I suspect that this particular
example may emulate rather than implement a FAT system.
http://www.yqcomputer.com/
(it's called STM32_USB-FS-Device_Lib)

Paul.
 
 
 

FAT32 file system - Adding and removing files.

Post by Chris M. T » Sat, 19 Sep 2009 21:14:24


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://www.yqcomputer.com/


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






;^)
 
 
 

FAT32 file system - Adding and removing files.

Post by superhac00 » Sat, 19 Sep 2009 22:39:40


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
 
 
 

FAT32 file system - Adding and removing files.

Post by robertwess » Sun, 20 Sep 2009 02:15:15

On Sep 18, 8:39m, " XXXX@XXXXX.COM " < XXXX@XXXXX.COM >





While OT, this is pretty much the definitive specification for FAT:

http://www.yqcomputer.com/