diff options
author | Karel Zak | 2009-09-22 14:58:34 +0200 |
---|---|---|
committer | Karel Zak | 2009-09-22 14:58:34 +0200 |
commit | ec7498784c9c79952d5fda36a1195e8242d382f7 (patch) | |
tree | 4950fb2741ebc6b7c6ba1629c70671f28621abc8 /shlibs | |
parent | libblkid: trim tailing whitespace from unicode LABELs (diff) | |
download | kernel-qcow2-util-linux-ec7498784c9c79952d5fda36a1195e8242d382f7.tar.gz kernel-qcow2-util-linux-ec7498784c9c79952d5fda36a1195e8242d382f7.tar.xz kernel-qcow2-util-linux-ec7498784c9c79952d5fda36a1195e8242d382f7.zip |
libblkid: prefer ISO9660 PVD Label to Joliet Label
The old good libvolume_id had the same behavior.
Reported-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r-- | shlibs/blkid/src/superblocks/iso9660.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/shlibs/blkid/src/superblocks/iso9660.c b/shlibs/blkid/src/superblocks/iso9660.c index 3206f5cae..976dee12f 100644 --- a/shlibs/blkid/src/superblocks/iso9660.c +++ b/shlibs/blkid/src/superblocks/iso9660.c @@ -19,6 +19,7 @@ #include "superblocks.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), |