From owner-freebsd-arch@FreeBSD.ORG Sat Oct 6 08:49:45 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93ECD106566B for ; Sat, 6 Oct 2012 08:49:45 +0000 (UTC) (envelope-from stefan@fafoe.narf.at) Received: from fep17.mx.upcmail.net (fep17.mx.upcmail.net [62.179.121.37]) by mx1.freebsd.org (Postfix) with ESMTP id D60FC8FC08 for ; Sat, 6 Oct 2012 08:49:44 +0000 (UTC) Received: from edge03.upcmail.net ([192.168.13.238]) by viefep17-int.chello.at (InterMail vM.8.01.05.05 201-2260-151-110-20120111) with ESMTP id <20121006084937.SLZF5175.viefep17-int.chello.at@edge03.upcmail.net> for ; Sat, 6 Oct 2012 10:49:37 +0200 Received: from mole.fafoe.narf.at ([80.109.55.137]) by edge03.upcmail.net with edge id 7kpd1k00H2xdvHc03kpduB; Sat, 06 Oct 2012 10:49:37 +0200 X-SourceIP: 80.109.55.137 Received: by mole.fafoe.narf.at (Postfix, from userid 1001) id D63E56D430; Sat, 6 Oct 2012 10:49:36 +0200 (CEST) Date: Sat, 6 Oct 2012 10:49:36 +0200 From: Stefan Farfeleder To: arch@freebsd.org Message-ID: <20121006084936.GA1434@mole.fafoe.narf.at> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="bp/iNruPH9dso1Pn" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: Allowing \xxx in fstab X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 08:49:45 -0000 --bp/iNruPH9dso1Pn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I want to add support to specify device names containing spaces in fstab. Filesystem labels often contain spaces and we create corresponding devices names, e.g., /dev/msdosfs/FOO BAR. Currently there's no way to mount such devices via fstab. The standard way of doing that in Linux seems to be to encode the space with '\040' in fstab, so I followed that approach. There's a patch in PR 117687 (http://www.freebsd.org/cgi/query-pr.cgi?pr=117687) that uses strunvis() but I feel not very confident with the function as it translates more things than just \xxx. Comments? Stefan --bp/iNruPH9dso1Pn Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fstab-octal-escape-sequence.diff" Index: lib/libc/gen/fstab.c =================================================================== --- lib/libc/gen/fstab.c (revision 241046) +++ lib/libc/gen/fstab.c (working copy) @@ -107,6 +107,25 @@ _fs_fstab.fs_spec = buf; } +static void +unescapeoctal(char *s) +{ + char *p; + +#define oct(x) ((x) >= '0' && (x) <= '7') + /* Replace \xxx with the corresponding character. */ + p = s; + while (*s != '\0') + if (s[0] == '\\' && oct(s[1]) && oct(s[2]) && oct(s[3])) { + *p++ = (s[1] - '0') * 64 + (s[2] - '0') * 8 + + (s[3] - '0'); + s += 4; + } else + *p++ = *s++; + *p = '\0'; +#undef oct +} + static int fstabscan() { @@ -150,6 +169,7 @@ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; _fs_fstab.fs_spec = cp; + unescapeoctal(_fs_fstab.fs_spec); if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') --bp/iNruPH9dso1Pn--