From 936c5d9951353e7aaf848ce2ec5dbb0e1b5ca35e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 24 Oct 2022 23:34:04 +0200 Subject: [PATCH] libblkid: cramfs: report version --- libblkid/src/superblocks/cramfs.c | 7 +++---- tests/expected/blkid/low-probe-cramfs | 1 + tests/expected/blkid/low-probe-cramfs-big | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libblkid/src/superblocks/cramfs.c b/libblkid/src/superblocks/cramfs.c index 8d01d39fcb..39e12c1a76 100644 --- a/libblkid/src/superblocks/cramfs.c +++ b/libblkid/src/superblocks/cramfs.c @@ -57,9 +57,6 @@ static int cramfs_verify_csum(blkid_probe pr, const struct blkid_idmag *mag, uint32_t crc, expected, csummed_size; unsigned char *csummed; - if (!(cfs32_to_cpu(le, cs->flags) & CRAMFS_FLAG_FSID_VERSION_2)) - return 1; - expected = cfs32_to_cpu(le, cs->info.crc); csummed_size = cfs32_to_cpu(le, cs->size); @@ -86,12 +83,14 @@ static int probe_cramfs(blkid_probe pr, const struct blkid_idmag *mag) return errno ? -errno : 1; int le = cramfs_is_little_endian(mag); + int v2 = cfs32_to_cpu(le, cs->flags) & CRAMFS_FLAG_FSID_VERSION_2; - if (!cramfs_verify_csum(pr, mag, cs, le)) + if (v2 && !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)); + blkid_probe_sprintf_version(pr, "%d", v2 ? 2 : 1); return 0; } diff --git a/tests/expected/blkid/low-probe-cramfs b/tests/expected/blkid/low-probe-cramfs index a82046a9f5..ccab3d75ef 100644 --- a/tests/expected/blkid/low-probe-cramfs +++ b/tests/expected/blkid/low-probe-cramfs @@ -3,3 +3,4 @@ ID_FS_LABEL=test-cram ID_FS_LABEL_ENC=test-cram ID_FS_TYPE=cramfs ID_FS_USAGE=filesystem +ID_FS_VERSION=2 diff --git a/tests/expected/blkid/low-probe-cramfs-big b/tests/expected/blkid/low-probe-cramfs-big index 9a4dfca7be..f5f378fea9 100644 --- a/tests/expected/blkid/low-probe-cramfs-big +++ b/tests/expected/blkid/low-probe-cramfs-big @@ -3,3 +3,4 @@ ID_FS_LABEL=Compressed ID_FS_LABEL_ENC=Compressed ID_FS_TYPE=cramfs ID_FS_USAGE=filesystem +ID_FS_VERSION=2 -- 2.47.3