From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 8 12:50:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED7961065672 for ; Sun, 8 Aug 2010 12:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A95768FC23 for ; Sun, 8 Aug 2010 12:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o78Co1No000220 for ; Sun, 8 Aug 2010 12:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o78Co19d000219; Sun, 8 Aug 2010 12:50:01 GMT (envelope-from gnats) Resent-Date: Sun, 8 Aug 2010 12:50:01 GMT Resent-Message-Id: <201008081250.o78Co19d000219@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, walter@pelissero.de Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF35F106564A for ; Sun, 8 Aug 2010 12:44:25 +0000 (UTC) (envelope-from walter.pelissero@iesy.net) Received: from mail01.ish.de (mailout.ish.de [80.69.98.251]) by mx1.freebsd.org (Postfix) with ESMTP id 6258E8FC17 for ; Sun, 8 Aug 2010 12:44:24 +0000 (UTC) Received: from [95.222.206.96] (account walter.pelissero@iesy.net HELO zaphod.home.lan) by mail-fe-02.mail01.ish.de (CommuniGate Pro SMTP 5.2.18) with ESMTPSA id 372405519 for FreeBSD-gnats-submit@freebsd.org; Sun, 08 Aug 2010 14:34:21 +0200 Received: from zaphod.home.lan (localhost [127.0.0.1]) by zaphod.home.lan (8.14.4/8.14.4) with ESMTP id o78CVvYi012033 for ; Sun, 8 Aug 2010 14:31:57 +0200 (CEST) (envelope-from wcp@zaphod.home.lan) Received: (from wcp@localhost) by zaphod.home.lan (8.14.4/8.14.4/Submit) id o78CVv9m012032; Sun, 8 Aug 2010 14:31:57 +0200 (CEST) (envelope-from wcp) Message-Id: <201008081231.o78CVv9m012032@zaphod.home.lan> Date: Sun, 8 Aug 2010 14:31:57 +0200 (CEST) From: "Walter C. Pelissero" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/149424: fstab and labels with whitespace X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: walter@pelissero.de List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Aug 2010 12:50:02 -0000 >Number: 149424 >Category: bin >Synopsis: fstab and labels with whitespace >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Aug 08 12:50:00 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Walter C. Pelissero >Release: FreeBSD 8.1-PRERELEASE i386 >Organization: >Environment: System: FreeBSD zaphod.home.lan 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #1: Tue Jul 13 22:21:06 CEST 2010 root@zaphod.home.lan:/usr/home/obj/usr/src/sys/TIGER-MP i386 >Description: /etc/fstab currently doesn't allow for whitespace anywhere but between fields (or in comments). This makes impossible to use a label in place of a device name when mounting volumes containing whitespace in the name. Take for instance CF or SD memory cards created by Nikon cameras: they are labelled "NIKON ", with a whitespace between NIKON and the model name. Although it's still possible to mount the /dev/da* device, the label is arguably much more convenient. >How-To-Repeat: >Fix: The following patch modifies libc to allow for special characters in the first field of a fstab entry. A single space can be written as \s, as in NIKON\sD300S, or \040, as in NIKON\040D300S. Indeed, any octal escape sequence can be used, or sequences such as \t, \r, or \n. I'm afraid, this patch does not update fstab.5. Index: fstab.c =================================================================== RCS file: /repos/src/lib/libc/gen/fstab.c,v retrieving revision 1.15.10.1 diff -u -r1.15.10.1 fstab.c --- fstab.c 3 Aug 2009 08:13:06 -0000 1.15.10.1 +++ fstab.c 8 Aug 2010 11:51:02 -0000 @@ -106,6 +106,40 @@ _fs_fstab.fs_spec = buf; } +#define isoctal(c) ((c) >= '0' && (c) <= '7') +#define octdigit2int(c) ((c) - '0') + +static char * +unescape (char *string) +{ + static char special[] = "s\\trn"; + static char translation[] = " \\\t\r\n"; + char *s, *d; + + for (s = d = string; *s; ++s, ++d) + { + if (s[0] == '\\') { + char *p; + + if ((p = strchr(special, s[1]))) { + *d = translation[p - special]; + ++s; + } else if (isoctal(s[1]) && + isoctal(s[2]) && + isoctal(s[3])) { + *d = octdigit2int(s[1]) * 8 * 8 + + octdigit2int(s[2]) * 8 + + octdigit2int(s[3]); + s += 3; + } else + *d = *s; + } else + *d = *s; + } + *d = '\0'; + return string; +} + static int fstabscan() { @@ -148,7 +182,7 @@ /* OLD_STYLE_FSTAB */ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - _fs_fstab.fs_spec = cp; + _fs_fstab.fs_spec = unescape(cp); if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') >Release-Note: >Audit-Trail: >Unformatted: