From owner-freebsd-bugs@FreeBSD.ORG Wed Feb 20 11:20:04 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8617D16A400 for ; Wed, 20 Feb 2008 11:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 74C0613C45D for ; Wed, 20 Feb 2008 11:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m1KBK4hl006299 for ; Wed, 20 Feb 2008 11:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m1KBK4l3006298; Wed, 20 Feb 2008 11:20:04 GMT (envelope-from gnats) Date: Wed, 20 Feb 2008 11:20:04 GMT Message-Id: <200802201120.m1KBK4l3006298@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Dominic Fandrey Cc: Subject: Re: bin/120784: [patch] mount(8): allow mount from fstab with 3rd party tools like ntfs-3g X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dominic Fandrey List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2008 11:20:04 -0000 The following reply was made to PR bin/120784; it has been noted by GNATS. From: Dominic Fandrey To: bug-followup@FreeBSD.org, kamikaze@bsdforen.de Cc: Subject: Re: bin/120784: [patch] mount(8): allow mount from fstab with 3rd party tools like ntfs-3g Date: Wed, 20 Feb 2008 12:17:25 +0100 This is an alternative patch I have sent to Remko Lodder. It probably should be available here, too. This one also gets rid of the use_mountprog() stuff, since things simply work automatically due to the fallback. The previous version of the patch was targeted at touching as few lines as possible. This one is meant to be as clean as I can make it. I prefer it, but both versions work and a more conservative mind might prefer the previous patch. diff -Pur sbin/mount.orig/mount.c sbin/mount/mount.c --- sbin/mount.orig/mount.c 2008-02-18 19:44:05.000000000 +0100 +++ sbin/mount/mount.c 2008-02-19 19:02:43.000000000 +0100 @@ -126,28 +126,6 @@ static const char groupquotaeq[] = "groupquota="; static int -use_mountprog(const char *vfstype) -{ - /* XXX: We need to get away from implementing external mount - * programs for every filesystem, and move towards having - * each filesystem properly implement the nmount() system call. - */ - unsigned int i; - const char *fs[] = { - "cd9660", "mfs", "msdosfs", "nfs", "nfs4", "ntfs", - "nwfs", "nullfs", "portalfs", "smbfs", "udf", "unionfs", - NULL - }; - - for (i = 0; fs[i] != NULL; ++i) { - if (strcmp(vfstype, fs[i]) == 0) - return (1); - } - - return (0); -} - -static int exec_mountprog(const char *name, const char *execname, char *const argv[]) { pid_t pid; @@ -547,20 +525,18 @@ argv[argc] = NULL; if (debug) { - if (use_mountprog(vfstype)) - printf("exec: mount_%s", vfstype); - else - printf("mount -t %s", vfstype); + printf("mount -t %s", vfstype); for (i = 1; i < argc; i++) (void)printf(" %s", argv[i]); (void)printf("\n"); return (0); } - if (use_mountprog(vfstype)) { + ret = mount_fs(vfstype, argc, argv); + if (ret < 0) { + if (verbose) + warn("falling back to old style mount"); ret = exec_mountprog(name, execname, argv); - } else { - ret = mount_fs(vfstype, argc, argv); } free(optbuf); diff -Pur sbin/mount.orig/mount_fs.c sbin/mount/mount_fs.c --- sbin/mount.orig/mount_fs.c 2008-02-18 19:44:05.000000000 +0100 +++ sbin/mount/mount_fs.c 2008-02-18 19:44:37.000000000 +0100 @@ -107,6 +107,11 @@ val = p + 1; } build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); + // Repair arguments, in case they are required when + // falling back to the old style exec_mountprog. + if (p != NULL) { + *p = '='; + } break; case '?': default: @@ -131,8 +136,6 @@ build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); ret = nmount(iov, iovlen, mntflags); - if (ret < 0) - err(1, "%s %s", dev, errmsg); return (ret); }