Hi Rugxulo,
as you already found out, FAT16 is limited to 64k files
per partition and 128 kB (usually 256 sectors) per FAT.
Only rather small FAT16 drives use far less than 64k
clusters. Most drive sizes differ mainly in how large
clusters are. With the usual side-effects.
FAT32 usually has way more clusters and way larger FAT,
making it very slow to read the whole FAT to figure out
how much disk space is used and free.
*Cached FAT*
You can improve speed by loading a cache, preferably
with read-ahead, before you start doing "large" stuff
with the FAT.
If I remember correctly, I even have an example in
the LBACACHE and TICKLE docs where you deliberately
DIR /S > NUL to get all FAT and directory info in
the cache, so it already is cached when you need it
again later. Poor man's "copy disk to RAMDRIVE" ;-)
*Cached disk usage info*
You are right that Win9x buffers the answer to that in
https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#FS_Information_Sector
but you also have to keep track of whether the values
are up to data. Win9x does that by forcing you to
explicitly shut down instead of powering off. Each
time you fail to do that, it has to read the entire
FAT on the next boot to re-compute FSinfo values.
You do not want to force DOS users to explicitly
shut down before they power off. However, you could
implement something similar to the following in DOS:
I. When DOS gets asked for used/free disk space:
1. if DOS has the answer in RAM, return that
2. else read FSinfo and FAT headers to see if
FSinfo values are up to date. If yes, return
values and keep a copy of the answer in RAM :-)
3. else read entire FAT to compute values,
return them and, again, keep a copy in RAM.
For all cases (1, 2, 3) also update a copy
of the values in FSinfo and set a flag there
and/or in FAT headers, unless drive is R/O.
Only write FSinfo and FAT headers on disk
if the write would really change values!
II. When the FAT gets updated in a way which
has an effect on used/free disk space:
Reset the mentioned flag in FSinfo and/or FAT
headers, to indicate values are no longer up
to date, but do update used/free count in RAM.
Only write the flag to disk if it actually did
change! Use a copy in RAM to keep track of it.
III. You can also trigger FSinfo updates on disk
for a few selected other events, such as file
system sync / flush calls or apps exiting via
int 21.4c / int 20 etc.
Regards, Eric
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user