Chapter 37. Formatting Support
If the option CYGSEM_FS_FAT_FORMAT
is enabled, the
filesystem is able to format the chosen volume with a FAT filesystem
while mounting it. This is controlled by a number of options passed
to the filesystem through the mount function.
- format
-
This option enables formatting. If this is present without an
argument, then the volume will only be formatted if the file system
cannot be mounted. With an argument of
force
the volume will be formatted regardless of its current contents. Without this option present, the following options will be ignored. - fat16
- This option forces the file system to be formatted using FAT16.
- fat32
-
This option forces the file system to be formatted using FAT32. If
neither the
fat16
orfat32
options are provided, the formatter will choose the format based on the size of the volume. At present, any volume less than 512MiB in size will be formatted as FAT16, all others will be FAT32. - clsize
- This option takes an argument giving the size of each cluster in KiB. It should be a power of 2. If not supplied, the formatter will choose a cluster size based on the size of the volume.
- label
- This option takes a name which should be up to 11 characters in length. This is used to set the volume label in the boot block and to create a volume label entry in the root directory. If not supplied a default volume label will be set (currently "eCos DISK").
A somewhat contrived example of a mount call with the format option might be as follows:
err = mount("/dev/hd0/1", "/disk0", "fatfs:format=force,fat16,clsize=8,label=My Volume");
Under normal circumstances, just giving the format
option should be sufficient for most purposes:
err = mount("/dev/hd0/1", "/disk0", "fatfs:format");
This will cause the volume to be formatted according to its size, but only if it is not already mountable.
2024-12-10 | eCosPro Non-Commercial Public License |