Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Apr 2004 22:08:16 +0200
From:      Simon Barner <barner@in.tum.de>
To:        Darryl Hoar <darryl@osborne-ind.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Samba Question
Message-ID:  <20040404200816.GB44569@zi025.glhnet.mhn.de>
In-Reply-To: <008b01c418f2$43ecef50$0701a8c0@darryl>
References:  <008b01c418f2$43ecef50$0701a8c0@darryl>

next in thread | previous in thread | raw e-mail | index | archive | help

--lCAWRPmW1mITcIfM
Content-Type: multipart/mixed; boundary="tjCHc7DPkfUGtrlw"
Content-Disposition: inline


--tjCHc7DPkfUGtrlw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Darryl Hoar wrote:
> I have Samba installed on a Freebsd 5.1 server.
> I am trying to map a share from a windows machine
> so that I can copy the data.  I can not change the
> windows share name.  It has a space in it.  How
> do I specify the share name in fstab.
>=20
> share name:  PSR COMPLETE
>=20
> //user@mymachine/PSR COMPLETE  /psrcomplete smbfs  ro,noauto 0  0
>=20
> doesn't work.  Can't use quote marks

Hi,

I once had the same problem, and I came up with the following patch:
http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dbin/55539

(I have attached version of the patch that applies to FreeBSD 5.2.1,
otherwise please use the very last version of it (at the bottom of the
problem report page).

The following instructions assume that you have the system sources in
/usr/src

# cd /usr/src
# patch < /path/to/fstab-vis.patch

Now either do a full buildworld cycle, or use the following commands
(untested):

# cd /usr/src/lib/libc
# make depend && make && make install clean
# cd /usr/src/share/man/man5
# make depend && make && make install clean

Now you can encode the spaces with the vis(1) utility:

vis -w
<your mount point goes here><ENTER>

See also the updated fstab(5) man page.

If you try this patch, please tell me, whether it works for you, perhaps
someday I can get it committed.

Regards,
 Simon

--tjCHc7DPkfUGtrlw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fstab-vis.patch"
Content-Transfer-Encoding: quoted-printable

--- lib/libc/gen/fstab.c.orig	Mon Apr  7 14:55:00 2003
+++ lib/libc/gen/fstab.c	Sun Apr  4 21:45:30 2004
@@ -49,6 +49,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <vis.h>
 #include "un-namespace.h"
=20
 static FILE *_fs_fp;
@@ -110,6 +111,41 @@
 	_fs_fstab.fs_spec =3D buf;
 }
=20
+/*
+ * Converts a string *str, that possibly contains vis(1|3) encoded
+ * characters (visual representation) into the original form.
+ * See also: unvis(1|3)
+ *
+ * Return values: 0 on success, 1 otherwise
+ */
+int unescape (char *str) {
+	int state =3D 0;
+	char out, *s =3D str, *t =3D str;
+
+	if (str =3D=3D NULL)
+		return 1;
+
+	while (*s !=3D '\0') {
+	again:
+		switch(unvis(&out, *s, &state, 0)) {
+		case 0:
+		case UNVIS_NOCHAR:
+			break;
+		case UNVIS_VALID:
+			*t++ =3D out;
+			break;
+		case UNVIS_VALIDPUSH:
+			*t++ =3D out;
+			goto again;
+		case UNVIS_SYNBAD:
+			return 1;
+		}
+		++s;
+	}
+	*t =3D '\0';
+	return 0;
+}
+
 static int
 fstabscan()
 {
@@ -128,9 +164,19 @@
 		if (*line =3D=3D '#' || *line =3D=3D '\n')
 			continue;
 		if (!strpbrk(p, " \t")) {
-			_fs_fstab.fs_spec =3D strsep(&p, ":\n");
-			_fs_fstab.fs_file =3D strsep(&p, ":\n");
+		cp =3D strsep(&p, ":\n");
+			if (!unescape (cp))
+				_fs_fstab.fs_spec =3D cp;
+			else
+				goto bad;
+		=09
+			cp =3D strsep(&p, ":\n");
+			if (!unescape (cp))
+				_fs_fstab.fs_file =3D cp;
+			else
+				goto bad;
 			fixfsfile();
+		=09
 			_fs_fstab.fs_type =3D strsep(&p, ":\n");
 			if (_fs_fstab.fs_type) {
 				if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
@@ -152,13 +198,21 @@
 /* OLD_STYLE_FSTAB */
 		while ((cp =3D strsep(&p, " \t\n")) !=3D NULL && *cp =3D=3D '\0')
 			;
-		_fs_fstab.fs_spec =3D cp;
+		if (!unescape (cp))
+			_fs_fstab.fs_spec =3D cp;
+		else
+			goto bad;
 		if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec =3D=3D '#')
 			continue;
+		=09
 		while ((cp =3D strsep(&p, " \t\n")) !=3D NULL && *cp =3D=3D '\0')
 			;
-		_fs_fstab.fs_file =3D cp;
+		if (!unescape (cp))
+			_fs_fstab.fs_file =3D cp;
+		else
+			goto bad;
 		fixfsfile();
+	=09
 		while ((cp =3D strsep(&p, " \t\n")) !=3D NULL && *cp =3D=3D '\0')
 			;
 		_fs_fstab.fs_vfstype =3D cp;
--- share/man/man5/fstab.5.orig	Thu Dec 12 18:25:57 2002
+++ share/man/man5/fstab.5	Sun Apr  4 21:46:35 2004
@@ -10,7 +10,7 @@
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\" 3. All advertising materials mentioning features or use of this softwa=
re
-.\"    must display the following acknowledgement:
+.\"    must display the following acknowledgment:
 .\"	This product includes software developed by the University of
 .\"	California, Berkeley and its contributors.
 .\" 4. Neither the name of the University nor the names of its contributors
@@ -78,6 +78,19 @@
 .Pq Fa fs_file ,
 describes the mount point for the file system.
 For swap partitions, this field should be specified as ``none''.
+.Pp
+Both the
+.Fa fs_spec
+and the
+.Fa fs_file
+field may contain white spaces, that must be encoded in a
+.Xr vis 1 compatible way (you can run ``vis -wc'' or  ``vis -w'' to
+encode the path names properly).
+Despite this ability to handle path names with with spaces, system
+administrators should avoid them wherever possible in order to keep
+file system and mount point specifications simple and clean.
+It is only only intended to provide compatibility with systems,
+where white spaces in path names are common (mostly SMB/CIFS shares).
 .Pp
 The third field,
 .Pq Fa fs_vfstype ,

--tjCHc7DPkfUGtrlw--

--lCAWRPmW1mITcIfM
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAcGswCkn+/eutqCoRAiA+AKC+4E+PfjP4RXpd0XzA2jo6cJ9mLwCfdZez
k7YIkDnlAY8pi/ISquuzXEg=
=kvmj
-----END PGP SIGNATURE-----

--lCAWRPmW1mITcIfM--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040404200816.GB44569>