Date: Sat, 6 Oct 2012 10:49:36 +0200 From: Stefan Farfeleder <stefanf@FreeBSD.org> To: arch@freebsd.org Subject: Allowing \xxx in fstab Message-ID: <20121006084936.GA1434@mole.fafoe.narf.at>
next in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121006084936.GA1434>