From: Thomas Weißschuh Date: Tue, 29 Nov 2022 03:14:33 +0000 (+0100) Subject: libblkid: vfat: report fssize X-Git-Tag: v2.39-rc1~366^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67dc634fe2f241fa7b54a18a4416037eeee5e99c;p=thirdparty%2Futil-linux.git libblkid: vfat: report fssize --- diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c index 6cd58cc71f..6d3b09171e 100644 --- a/libblkid/src/superblocks/vfat.c +++ b/libblkid/src/superblocks/vfat.c @@ -185,10 +185,11 @@ static int fat_valid_superblock(blkid_probe pr, const struct blkid_idmag *mag, struct msdos_super_block *ms, struct vfat_super_block *vs, - uint32_t *cluster_count, uint32_t *fat_size) + uint32_t *cluster_count, uint32_t *fat_size, + uint32_t *sect_count) { uint16_t sector_size, dir_entries, reserved; - uint32_t sect_count, __fat_size, dir_size, __cluster_count, fat_length; + uint32_t __sect_count, __fat_size, dir_size, __cluster_count, fat_length; uint32_t max_count; /* extra check for FATs without magic strings */ @@ -230,10 +231,10 @@ static int fat_valid_superblock(blkid_probe pr, dir_entries = unaligned_le16(&ms->ms_dir_entries); reserved = le16_to_cpu(ms->ms_reserved); - sect_count = unaligned_le16(&ms->ms_sectors); + __sect_count = unaligned_le16(&ms->ms_sectors); - if (sect_count == 0) - sect_count = le32_to_cpu(ms->ms_total_sect); + if (__sect_count == 0) + __sect_count = le32_to_cpu(ms->ms_total_sect); fat_length = le16_to_cpu(ms->ms_fat_length); if (fat_length == 0) @@ -243,7 +244,7 @@ static int fat_valid_superblock(blkid_probe pr, dir_size = ((dir_entries * sizeof(struct vfat_dir_entry)) + (sector_size-1)) / sector_size; - __cluster_count = (sect_count - (reserved + __fat_size + dir_size)) / + __cluster_count = (__sect_count - (reserved + __fat_size + dir_size)) / ms->ms_cluster_size; if (!ms->ms_fat_length && vs->vs_fat32_length) max_count = FAT32_MAX; @@ -257,6 +258,8 @@ static int fat_valid_superblock(blkid_probe pr, *fat_size = __fat_size; if (cluster_count) *cluster_count = __cluster_count; + if (sect_count) + *sect_count = __sect_count; if (blkid_probe_is_bitlocker(pr)) return 0; @@ -291,7 +294,7 @@ int blkid_probe_is_vfat(blkid_probe pr) if (!vs) return errno ? -errno : 0; - return fat_valid_superblock(pr, mag, ms, vs, NULL, NULL); + return fat_valid_superblock(pr, mag, ms, vs, NULL, NULL, NULL); } /* FAT label extraction from the root directory taken from Kay @@ -304,7 +307,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag) const unsigned char *boot_label = NULL; unsigned char *vol_serno = NULL, vol_label_buf[11]; uint16_t sector_size = 0, reserved; - uint32_t cluster_count, fat_size; + uint32_t cluster_count, fat_size, sect_count; const char *version = NULL; ms = blkid_probe_get_sb(pr, mag, struct msdos_super_block); @@ -315,7 +318,8 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag) if (!vs) return errno ? -errno : 1; - if (!fat_valid_superblock(pr, mag, ms, vs, &cluster_count, &fat_size)) + if (!fat_valid_superblock(pr, mag, ms, vs, &cluster_count, &fat_size, + §_count)) return 1; sector_size = unaligned_le16(&ms->ms_sector_size); @@ -435,6 +439,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag) blkid_probe_set_fsblocksize(pr, vs->vs_cluster_size * sector_size); blkid_probe_set_block_size(pr, sector_size); + blkid_probe_set_fssize(pr, (uint64_t) sector_size * sect_count); return 0; } diff --git a/tests/expected/blkid/low-probe-fat b/tests/expected/blkid/low-probe-fat index bb686b24e5..24099f5f4c 100644 --- a/tests/expected/blkid/low-probe-fat +++ b/tests/expected/blkid/low-probe-fat @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=1474560 ID_FS_LABEL=TEST-FAT ID_FS_LABEL_ENC=TEST-FAT ID_FS_LABEL_FATBOOT=TEST-FAT diff --git a/tests/expected/blkid/low-probe-fat16_noheads b/tests/expected/blkid/low-probe-fat16_noheads index 5b8fc916eb..22e6d49d63 100644 --- a/tests/expected/blkid/low-probe-fat16_noheads +++ b/tests/expected/blkid/low-probe-fat16_noheads @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=4096 +ID_FS_FSSIZE=219898368 ID_FS_LABEL=VTech_1070 ID_FS_LABEL_ENC=VTech\x201070 ID_FS_SEC_TYPE=msdos diff --git a/tests/expected/blkid/low-probe-fat32_cp850_O_tilde b/tests/expected/blkid/low-probe-fat32_cp850_O_tilde index 16c5198847..00cb875014 100644 --- a/tests/expected/blkid/low-probe-fat32_cp850_O_tilde +++ b/tests/expected/blkid/low-probe-fat32_cp850_O_tilde @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=___ ID_FS_LABEL_ENC=\xe5\xe5\xe5 ID_FS_LABEL_FATBOOT=___ diff --git a/tests/expected/blkid/low-probe-fat32_label_64MB b/tests/expected/blkid/low-probe-fat32_label_64MB index 41b656a84c..31bdb9f330 100644 --- a/tests/expected/blkid/low-probe-fat32_label_64MB +++ b/tests/expected/blkid/low-probe-fat32_label_64MB @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=65454080 ID_FS_LABEL=BINGO ID_FS_LABEL_ENC=BINGO ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1 b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1 index 14aee2eb9a..35afd616ca 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=label1 ID_FS_LABEL_ENC=label1 ID_FS_LABEL_FATBOOT=label1 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_NO_NAME b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_NO_NAME index 1891157edc..449716a2a0 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_NO_NAME +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_NO_NAME @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=NO_NAME ID_FS_LABEL_ENC=NO\x20NAME ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_empty b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_empty index 206782fa9c..93b55c72bd 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_empty +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_empty @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_TYPE=vfat ID_FS_USAGE=filesystem ID_FS_UUID=92B4-BA66 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_label2 b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_label2 index cf635a2186..5ad9e08e60 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_label2 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_label2 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=label2 ID_FS_LABEL_ENC=label2 ID_FS_LABEL_FATBOOT=label2 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_NO_NAME b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_NO_NAME index 1891157edc..449716a2a0 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_NO_NAME +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_NO_NAME @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=NO_NAME ID_FS_LABEL_ENC=NO\x20NAME ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_erase b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_erase index 206782fa9c..93b55c72bd 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_erase +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_erase @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_TYPE=vfat ID_FS_USAGE=filesystem ID_FS_UUID=92B4-BA66 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_erase b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_erase index 6088d17be2..52e79f9bfd 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_erase +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_erase @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL_FATBOOT=label1 ID_FS_LABEL_FATBOOT_ENC=label1 ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_label2 b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_label2 index 802a66f14c..65b19e99c0 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_label2 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_label2 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=LABEL2 ID_FS_LABEL_ENC=LABEL2 ID_FS_LABEL_FATBOOT=label1 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none b/tests/expected/blkid/low-probe-fat32_mkdosfs_none index 66a7923ed7..fdd9129cd2 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_TYPE=vfat ID_FS_USAGE=filesystem ID_FS_UUID=E6B8-AF8C diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_NO_NAME b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_NO_NAME index 66a7923ed7..fdd9129cd2 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_NO_NAME +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_NO_NAME @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_TYPE=vfat ID_FS_USAGE=filesystem ID_FS_UUID=E6B8-AF8C diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1 b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1 index e45da35d82..b5ae67aa17 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL_FATBOOT=label1 ID_FS_LABEL_FATBOOT_ENC=label1 ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1_xp_label2 b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1_xp_label2 index ad2bf8fda7..dd21413e06 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1_xp_label2 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1_xp_label2 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=LABEL2 ID_FS_LABEL_ENC=LABEL2 ID_FS_LABEL_FATBOOT=label1 diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1 b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1 index a5e4900640..656439608e 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=LABEL1 ID_FS_LABEL_ENC=LABEL1 ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1_dosfslabel_label2 b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1_dosfslabel_label2 index e3473b9cc5..33ef639e83 100644 --- a/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1_dosfslabel_label2 +++ b/tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1_dosfslabel_label2 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=label2 ID_FS_LABEL_ENC=label2 ID_FS_LABEL_FATBOOT=label2 diff --git a/tests/expected/blkid/low-probe-fat32_xp_label1 b/tests/expected/blkid/low-probe-fat32_xp_label1 index 9a82d11c2b..39ade41b05 100644 --- a/tests/expected/blkid/low-probe-fat32_xp_label1 +++ b/tests/expected/blkid/low-probe-fat32_xp_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=LABEL1 ID_FS_LABEL_ENC=LABEL1 ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_xp_none b/tests/expected/blkid/low-probe-fat32_xp_none index b4d6f4fdf8..4490b16032 100644 --- a/tests/expected/blkid/low-probe-fat32_xp_none +++ b/tests/expected/blkid/low-probe-fat32_xp_none @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_TYPE=vfat ID_FS_USAGE=filesystem ID_FS_UUID=54B6-DC94 diff --git a/tests/expected/blkid/low-probe-fat32_xp_none_dosfslabel_label1 b/tests/expected/blkid/low-probe-fat32_xp_none_dosfslabel_label1 index 560b394a09..89d32a1bac 100644 --- a/tests/expected/blkid/low-probe-fat32_xp_none_dosfslabel_label1 +++ b/tests/expected/blkid/low-probe-fat32_xp_none_dosfslabel_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL_FATBOOT=label1 ID_FS_LABEL_FATBOOT_ENC=label1 ID_FS_TYPE=vfat diff --git a/tests/expected/blkid/low-probe-fat32_xp_none_mlabel_label1 b/tests/expected/blkid/low-probe-fat32_xp_none_mlabel_label1 index 1b0a87806f..9c7c7d4eeb 100644 --- a/tests/expected/blkid/low-probe-fat32_xp_none_mlabel_label1 +++ b/tests/expected/blkid/low-probe-fat32_xp_none_mlabel_label1 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=34603008 ID_FS_LABEL=LABEL1 ID_FS_LABEL_ENC=LABEL1 ID_FS_LABEL_FATBOOT=LABEL1 diff --git a/tests/expected/blkid/low-probe-small-fat32 b/tests/expected/blkid/low-probe-small-fat32 index e6ffb65507..d215a6e05c 100644 --- a/tests/expected/blkid/low-probe-small-fat32 +++ b/tests/expected/blkid/low-probe-small-fat32 @@ -1,5 +1,6 @@ ID_FS_BLOCK_SIZE=512 ID_FS_FSBLOCKSIZE=512 +ID_FS_FSSIZE=1474560 ID_FS_LABEL=TESTVFAT ID_FS_LABEL_ENC=TESTVFAT ID_FS_LABEL_FATBOOT=TESTVFAT