From owner-freebsd-bugs@FreeBSD.ORG Wed Dec 12 15:30:00 2012 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B1C03FA2 for ; Wed, 12 Dec 2012 15:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 8170D8FC08 for ; Wed, 12 Dec 2012 15:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qBCFU0FT068942 for ; Wed, 12 Dec 2012 15:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qBCFU0dZ068941; Wed, 12 Dec 2012 15:30:00 GMT (envelope-from gnats) Resent-Date: Wed, 12 Dec 2012 15:30:00 GMT Resent-Message-Id: <201212121530.qBCFU0dZ068941@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, William Grzybowski Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 47EA8DCE for ; Wed, 12 Dec 2012 15:27:09 +0000 (UTC) (envelope-from william88@gmail.com) Received: from mail-ye0-f182.google.com (mail-ye0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id F11648FC0C for ; Wed, 12 Dec 2012 15:27:08 +0000 (UTC) Received: by mail-ye0-f182.google.com with SMTP id q5so174255yen.13 for ; Wed, 12 Dec 2012 07:27:08 -0800 (PST) Received: by 10.236.77.229 with SMTP id d65mr2073729yhe.124.1355326028103; Wed, 12 Dec 2012 07:27:08 -0800 (PST) Received: from localhost ([177.16.183.188]) by mx.google.com with ESMTPS id q48sm35330268yhk.7.2012.12.12.07.27.06 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 07:27:07 -0800 (PST) Message-Id: <50c8a24b.c89eec0a.0cd7.ffffaf07@mx.google.com> Date: Wed, 12 Dec 2012 07:27:07 -0800 (PST) From: William Grzybowski To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/174398: [PATCH] fstab(5): add support for spaces and tabs X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: William Grzybowski List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2012 15:30:00 -0000 >Number: 174398 >Category: bin >Synopsis: [PATCH] fstab(5): add support for spaces and tabs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Dec 12 15:30:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: William Grzybowski >Release: FreeBSD 10.0-CURRENT amd64 r242822 >Organization: >Environment: >Description: It is well known that FreeBSD cannot mount files with spaces or tabs using fstab(5). I'm aware of PRs conf/37569, bin/55539, bin/117687 but they seem to handle it using quotes which does not seem a very good way, besides they are quite old and are not getting any attention. What I'm proposing here is to handle it like Linux, decoding the octal ascii character, e.g.: /mnt/my\040folder here becomes: /mnt/my folder This is a recurrent problem, specially with people mounting CIFS shares where shares with spaces are quite common. The workaround is remove the space but that is not practical. I'm aware the patch is not complete, it does not change fstab man page, probably does not follow style(9) etc, however I would like any reviews or comments before wasting more time on this. Let me know what you think and I can fix it. Thank you. >How-To-Repeat: Try to mount to or from "/mnt/my folder" using fstab(5). >Fix: See attached patch --- fstab_decode.patch begins here --- Index: lib/libc/gen/fstab.c =================================================================== --- lib/libc/gen/fstab.c (revision 242822) +++ lib/libc/gen/fstab.c (working copy) @@ -60,6 +60,34 @@ static void fixfsfile(void); static int fstabscan(void); +static char * +decode_name(char *buf) +{ + char *rd = buf, *wr = buf; + + do { + if (rd[0] == '\\') { + if(rd[1] == '0' && rd[2] == '4' && rd[3] == '0') { + *wr++ = ' '; // \040 is a space + rd += 3; + } else if (rd[1] == '0' && rd[2] == '1' && rd[3] == '1') { + *wr++ = '\t'; // \011 is a tab + rd += 3; + } else if (rd[1] == '\\') { + *wr++ = '\\'; // Escape backslash + rd += 1; + } else if (rd[1] == '1' && rd[2] == '3' && rd[3] == '4') { + *wr++ = '\\'; // \134 is also backslash + rd += 3; + } else + *wr++ = *rd; + } else + *wr++ = *rd; + } while (*rd++ != '\0'); + + return buf; +} + void setfstab(const char *file) { @@ -126,8 +154,8 @@ if (*line == '#' || *line == '\n') continue; if (!strpbrk(p, " \t")) { - _fs_fstab.fs_spec = strsep(&p, ":\n"); - _fs_fstab.fs_file = strsep(&p, ":\n"); + _fs_fstab.fs_spec = decode_name(strsep(&p, ":\n")); + _fs_fstab.fs_file = decode_name(strsep(&p, ":\n")); fixfsfile(); _fs_fstab.fs_type = strsep(&p, ":\n"); if (_fs_fstab.fs_type) { @@ -150,14 +178,14 @@ /* OLD_STYLE_FSTAB */ while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - _fs_fstab.fs_spec = cp; + _fs_fstab.fs_spec = decode_name(cp); if (_fs_fstab.fs_spec == NULL || *_fs_fstab.fs_spec == '#') continue; if (strunvis(_fs_fstab.fs_spec, _fs_fstab.fs_spec) < 0) goto bad; while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; - _fs_fstab.fs_file = cp; + _fs_fstab.fs_file = decode_name(cp); if (_fs_fstab.fs_file == NULL) goto bad; if (strunvis(_fs_fstab.fs_file, _fs_fstab.fs_file) < 0) --- fstab_decode.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: