]> err.no Git - util-linux/commitdiff
libblkid: prefer ISO9660 PVD Label to Joliet Label
authorKarel Zak <kzak@redhat.com>
Tue, 22 Sep 2009 12:58:34 +0000 (14:58 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 2 Oct 2009 18:32:50 +0000 (20:32 +0200)
The old good libvolume_id had the same behavior.

Reported-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/probers/iso9660.c

index 1ea704c1923a4f492a8185b6e786316c9f09388b..1ebcccf0649efccc830fcde37459a4aa22dfbc66 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "blkidP.h"
 
+/* PVD - Primary volume descriptor */
 struct iso_volume_descriptor {
        unsigned char   vd_type;
        unsigned char   vd_id[5];
@@ -48,6 +49,20 @@ struct high_sierra_volume_descriptor {
        unsigned char   volume_id[32];
 };
 
+/* returns 1 if the begin of @ascii is equal to @utf16 string.
+ */
+static int ascii_eq_utf16be(unsigned char *ascii,
+                       unsigned char *utf16, size_t len)
+{
+       int a, u;
+
+       for (a = 0, u = 0; u < len; a++, u += 2) {
+               if (utf16[u] != 0x0 || ascii[a] != utf16[u + 1])
+                       return 0;
+       }
+       return 1;
+}
+
 /* old High Sierra format */
 static int probe_iso9660_hsfs(blkid_probe pr, const struct blkid_idmag *mag)
 {
@@ -96,6 +111,13 @@ static int probe_iso9660(blkid_probe pr, const struct blkid_idmag *mag)
                    memcmp(iso->escape_sequences, "%/C", 3) == 0 ||
                    memcmp(iso->escape_sequences, "%/E", 3) == 0) {
 
+                       /* Is the Joliet (UTF16BE) label equal to the label in
+                        * the PVD? If yes, use PVD label.  The Jolied version
+                        * of the label could be trimed (because UTF16..).
+                        */
+                       if (ascii_eq_utf16be(label, iso->volume_id, 32))
+                               break;
+
                        blkid_probe_set_utf8label(pr,
                                        iso->volume_id,
                                        sizeof(iso->volume_id),