From owner-freebsd-bugs@FreeBSD.ORG Sat Nov 6 00:20:06 2010 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 A02531065673 for ; Sat, 6 Nov 2010 00:20:06 +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 587F58FC0A for ; Sat, 6 Nov 2010 00:20:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oA60K6ex050459 for ; Sat, 6 Nov 2010 00:20:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oA60K6qY050446; Sat, 6 Nov 2010 00:20:06 GMT (envelope-from gnats) Resent-Date: Sat, 6 Nov 2010 00:20:06 GMT Resent-Message-Id: <201011060020.oA60K6qY050446@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, John Hixson Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C87D1065674 for ; Sat, 6 Nov 2010 00:13:19 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 1A5958FC0A for ; Sat, 6 Nov 2010 00:13:19 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oA60DI8b063294 for ; Sat, 6 Nov 2010 00:13:18 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id oA60DIhR063293; Sat, 6 Nov 2010 00:13:18 GMT (envelope-from nobody) Message-Id: <201011060013.oA60DIhR063293@www.freebsd.org> Date: Sat, 6 Nov 2010 00:13:18 GMT From: John Hixson To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/151976: mount_nullfs patch to add support for exposing sockets and fifos of layered filesystems X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 00:20:06 -0000 >Number: 151976 >Category: bin >Synopsis: mount_nullfs patch to add support for exposing sockets and fifos of layered filesystems >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sat Nov 06 00:20:05 UTC 2010 >Closed-Date: >Last-Modified: >Originator: John Hixson >Release: 9.0-CURRENT >Organization: iXsystems >Environment: FreeBSD thinkbsd 9.0-CURRENT FreeBSD 9.0-CURRENT #11: Fri Oct 29 04:51:53 PDT 2010 john@thinkbsd:/usr/obj/usr/src/sys/THINKBSD amd64 >Description: Update to PR 151736 , which would panic. >How-To-Repeat: >Fix: Patch attached with submission follows: diff -urN sbin/mount_nullfs.orig/mount_nullfs.8 sbin/mount_nullfs/mount_nullfs.8 --- sbin/mount_nullfs.orig/mount_nullfs.8 2006-04-19 12:21:42.000000000 -0700 +++ sbin/mount_nullfs/mount_nullfs.8 2010-10-25 16:50:35.000000000 -0700 @@ -73,6 +73,8 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl i +Expose sockets and fifos across the nullfs mounted filesystem. .It Fl o Options are specified with a .Fl o @@ -80,6 +82,13 @@ See the .Xr mount 8 man page for possible options and their meanings. +The following nullfs specific options are available: +.Pp +.Bl -tag -width "ipc" -compact +.It Cm ipc +Same as +.Fl i . +.El .El .Pp The null layer has two purposes. diff -urN sbin/mount_nullfs.orig/mount_nullfs.c sbin/mount_nullfs/mount_nullfs.c --- sbin/mount_nullfs.orig/mount_nullfs.c 2009-12-29 14:53:27.000000000 -0800 +++ sbin/mount_nullfs/mount_nullfs.c 2010-10-25 16:57:31.000000000 -0700 @@ -48,6 +48,8 @@ #include #include +#include + #include #include #include @@ -68,16 +70,25 @@ int main(int argc, char *argv[]) { - struct iovec iov[6]; - int ch, mntflags; + struct iovec *iov; char source[MAXPATHLEN]; char target[MAXPATHLEN]; + char fstype[] = "nullfs"; + int ch, iovlen, mntflags, nullfs_flags; - mntflags = 0; - while ((ch = getopt(argc, argv, "o:")) != -1) + iov = NULL; + getmnt_silent = 1; + iovlen = mntflags = nullfs_flags = 0; + while ((ch = getopt(argc, argv, "io:")) != -1) switch(ch) { + case 'i': + nullfs_flags |= NULLFSMNT_IPC; + break; case 'o': getmntopts(optarg, mopts, &mntflags, 0); + if (strncmp(optarg, "ipc", 3) == 0) + nullfs_flags |= NULLFSMNT_IPC; + break; case '?': default: @@ -97,20 +108,14 @@ errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); - iov[0].iov_base = strdup("fstype"); - iov[0].iov_len = sizeof("fstype"); - iov[1].iov_base = strdup("nullfs"); - iov[1].iov_len = strlen(iov[1].iov_base) + 1; - iov[2].iov_base = strdup("fspath"); - iov[2].iov_len = sizeof("fspath"); - iov[3].iov_base = source; - iov[3].iov_len = strlen(source) + 1; - iov[4].iov_base = strdup("target"); - iov[4].iov_len = sizeof("target"); - iov[5].iov_base = target; - iov[5].iov_len = strlen(target) + 1; + build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); + build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); + build_iovec(&iov, &iovlen, "target", target, (size_t)-1); + + if (nullfs_flags & NULLFSMNT_IPC) + build_iovec(&iov, &iovlen, "ipc", NULL, 0); - if (nmount(iov, 6, mntflags)) + if (nmount(iov, iovlen, mntflags)) err(1, NULL); exit(0); } @@ -134,6 +139,6 @@ usage(void) { (void)fprintf(stderr, - "usage: mount_nullfs [-o options] target mount-point\n"); + "usage: mount_nullfs [-o options] [-i] target mount-point\n"); exit(1); } diff -urN sys/fs/nullfs.orig/null.h sys/fs/nullfs/null.h --- sys/fs/nullfs.orig/null.h 2005-03-15 05:49:33.000000000 -0800 +++ sys/fs/nullfs/null.h 2010-10-25 11:19:16.000000000 -0700 @@ -39,6 +39,8 @@ struct vnode *nullm_rootvp; /* Reference to root null_node */ }; +#define NULLFSMNT_IPC 0x00000001 + #ifdef _KERNEL /* * A cache of vnode references diff -urN sys/fs/nullfs.orig/null_subr.c sys/fs/nullfs/null_subr.c --- sys/fs/nullfs.orig/null_subr.c 2009-05-31 07:54:20.000000000 -0700 +++ sys/fs/nullfs/null_subr.c 2010-10-25 16:55:31.000000000 -0700 @@ -230,6 +230,11 @@ xp->null_vnode = vp; xp->null_lowervp = lowervp; vp->v_type = lowervp->v_type; + + if (vp->v_type == VSOCK || vp->v_type == VFIFO) + if (vfs_getopt(mp->mnt_optnew, "ipc", NULL, NULL) == 0) + vp->v_un = lowervp->v_un; + vp->v_data = xp; vp->v_vnlock = lowervp->v_vnlock; if (vp->v_vnlock == NULL) >Release-Note: >Audit-Trail: >Unformatted: