From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 24 08:00:30 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5D4F916A421 for ; Mon, 24 Oct 2005 08:00:30 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 837BD43D55 for ; Mon, 24 Oct 2005 08:00:27 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j9O80RAY029284 for ; Mon, 24 Oct 2005 08:00:27 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j9O80Rth029276; Mon, 24 Oct 2005 08:00:27 GMT (envelope-from gnats) Resent-Date: Mon, 24 Oct 2005 08:00:27 GMT Resent-Message-Id: <200510240800.j9O80Rth029276@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, "Andrey V. Elsukov" Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A5FE116A41F for ; 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 ; 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" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/87906: [PATCH] nullfs NFS exporting X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Andrey V. Elsukov" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2005 08:00:30 -0000 >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 #include +#include 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 #include #include +#include #include /* XXX need isofs in include */ #include @@ -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: