When you delete an entry in the DIR by writing E5 to the first byte, you
must first deallocate all used sectors.
(If you don't, you have to old DOS problem of lost clusters)
Delete File:
Starting at First Cluster, (from Dir entry)
Walk through the cluster allocation table,
unlinking each cluster from the file (returning to free)
Then mark first byte of file name to E5.
As for writing, it is just the reverse...
Make sure the files does not exist, if it does, delete it per above.
Search the directory for an entry starting in NULL or 0xE5 (previously
deleted)
Fill in your information in that structure. (File names are fixed size,
not null terminated. Pad with blanks)
Find a free cluster from the Cluster Allocation Table.
Put that entry into the Dir.
Mark that cluster as EOF (FFFF) in the CAT
Write the first cluster of information.
If there is more, find another free cluster
Mark the new cluster as EOF in the Cat
Change the EOF on the prior cluster from EOF to point to
this cluster
Repeat till end of file...
Update the directory structure with file size, time (if desired).
_____
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf
Of rtstofer
Sent: Thursday, November 10, 2005 12:15 PM
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: Cheap SD Flash File System
--- In lpc2000@yahoogroups.com, "Joel Winarske" <joelw@i...> wrote:
>
> > > does somebody have some good documentations about FAT12/16/32?
(And
> > > would share it?) ;-)
> >
> >
> > http://www.ntfs.com/fat-systems.htm
>
> Also:
>
> http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
>
>
> Joel
>
I just ported the FAT32 file system stuff from WinAVR to ARM. I
used both of the references above and, at the moment, I can read and
follow the chains of files created by WinXP. The files don't have
to be defragged but, as a limitation, I only use the short file name.
Neither of those specs deals with the issue of creating a file. Do
you just go look for a deleted file and use all of its' allocation
until you need more? Since you only have the single directory
entry, how do you grab allocation units away from other deleted
files? How do you find an empty allocation unit in the FAT? How do
you insure that you are building a proper short file name from a
long one, and vice versa. In FAT32, both are required and the
directory entries must be contiguous.
There are HUGE holes in both of those docs. So, for my MP3 player,
I can only read files based on 8.3 names. Not a good situation.
I really want a writable configuration file that will tell the
player how to deal with serial commands, telnet commands and the
hardware inputs/outputs. At a minimum, I need to tie a file name to
an input pin so an effect file will play if a sensor is tripped. I
would like to do the configuration interactively via serial or
telnet but, as I can't open a file for writing, that isn't
happening, yet... It's on back burner until I get the ethernet
stuff integrated with the CF and MP3 - maybe next week.
Richard
SPONSORED LINKS
Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2
=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=9
3&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&
w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s
=93&.sig=DvJVNqC_pqRTm8Xq01nxwg>
Pic microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microproces
sor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c
=4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
8051 microprocessor
<http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocess
or&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=
4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A>
_____
YAHOO! GROUPS LINKS
* Visit your group "lpc2000
<http://groups.yahoo.com/group/lpc2000> " on the web.
* To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> .
_____
[Non-text portions of this message have been removed]Message
RE: [lpc2000] Re: Cheap SD Flash File System
2005-11-10 by Dan Beadle
Attachments
- No local attachments were found for this message.