From: Thomas Weißschuh Date: Mon, 24 Oct 2022 21:19:34 +0000 (+0200) Subject: libblkid: cramfs: report filesystem size X-Git-Tag: v2.39-rc1~456^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=606a47afaa7ea7bbc0b193ce41a2bfbf21947447;p=thirdparty%2Futil-linux.git libblkid: cramfs: report filesystem size --- diff --git a/libblkid/src/superblocks/cramfs.c b/libblkid/src/superblocks/cramfs.c index 76b5611e9a..8d01d39fcb 100644 --- a/libblkid/src/superblocks/cramfs.c +++ b/libblkid/src/superblocks/cramfs.c @@ -51,11 +51,11 @@ static uint32_t cfs32_to_cpu(int le, uint32_t value) return be32_to_cpu(value); } -static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag, struct cramfs_super *cs) +static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag, + struct cramfs_super *cs, int le) { uint32_t crc, expected, csummed_size; unsigned char *csummed; - int le = cramfs_is_little_endian(mag); if (!(cfs32_to_cpu(le, cs->flags) & CRAMFS_FLAG_FSID_VERSION_2)) return 1; @@ -85,10 +85,13 @@ static int probe_cramfs(blkid_probe pr, const struct blkid_idmag *mag) if (!cs) return errno ? -errno : 1; - if (!cramfs_verify_csum(pr, mag, cs)) + int le = cramfs_is_little_endian(mag); + + if (!cramfs_verify_csum(pr, mag, cs, le)) return 1; blkid_probe_set_label(pr, cs->name, sizeof(cs->name)); + blkid_probe_set_fssize(pr, cfs32_to_cpu(le, cs->size)); return 0; } diff --git a/tests/expected/blkid/low-probe-cramfs b/tests/expected/blkid/low-probe-cramfs index 7898a36720..a82046a9f5 100644 --- a/tests/expected/blkid/low-probe-cramfs +++ b/tests/expected/blkid/low-probe-cramfs @@ -1,3 +1,4 @@ +ID_FS_FSSIZE=4096 ID_FS_LABEL=test-cram ID_FS_LABEL_ENC=test-cram ID_FS_TYPE=cramfs diff --git a/tests/expected/blkid/low-probe-cramfs-big b/tests/expected/blkid/low-probe-cramfs-big index c7a2a3ee8b..9a4dfca7be 100644 --- a/tests/expected/blkid/low-probe-cramfs-big +++ b/tests/expected/blkid/low-probe-cramfs-big @@ -1,3 +1,4 @@ +ID_FS_FSSIZE=4096 ID_FS_LABEL=Compressed ID_FS_LABEL_ENC=Compressed ID_FS_TYPE=cramfs