From root@heavennet.ru  Mon Oct 24 07:53:58 2005
Return-Path: <root@heavennet.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A5FE116A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Oct 2005 07:53:58 +0000 (GMT)
	(envelope-from root@heavennet.ru)
Received: from mail.heavennet.ru (proxy.heavennet.ru [81.18.141.41])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B222343D48
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Oct 2005 07:53:55 +0000 (GMT)
	(envelope-from root@heavennet.ru)
Received: by mail.heavennet.ru (Postfix, from userid 0)
	id 2D7DF49F2C; Mon, 24 Oct 2005 11:53:51 +0400 (MSD)
Message-Id: <20051024075351.2D7DF49F2C@mail.heavennet.ru>
Date: Mon, 24 Oct 2005 11:53:51 +0400 (MSD)
From: Andrey V. Elsukov <bu7cher@yandex.ru>
Reply-To: Andrey V. Elsukov <bu7cher@yandex.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] nullfs NFS exporting
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         87906
>Category:       kern
>Synopsis:       [nullfs] [patch] nullfs NFS exporting
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 24 08:00:26 GMT 2005
>Closed-Date:    Sun May 28 20:12:04 GMT 2006
>Last-Modified:  Sun May 28 20:12:04 GMT 2006
>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:
Responsible-Changed-From-To: freebsd-bugs->rodrigc 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Sat Nov 12 16:50:51 GMT 2005 
Responsible-Changed-Why:  
I am looking at mount() issues, so I'll grab this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87906 
State-Changed-From-To: open->closed 
State-Changed-By: rodrigc 
State-Changed-When: Sun May 28 20:10:50 UTC 2006 
State-Changed-Why:  
This patch is unnecessary, due to my recent changes 
to convert mountd to use nmount(), and 
also my fix to null_vfsops.c in version 1.78 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87906 
>Unformatted:
