]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: cramfs: report version
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 24 Oct 2022 21:34:04 +0000 (23:34 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 25 Oct 2022 22:43:18 +0000 (00:43 +0200)
libblkid/src/superblocks/cramfs.c
tests/expected/blkid/low-probe-cramfs
tests/expected/blkid/low-probe-cramfs-big

index 8d01d39fcb76b102b5858e79e8b24939d1257e74..39e12c1a76cc34c3072878f99188355174a67386 100644 (file)
@@ -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;
 }
 
index a82046a9f5b8e7670955ead6d8806385914da15f..ccab3d75ef1e68a0371012c9cc029505325516db 100644 (file)
@@ -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
index 9a4dfca7be758ba74cbae58280fa3386231f9e4c..f5f378fea99634b1fd2d05b87d441e25940f2fec 100644 (file)
@@ -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