From owner-svn-src-head@FreeBSD.ORG Thu Mar 5 08:57:36 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B089106566C; Thu, 5 Mar 2009 08:57:36 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 392408FC16; Thu, 5 Mar 2009 08:57:36 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n258vage067923; Thu, 5 Mar 2009 08:57:36 GMT (envelope-from rodrigc@svn.freebsd.org) Received: (from rodrigc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n258vajL067921; Thu, 5 Mar 2009 08:57:36 GMT (envelope-from rodrigc@svn.freebsd.org) Message-Id: <200903050857.n258vajL067921@svn.freebsd.org> From: Craig Rodrigues Date: Thu, 5 Mar 2009 08:57:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189397 - head/sbin/mount X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2009 08:57:36 -0000 Author: rodrigc Date: Thu Mar 5 08:57:35 2009 New Revision: 189397 URL: http://svn.freebsd.org/changeset/base/189397 Log: Add a -o mountprog parameter to mount which explicitly allows an alternative program to be used for mounting a file system. Ideally, all file systems should be converted to pass string arguments to nmount(), so that /sbin/mount can handle them. However, certain file systems such as FUSE have not done this, and want to have their own userland mount programs. For example, to mount an NTFS file system with the FUSE NTFS driver: mount -t ntfs -o mountprog=/usr/local/bin/ntfs-3g /dev/acd0 /mnt or via an fstab entry: /dev/acd0 /mnt ntfs ro,noauto,mountprog=/usr/local/bin/ntfs-3g 0 0 PR: 120784 Requested by: Dominic Fandrey Modified: head/sbin/mount/mount.8 head/sbin/mount/mount.c Modified: head/sbin/mount/mount.8 ============================================================================== --- head/sbin/mount/mount.8 Thu Mar 5 08:08:09 2009 (r189396) +++ head/sbin/mount/mount.8 Thu Mar 5 08:57:35 2009 (r189397) @@ -163,6 +163,15 @@ is run with the flag but without the .Fl l flag. +.It Cm mountprog Ns = Ns Aq Ar program +Force +.Nm +to use the specified program to mount the file system, instead of calling +.Xr nmount 2 +directly. For example: +.Bd -literal +mount -t foofs -o mountprog=/mydir/fooprog /dev/acd0 /mnt +.Ed .It Cm multilabel Enable multi-label Mandatory Access Control, or MAC, on the specified file system. Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Thu Mar 5 08:08:09 2009 (r189396) +++ head/sbin/mount/mount.c Thu Mar 5 08:57:35 2009 (r189397) @@ -129,6 +129,8 @@ remountable_fs_names[] = { static const char userquotaeq[] = "userquota="; static const char groupquotaeq[] = "groupquota="; +static char *mountprog = NULL; + static int use_mountprog(const char *vfstype) { @@ -143,6 +145,9 @@ use_mountprog(const char *vfstype) NULL }; + if (mountprog != NULL) + return (1); + for (i = 0; fs[i] != NULL; ++i) { if (strcmp(vfstype, fs[i]) == 0) return (1); @@ -165,8 +170,10 @@ exec_mountprog(const char *name, const c /* Go find an executable. */ execvP(execname, _PATH_SYSPATH, argv); if (errno == ENOENT) { - warn("exec %s not found in %s", execname, - _PATH_SYSPATH); + warn("exec %s not found", execname); + if (execname[0] != '/') { + warnx("in path: %s", _PATH_SYSPATH); + } } exit(1); default: /* Parent. */ @@ -558,13 +565,16 @@ mountfs(const char *vfstype, const char mnt_argv.c = -1; append_arg(&mnt_argv, execname); mangle(optbuf, &mnt_argv); + if (mountprog != NULL) + strcpy(execname, mountprog); + append_arg(&mnt_argv, strdup(spec)); append_arg(&mnt_argv, strdup(name)); append_arg(&mnt_argv, NULL); if (debug) { if (use_mountprog(vfstype)) - printf("exec: mount_%s", vfstype); + printf("exec: %s", execname); else printf("mount -t %s", vfstype); for (i = 1; i < mnt_argv.c; i++) @@ -681,7 +691,7 @@ catopt(char *s0, const char *s1) void mangle(char *options, struct cpa *a) { - char *p, *s; + char *p, *s, *val; for (s = options; (p = strsep(&s, ",")) != NULL;) if (*p != '\0') { @@ -703,6 +713,22 @@ mangle(char *options, struct cpa *a) * before mountd starts. */ continue; + } else if (strncmp(p, "mountprog", 9) == 0) { + /* + * "mountprog" is used to force the use of + * userland mount programs. + */ + val = strchr(p, '='); + if (val != NULL) { + ++val; + if (*val != '\0') + mountprog = strdup(val); + } + + if (mountprog == NULL) { + errx(1, "Need value for -o mountprog"); + } + continue; } else if (strcmp(p, "userquota") == 0) { continue; } else if (strncmp(p, userquotaeq,