typedef struct { CTL_MS_BLOCK_DRIVER_t *block_driver; CTL_MUTEX_t mutex; CTL_MS_VOLUME_STATE_t state; unsigned sectors_per_cluster; unsigned reserved_sector_count; unsigned root_entry_count; unsigned number_of_fats; CTL_MS_FILE_SYSTEM_FORMAT_t format; CTL_MS_LBA_t second_fat_offset; CTL_MS_LBA_t partition_addr; CTL_MS_LBA_t root_dir_sector; CTL_MS_LBA_t current_dir_sector; CTL_MS_LBA_t working_dir_sector; CTL_MS_LBA_t fat1_sector; CTL_MS_LBA_t fat2_sector; CTL_MS_LBA_t first_data_sector; CTL_MS_CLUSTER_t total_data_clusters; CTL_MS_CLUSTER_t free_cluster; CTL_MS_CLUSTER_t root_cluster; CTL_MS_LBA_t fsinfo_sector; CTL_STATUS_t error; char temp_name[]; CTL_MS_FILE_tag *__open_files; CTL_MS_VOLUME_s *__next; const char *__name; const CTL_STREAM_DRIVER_t *methods; CTL_STATUS_t (*open_fcb)(CTL_MS_VOLUME_s *, CTL_MS_FCB_t *, const char *, const char *, CTL_MS_MODE_t); } CTL_MS_VOLUME_t;
CTL_MS_VOLUME_t describes the internal state of a volume which the mass storage library uses. It is not publicized by any function and all data inside it, if you wish to examine members, should be considered read-only. We do not guarantee that the structure will be stable across releases of the mass storage library.
Only the members block_driver, mutex, and state are valid for volumes that are not mounted; all other members should be considered invalid for offline volumes.
Member | Description |
block_driver | This is public knowledge and you're responsible for populating it. Methods to read and write a single 512-byte sector. |
mutex | Volume mutex; this is a per-volume mutex that is locked when the volume is accessed by the mass storage library. |
state | The internal state of the volume. A volume can be in offline, online, and mounted states. |
sectors_per_cluster | The number of 512-byte sectors per FAT cluster. |
reserved_sector_count | The number of sectors that are marked as reserved at the start of the media. |
root_entry_count | The number of directory entries in the root directory for FAT12 and FAT16 volumes. |
number_of_fats | The number of FATs contained on the volume. This is either one or two. |
fat_type | The type of FAT volume, either FAT12, FAT16, or FAT32. |
second_fat_offset | The LBA offset from the start of the volume for the second FAT. |
partition_addr | The LBA of the first sector of the volume on the media. |
root_dir_sector | The LBA of the first sector of the volume's root directory. |
current_dir_sector | The LBA of the internal current working directory. This does not correspond to the ‘current directory’ that operating systems such as MS-DOS, Windows, and Unix have. This is purely an internal convenience for the implementation of the mass storage library. |
working_dir_sector | The LBA of the internal working directory. This is purely an internal convenience for the implementation of the mass storage library. |
fat1_sector | The LBA of the first sector of the first FAT. |
fat2_sector | The LBA of the first sector of the second FAT; if there is no second FAT, this member is undefined. |
first_data_sector | The LBA of the first data sector relative to the start of the volume. The first data sector follows the reserved sectors, FATs, and root directory entries. |
total_data_clusters | The number of data clusters for the volume. |
free_cluster | The index of the first potentially-free cluster on the volume. The first two clusters of a FAT volume are reserved. This member is maintained internally by the mass storage library to accelerate finding free clusters in the FAT. |
root_cluster | The cluster index of the root directory for FAT32 volumes. This member is undefined for FAT12 and FAT16 volumes. |
fsinfo_sector | The LBA of the FSInfo sector relative to the start of the volume. This member is undefined for FAT12 and FAT16 volumes. |
error | The last reported error for the volume. This is maintained internally by the mass storage library and has no relevance for any client. |
temp_name | A temporary working name store for the mass storage library. This is maintained internally by the mass storage library and has no relevance for any client. |
open_files | A linked list of files that are open on the volume. |