From 8053b51c7601c4a7e5f2eca45610b8228f53d408 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Tue, 12 Feb 2013 03:33:18 +0200 Subject: [PATCH] libblkid: Probe UDF volumes for ISO9660 info as well I have seen blkid failing to report any meaningful data on some of UDF volumes I have (Windows installer media): $ ./blkid -p -o udev en_windows_7_professional_with_sp1_x64_dvd_u_676939.iso ID_FS_LABEL=UDF_Volume ID_FS_LABEL_ENC=UDF\x20Volume ID_FS_TYPE=udf Also, once my patches to expose more of ISO9660 info get merged, we'd also need the same info to be exposed for UDF volumes. This patch adds ISO9660 probing to UDF volumes and here is the result I see on my example UDF volume (together with my pending patch to expose more ISO9660 information): $ ./blkid -p -o udev en_windows_7_professional_with_sp1_x64_dvd_u_676939.iso ID_FS_PUBLISHER_ID=MICROSOFT CORPORATION ID_FS_APPLICATION_ID=CDIMAGE 2.54 (01/01/2005 TM) ID_FS_UUID=2011-04-12-02-38-58-00 ID_FS_UUID_ENC=2011-04-12-02-38-58-00 ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION ID_FS_LABEL=GSP1RMCPRXFRER_EN_DVD ID_FS_LABEL_ENC=GSP1RMCPRXFRER_EN_DVD ID_FS_TYPE=iso9660 $ ./blkid -p -o udev en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso ID_FS_PUBLISHER_ID=MICROSOFT CORPORATION ID_FS_APPLICATION_ID=CDIMAGE 2.52 (03/09/2004 TM) ID_FS_UUID=2008-04-14-12-00-00-00 ID_FS_UUID_ENC=2008-04-14-12-00-00-00 ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION ID_FS_LABEL=GRTMPFPP_EN ID_FS_LABEL_ENC=GRTMPFPP_EN ID_FS_TYPE=iso9660 Before anyone asks, Yes! The UDF media I have is all legal and downloaded directly from MSDN. :) [kzak@redhat.com: - read LABEL from UDF only if not found anything useful in ISO9660] Signed-off-by: Karel Zak --- libblkid/src/Makemodule.am | 1 + libblkid/src/superblocks/iso9660.c | 2 +- libblkid/src/superblocks/iso9660.h | 14 ++++++++++++++ libblkid/src/superblocks/udf.c | 18 +++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 libblkid/src/superblocks/iso9660.h diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am index 90efa3d98d..1c3c7bb71d 100644 --- a/libblkid/src/Makemodule.am +++ b/libblkid/src/Makemodule.am @@ -60,6 +60,7 @@ libblkid_la_SOURCES = \ libblkid/src/superblocks/highpoint_raid.c \ libblkid/src/superblocks/hpfs.c \ libblkid/src/superblocks/iso9660.c \ + libblkid/src/superblocks/iso9660.h \ libblkid/src/superblocks/isw_raid.c \ libblkid/src/superblocks/jfs.c \ libblkid/src/superblocks/jmicron_raid.c \ diff --git a/libblkid/src/superblocks/iso9660.c b/libblkid/src/superblocks/iso9660.c index ad7bf3de12..c553012dec 100644 --- a/libblkid/src/superblocks/iso9660.c +++ b/libblkid/src/superblocks/iso9660.c @@ -166,7 +166,7 @@ static int is_str_empty(const unsigned char *str, size_t len) } /* iso9660 [+ Microsoft Joliet Extension] */ -static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag) +int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag) { struct iso_volume_descriptor *iso; unsigned char label[32]; diff --git a/libblkid/src/superblocks/iso9660.h b/libblkid/src/superblocks/iso9660.h new file mode 100644 index 0000000000..a8d729df6d --- /dev/null +++ b/libblkid/src/superblocks/iso9660.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2013 Zeeshan Ali (Khattak) + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#ifndef _BLKID_ISO9660_H +#define _BLKID_ISO9660_H + +#include "blkidP.h" + +extern int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag); + +#endif /* _BLKID_ISO9660_H */ diff --git a/libblkid/src/superblocks/udf.c b/libblkid/src/superblocks/udf.c index a5afc5c587..2cb471df27 100644 --- a/libblkid/src/superblocks/udf.c +++ b/libblkid/src/superblocks/udf.c @@ -17,6 +17,7 @@ #include #include "superblocks.h" +#include "iso9660.h" struct volume_descriptor { struct descriptor_tag { @@ -115,7 +116,7 @@ anchor: count = le32_to_cpu(vd->type.anchor.length) / bs; loc = le32_to_cpu(vd->type.anchor.location); - /* pick the primary descriptor from the list */ + /* check if the list is usable */ for (b = 0; b < count; b++) { vd = (struct volume_descriptor *) blkid_probe_get_buffer(pr, @@ -123,6 +124,21 @@ anchor: sizeof(*vd)); if (!vd) return -1; + } + + /* Try extract all possible ISO9660 information -- if there is + * usable LABEL in ISO header then use it, otherwise read UDF + * specific LABEL */ + if (probe_iso9660(pr, mag) == 0 && + __blkid_probe_lookup_value(pr, "LABEL") != NULL) + return 0; + + /* Read UDF label */ + for (b = 0; b < count; b++) { + vd = (struct volume_descriptor *) + blkid_probe_get_buffer(pr, + (blkid_loff_t) (loc + b) * bs, + sizeof(*vd)); type = le16_to_cpu(vd->tag.id); if (type == 0) -- 2.47.2