[BUG] Cdrom labels are always 'padded' with spaces at the end

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, 

After updating to ubuntu 9.10 I noticed that cdrom labels are always
prepended a long row of spaces.

like that:

maxim@maxim-laptop:~$ sudo /sbin/blkid -o udev -p /dev/sr0
ID_FS_LABEL=CDROM
ID_FS_LABEL_ENC=CDROM\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_FS_VERSION=Joliet\x20Extension
ID_FS_TYPE=iso9660
ID_FS_USAGE=filesystem


It appears that it is ok for superblock probe drivers to send a label
that is padded with spaces on physical hardware.

However blkid_probe_set_label removes this whitespace, but
blkid_probe_set_utf8label don't.

Attached patch (against -git) just adds the whitespace removal to second
function.

Bug reported at launchpad at:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/432215


Best regards,
Maxim Levitsky

commit 326f3669ea0d0bfe9b811a953b1d9129a8321b23
Author: Maxim Levitsky <maximlevitsky@xxxxxxxxx>
Date:   Tue Sep 22 02:58:09 2009 +0300

    fix spaces of labels

diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c
index 0abdab2..974dfb2 100644
--- a/shlibs/blkid/src/superblocks/superblocks.c
+++ b/shlibs/blkid/src/superblocks/superblocks.c
@@ -463,6 +463,18 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
 	return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
 }
 
+static int blkid_remove_trailing_whitespace(unsigned char *str)
+{
+	int i = strlen(str);
+
+	while (i--) {
+		if (!isspace(str[i]))
+			break;
+	}
+	str[++i] = '\0';
+	return i + 1;
+}
+
 int blkid_probe_set_label(blkid_probe pr, unsigned char *label, size_t len)
 {
 	struct blkid_chain *chn = blkid_probe_get_chain(pr);
@@ -488,13 +500,7 @@ int blkid_probe_set_label(blkid_probe pr, unsigned char *label, size_t len)
 	v->data[len] = '\0';
 
 	/* remove trailing whitespace */
-	i = strlen((char *) v->data);
-	while (i--) {
-		if (!isspace(v->data[i]))
-			break;
-	}
-	v->data[++i] = '\0';
-	v->len = i + 1;
+	v->len = blkid_remove_trailing_whitespace ((char *) v->data);
 	return 0;
 }
 
@@ -513,7 +519,11 @@ int blkid_probe_set_utf8label(blkid_probe pr, unsigned char *label,
 	if (!v)
 		return -1;
 
-	v->len = blkid_encode_to_utf8(enc, v->data, sizeof(v->data), label, len);
+	blkid_encode_to_utf8(enc, v->data, sizeof(v->data), label, len);
+
+	/* remove trailing whitespace */
+	v->len = blkid_remove_trailing_whitespace ((char *) v->data);
+
 	return 0;
 }
 

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux