From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 26 00:10:11 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 63CBC10656A7 for ; Tue, 26 Oct 2010 00:10:11 +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 2408F8FC33 for ; Tue, 26 Oct 2010 00:10:10 +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 o9Q0AATU002872 for ; Tue, 26 Oct 2010 00:10:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9Q0AAIM002871; Tue, 26 Oct 2010 00:10:10 GMT (envelope-from gnats) Resent-Date: Tue, 26 Oct 2010 00:10:10 GMT Resent-Message-Id: <201010260010.o9Q0AAIM002871@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 C16E7106567A for ; Tue, 26 Oct 2010 00:03:01 +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 AE9948FC19 for ; Tue, 26 Oct 2010 00:03:01 +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 o9Q031gf096259 for ; Tue, 26 Oct 2010 00:03:01 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o9Q031oB096258; Tue, 26 Oct 2010 00:03:01 GMT (envelope-from nobody) Message-Id: <201010260003.o9Q031oB096258@www.freebsd.org> Date: Tue, 26 Oct 2010 00:03:01 GMT From: John Hixson To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/151736: 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: Tue, 26 Oct 2010 00:10:11 -0000 >Number: 151736 >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: change-request >Submitter-Id: current-users >Arrival-Date: Tue Oct 26 00:10:09 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 #7: Fri Oct 22 12:26:59 PDT 2010 john@thinkbsd:/usr/obj/usr/src/sys/THINKBSD amd64 >Description: This patch modifies mount_nullfs to have the -i option that will tell the lower layer nullfs code to expose sockets and fifo's from the layered filesystem across the nullfs mount. The nullfs code has been changed to allow this. >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 (vfs_getopt(mp->mnt_optnew, "ipc", NULL, NULL) == 0) + if (vp->v_type == VSOCK || vp->v_type == VFIFO) + 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: