FAT32Considerations.htm

Latest update: March 29, 2005

 

 

FAT32

Support for FAT32 file and drive operations are the driving force behind the version 4 release of PicoDOS and since file and drive operations represent the primary purpose of PicoDOS, the changes, at least internally, are extensive. However, from the outside the appearance and APIs remain mostly the same and most users will be able to migrate with little or no effort. The few but important exceptions are described after introducing the benefits of FAT32.

Volumes larger than 2GB!
FAT32 adds support for volumes greater than 2GB which had been the PicoDOS limit in earlier versions which offered only FAT12 and FAT16 support. The number after “FAT” refers to the size in bits of the index entries used to map out space on DOS/Windows file systems like the one used by PicoDOS. The smaller the bit-size, the less space is used for managing files and the more space available for your data. However, the smaller the bit-size, the smaller is the maximum volume size supported. FAT12 is generally used only for volumes less than about 5MB. FAT16 is viable for everything from 5MB to 2GB and both PicoDOS will attempt to format volumes over 2GB as FAT32. This cutover value can be overridden as described ahead.

Root Directories - FAT32 volumes grow as needed, FAT16 defaults to maximum of 512 files in root!
FAT32 volumes treat the root directory just like any other subdirectory. This means they can grow dynamically to meet specific needs. On the other hand, FAT16 volumes default to a paltry 512 entries in the root directory. Prior to version 4, PicoDOS had to resort to non-standard formatting tricks get more entries into the root. This worked, but it made data recovery from damaged media more difficult with automated tools. The version 4 FORMAT command still supports extended root entries for FAT32 but requires an explicit \Dnnnn switch in the command line.

Free space hints
32-bit FAT entries and 100GB drives can expand the FAT table size by a factor of 100 over the largest FAT16 volume. That also means that some file and drive operations can also now take up to 100 times longer than they did with FAT16. In particular, finding new space to write data after opening a file could take increasingly more time as the volume fills up because the larger amounts of FAT information have to be read in and scanned. Finding out the total amount of free space could require reading the entire 10MB+ FAT table. That translates to about a minute for either a fast 100GB hard drive or a 10GB flash card. To deal with this, Microsoft introduced hint mechanisms with FAT32 to address both of these issues. The end result actually makes well-behaved FAT32 volumes work faster than smaller FAT16 volumes.

API Changes

There are two classes of API changes in PicoDOS version 4. One is the elimination of a few unnecessary public functions to make room for the FAT32 code. The other is changes forced on PicoDOS to deal with volume sizes that are larger than 32-bit longs and with functions that can no longer deal correctly with that.

Gone from PicoDOS are:

         DIRFreeSpace returned a volumes free space in bytes which overflows to become a meaningless number for volumes over 2GB. Version 4 returns -1 for any result that can't be expressed in a signed long. See DSDFreeSectors ahead for functional replacement.

         DIRTotalSpace has the same problems as DIRFreeSpace and you should see DSDDataSectors ahead for its functional replacement.

         pdcfinfo has the same problems as DIRFreeSpace and DIRTotalSpace but this legacy call has no direct replacement in version 4 other than that its results can be determined by calls to both DSDFreeSectors and DSDDataSectors.

         FAT12 formatting is no longer supported with version 4 although it will still mount and allow file operations on cards formatted outside of PicoDOS. It’s very likely that FAT12 will be completely eliminated in a future version of PicoDOS. Squawk now if you have a problem with that.

 

New to PicoDOS are:

         DSDFreeSectors returns the count of sectors currently available for data on the specified logical. For volumes less than 2GB you can simply multiple the returned value by SECTOR_SIZE to get the byte count. Be aware that the predecessor DIRFreeSpace function passed in a drive string argument while DSDFreeSectors uses a logdrv integer value.

         DSDDataSectors returns the count of sectors available for data on the specified logical drive it is empty. For volumes less than 2GB you can simply multiple the returned value by SECTOR_SIZE to get the byte count. Be aware that the predecessor DIRFreeSpace function passed in a drive string argument while DIRTotalSpace uses a logdrv integer value.

         SYS.F32MBCUT allows you to override the 2GB FAT32 cutover default value used by FDISK and FORMAT when creating partitions. Find this defined in <_cfx_globals.h>. Change this from the C:\> prompt as follows:
C:\>set /l

VEE variable name ? SYS.F32MBCUT

Long integer data ? 300
You can also override the cutover in the command line to FDISK with the /M and then overriding the PTyp setting offered by fdisk with the value 12 which forces FAT32.

         SYS.F32TRUST allows you to override the default skeptical hint acceptance that PicoDOS applies to newly mounted volumes. Find this defined in <_cfx_globals.h>.