Hi, Mark just confirmed that he REALLY means 32768 BYTES PER SECTOR.
This fun is brought to us by NTFS4DOS which creates fake cluster sizes
of 1 MB and bigger to get the statistics displayed right for insanely
big drives...

Still I insist on the need for "you must not only check the carry
flag but also the returned AL value, otherwise you will treat MS
DOS 6 kernels as if they would support FAT32, and will start to do
calculations with random values"...!

Back to the overflow / underflow...

> >                 convert(FAT32_Free_Space.free_clusters / 
> >                                   ((1024l*1024) / clustersize), buffer);

Divides by zero if you have less than 1 cluster per megabyte.
Same for my approach, although I still like it better:

> convert(FAT32_Free_Space.free_clusters / (2048UL / (clustersize/512)), 
> buffer);

I suggest the solution for the underflow as follows:

while (clustersize > (1024L*1024)) {
  FAT32_Free_Space.free_clusters <<= 1;
argh! yikes... sorry. next attempt...

while (clustersize > (1024L*1024)) { 
  FAT32_Free_Space.free_clusters >>= 1;
  clustersize >>= 1;
}
convert(FAT32_Free_Space.free_clusters /
  (2048UL / (clustersize/512)), buffer);

That should finally be foolproof for cluster sizes between 512 bytes
(but not for smaller ones!) and infinity... Even more foolproof might be:

while (clustersize > (1024L*1024)) { 
  FAT32_Free_Space.free_clusters >>= 1;
  clustersize >>= 1;
}
convert(FAT32_Free_Space.free_clusters /
  ((1024L*1024) / clustersize), buffer);

which should work for cluster sizes between 1 byte and 1 or 2 GBytes ;-).

Eric



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to