Bug#576537: Incorrect labels generated in /etc/fstab during PATA conversion
On Mon, Apr 05, 2010 at 04:48:13PM +0100, Ben Hutchings wrote:
> On Mon, 2010-04-05 at 16:12 +0200, Moritz Muehlenhoff wrote:
> > Package: linux-base
> > Version: 2.6.32-10
> > Severity: normal
> >
> > The conversion on my Thinkpad X31 seems to have generated incorrect
> > labels, which lead to the home partition not being mounted automatically:
>
> Oops.
>
> > This is the /etc/fstab which was generated:
> >
> > # /etc/fstab: static file system information.
> > #
> > # <file system> <mount point> <type> <options> <dump> <pass>
> > proc /proc proc defaults 0 0
> > # /dev/hda1 / ext3 defaults,errors=remount-ro 0 1
> > LABEL=\x2f / ext3 defaults,errors=remount-ro 0 1
> > # /dev/hda6 /home ext3 defaults,noatime 0 2
> > LABEL=\x2fhome /home ext3 defaults,noatime 0 2
> > # /dev/hda5 none swap sw 0 0
> > UUID=0603958c-bb68-46df-940b-c562b9fdb4aa none swap sw 0 0
> > /dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
> > /dev/sda /stick vfat rw,user,noauto 0 0
> >
> > The labels itself seem correct:
> >
> > root@galadriel:~# e2label /dev/sda1
> > /
> > root@galadriel:~# e2label /dev/sda6
> > /home
> > root@galadriel:~#
> >
> > I have no idea where "\x2f" instead of "/" is coming from?
> [...]
>
> /sbin/blkid -o udev /dev/sda1 | grep ^ID_FS_LABEL_ENC
>
> We definitely do need to escape whitespace and I thought libblkid would
> accept the escaped strings. Evidently not. I think we may just have to
> ignore labels with whitespace in, and go for UUIDs on those devices.
> (We already prefer UUIDs but it looks like those partitions don't have
> them.)
At least blkid shows a UUID:
root@galadriel:~# /sbin/blkid -o udev /dev/sda1
ID_FS_LABEL=/
ID_FS_LABEL_ENC=\x2f
ID_FS_UUID=6af102ec-0002-499f-b85d-193ecec7993e
ID_FS_UUID_ENC=6af102ec-0002-499f-b85d-193ecec7993e
ID_FS_SEC_TYPE=ext2
ID_FS_TYPE=ext3
Or was the code which prefers UUIDs over labels added post -10?
The "\x2f" encoding is applied through the blkid_encode_string()
function from shlibs/blkid/src/encode.c of util-linux:
/**
* blkid_encode_string:
* @str: input string to be encoded
* @str_enc: output string to store the encoded input string
* @len: maximum size of the output string, which may be
* four times as long as the input string
*
* Encode all potentially unsafe characters of a string to the
* corresponding hex value prefixed by '\x'.
*
* Returns: 0 if the entire string was copied, non-zero otherwise.
**/
int blkid_encode_string(const char *str, char *str_enc, size_t len)
Maybe we should convert it back in linux-base.postinst?
Cheers,
Moritz
Reply to: