kern/87906: [PATCH] nullfs NFS exporting

Andrey V. Elsukov bu7cher at yandex.ru
Mon Oct 24 01:00:30 PDT 2005


>Number:         87906
>Category:       kern
>Synopsis:       [PATCH] nullfs NFS exporting
>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:   Mon Oct 24 08:00:26 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Andrey V. Elsukov
>Release:        FreeBSD 7.0 CURRENT
>Organization:
>Environment:
	tested on 7.0-CURRENT
>Description:
	This patch add support nullfs over NFS exporting.
>How-To-Repeat:
>Fix:

--- nullfs_export.diff begins here ---
--- sys/fs/nullfs/null_vfsops.c	Mon Apr 11 11:16:29 2005
+++ sys/fs/nullfs/null_vfsops.c	Sat Oct 22 10:22:28 2005
@@ -52,11 +52,12 @@
 #include <sys/vnode.h>
 
 #include <fs/nullfs/null.h>
+#include <fs/nullfs/nullfsmount.h>
 
 static MALLOC_DEFINE(M_NULLFSMNT, "NULLFS mount", "NULLFS mount structure");
 
 static vfs_fhtovp_t	nullfs_fhtovp;
-static vfs_checkexp_t	nullfs_checkexp;
+static vfs_cmount_t	nullfs_cmount;
 static vfs_mount_t	nullfs_mount;
 static vfs_quotactl_t	nullfs_quotactl;
 static vfs_root_t	nullfs_root;
@@ -67,6 +68,27 @@
 static vfs_vptofh_t	nullfs_vptofh;
 static vfs_extattrctl_t	nullfs_extattrctl;
 
+static int
+nullfs_cmount(
+	struct mntarg *ma,
+	void *data,
+	int flags,
+	struct thread *td
+	)
+{
+	int error;
+	struct nullfs_args args;
+
+	if (data == NULL)
+		return (EINVAL);
+
+	error = copyin(data, (caddr_t)&args, sizeof(args));
+	if (error)
+		return error;
+	ma = mount_arg(ma, "export", &args.export, sizeof(args.export));
+	return kernel_mount(ma, flags);
+}
+
 /*
  * Mount null layer
  */
@@ -80,15 +102,23 @@
 	char *target;
 	int isvnunlocked = 0, len;
 	struct nameidata nd, *ndp = &nd;
+	struct export_args export;
 
 	NULLFSDEBUG("nullfs_mount(mp = %p)\n", (void *)mp);
 
 	if (mp->mnt_flag & MNT_ROOTFS)
 		return (EOPNOTSUPP);
-	/*
-	 * Update is a no-op
-	 */
+	
 	if (mp->mnt_flag & MNT_UPDATE) {
+		error = vfs_copyopt(mp->mnt_optnew, "export",
+					&export, sizeof(export));
+		if (error == 0 && export.ex_flags != 0) {
+			xmp = MOUNTTONULLMOUNT(mp);
+			/* The lower layer support NFS exporting? */
+			if (xmp->nullm_vfs->mnt_op->vfs_fhtovp != vfs_stdfhtovp &&
+				xmp->nullm_vfs->mnt_op->vfs_vptofh != vfs_stdvptofh)
+				return vfs_export(mp, &export);
+		}
 		return (EOPNOTSUPP);
 		/* return VFS_MOUNT(MOUNTTONULLMOUNT(mp)->nullm_vfs, path, data, ndp, td);*/
 	}
@@ -338,18 +368,6 @@
 }
 
 static int
-nullfs_checkexp(mp, nam, extflagsp, credanonp)
-	struct mount *mp;
-	struct sockaddr *nam;
-	int *extflagsp; 
-	struct ucred **credanonp;
-{
-
-	return VFS_CHECKEXP(MOUNTTONULLMOUNT(mp)->nullm_vfs, nam, 
-		extflagsp, credanonp);
-}
-
-static int
 nullfs_vptofh(vp, fhp)
 	struct vnode *vp;
 	struct fid *fhp;
@@ -375,7 +393,7 @@
 
 
 static struct vfsops null_vfsops = {
-	.vfs_checkexp =		nullfs_checkexp,
+	.vfs_cmount =		nullfs_cmount,
 	.vfs_extattrctl =	nullfs_extattrctl,
 	.vfs_fhtovp =		nullfs_fhtovp,
 	.vfs_init =		nullfs_init,
--- sys/fs/nullfs/nullfsmount.h	Thu Jan  1 00:00:00 1970
+++ sys/fs/nullfs/nullfsmount.h	Sat Oct 22 09:47:04 2005
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2005 by Andrey V. Elsukov
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _NULLFSMOUNT_H_
+#define _NULLFSMOUNT_H_
+
+/*
+ * Arguments to mount nullfs.
+ */
+struct nullfs_args {
+	char	*target;            /* target of loopback */
+	struct	export_args export; /* network export information */
+};
+
+#endif /* _NULLFSMOUNT_H_ */
--- usr.sbin/mountd/mountd.c	Fri Sep 16 11:24:27 2005
+++ usr.sbin/mountd/mountd.c	Sat Oct 22 09:49:54 2005
@@ -65,6 +65,7 @@
 #include <ufs/ufs/ufsmount.h>
 #include <fs/msdosfs/msdosfsmount.h>
 #include <fs/ntfs/ntfsmount.h>
+#include <fs/nullfs/nullfsmount.h>
 #include <isofs/cd9660/cd9660_mount.h>	/* XXX need isofs in include */
 
 #include <arpa/inet.h>
@@ -1004,11 +1005,13 @@
 			struct iso_args ia;
 			struct msdosfs_args da;
 			struct ntfs_args na;
+			struct nullfs_args nulla;
 		} targs;
 
 		if (!strcmp(fsp->f_fstypename, "ufs") ||
 		    !strcmp(fsp->f_fstypename, "msdosfs") ||
 		    !strcmp(fsp->f_fstypename, "ntfs") ||
+		    !strcmp(fsp->f_fstypename, "nullfs") ||
 		    !strcmp(fsp->f_fstypename, "cd9660")) {
 			bzero(&targs, sizeof targs);
 			targs.ua.fspec = NULL;
@@ -1802,6 +1805,7 @@
 		struct iso_args ia;
 		struct msdosfs_args da;
 		struct ntfs_args na;
+		struct nullfs_args nulla;
 	} args;
 
 	bzero(&args, sizeof args);
--- nullfs_export.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list