bin/151976: mount_nullfs patch to add support for exposing sockets
and fifos of layered filesystems
John Hixson
john at ixsystems.com
Sat Nov 6 00:20:06 UTC 2010
>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 at 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 <sys/mount.h>
#include <sys/uio.h>
+#include <fs/nullfs/null.h>
+
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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:
More information about the freebsd-bugs
mailing list