]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: udf: Fix parsing UDF revision
authorPali Rohár <pali.rohar@gmail.com>
Mon, 20 Nov 2017 17:16:59 +0000 (18:16 +0100)
committerPali Rohár <pali.rohar@gmail.com>
Mon, 20 Nov 2017 17:16:59 +0000 (18:16 +0100)
UDF revision is stored as decimal number in hexadecimal format.
E.g. number 0x0150 is revision 1.50, number 0x0201 is revision 2.01.

Apparently all UDF test images have number which has same representation in
decimal and hexadecimal format, so problem was not detected.

This patch adds new test image with UDF revision 1.50. Internally number is
stored as 0x0150. In decimal format it is (incorrectly) 1.80, but in
hexadecimal correct 1.50.

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-8.img bs=1M count=10
$ mkudffs -r 0x150 -b 512 udf-hdd-mkudffs-1.3-8.img

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
libblkid/src/superblocks/udf.c
tests/expected/blkid/low-probe-udf-hdd-mkudffs-1.3-8 [new file with mode: 0644]
tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz [new file with mode: 0644]

index 756fbcf63b67a638dbc9468162fc2a09392a0876..bd8e0a5c2565f7d01588430b092436dc477fecf3 100644 (file)
@@ -450,7 +450,9 @@ real_blksz:
        }
 
        if (udf_rev)
-               blkid_probe_sprintf_version(pr, "%d.%02d", (int)(udf_rev >> 8), (int)(udf_rev & 0xFF));
+               /* UDF revision is stored as decimal number in hexadecimal format.
+                * E.g. number 0x0150 is revision 1.50, number 0x0201 is revision 2.01. */
+               blkid_probe_sprintf_version(pr, "%x.%02x", (unsigned int)(udf_rev >> 8), (unsigned int)(udf_rev & 0xFF));
 
        return 0;
 }
diff --git a/tests/expected/blkid/low-probe-udf-hdd-mkudffs-1.3-8 b/tests/expected/blkid/low-probe-udf-hdd-mkudffs-1.3-8
new file mode 100644 (file)
index 0000000..448c8f9
--- /dev/null
@@ -0,0 +1,10 @@
+ID_FS_LABEL=LinuxUDF
+ID_FS_LABEL_ENC=LinuxUDF
+ID_FS_LOGICAL_VOLUME_ID=LinuxUDF
+ID_FS_TYPE=udf
+ID_FS_USAGE=filesystem
+ID_FS_UUID=5a11940936fe76a8
+ID_FS_UUID_ENC=5a11940936fe76a8
+ID_FS_VERSION=1.50
+ID_FS_VOLUME_ID=LinuxUDF
+ID_FS_VOLUME_SET_ID=5a11940936fe76a8LinuxUDF
diff --git a/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz
new file mode 100644 (file)
index 0000000..b91180c
Binary files /dev/null and b/tests/ts/blkid/images-fs/udf-hdd-mkudffs-1.3-8.img.xz differ