]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: vfat: report fssize
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 29 Nov 2022 03:14:33 +0000 (04:14 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 13 Dec 2022 18:34:40 +0000 (18:34 +0000)
24 files changed:
libblkid/src/superblocks/vfat.c
tests/expected/blkid/low-probe-fat
tests/expected/blkid/low-probe-fat16_noheads
tests/expected/blkid/low-probe-fat32_cp850_O_tilde
tests/expected/blkid/low-probe-fat32_label_64MB
tests/expected/blkid/low-probe-fat32_mkdosfs_label1
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_NO_NAME
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_empty
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_dosfslabel_label2
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_NO_NAME
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_mlabel_erase
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_erase
tests/expected/blkid/low-probe-fat32_mkdosfs_label1_xp_label2
tests/expected/blkid/low-probe-fat32_mkdosfs_none
tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_NO_NAME
tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1
tests/expected/blkid/low-probe-fat32_mkdosfs_none_dosfslabel_label1_xp_label2
tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1
tests/expected/blkid/low-probe-fat32_mkdosfs_none_xp_label1_dosfslabel_label2
tests/expected/blkid/low-probe-fat32_xp_label1
tests/expected/blkid/low-probe-fat32_xp_none
tests/expected/blkid/low-probe-fat32_xp_none_dosfslabel_label1
tests/expected/blkid/low-probe-fat32_xp_none_mlabel_label1
tests/expected/blkid/low-probe-small-fat32

index 6cd58cc71f95467407052acaadef3a5362e256b2..6d3b09171e1f8001bc4ad92cd60c780a8d36a066 100644 (file)
@@ -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,
+                               &sect_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;
 }
index bb686b24e552be288e83a4dbfbe89c8c609316fd..24099f5f4cdf3b082ef5f6099ecb7441020da611 100644 (file)
@@ -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
index 5b8fc916ebc26e2129b1ca16bd4e2c37269cd1fd..22e6d49d63468fb1deeba6dfd4a1a293c8b73821 100644 (file)
@@ -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
index 16c5198847fdb3d379055643468574bd7c089fcc..00cb87501416b53b952daa0f4325e051f714b033 100644 (file)
@@ -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=___
index 41b656a84c8de68e5c7078c5df3be54b5ffe90ad..31bdb9f33036049212db033b52f060a09326d60e 100644 (file)
@@ -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
index 14aee2eb9a31b077853c9afcfebd83c292d4ebee..35afd616ca73657f7e9e89243835447d65654c2f 100644 (file)
@@ -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
index 1891157edcb7732035bb679d599c4e8825323839..449716a2a094969019853a8722b7acecd2c263c7 100644 (file)
@@ -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
index 206782fa9c58103e9930433cd59312025fb859a7..93b55c72bd9a97c01055d60c1c24c9cfb661f9a4 100644 (file)
@@ -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
index cf635a2186aba2ee0479592b262cce5ecf1d4f75..5ad9e08e6043c6d5729f1439aaf29af46092280a 100644 (file)
@@ -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
index 1891157edcb7732035bb679d599c4e8825323839..449716a2a094969019853a8722b7acecd2c263c7 100644 (file)
@@ -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
index 206782fa9c58103e9930433cd59312025fb859a7..93b55c72bd9a97c01055d60c1c24c9cfb661f9a4 100644 (file)
@@ -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
index 6088d17be248337e00aaf6757db537da9266ed00..52e79f9bfde89b9a444ffe2906bee35ffc62ff27 100644 (file)
@@ -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
index 802a66f14c0b3ee5d3498bea278e3387d581f448..65b19e99c09a03d67686ae0929baadb8f4e66364 100644 (file)
@@ -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
index 66a7923ed7bfcef64a35eee5053db4d1921a9362..fdd9129cd2673ca09d1cb1d0857165e065dd8a23 100644 (file)
@@ -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
index 66a7923ed7bfcef64a35eee5053db4d1921a9362..fdd9129cd2673ca09d1cb1d0857165e065dd8a23 100644 (file)
@@ -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
index e45da35d827dff05075fddccbb65ad71797122b4..b5ae67aa17abdd0e17f42af1ea93649f2e85a8dd 100644 (file)
@@ -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
index ad2bf8fda7433be81500b06926de23bbb1b9033d..dd21413e06a79247dabfe0ff913bf8e189f43a24 100644 (file)
@@ -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
index a5e49006409be9980d216b6c5a3cd35ecd8f24cd..656439608e8b55ad988e8a73dc486d2e504f87c1 100644 (file)
@@ -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
index e3473b9cc583c4971d9ce6d8d86fe759339cd617..33ef639e834d569cbbc4f7716feea969265b88d9 100644 (file)
@@ -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
index 9a82d11c2b744737d09a13709a3bebedfdc18300..39ade41b05e89d849d61ced97f02a03c4d819d1d 100644 (file)
@@ -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
index b4d6f4fdf8e8b279328859f40201c8fa7d2b5cdf..4490b16032078737a3fe11725272acfebe6e52d7 100644 (file)
@@ -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
index 560b394a092584eb34b6d4ae1ab60a6047d09824..89d32a1bac9e8ed0e90aafb77232021525cb9932 100644 (file)
@@ -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
index 1b0a87806fe7a69b674c91a71c04ae7bc1aaf8eb..9c7c7d4eeb76c981346a8b4ce215e3b815e22a25 100644 (file)
@@ -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
index e6ffb6550762e4a4e3bde34db2cfbd415cb97b35..d215a6e05c2933bdab2d200d4f3ac0ab9215f849 100644 (file)
@@ -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