Index: sys/conf/files =================================================================== RCS file: /cvsroot/src/sys/conf/files,v retrieving revision 1.731 diff -u -u -p -r1.731 files --- sys/conf/files 17 Sep 2005 14:38:40 -0000 1.731 +++ sys/conf/files 23 Sep 2005 10:00:05 -0000 @@ -1293,6 +1293,7 @@ file kern/uipc_usrreq.c file kern/vfs_bio.c file kern/vfs_cache.c file kern/vfs_getcwd.c +file kern/vfs_hooks.c file kern/vfs_init.c file kern/vfs_lockf.c file kern/vfs_lookup.c Index: distrib/sets/lists/comp/mi =================================================================== RCS file: /cvsroot/src/distrib/sets/lists/comp/mi,v retrieving revision 1.816 diff -u -u -p -r1.816 mi --- distrib/sets/lists/comp/mi 19 Sep 2005 03:16:40 -0000 1.816 +++ distrib/sets/lists/comp/mi 23 Sep 2005 10:00:07 -0000 @@ -5739,6 +5739,8 @@ ./usr/share/man/cat9/vfs_getnewfsid.0 comp-sys-catman .cat ./usr/share/man/cat9/vfs_getopsbyname.0 comp-sys-catman .cat ./usr/share/man/cat9/vfs_getvfs.0 comp-sys-catman .cat +./usr/share/man/cat9/vfs_hooks.0 comp-sys-catman .cat +./usr/share/man/cat9/vfs_hooks_unmount.0 comp-sys-catman .cat ./usr/share/man/cat9/vfs_mountedon.0 comp-sys-catman .cat ./usr/share/man/cat9/vfs_mountroot.0 comp-sys-catman .cat ./usr/share/man/cat9/vfs_reinit.0 comp-sys-catman .cat @@ -9648,6 +9650,8 @@ ./usr/share/man/man9/vfs_getnewfsid.9 comp-sys-man .man ./usr/share/man/man9/vfs_getopsbyname.9 comp-sys-man .man ./usr/share/man/man9/vfs_getvfs.9 comp-sys-man .man +./usr/share/man/man9/vfs_hooks.9 comp-sys-man .man +./usr/share/man/man9/vfs_hooks_unmount.9 comp-sys-man .man ./usr/share/man/man9/vfs_mountedon.9 comp-sys-man .man ./usr/share/man/man9/vfs_mountroot.9 comp-sys-man .man ./usr/share/man/man9/vfs_reinit.9 comp-sys-man .man Index: doc/CHANGES =================================================================== RCS file: /cvsroot/src/doc/CHANGES,v retrieving revision 1.524 diff -u -u -p -r1.524 CHANGES --- doc/CHANGES 22 Sep 2005 07:54:11 -0000 1.524 +++ doc/CHANGES 23 Sep 2005 10:00:07 -0000 @@ -109,3 +109,12 @@ Changes from NetBSD 3.0 to NetBSD 4.0: kernel: Reset the AMD Geode SC1100 microcontroller. [dyoung 20050922] geodewdog(4): Add driver for AMD Geode SC1100 microcontroller's watchdog timer. [dyoung 20050922] + kernel: Add the VFS hooks interface so that kernel subsystems + other than VFS can execute code upon VFS operations. + [jmmv 20050923] + kernel: Re-factor NFS exports list code handling, making it simpler + by abstracting all the details into the NFS generic code, + using the previously mentioned VFS hooks interface to make + it work. [jmmv 20050923] + mountd(8): Make this utility file system independent, also simplifying + its code. [jmmv 20050923] Index: doc/TODO =================================================================== RCS file: /cvsroot/src/doc/TODO,v retrieving revision 1.12 diff -u -u -p -r1.12 TODO --- doc/TODO 29 Nov 2004 09:48:03 -0000 1.12 +++ doc/TODO 23 Sep 2005 10:00:07 -0000 @@ -93,4 +93,7 @@ This is a list of suggested smaller proj be easy to accommodate MP code + Examine our vnode locking and vfs layer and see what needs to be changed for locking in layered filesystems to really work - ++ Make mountd(8) update the in-kernel exports list for each file system + atomically. Many parts of the utility will need a rewrite, but the kernel + functionality is already there (just enable the "notyet" blocks of code in + sys/nfs/nfs_export.c). Index: lib/libc/sys/nfssvc.2 =================================================================== RCS file: /cvsroot/src/lib/libc/sys/nfssvc.2,v retrieving revision 1.20 diff -u -u -p -r1.20 nfssvc.2 --- lib/libc/sys/nfssvc.2 13 May 2004 10:20:58 -0000 1.20 +++ lib/libc/sys/nfssvc.2 23 Sep 2005 10:00:08 -0000 @@ -29,7 +29,7 @@ .\" .\" @(#)nfssvc.2 8.1 (Berkeley) 6/9/93 .\" -.Dd June 9, 1993 +.Dd September 23, 2005 .Dt NFSSVC 2 .Os .Sh NAME @@ -54,7 +54,7 @@ once in the kernel and the .Fa argstructp points to one of three structures depending on which bits are set in flags. -.Pp +.Ss Calls used by Xr mount_nfs 8 On the client side, .Fn nfssvc is only used for @@ -114,7 +114,7 @@ will be called with the flags and .Dv NFSSVC_AUTHINFAIL to denote a failed authentication attempt. -.Pp +.Ss Calls used by Xr nfsd 8 On the server side, .Fn nfssvc is called with the flag @@ -190,6 +190,30 @@ to pass a server side socket into the kernel for servicing by the .Xr nfsd 8 daemons. +.Ss Calls used by Xr mountd 8 +The +.Xr mountd 8 +server daemon calls +.Fn nfssvc +with the flag +.Dv NFSSVC_SETEXPORTSLIST +and a pointer to a +.Ft struct mountd_exports_list +object to atomically change the exports lists of a specific file system. +This structure has the following fields: +.Bl -tag +.It Vt const char *mel_path +Path to the file system that will have its exports list replaced by the +one described in the other fields. +.It Vt size_t mel_nexports +Number of valid entries in the +.Vt mel_export +field. +If zero, the exports list will be cleared for the given file system. +.It Vt struct export_args mel_export[AF_MAX] +Set of exports to be used for the given file system. +.El +.Pp .Sh RETURN VALUES Normally .Nm Index: share/man/man9/Makefile =================================================================== RCS file: /cvsroot/src/share/man/man9/Makefile,v retrieving revision 1.176 diff -u -u -p -r1.176 Makefile --- share/man/man9/Makefile 10 Sep 2005 19:20:48 -0000 1.176 +++ share/man/man9/Makefile 23 Sep 2005 10:00:08 -0000 @@ -36,7 +36,7 @@ MAN= altq.9 arc4random.9 arp.9 audio.9 a scsipi.9 setjmp.9 setrunqueue.9 shutdownhook_establish.9 \ signal.9 softintr.9 spl.9 store.9 suser.9 suspendsched.9 \ sysctl.9 tc.9 time.9 tmpfs.9 todr.9 uiomove.9 ucom.9 userret.9 \ - vattr.9 vfs.9 vfsops.9 vfssubr.9 vme.9 vnfileops.9 \ + vattr.9 vfs.9 vfs_hooks.9 vfsops.9 vfssubr.9 vme.9 vnfileops.9 \ vnode.9 vnodeops.9 vnsubr.9 \ usbdi.9 uvm.9 wdc.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 @@ -547,6 +547,7 @@ MLINKS+=vme.9 vme_probe.9 \ vme.9 vme_space_get.9 MLINKS+=vattr.9 vattr_null.9 \ vattr.9 VATTR_NULL.9 +MLINKS+=vfs_hooks.9 vfs_hooks_unmount.9 MLINKS+=vfsops.9 VFS_MOUNT.9 \ vfsops.9 VFS_START.9 \ vfsops.9 VFS_UNMOUNT.9 \ Index: share/man/man9/vfs_hooks.9 =================================================================== RCS file: share/man/man9/vfs_hooks.9 diff -N share/man/man9/vfs_hooks.9 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ share/man/man9/vfs_hooks.9 23 Sep 2005 10:00:08 -0000 @@ -0,0 +1,110 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2005 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Julio M. Merino Vidal. +.\" +.\" 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. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. +.\" +.Dd September 23, 2005 +.Dt VFSSUBR 9 +.Os +.Sh NAME +.Nm vfs_hooks , +.Nm vfs_hooks_unmount +.Nd VFS hooks interface +.Sh SYNOPSIS +.In sys/param.h +.In sys/mount.h +.Ft void +.Fn vfs_hooks_unmount "struct mount *mp" +.Sh DESCRIPTION +The VFS hooks interface provides a way for different kernel subsystems to +attach custom functions to specific VFS operations. +This enforces code separation by keeping the VFS's core sources uncluttered +and makes all subsystem functionality reside in a single place. +As an example, this interface is used by the NFS server code to automatically +handle the exports list for each mount point. +.Pp +Hooks are described by a +.Ft struct vfs_hooks +object, as seen below: +.Bd -literal +struct vfs_hooks { + int (*vh_unmount)(struct mount *); +}; +.Ed +.Pp +For simplicity, each field is named after the VFS operation it refers to. +The purpose of each member function, alongside some important notes, is +shown below: +.Bl -tag -width compat +.It Fn vh_unmount "mp" +This hook is executed during the unmount process of a file system. +.El +.Pp +For more information about the purpose of each operation, see +.Xr vfsops 9 . +Note that any of these fields may be a null pointer. +.Pp +After the definition of a +.Ft struct vfs_hooks +object, the kernel has to add it to the +.Dt vfs_hooks +link set using the +.Fn VFS_HOOKS_ATTACH "struct vfs_hooks *" +macro. +.Pp +Please note that this interface is incomplete on purpose to keep it in its +smallest possible size (i.e., do not provide a hook that is not used). +If you feel the need to hook a routine to a VFS operation that is not yet +supported by this interface, just add it to the files described in +.Sx CODE REFERENCES . +.Sh FUNCTIONS +The following functions are provided to the VFS code to run the hooked +functions: +.Bl -tag -width compact +.It Fn vfs_hooks_unmount "mp" +Runs all hooks for the VFS unmount operation. +Given that these operations shall not fail, it returns +.Ft void . +.Sh CODE REFERENCES +The VFS hooks interface is implemented within the files +.Pa sys/kern/vfs_hooks.c +and +.Pa sys/sys/mount.h . +.Sh SEE ALSO +.Xr intro 9 , +.Xr vfs 9 , +.Xr vfsops 9 +.Sh HISTORY +The VFS hooks interface appeared in +.Nx 4.0 . Index: share/man/man9/vfsops.9 =================================================================== RCS file: /cvsroot/src/share/man/man9/vfsops.9,v retrieving revision 1.21 diff -u -u -p -r1.21 vfsops.9 --- share/man/man9/vfsops.9 20 Jul 2005 12:55:14 -0000 1.21 +++ share/man/man9/vfsops.9 23 Sep 2005 10:00:09 -0000 @@ -34,7 +34,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 20, 2005 +.Dd September 23, 2005 .Dt VFSOPS 9 .Os .Sh NAME @@ -49,7 +49,6 @@ .Nm VFS_VGET , .Nm VFS_FHTOVP , .Nm VFS_VPTOFH , -.Nm VFS_CHECKEXP , .Nm VFS_SNAPSHOT .Nd kernel file system interface .Sh SYNOPSIS @@ -80,8 +79,6 @@ .Ft int .Fn VFS_VPTOFH "struct vnode *vp" "struct fid *fhp" .Ft int -.Fn VFS_CHECKEXP "struct mount *mp" "struct mbuf *nam" \ -"int *extflagsp" "struct ucred **credanonp" .Ft int .Fn VFS_SNAPSHOT "struct mount *mp" "struct vnode *vp" "struct timespec *ts" .Sh DESCRIPTION @@ -125,7 +122,6 @@ void (*vfs_init)() - Initialise file sys void (*vfs_reinit)() - Reinitialise file system void (*vfs_done)() - Cleanup unmounted file system int (*vfs_mountroot)() - Mount the root file system -int (*vfs_checkexp)() VFS_CHECKEXP Check if file system is exported int (*vfs_snapshot)() VFS_SNAPSHOT Take a snapshot .fi .Pp @@ -139,9 +135,11 @@ operation, but it must assign each membe suitable function to do the minimum required of it. In most cases, such functions either do nothing or return an error value to the effect that it is not supported. -.Em vfs_reinit +.Em vfs_reinit , +.Em vfs_mountroot , +.Em vfs_fhtovp and -.Em vfs_mountroot +.Em vfs_vptofh may be .Dv NULL . @@ -316,8 +314,14 @@ The locked vnode is returned in A call to .Fn VFS_FHTOVP should generally be followed by a call to -.Fn VFS_CHECKEXP +.Fn nfs_check_export to check if the file is accessable to the client. +.Pp +If this function's pointer is set to NULL, the underlying file system will +not be NFS exportable. +If it is defined, though, +.Fn VFS_VPTOFH +must be defined too. .It Fn VFS_VPTOFH "vp" "fhp" Get a unique NFS file handle for the file specified by the vnode .Fa vp . @@ -328,25 +332,12 @@ not examined by any other subsystems. It should contain enough information to uniquely identify a file within the file system as well as noticing when a file has been removed and the file system resources have been recycled for a new file. -.It Fn VFS_CHECKEXP "mp" "nam" "extflagsp" "credanonp" -Check if the file system specified by the mount structure -.Fa mp -is exported to a client with anonymous credentials -.Fa credanonp . -The argument -.Fa nam -is an mbuf containing the network address of the client. -The return parameters for the export flags for the client are returned -in the address specified by -.Fa exflagsp . -This function is used by the NFS server. -It is generally invoked before +.Pp +If this function's pointer is set to NULL, the underlying file system will +not be NFS exportable. +If it is defined, though, .Fn VFS_FHTOVP -to validate that client has access to the file system. -The file system should call -.Fn vfs_export_lookup -with the address of an appropriate netexport structure and the address -of the client to verify that the client can access this file system. +must be defined too. .It Fn VFS_SNAPSHOT "mp" "vp" "ts" Take a snapshot of the file system specified by the mount structure .Fa mp Index: share/man/man9/vfssubr.9 =================================================================== RCS file: /cvsroot/src/share/man/man9/vfssubr.9,v retrieving revision 1.10 diff -u -u -p -r1.10 vfssubr.9 --- share/man/man9/vfssubr.9 21 Apr 2004 01:05:35 -0000 1.10 +++ share/man/man9/vfssubr.9 23 Sep 2005 10:00:09 -0000 @@ -34,7 +34,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 10, 2004 +.Dd September 23, 2005 .Dt VFSSUBR 9 .Os .Sh NAME @@ -68,12 +68,6 @@ .Ft struct mount * .Fn vfs_getvfs "fsid_t *fsid" .Ft int -.Fn vfs_export "struct mount *mp" "struct netexport *nep" \ -"struct export_args *argp" -.Ft void -.Fn vfs_showexport "struct mount *mp" "struct export_args *argp" \ -"struct netexport *nep" -.Ft int .Fn vfs_export_lookup "struct mount *mp" "struct netexport *nep" \ "struct export_args *argp" .Ft int @@ -120,10 +114,6 @@ The file system id type is stored in .It Fn vfs_getvfs "fsid" Lookup a mount point with the file system identifier .Fa fsid . -.It Fn vfs_export "mp" "nep" "argp" -Undocumented. -.It Fn vfs_showexport "mp" "argp" "nep" -Undocumented. .It Fn vfs_export_lookup "mp" "nep" "argp" Check client permission on the exportable file system specified by the mount structure Index: sys/coda/coda_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/coda/coda_vfsops.c,v retrieving revision 1.45 diff -u -u -p -r1.45 coda_vfsops.c --- sys/coda/coda_vfsops.c 30 Aug 2005 22:24:11 -0000 1.45 +++ sys/coda/coda_vfsops.c 23 Sep 2005 10:00:09 -0000 @@ -110,16 +110,12 @@ struct vfsops coda_vfsops = { coda_nb_statvfs, coda_sync, coda_vget, - (int (*) (struct mount *, struct fid *, struct vnode ** )) - eopnotsupp, - (int (*) (struct vnode *, struct fid *)) eopnotsupp, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ coda_init, NULL, coda_done, - NULL, (int (*)(void)) eopnotsupp, - (int (*)(struct mount *, struct mbuf *, int *, struct ucred **)) - eopnotsupp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, coda_vnodeopv_descs, Index: sys/fs/adosfs/adosfs.h =================================================================== RCS file: /cvsroot/src/sys/fs/adosfs/adosfs.h,v retrieving revision 1.5 diff -u -u -p -r1.5 adosfs.h --- sys/fs/adosfs/adosfs.h 26 Feb 2005 22:58:54 -0000 1.5 +++ sys/fs/adosfs/adosfs.h 23 Sep 2005 10:00:09 -0000 @@ -36,7 +36,7 @@ */ struct adosfs_args { char *fspec; /* blocks special holding the fs to mount */ - struct export_args export; /* network export information */ + struct compat_export_args _pad1; /* compat with old userland tools */ uid_t uid; /* uid that owns adosfs files */ gid_t gid; /* gid that owns adosfs files */ mode_t mask; /* mask to be applied for adosfs perms */ @@ -123,7 +123,6 @@ struct adosfsmount { u_long mask; /* mode mask */ struct vnode *devvp; /* blk device mounted on */ struct vnode *rootvp; /* out root vnode */ - struct netexport export; u_long *bitmap; /* allocation bitmap */ u_long numblks; /* number of usable blocks */ u_long freeblks; /* number of free blocks */ Index: sys/fs/adosfs/advfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/adosfs/advfsops.c,v retrieving revision 1.24 diff -u -u -p -r1.24 advfsops.c --- sys/fs/adosfs/advfsops.c 19 Aug 2005 04:15:02 -0000 1.24 +++ sys/fs/adosfs/advfsops.c 23 Sep 2005 10:00:09 -0000 @@ -70,8 +70,6 @@ int adosfs_statvfs __P((struct mount *, int adosfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); int adosfs_vget __P((struct mount *, ino_t, struct vnode **)); int adosfs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); -int adosfs_checkexp __P((struct mount *, struct mbuf *, int *, - struct ucred **)); int adosfs_vptofh __P((struct vnode *, struct fid *)); int adosfs_mountfs __P((struct vnode *, struct mount *, struct proc *)); @@ -114,7 +112,6 @@ adosfs_mount(mp, path, data, ndp, p) args.gid = amp->gid; args.mask = amp->mask; args.fspec = NULL; - vfs_showexport(mp, &args.export, &->export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof(struct adosfs_args)); @@ -123,15 +120,10 @@ adosfs_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EROFS); - /* - * If updating, check whether changing from read-only to - * read/write; if there is no device name, that's all we do. - */ - if (mp->mnt_flag & MNT_UPDATE) { - amp = VFSTOADOSFS(mp); - if (args.fspec == 0) - return (vfs_export(mp, &->export, &args.export)); - } + + if ((mp->mnt_flag & MNT_UPDATE) && args.fspec == NULL) + return EOPNOTSUPP; + /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. @@ -740,35 +732,6 @@ adosfs_fhtovp(mp, fhp, vpp) } int -adosfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - struct adosfsmount *amp = VFSTOADOSFS(mp); -#if 0 - struct anode *ap; -#endif - struct netcred *np; - -#ifdef ADOSFS_DIAGNOSTIC - printf("adcheckexp(%x, %x, %x)\n", mp, nam, exflagsp); -#endif - - /* - * Get the export permission structure for this tuple. - */ - np = vfs_export_lookup(mp, &->export, nam); - if (np == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return(0); -} - -int adosfs_vptofh(vp, fhp) struct vnode *vp; struct fid *fhp; @@ -883,9 +846,7 @@ struct vfsops adosfs_vfsops = { adosfs_init, NULL, adosfs_done, - NULL, NULL, /* vfs_mountroot */ - adosfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, adosfs_vnodeopv_descs, Index: sys/fs/cd9660/cd9660_extern.h =================================================================== RCS file: /cvsroot/src/sys/fs/cd9660/cd9660_extern.h,v retrieving revision 1.14 diff -u -u -p -r1.14 cd9660_extern.h --- sys/fs/cd9660/cd9660_extern.h 30 Aug 2005 18:47:19 -0000 1.14 +++ sys/fs/cd9660/cd9660_extern.h 23 Sep 2005 10:00:09 -0000 @@ -74,7 +74,6 @@ struct iso_mnt { int im_bmask; int volume_space_size; - struct netexport im_export; char root[ISODCL (157, 190)]; int root_extent; @@ -105,8 +104,6 @@ int cd9660_statvfs(struct mount *, struc int cd9660_sync(struct mount *, int, struct ucred *, struct proc *); int cd9660_vget(struct mount *, ino_t, struct vnode **); int cd9660_fhtovp(struct mount *, struct fid *, struct vnode **); -int cd9660_check_export(struct mount *, struct mbuf *, int *, - struct ucred **); int cd9660_vptofh(struct vnode *, struct fid *); void cd9660_init(void); void cd9660_reinit(void); Index: sys/fs/cd9660/cd9660_mount.h =================================================================== RCS file: /cvsroot/src/sys/fs/cd9660/cd9660_mount.h,v retrieving revision 1.3 diff -u -u -p -r1.3 cd9660_mount.h --- sys/fs/cd9660/cd9660_mount.h 3 Oct 2003 16:34:31 -0000 1.3 +++ sys/fs/cd9660/cd9660_mount.h 23 Sep 2005 10:00:09 -0000 @@ -40,7 +40,7 @@ */ struct iso_args { const char *fspec; /* block special device to mount */ - struct export_args export; /* network export info */ + struct compat_export_args _pad1; /* compat with old userland tools */ int flags; /* mounting flags, see below */ }; #define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/ Index: sys/fs/cd9660/cd9660_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/cd9660/cd9660_vfsops.c,v retrieving revision 1.26 diff -u -u -p -r1.26 cd9660_vfsops.c --- sys/fs/cd9660/cd9660_vfsops.c 30 Aug 2005 18:47:19 -0000 1.26 +++ sys/fs/cd9660/cd9660_vfsops.c 23 Sep 2005 10:00:09 -0000 @@ -99,9 +99,7 @@ struct vfsops cd9660_vfsops = { cd9660_init, cd9660_reinit, cd9660_done, - NULL, cd9660_mountroot, - cd9660_check_export, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, cd9660_vnodeopv_descs, @@ -179,7 +177,6 @@ cd9660_mount(mp, path, data, ndp, p) return EIO; args.fspec = NULL; args.flags = imp->im_flags; - vfs_showexport(mp, &args.export, &imp->im_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof (struct iso_args)); @@ -189,15 +186,9 @@ cd9660_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EROFS); - /* - * If updating, check whether changing from read-only to - * read/write; if there is no device name, that's all we do. - */ - if (mp->mnt_flag & MNT_UPDATE) { - imp = VFSTOISOFS(mp); - if (args.fspec == 0) - return (vfs_export(mp, &imp->im_export, &args.export)); - } + if ((mp->mnt_flag & MNT_UPDATE) && args.fspec == NULL) + return EINVAL; + /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. @@ -697,34 +688,6 @@ cd9660_fhtovp(mp, fhp, vpp) return (0); } -/* ARGSUSED */ -int -cd9660_check_export(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - struct netcred *np; - struct iso_mnt *imp = VFSTOISOFS(mp); - -#ifdef ISOFS_DBG - printf("check_export: ino %d, start %ld\n", - ifhp->ifid_ino, ifhp->ifid_start); -#endif - - /* - * Get the export permission structure for this tuple. - */ - np = vfs_export_lookup(mp, &imp->im_export, nam); - if (np == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} - int cd9660_vget(mp, ino, vpp) struct mount *mp; Index: sys/fs/filecorefs/filecore_extern.h =================================================================== RCS file: /cvsroot/src/sys/fs/filecorefs/filecore_extern.h,v retrieving revision 1.9 diff -u -u -p -r1.9 filecore_extern.h --- sys/fs/filecorefs/filecore_extern.h 20 May 2004 06:34:26 -0000 1.9 +++ sys/fs/filecorefs/filecore_extern.h 23 Sep 2005 10:00:09 -0000 @@ -92,7 +92,6 @@ struct filecore_mnt { uid_t fc_uid; /* uid to set as owner of the files */ gid_t fc_gid; /* gid to set as owner of the files */ int fc_mntflags; - struct netexport fc_export; struct filecore_disc_record drec; }; Index: sys/fs/filecorefs/filecore_mount.h =================================================================== RCS file: /cvsroot/src/sys/fs/filecorefs/filecore_mount.h,v retrieving revision 1.3 diff -u -u -p -r1.3 filecore_mount.h --- sys/fs/filecorefs/filecore_mount.h 3 Oct 2003 16:34:31 -0000 1.3 +++ sys/fs/filecorefs/filecore_mount.h 23 Sep 2005 10:00:09 -0000 @@ -70,7 +70,7 @@ */ struct filecore_args { char *fspec; /* block special device to mount */ - struct export_args export; /* network export info */ + struct compat_export_args _pad1; /* compat with old userland tools */ uid_t uid; /* uid that owns filecore files */ gid_t gid; /* gid that owns filecore files */ int flags; /* mounting flags, see below */ Index: sys/fs/filecorefs/filecore_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/filecorefs/filecore_vfsops.c,v retrieving revision 1.20 diff -u -u -p -r1.20 filecore_vfsops.c --- sys/fs/filecorefs/filecore_vfsops.c 28 Jun 2005 09:30:37 -0000 1.20 +++ sys/fs/filecorefs/filecore_vfsops.c 23 Sep 2005 10:00:09 -0000 @@ -117,9 +117,7 @@ struct vfsops filecore_vfsops = { filecore_init, filecore_reinit, filecore_done, - NULL, NULL, /* filecore_mountroot */ - filecore_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, filecore_vnodeopv_descs, @@ -203,7 +201,6 @@ filecore_mount(mp, path, data, ndp, p) args.uid = fcmp->fc_uid; args.gid = fcmp->fc_gid; args.fspec = NULL; - vfs_showexport(mp, &args.export, &fcmp->fc_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof (struct filecore_args)); @@ -213,15 +210,9 @@ filecore_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) return (EROFS); - /* - * If updating, check whether changing from read-only to - * read/write; if there is no device name, that's all we do. - */ - if (mp->mnt_flag & MNT_UPDATE) { - fcmp = VFSTOFILECORE(mp); - if (args.fspec == 0) - return (vfs_export(mp, &fcmp->fc_export, &args.export)); - } + if ((mp->mnt_flag & MNT_UPDATE) && args.fspec == NULL) + return EINVAL; + /* * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. @@ -569,29 +560,6 @@ filecore_fhtovp(mp, fhp, vpp) return (0); } -/* ARGSUSED */ -int -filecore_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - struct filecore_mnt *fcmp = VFSTOFILECORE(mp); - struct netcred *np; - - /* - * Get the export permission structure for this tuple. - */ - np = vfs_export_lookup(mp, &fcmp->fc_export, nam); - if (np == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} - /* This looks complicated. Look at other vgets as well as the iso9660 one. * * The filecore inode number is made up of 1 byte directory entry index and Index: sys/fs/msdosfs/msdosfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfs_vfsops.c,v retrieving revision 1.27 diff -u -u -p -r1.27 msdosfs_vfsops.c --- sys/fs/msdosfs/msdosfs_vfsops.c 10 Sep 2005 17:33:45 -0000 1.27 +++ sys/fs/msdosfs/msdosfs_vfsops.c 23 Sep 2005 10:00:10 -0000 @@ -95,8 +95,6 @@ int msdosfs_statvfs(struct mount *, stru int msdosfs_sync(struct mount *, int, struct ucred *, struct proc *); int msdosfs_vget(struct mount *, ino_t, struct vnode **); int msdosfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int msdosfs_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); int msdosfs_vptofh(struct vnode *, struct fid *); int msdosfs_mountfs(struct vnode *, struct mount *, struct proc *, @@ -131,9 +129,7 @@ struct vfsops msdosfs_vfsops = { msdosfs_init, msdosfs_reinit, msdosfs_done, - NULL, msdosfs_mountroot, - msdosfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, msdosfs_vnodeopv_descs, @@ -265,7 +261,6 @@ msdosfs_mount(mp, path, data, ndp, p) args.version = MSDOSFSMNT_VERSION; args.dirmask = pmp->pm_dirmask; args.gmtoff = pmp->pm_gmtoff; - vfs_showexport(mp, &args.export, &pmp->pm_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof(struct msdosfs_args)); @@ -321,20 +316,8 @@ msdosfs_mount(mp, path, data, ndp, p) } pmp->pm_flags &= ~MSDOSFSMNT_RONLY; } - if (args.fspec == 0) { -#ifdef __notyet__ /* doesn't work correctly with current mountd XXX */ - if (args.flags & MSDOSFSMNT_MNTOPT) { - pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT; - pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT; - if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) - pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; - } -#endif - /* - * Process export requests. - */ - return (vfs_export(mp, &pmp->pm_export, &args.export)); - } + if (args.fspec == NULL) + return EINVAL; } /* * Not an update, or updating the name: look up the name @@ -993,24 +976,6 @@ msdosfs_fhtovp(mp, fhp, vpp) } int -msdosfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); - struct netcred *np; - - np = vfs_export_lookup(mp, &pmp->pm_export, nam); - if (np == NULL) - return (EACCES); - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} - -int msdosfs_vptofh(vp, fhp) struct vnode *vp; struct fid *fhp; Index: sys/fs/msdosfs/msdosfsmount.h =================================================================== RCS file: /cvsroot/src/sys/fs/msdosfs/msdosfsmount.h,v retrieving revision 1.8 diff -u -u -p -r1.8 msdosfsmount.h --- sys/fs/msdosfs/msdosfsmount.h 30 Aug 2005 18:49:19 -0000 1.8 +++ sys/fs/msdosfs/msdosfsmount.h 23 Sep 2005 10:00:10 -0000 @@ -52,7 +52,7 @@ */ struct msdosfs_args { char *fspec; /* blocks special holding the fs to mount */ - struct export_args export; /* network export information */ + struct compat_export_args _pad1; /* compat with old userland tools */ uid_t uid; /* uid that owns msdosfs files */ gid_t gid; /* gid that owns msdosfs files */ mode_t mask; /* mask to be applied for msdosfs perms */ @@ -130,7 +130,6 @@ struct msdosfsmount { u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */ u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */ u_int pm_flags; /* see below */ - struct netexport pm_export; /* export information */ }; /* Byte offset in FAT on filesystem pmp, cluster cn */ #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) Index: sys/fs/ntfs/ntfs.h =================================================================== RCS file: /cvsroot/src/sys/fs/ntfs/ntfs.h,v retrieving revision 1.9 diff -u -u -p -r1.9 ntfs.h --- sys/fs/ntfs/ntfs.h 30 Aug 2005 19:01:29 -0000 1.9 +++ sys/fs/ntfs/ntfs.h 23 Sep 2005 10:00:10 -0000 @@ -261,7 +261,6 @@ struct ntfsmount { cn_t ntm_cfree; struct ntvattrdef *ntm_ad; int ntm_adnum; - struct netexport ntm_export; /* export information */ ntfs_wget_func_t *ntm_wget; /* decode string to Unicode string */ ntfs_wput_func_t *ntm_wput; /* encode Unicode string to string */ ntfs_wcmp_func_t *ntm_wcmp; /* compare to wide characters */ Index: sys/fs/ntfs/ntfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/ntfs/ntfs_vfsops.c,v retrieving revision 1.33 diff -u -u -p -r1.33 ntfs_vfsops.c --- sys/fs/ntfs/ntfs_vfsops.c 30 Aug 2005 19:01:30 -0000 1.33 +++ sys/fs/ntfs/ntfs_vfsops.c 23 Sep 2005 10:00:11 -0000 @@ -99,8 +99,6 @@ static void ntfs_reinit(void); static void ntfs_done(void); static int ntfs_fhtovp(struct mount *, struct fid *, struct vnode **); -static int ntfs_checkexp(struct mount *, struct mbuf *, - int *, struct ucred **); static int ntfs_mountroot(void); #else static int ntfs_init(void); @@ -114,31 +112,6 @@ static const struct genfs_ops ntfs_genfs }; #ifdef __NetBSD__ -/* - * Verify a remote client has export rights and return these rights via. - * exflagsp and credanonp. - */ -static int -ntfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - struct netcred *np; - struct ntfsmount *ntm = VFSTONTFS(mp); - - /* - * Get the export permission structure for this tuple. - */ - np = vfs_export_lookup(mp, &ntm->ntm_export, nam); - if (np == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} SYSCTL_SETUP(sysctl_vfs_ntfs_setup, "sysctl vfs.ntfs subtree setup") { @@ -277,7 +250,6 @@ ntfs_mount ( args.gid = ntmp->ntm_gid; args.mode = ntmp->ntm_mode; args.flag = ntmp->ntm_flag; - vfs_showexport(mp, &args.export, &ntmp->ntm_export); return copyout(&args, data, sizeof(args)); } /* @@ -296,16 +268,6 @@ ntfs_mount ( * read/write; if there is no device name, that's all we do. */ if (mp->mnt_flag & MNT_UPDATE) { - /* if not updating name...*/ - if (args.fspec == 0) { - /* - * Process export requests. Jumping to "success" - * will return the vfs_export() error code. - */ - struct ntfsmount *ntm = VFSTONTFS(mp); - return (vfs_export(mp, &ntm->ntm_export, &args.export)); - } - printf("ntfs_mount(): MNT_UPDATE not supported\n"); return (EINVAL); } @@ -1027,9 +989,7 @@ struct vfsops ntfs_vfsops = { ntfs_init, ntfs_reinit, ntfs_done, - NULL, ntfs_mountroot, - ntfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, ntfs_vnodeopv_descs, Index: sys/fs/ntfs/ntfsmount.h =================================================================== RCS file: /cvsroot/src/sys/fs/ntfs/ntfsmount.h,v retrieving revision 1.2 diff -u -u -p -r1.2 ntfsmount.h --- sys/fs/ntfs/ntfsmount.h 3 Oct 2003 16:34:31 -0000 1.2 +++ sys/fs/ntfs/ntfsmount.h 23 Sep 2005 10:00:11 -0000 @@ -33,7 +33,7 @@ struct ntfs_args { char *fspec; /* block special device to mount */ - struct export_args export; /* network export information */ + struct compat_export_args _pad1; /* compat with old userland tools */ uid_t uid; /* uid that owns ntfs files */ gid_t gid; /* gid that owns ntfs files */ mode_t mode; /* mask to be applied for ntfs perms */ Index: sys/fs/ptyfs/ptyfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/ptyfs/ptyfs_vfsops.c,v retrieving revision 1.8 diff -u -u -p -r1.8 ptyfs_vfsops.c --- sys/fs/ptyfs/ptyfs_vfsops.c 29 May 2005 21:00:29 -0000 1.8 +++ sys/fs/ptyfs/ptyfs_vfsops.c 23 Sep 2005 10:00:11 -0000 @@ -72,9 +72,6 @@ int ptyfs_statvfs(struct mount *, struct int ptyfs_quotactl(struct mount *, int, uid_t, void *, struct proc *); int ptyfs_sync(struct mount *, int, struct ucred *, struct proc *); int ptyfs_vget(struct mount *, ino_t, struct vnode **); -int ptyfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int ptyfs_checkexp(struct mount *, struct mbuf *, int *, struct ucred **); -int ptyfs_vptofh(struct vnode *, struct fid *); static int ptyfs__allocvp(struct ptm_pty *, struct proc *, struct vnode **, dev_t, char); @@ -328,20 +325,6 @@ ptyfs_vget(struct mount *mp, ino_t ino, return EOPNOTSUPP; } -/*ARGSUSED*/ -int -ptyfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) -{ - return EOPNOTSUPP; -} - -/*ARGSUSED*/ -int -ptyfs_checkexp(struct mount *mp, struct mbuf *mb, int *wh, struct ucred **anon) -{ - return EOPNOTSUPP; -} - SYSCTL_SETUP(sysctl_vfs_ptyfs_setup, "sysctl vfs.ptyfs subtree setup") { @@ -364,13 +347,6 @@ SYSCTL_SETUP(sysctl_vfs_ptyfs_setup, "sy } -/*ARGSUSED*/ -int -ptyfs_vptofh(struct vnode *vp, struct fid *fhp) -{ - return EOPNOTSUPP; -} - extern const struct vnodeopv_desc ptyfs_vnodeop_opv_desc; const struct vnodeopv_desc * const ptyfs_vnodeopv_descs[] = { @@ -388,14 +364,12 @@ struct vfsops ptyfs_vfsops = { ptyfs_statvfs, ptyfs_sync, ptyfs_vget, - ptyfs_fhtovp, - ptyfs_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofp */ ptyfs_init, ptyfs_reinit, ptyfs_done, - NULL, NULL, /* vfs_mountroot */ - ptyfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *))eopnotsupp, (int (*)(struct mount *, int, struct vnode *, int, const char *, struct proc *))eopnotsupp, Index: sys/fs/smbfs/smbfs.h =================================================================== RCS file: /cvsroot/src/sys/fs/smbfs/smbfs.h,v retrieving revision 1.10 diff -u -u -p -r1.10 smbfs.h --- sys/fs/smbfs/smbfs.h 26 Feb 2005 22:58:55 -0000 1.10 +++ sys/fs/smbfs/smbfs.h 23 Sep 2005 10:00:11 -0000 @@ -61,7 +61,6 @@ struct smbfs_args { mode_t file_mode; mode_t dir_mode; int caseopt; - struct export_args export; /* network export information */ }; #ifdef _KERNEL Index: sys/fs/smbfs/smbfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/smbfs/smbfs_vfsops.c,v retrieving revision 1.49 diff -u -u -p -r1.49 smbfs_vfsops.c --- sys/fs/smbfs/smbfs_vfsops.c 20 Jun 2005 02:49:19 -0000 1.49 +++ sys/fs/smbfs/smbfs_vfsops.c 23 Sep 2005 10:00:11 -0000 @@ -109,8 +109,6 @@ void smbfs_reinit(void); void smbfs_done(void); int smbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp); -int smbfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int smbfs_vptofh(struct vnode *, struct fid *); POOL_INIT(smbfs_node_pool, sizeof(struct smbnode), 0, 0, 0, "smbfsnopl", &pool_allocator_nointr); @@ -131,15 +129,12 @@ struct vfsops smbfs_vfsops = { smbfs_statvfs, smbfs_sync, smbfs_vget, - smbfs_fhtovp, - smbfs_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ smbfs_init, smbfs_reinit, smbfs_done, - NULL, (int (*) (void)) eopnotsupp, /* mountroot */ - (int (*) (struct mount *, struct mbuf *, int *, - struct ucred **)) eopnotsupp, /* checkexp */ (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, smbfs_vnodeopv_descs, @@ -492,25 +487,4 @@ int smbfs_vget(mp, ino, vpp) return (EOPNOTSUPP); } -/* ARGSUSED */ -int smbfs_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - return (EINVAL); -} - -/* - * Vnode pointer to File handle, should never happen either - */ -/* ARGSUSED */ -int -smbfs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - return (EINVAL); -} - #endif /* __FreeBSD_version < 400009 */ Index: sys/fs/tmpfs/tmpfs.h =================================================================== RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs.h,v retrieving revision 1.4 diff -u -u -p -r1.4 tmpfs.h --- sys/fs/tmpfs/tmpfs.h 15 Sep 2005 12:34:35 -0000 1.4 +++ sys/fs/tmpfs/tmpfs.h 23 Sep 2005 10:00:11 -0000 @@ -149,7 +149,6 @@ struct tmpfs_mount { size_t tm_pages_used; struct tmpfs_node * tm_root; - struct netexport tm_export; ino_t tm_nodes_max; ino_t tm_nodes_last; @@ -344,12 +343,4 @@ struct tmpfs_args { uid_t ta_root_uid; gid_t ta_root_gid; mode_t ta_root_mode; - - /* Used to update NFS export properties. Due to the way these - * fields are used by mountd(8), they must come first, but as - * I would like to remove this restriction, I'm placing them - * here (there is no problem in doing so because, ATM, mountd(8) - * does not recognize tmpfs). XXX */ - const char * ta_fspec; - struct export_args ta_export; }; Index: sys/fs/tmpfs/tmpfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs_vfsops.c,v retrieving revision 1.3 diff -u -u -p -r1.3 tmpfs_vfsops.c --- sys/fs/tmpfs/tmpfs_vfsops.c 13 Sep 2005 21:30:52 -0000 1.3 +++ sys/fs/tmpfs/tmpfs_vfsops.c 23 Sep 2005 10:00:12 -0000 @@ -70,8 +70,6 @@ static int tmpfs_statvfs(struct mount *, static int tmpfs_sync(struct mount *, int, struct ucred *, struct proc *); static void tmpfs_init(void); static void tmpfs_done(void); -static int tmpfs_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); static int tmpfs_snapshot(struct mount *, struct vnode *, struct timespec *); @@ -95,7 +93,6 @@ tmpfs_mount(struct mount *mp, const char tmp = VFS_TO_TMPFS(mp); args.ta_version = TMPFS_ARGS_VERSION; - args.ta_fspec = NULL; args.ta_nodes_max = tmp->tm_nodes_max; args.ta_size_max = tmp->tm_pages_max * PAGE_SIZE; @@ -104,8 +101,6 @@ tmpfs_mount(struct mount *mp, const char args.ta_root_gid = root->tn_gid; args.ta_root_mode = root->tn_mode; - vfs_showexport(mp, &args, &tmp->tm_export); - return copyout(&args, data, sizeof(args)); } @@ -119,15 +114,6 @@ tmpfs_mount(struct mount *mp, const char return error; if (mp->mnt_flag & MNT_UPDATE) { - if (mp->mnt_data == NULL) - return EIO; - tmp = VFS_TO_TMPFS(mp); - - if (args.ta_fspec == NULL) { - /* Update NFS export information. */ - return vfs_export(mp, &tmp->tm_export, &args.ta_export); - } - /* XXX: There is no support yet to update file system * settings. Should be added. */ @@ -174,7 +160,6 @@ tmpfs_mount(struct mount *mp, const char tmpfs_pool_init(&tmp->tm_node_pool, sizeof(struct tmpfs_node), "node", tmp); tmpfs_str_pool_init(&tmp->tm_str_pool, tmp); - bzero(&tmp->tm_export, sizeof(struct netexport)); /* Allocate the root node. */ error = tmpfs_alloc_node(tmp, VDIR, args.ta_root_uid, @@ -423,26 +408,6 @@ tmpfs_done(void) /* --------------------------------------------------------------------- */ static int -tmpfs_checkexp(struct mount *mp, struct mbuf *mb, int *wh, - struct ucred **anon) -{ - struct netcred *np; - struct tmpfs_mount *tmp; - - tmp = VFS_TO_TMPFS(mp); - - np = vfs_export_lookup(mp, &tmp->tm_export, mb); - if (np != NULL) { - *wh = np->netc_exflags; - *anon = &np->netc_anon; - } - - return np == NULL ? EACCES : 0; -} - -/* --------------------------------------------------------------------- */ - -static int tmpfs_snapshot(struct mount *mp, struct vnode *vp, struct timespec *ctime) { @@ -481,9 +446,7 @@ struct vfsops tmpfs_vfsops = { tmpfs_init, /* vfs_init */ NULL, /* vfs_reinit */ tmpfs_done, /* vfs_done */ - NULL, /* vfs_wassysctl: deprecated */ NULL, /* vfs_mountroot */ - tmpfs_checkexp, /* vfs_checkexp */ tmpfs_snapshot, /* vfs_snapshot */ vfs_stdextattrctl, /* vfs_extattrctl */ tmpfs_vnodeopv_descs, Index: sys/fs/union/union_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/fs/union/union_vfsops.c,v retrieving revision 1.29 diff -u -u -p -r1.29 union_vfsops.c --- sys/fs/union/union_vfsops.c 30 Aug 2005 19:11:43 -0000 1.29 +++ sys/fs/union/union_vfsops.c 23 Sep 2005 10:00:12 -0000 @@ -103,10 +103,6 @@ int union_quotactl(struct mount *, int, int union_statvfs(struct mount *, struct statvfs *, struct proc *); int union_sync(struct mount *, int, struct ucred *, struct proc *); int union_vget(struct mount *, ino_t, struct vnode **); -int union_fhtovp(struct mount *, struct fid *, struct vnode **); -int union_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); -int union_vptofh(struct vnode *, struct fid *); /* * Mount union filesystem @@ -561,39 +557,6 @@ union_vget(mp, ino, vpp) return (EOPNOTSUPP); } -/*ARGSUSED*/ -int -union_fhtovp(mp, fidp, vpp) - struct mount *mp; - struct fid *fidp; - struct vnode **vpp; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -union_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -union_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - - return (EOPNOTSUPP); -} - SYSCTL_SETUP(sysctl_vfs_union_setup, "sysctl vfs.union subtree setup") { @@ -632,14 +595,12 @@ struct vfsops union_vfsops = { union_statvfs, union_sync, union_vget, - union_fhtovp, - union_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ union_init, NULL, /* vfs_reinit */ union_done, - NULL, NULL, /* vfs_mountroot */ - union_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, union_vnodeopv_descs, Index: sys/kern/kern_time.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_time.c,v retrieving revision 1.92 diff -u -u -p -r1.92 kern_time.c --- sys/kern/kern_time.c 23 Jul 2005 18:54:07 -0000 1.92 +++ sys/kern/kern_time.c 23 Sep 2005 10:00:12 -0000 @@ -94,6 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time.c, #if defined(NFS) || defined(NFSSERVER) #include #include +#include #include #endif Index: sys/kern/vfs_hooks.c =================================================================== RCS file: sys/kern/vfs_hooks.c diff -N sys/kern/vfs_hooks.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/kern/vfs_hooks.c 23 Sep 2005 10:00:12 -0000 @@ -0,0 +1,115 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2005 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * VFS hooks. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include + +/* + * Static list of file system specific hook sets supported by the kernel. + */ +__link_set_decl(vfs_hooks, struct vfs_hooks); + +/* + * Initialize a VFS hook set that does nothing. This is to ensure that + * we have, at the very least, one item in the link set. Otherwise, + * ld(1) will complain. + */ +static struct vfs_hooks null_hooks = { + NULL /* vh_unmount */ +}; +VFS_HOOKS_ATTACH(null_hooks); + +/* + * Macro to be used in one of the vfs_hooks_* function for hooks that + * return an error code. Calls will stop as soon as one of the hooks + * fails. + */ +#define VFS_HOOKS_W_ERROR(func, args) \ + int error; \ + struct vfs_hooks * const *hp; \ + \ + error = 0; \ + \ + __link_set_foreach(hp, vfs_hooks) { \ + if ((*hp)-> func != NULL) { \ + error = (*hp)-> func args; \ + if (error != 0) \ + break; \ + } \ + } \ + \ + return error; + +/* + * Macro to be used in one of the vfs_hooks_* function for hooks that + * do not return any error code. All hooks will be executed + * unconditionally. + */ +#define VFS_HOOKS_WO_ERROR(func, fargs, hook, hargs) \ +void \ +func fargs \ +{ \ + struct vfs_hooks * const *hp; \ + \ + __link_set_foreach(hp, vfs_hooks) { \ + if ((*hp)-> hook != NULL) \ + (*hp)-> hook hargs; \ + } \ +} + +/* + * Routines to iterate over VFS hooks lists and execute them. + */ + +VFS_HOOKS_WO_ERROR(vfs_hooks_unmount, (struct mount *mp), vh_unmount, (mp)); + +/* +void +vfs_hooks_unmount(struct mount *mp) +{ + + VFS_HOOKS_WO_ERROR(vh_unmount, (mp)); +} +*/ Index: sys/kern/vfs_subr.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v retrieving revision 1.253 diff -u -u -p -r1.253 vfs_subr.c --- sys/kern/vfs_subr.c 13 Sep 2005 01:45:14 -0000 1.253 +++ sys/kern/vfs_subr.c 23 Sep 2005 10:00:13 -0000 @@ -92,8 +92,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v #include #include #include -#include -#include #include #include #include @@ -107,20 +105,15 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v #include #include #include -#include #include #include #include #include -#include - #include #include -#include - #include const enum vtype iftovt_tab[16] = { @@ -154,8 +147,6 @@ struct mntlist mountlist = /* mounted struct vfs_list_head vfs_list = /* vfs list */ LIST_HEAD_INITIALIZER(vfs_list); -struct nfs_public nfs_pub; /* publicly exported FS */ - struct simplelock mountlist_slock = SIMPLELOCK_INITIALIZER; static struct simplelock mntid_slock = SIMPLELOCK_INITIALIZER; struct simplelock mntvnode_slock = SIMPLELOCK_INITIALIZER; @@ -185,10 +176,6 @@ int getdevvp(dev_t, struct vnode **, enu void vclean(struct vnode *, int, struct proc *); -static int vfs_hang_addrlist(struct mount *, struct netexport *, - struct export_args *); -static int vfs_free_netcred(struct radix_node *, void *); -static void vfs_free_addrlist(struct netexport *); static struct vnode *getcleanvnode(struct proc *); #ifdef DEBUG @@ -2113,311 +2100,6 @@ vfs_mountedon(struct vnode *vp) return (error); } -static int -sacheck(struct sockaddr *sa) -{ - switch (sa->sa_family) { -#ifdef INET - case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)sa; - char *p = (char *)sin->sin_zero; - size_t i; - - if (sin->sin_len != sizeof(*sin)) - return -1; - if (sin->sin_port != 0) - return -1; - for (i = 0; i < sizeof(sin->sin_zero); i++) - if (*p++ != '\0') - return -1; - return 0; - } -#endif -#ifdef INET6 - case AF_INET6: { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; - - if (sin6->sin6_len != sizeof(*sin6)) - return -1; - if (sin6->sin6_port != 0) - return -1; - return 0; - } -#endif - default: - return -1; - } -} - -/* - * Build hash lists of net addresses and hang them off the mount point. - * Called by ufs_mount() to set up the lists of export addresses. - */ -static int -vfs_hang_addrlist(struct mount *mp, struct netexport *nep, - struct export_args *argp) -{ - struct netcred *np, *enp; - struct radix_node_head *rnh; - int i; - struct sockaddr *saddr, *smask = 0; - struct domain *dom; - int error; - - if (argp->ex_addrlen == 0) { - if (mp->mnt_flag & MNT_DEFEXPORTED) - return (EPERM); - np = &nep->ne_defexported; - np->netc_exflags = argp->ex_flags; - crcvt(&np->netc_anon, &argp->ex_anon); - np->netc_anon.cr_ref = 1; - mp->mnt_flag |= MNT_DEFEXPORTED; - return (0); - } - - if (argp->ex_addrlen > MLEN || argp->ex_masklen > MLEN) - return (EINVAL); - - i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; - np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK); - memset((caddr_t)np, 0, i); - saddr = (struct sockaddr *)(np + 1); - error = copyin(argp->ex_addr, (caddr_t)saddr, argp->ex_addrlen); - if (error) - goto out; - if (saddr->sa_len > argp->ex_addrlen) - saddr->sa_len = argp->ex_addrlen; - if (sacheck(saddr) == -1) - return EINVAL; - if (argp->ex_masklen) { - smask = (struct sockaddr *)((caddr_t)saddr + argp->ex_addrlen); - error = copyin(argp->ex_mask, (caddr_t)smask, argp->ex_masklen); - if (error) - goto out; - if (smask->sa_len > argp->ex_masklen) - smask->sa_len = argp->ex_masklen; - if (smask->sa_family != saddr->sa_family) - return EINVAL; - if (sacheck(smask) == -1) - return EINVAL; - } - i = saddr->sa_family; - if ((rnh = nep->ne_rtable[i]) == 0) { - /* - * Seems silly to initialize every AF when most are not - * used, do so on demand here - */ - DOMAIN_FOREACH(dom) { - if (dom->dom_family == i && dom->dom_rtattach) { - dom->dom_rtattach((void **)&nep->ne_rtable[i], - dom->dom_rtoffset); - break; - } - } - if ((rnh = nep->ne_rtable[i]) == 0) { - error = ENOBUFS; - goto out; - } - } - - enp = (struct netcred *)(*rnh->rnh_addaddr)(saddr, smask, rnh, - np->netc_rnodes); - if (enp != np) { - if (enp == NULL) { - enp = (struct netcred *)(*rnh->rnh_lookup)(saddr, - smask, rnh); - if (enp == NULL) { - error = EPERM; - goto out; - } - } else - enp->netc_refcnt++; - - goto check; - } else - enp->netc_refcnt = 1; - - np->netc_exflags = argp->ex_flags; - crcvt(&np->netc_anon, &argp->ex_anon); - np->netc_anon.cr_ref = 1; - return 0; -check: - if (enp->netc_exflags != argp->ex_flags || - crcmp(&enp->netc_anon, &argp->ex_anon) != 0) - error = EPERM; - else - error = 0; -out: - free(np, M_NETADDR); - return error; -} - -/* ARGSUSED */ -static int -vfs_free_netcred(struct radix_node *rn, void *w) -{ - struct radix_node_head *rnh = (struct radix_node_head *)w; - struct netcred *np = (struct netcred *)(void *)rn; - - (*rnh->rnh_deladdr)(rn->rn_key, rn->rn_mask, rnh); - if (--(np->netc_refcnt) <= 0) - free(np, M_NETADDR); - return (0); -} - -/* - * Free the net address hash lists that are hanging off the mount points. - */ -static void -vfs_free_addrlist(struct netexport *nep) -{ - int i; - struct radix_node_head *rnh; - - for (i = 0; i <= AF_MAX; i++) - if ((rnh = nep->ne_rtable[i]) != NULL) { - (*rnh->rnh_walktree)(rnh, vfs_free_netcred, rnh); - free((caddr_t)rnh, M_RTABLE); - nep->ne_rtable[i] = 0; - } -} - -int -vfs_export(struct mount *mp, struct netexport *nep, struct export_args *argp) -{ - int error; - - if (argp->ex_flags & MNT_DELEXPORT) { - if (mp->mnt_flag & MNT_EXPUBLIC) { - vfs_setpublicfs(NULL, NULL, NULL); - mp->mnt_flag &= ~MNT_EXPUBLIC; - } - vfs_free_addrlist(nep); - mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); - } - if (argp->ex_flags & MNT_EXPORTED) { - if (argp->ex_flags & MNT_EXPUBLIC) { - if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) - return (error); - mp->mnt_flag |= MNT_EXPUBLIC; - } - if ((error = vfs_hang_addrlist(mp, nep, argp)) != 0) - return (error); - mp->mnt_flag |= MNT_EXPORTED; - } - return (0); -} - -/* - * Set the publicly exported filesystem (WebNFS). Currently, only - * one public filesystem is possible in the spec (RFC 2054 and 2055) - */ -int -vfs_setpublicfs(struct mount *mp, struct netexport *nep, - struct export_args *argp) -{ - int error; - struct vnode *rvp; - char *cp; - - /* - * mp == NULL -> invalidate the current info, the FS is - * no longer exported. May be called from either vfs_export - * or unmount, so check if it hasn't already been done. - */ - if (mp == NULL) { - if (nfs_pub.np_valid) { - nfs_pub.np_valid = 0; - if (nfs_pub.np_index != NULL) { - FREE(nfs_pub.np_index, M_TEMP); - nfs_pub.np_index = NULL; - } - } - return (0); - } - - /* - * Only one allowed at a time. - */ - if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount) - return (EBUSY); - - /* - * Get real filehandle for root of exported FS. - */ - memset((caddr_t)&nfs_pub.np_handle, 0, sizeof(nfs_pub.np_handle)); - nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsidx; - - if ((error = VFS_ROOT(mp, &rvp))) - return (error); - - if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid))) - return (error); - - vput(rvp); - - /* - * If an indexfile was specified, pull it in. - */ - if (argp->ex_indexfile != NULL) { - MALLOC(nfs_pub.np_index, char *, MAXNAMLEN + 1, M_TEMP, - M_WAITOK); - error = copyinstr(argp->ex_indexfile, nfs_pub.np_index, - MAXNAMLEN, (size_t *)0); - if (!error) { - /* - * Check for illegal filenames. - */ - for (cp = nfs_pub.np_index; *cp; cp++) { - if (*cp == '/') { - error = EINVAL; - break; - } - } - } - if (error) { - FREE(nfs_pub.np_index, M_TEMP); - return (error); - } - } - - nfs_pub.np_mount = mp; - nfs_pub.np_valid = 1; - return (0); -} - -struct netcred * -vfs_export_lookup(struct mount *mp, struct netexport *nep, struct mbuf *nam) -{ - struct netcred *np; - struct radix_node_head *rnh; - struct sockaddr *saddr; - - np = NULL; - if (mp->mnt_flag & MNT_EXPORTED) { - /* - * Lookup in the export list first. - */ - if (nam != NULL) { - saddr = mtod(nam, struct sockaddr *); - rnh = nep->ne_rtable[saddr->sa_family]; - if (rnh != NULL) { - np = (struct netcred *) - (*rnh->rnh_matchaddr)((caddr_t)saddr, - rnh); - if (np && np->netc_rnodes->rn_flags & RNF_ROOT) - np = NULL; - } - } - /* - * If no address match, use the default if it exists. - */ - if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED) - np = &nep->ne_defexported; - } - return (np); -} - /* * Do the usual access checking. * file_mode, uid and gid are from the vnode in question, Index: sys/kern/vfs_syscalls.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.230 diff -u -u -p -r1.230 vfs_syscalls.c --- sys/kern/vfs_syscalls.c 30 Aug 2005 09:37:41 -0000 1.230 +++ sys/kern/vfs_syscalls.c 23 Sep 2005 10:00:14 -0000 @@ -541,8 +541,6 @@ dounmount(struct mount *mp, int flags, s lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock); vn_start_write(NULL, &mp, V_WAIT); - if (mp->mnt_flag & MNT_EXPUBLIC) - vfs_setpublicfs(NULL, NULL, NULL); async = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; cache_purgevfs(mp); /* remove cache entries for this file sys */ @@ -597,6 +595,7 @@ dounmount(struct mount *mp, int flags, s ltsleep(&mp->mnt_wcnt, PVFS, "mntwcnt2", 0, &mp->mnt_slock); } simple_unlock(&mp->mnt_slock); + vfs_hooks_unmount(mp); free(mp, M_MOUNT); return (0); } @@ -1192,6 +1191,8 @@ sys_getfh(struct lwp *l, void *v, regist if (error) return (error); vp = nd.ni_vp; + if (vp->v_mount->mnt_op->vfs_vptofh == NULL) + return EOPNOTSUPP; memset(&fh, 0, sizeof(fh)); fh.fh_fsid = vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(vp, &fh.fh_fid); @@ -1251,6 +1252,11 @@ sys_fhopen(struct lwp *l, void *v, regis goto bad; } + if (mp->mnt_op->vfs_fhtovp == NULL) { + error = EOPNOTSUPP; + goto bad; + } + if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)) != 0) { vp = NULL; /* most likely unnecessary sanity for bad: */ goto bad; @@ -1368,6 +1374,8 @@ sys_fhstat(struct lwp *l, void *v, regis if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) return (ESTALE); + if (mp->mnt_op->vfs_fhtovp == NULL) + return EOPNOTSUPP; if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) return (error); error = vn_stat(vp, &sb, p); @@ -1405,6 +1413,8 @@ sys_fhstatvfs1(struct lwp *l, void *v, r if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) return ESTALE; + if (mp->mnt_op->vfs_fhtovp == NULL) + return EOPNOTSUPP; if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) return error; Index: sys/miscfs/fdesc/fdesc_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/fdesc/fdesc_vfsops.c,v retrieving revision 1.56 diff -u -u -p -r1.56 fdesc_vfsops.c --- sys/miscfs/fdesc/fdesc_vfsops.c 30 Aug 2005 20:08:01 -0000 1.56 +++ sys/miscfs/fdesc/fdesc_vfsops.c 23 Sep 2005 10:00:14 -0000 @@ -70,10 +70,6 @@ int fdesc_quotactl(struct mount *, int, int fdesc_statvfs(struct mount *, struct statvfs *, struct proc *); int fdesc_sync(struct mount *, int, struct ucred *, struct proc *); int fdesc_vget(struct mount *, ino_t, struct vnode **); -int fdesc_fhtovp(struct mount *, struct fid *, struct vnode **); -int fdesc_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); -int fdesc_vptofh(struct vnode *, struct fid *); /* * Mount the per-process file descriptors (/dev/fd) @@ -271,38 +267,6 @@ fdesc_vget(mp, ino, vpp) } -/*ARGSUSED*/ -int -fdesc_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -fdesc_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -fdesc_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - return (EOPNOTSUPP); -} - SYSCTL_SETUP(sysctl_vfs_fdesc_setup, "sysctl vfs.fdesc subtree setup") { @@ -341,14 +305,12 @@ struct vfsops fdesc_vfsops = { fdesc_statvfs, fdesc_sync, fdesc_vget, - fdesc_fhtovp, - fdesc_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ fdesc_init, NULL, fdesc_done, - NULL, NULL, /* vfs_mountroot */ - fdesc_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, fdesc_vnodeopv_descs, Index: sys/miscfs/genfs/layer.h =================================================================== RCS file: /cvsroot/src/sys/miscfs/genfs/layer.h,v retrieving revision 1.8 diff -u -u -p -r1.8 layer.h --- sys/miscfs/genfs/layer.h 30 Aug 2005 20:08:01 -0000 1.8 +++ sys/miscfs/genfs/layer.h 23 Sep 2005 10:00:14 -0000 @@ -73,7 +73,7 @@ struct layer_args { char *target; /* Target of loopback */ - struct export_args export; /* network export info */ + struct compat_export_args _pad1; /* compat with old userland tools */ }; #ifdef _KERNEL @@ -85,7 +85,6 @@ LIST_HEAD(layer_node_hashhead, layer_nod struct layer_mount { struct mount *layerm_vfs; struct vnode *layerm_rootvp; /* Ref to root layer_node */ - struct netexport layerm_export; /* export info */ u_int layerm_flags; /* mount point layer flags */ u_int layerm_size; /* size of fs's struct node */ enum vtype layerm_tag; /* vtag of our vnodes */ Index: sys/miscfs/genfs/layer_extern.h =================================================================== RCS file: /cvsroot/src/sys/miscfs/genfs/layer_extern.h,v retrieving revision 1.18 diff -u -u -p -r1.18 layer_extern.h --- sys/miscfs/genfs/layer_extern.h 30 Aug 2005 20:08:01 -0000 1.18 +++ sys/miscfs/genfs/layer_extern.h 23 Sep 2005 10:00:14 -0000 @@ -90,8 +90,6 @@ int layerfs_statvfs(struct mount *, stru int layerfs_sync(struct mount *, int, struct ucred *, struct proc *); int layerfs_vget(struct mount *, ino_t, struct vnode **); int layerfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int layerfs_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); int layerfs_vptofh(struct vnode *, struct fid *); int layerfs_snapshot(struct mount *, struct vnode *, struct timespec *); Index: sys/miscfs/genfs/layer_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/genfs/layer_vfsops.c,v retrieving revision 1.20 diff -u -u -p -r1.20 layer_vfsops.c --- sys/miscfs/genfs/layer_vfsops.c 24 Jul 2005 17:33:24 -0000 1.20 +++ sys/miscfs/genfs/layer_vfsops.c 23 Sep 2005 10:00:14 -0000 @@ -244,27 +244,6 @@ layerfs_fhtovp(mp, fidp, vpp) } int -layerfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred**credanonp; -{ - struct netcred *np; - struct layer_mount *lmp = MOUNTTOLAYERMOUNT(mp); - - /* - * get the export permission structure for this tuple. - */ - if ((np = vfs_export_lookup(mp, &lmp->layerm_export, nam)) == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} - -int layerfs_vptofh(vp, fhp) struct vnode *vp; struct fid *fhp; Index: sys/miscfs/kernfs/kernfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/kernfs/kernfs_vfsops.c,v retrieving revision 1.68 diff -u -u -p -r1.68 kernfs_vfsops.c --- sys/miscfs/kernfs/kernfs_vfsops.c 30 Aug 2005 20:08:01 -0000 1.68 +++ sys/miscfs/kernfs/kernfs_vfsops.c 23 Sep 2005 10:00:14 -0000 @@ -77,10 +77,6 @@ int kernfs_quotactl(struct mount *, int, struct proc *); int kernfs_sync(struct mount *, int, struct ucred *, struct proc *); int kernfs_vget(struct mount *, ino_t, struct vnode **); -int kernfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int kernfs_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); -int kernfs_vptofh(struct vnode *, struct fid *); void kernfs_init() @@ -276,39 +272,6 @@ kernfs_vget(mp, ino, vpp) return (EOPNOTSUPP); } -/*ARGSUSED*/ -int -kernfs_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -kernfs_checkexp(mp, mb, what, anon) - struct mount *mp; - struct mbuf *mb; - int *what; - struct ucred **anon; -{ - - return (EOPNOTSUPP); -} - -/*ARGSUSED*/ -int -kernfs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - - return (EOPNOTSUPP); -} - SYSCTL_SETUP(sysctl_vfs_kernfs_setup, "sysctl vfs.kern subtree setup") { @@ -347,14 +310,12 @@ struct vfsops kernfs_vfsops = { kernfs_statvfs, kernfs_sync, kernfs_vget, - kernfs_fhtovp, - kernfs_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ kernfs_init, kernfs_reinit, kernfs_done, - NULL, NULL, /* vfs_mountroot */ - kernfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, kernfs_vnodeopv_descs, Index: sys/miscfs/nullfs/null_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/nullfs/null_vfsops.c,v retrieving revision 1.56 diff -u -u -p -r1.56 null_vfsops.c --- sys/miscfs/nullfs/null_vfsops.c 30 Aug 2005 20:08:01 -0000 1.56 +++ sys/miscfs/nullfs/null_vfsops.c 23 Sep 2005 10:00:14 -0000 @@ -119,7 +119,6 @@ nullfs_mount(mp, path, data, ndp, p) if (lmp == NULL) return EIO; args.la.target = NULL; - vfs_showexport(mp, &args.la.export, &lmp->layerm_export); return copyout(&args, data, sizeof(args)); } /* @@ -130,16 +129,10 @@ nullfs_mount(mp, path, data, ndp, p) return (error); /* - * Update only does export updating. + * Update is not supported */ - if (mp->mnt_flag & MNT_UPDATE) { - lmp = MOUNTTOLAYERMOUNT(mp); - if (args.nulla_target == NULL) - return (vfs_export(mp, &lmp->layerm_export, - &args.la.export)); - else - return (EOPNOTSUPP); - } + if (mp->mnt_flag & MNT_UPDATE) + return EOPNOTSUPP; /* * Find lower node @@ -317,9 +310,7 @@ struct vfsops nullfs_vfsops = { layerfs_init, NULL, layerfs_done, - NULL, NULL, /* vfs_mountroot */ - layerfs_checkexp, layerfs_snapshot, vfs_stdextattrctl, nullfs_vnodeopv_descs, Index: sys/miscfs/overlay/overlay_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/overlay/overlay_vfsops.c,v retrieving revision 1.31 diff -u -u -p -r1.31 overlay_vfsops.c --- sys/miscfs/overlay/overlay_vfsops.c 30 Aug 2005 20:08:01 -0000 1.31 +++ sys/miscfs/overlay/overlay_vfsops.c 23 Sep 2005 10:00:14 -0000 @@ -120,7 +120,6 @@ ov_mount(mp, path, data, ndp, p) if (lmp == NULL) return EIO; args.la.target = NULL; - vfs_showexport(mp, &args.la.export, &lmp->layerm_export); return copyout(&args, data, sizeof(args)); } /* @@ -131,16 +130,10 @@ ov_mount(mp, path, data, ndp, p) return (error); /* - * Update only does export updating. + * Update is not supported */ - if (mp->mnt_flag & MNT_UPDATE) { - lmp = MOUNTTOLAYERMOUNT(mp); - if (args.ova_target == 0) - return (vfs_export(mp, &lmp->layerm_export, - &args.la.export)); - else - return (EOPNOTSUPP); - } + if (mp->mnt_flag & MNT_UPDATE) + return EOPNOTSUPP; /* * Find lower node @@ -300,9 +293,7 @@ struct vfsops overlay_vfsops = { layerfs_init, NULL, layerfs_done, - NULL, NULL, /* vfs_mountroot */ - layerfs_checkexp, layerfs_snapshot, vfs_stdextattrctl, ov_vnodeopv_descs, Index: sys/miscfs/portal/portal_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/portal/portal_vfsops.c,v retrieving revision 1.52 diff -u -u -p -r1.52 portal_vfsops.c --- sys/miscfs/portal/portal_vfsops.c 30 Aug 2005 20:08:01 -0000 1.52 +++ sys/miscfs/portal/portal_vfsops.c 23 Sep 2005 10:00:15 -0000 @@ -78,10 +78,6 @@ int portal_quotactl(struct mount *, int, int portal_statvfs(struct mount *, struct statvfs *, struct proc *); int portal_sync(struct mount *, int, struct ucred *, struct proc *); int portal_vget(struct mount *, ino_t, struct vnode **); -int portal_fhtovp(struct mount *, struct fid *, struct vnode **); -int portal_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); -int portal_vptofh(struct vnode *, struct fid *); void portal_init() @@ -304,36 +300,6 @@ portal_vget(mp, ino, vpp) return (EOPNOTSUPP); } -int -portal_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - - return (EOPNOTSUPP); -} - -int -portal_checkexp(mp, mb, what, anon) - struct mount *mp; - struct mbuf *mb; - int *what; - struct ucred **anon; -{ - - return (EOPNOTSUPP); -} - -int -portal_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - - return (EOPNOTSUPP); -} - SYSCTL_SETUP(sysctl_vfs_portal_setup, "sysctl vfs.portal subtree setup") { @@ -372,14 +338,12 @@ struct vfsops portal_vfsops = { portal_statvfs, portal_sync, portal_vget, - portal_fhtovp, - portal_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ portal_init, NULL, portal_done, - NULL, NULL, /* vfs_mountroot */ - portal_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, portal_vnodeopv_descs, Index: sys/miscfs/procfs/procfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/procfs/procfs_vfsops.c,v retrieving revision 1.61 diff -u -u -p -r1.61 procfs_vfsops.c --- sys/miscfs/procfs/procfs_vfsops.c 30 Aug 2005 20:08:01 -0000 1.61 +++ sys/miscfs/procfs/procfs_vfsops.c 23 Sep 2005 10:00:15 -0000 @@ -112,10 +112,6 @@ int procfs_quotactl(struct mount *, int, int procfs_statvfs(struct mount *, struct statvfs *, struct proc *); int procfs_sync(struct mount *, int, struct ucred *, struct proc *); int procfs_vget(struct mount *, ino_t, struct vnode **); -int procfs_fhtovp(struct mount *, struct fid *, struct vnode **); -int procfs_checkexp(struct mount *, struct mbuf *, int *, - struct ucred **); -int procfs_vptofh(struct vnode *, struct fid *); /* * VFS Operations. @@ -284,39 +280,6 @@ procfs_vget(mp, ino, vpp) return (EOPNOTSUPP); } -/*ARGSUSED*/ -int -procfs_fhtovp(mp, fhp, vpp) - struct mount *mp; - struct fid *fhp; - struct vnode **vpp; -{ - - return (EINVAL); -} - -/*ARGSUSED*/ -int -procfs_checkexp(mp, mb, what, anon) - struct mount *mp; - struct mbuf *mb; - int *what; - struct ucred **anon; -{ - - return (EINVAL); -} - -/*ARGSUSED*/ -int -procfs_vptofh(vp, fhp) - struct vnode *vp; - struct fid *fhp; -{ - - return (EINVAL); -} - void procfs_init() { @@ -373,14 +336,12 @@ struct vfsops procfs_vfsops = { procfs_statvfs, procfs_sync, procfs_vget, - procfs_fhtovp, - procfs_vptofh, + NULL, /* vfs_fhtovp */ + NULL, /* vfs_vptofh */ procfs_init, procfs_reinit, procfs_done, - NULL, NULL, /* vfs_mountroot */ - procfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, procfs_vnodeopv_descs, Index: sys/miscfs/umapfs/umap_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/umapfs/umap_vfsops.c,v retrieving revision 1.54 diff -u -u -p -r1.54 umap_vfsops.c --- sys/miscfs/umapfs/umap_vfsops.c 30 Aug 2005 20:08:02 -0000 1.54 +++ sys/miscfs/umapfs/umap_vfsops.c 23 Sep 2005 10:00:15 -0000 @@ -82,7 +82,6 @@ umapfs_mount(mp, path, data, ndp, p) if (amp == NULL) return EIO; args.la.target = NULL; - vfs_showexport(mp, &args.la.export, &->umapm_export); args.nentries = amp->info_nentries; args.gnentries = amp->info_gnentries; return copyout(&args, data, sizeof(args)); @@ -104,16 +103,10 @@ umapfs_mount(mp, path, data, ndp, p) return (error); /* - * Update only does export updating. + * Update is not supported */ - if (mp->mnt_flag & MNT_UPDATE) { - amp = MOUNTTOUMAPMOUNT(mp); - if (args.umap_target == 0) - return (vfs_export(mp, &->umapm_export, - &args.umap_export)); - else - return (EOPNOTSUPP); - } + if (mp->mnt_flag & MNT_UPDATE) + return EOPNOTSUPP; /* * Find lower node @@ -334,9 +327,7 @@ struct vfsops umapfs_vfsops = { layerfs_init, NULL, layerfs_done, - NULL, NULL, /* vfs_mountroot */ - layerfs_checkexp, layerfs_snapshot, vfs_stdextattrctl, umapfs_vnodeopv_descs, Index: sys/nfs/files.nfs =================================================================== RCS file: /cvsroot/src/sys/nfs/files.nfs,v retrieving revision 1.5 diff -u -u -p -r1.5 files.nfs --- sys/nfs/files.nfs 26 Feb 2005 22:39:50 -0000 1.5 +++ sys/nfs/files.nfs 23 Sep 2005 10:00:15 -0000 @@ -22,6 +22,7 @@ file nfs/nfs_boot.c nfs file nfs/nfs_bootdhcp.c nfs & (nfs_boot_bootp | nfs_boot_dhcp) file nfs/nfs_bootparam.c nfs & nfs_boot_bootparam file nfs/nfs_bootstatic.c nfs & nfs_boot_bootstatic +file nfs/nfs_export.c nfsserver file nfs/nfs_kq.c nfs file nfs/nfs_node.c nfs file nfs/nfs_nqlease.c nfsserver | nfs Index: sys/nfs/nfs.h =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs.h,v retrieving revision 1.49 diff -u -u -p -r1.49 nfs.h --- sys/nfs/nfs.h 18 Sep 2005 23:44:54 -0000 1.49 +++ sys/nfs/nfs.h 23 Sep 2005 10:00:15 -0000 @@ -165,8 +165,24 @@ extern int nfs_niothreads; (time.tv_sec - (np)->n_mtime.tv_sec) / 10))) /* - * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs - * should ever try and use it. + * Export arguments for local filesystem mount calls. + * Keep in mind that changing this structure modifies nfssvc(2)'s ABI (see + * 'struct mountd_exports_list' below). + */ +struct export_args { + int ex_flags; /* export related flags */ + uid_t ex_root; /* mapping for root uid */ + struct uucred ex_anon; /* mapping for anonymous user */ + struct sockaddr *ex_addr; /* net address to which exported */ + int ex_addrlen; /* and the net address length */ + struct sockaddr *ex_mask; /* mask of valid bits in saddr */ + int ex_masklen; /* and the smask length */ + char *ex_indexfile; /* index file for WebNFS URLs */ +}; + +/* + * Structures for the nfssvc(2) syscall. Not that anyone but mountd, nfsd and + * mount_nfs should ever try and use it. */ struct nfsd_args { int sock; /* Socket to serve */ @@ -199,6 +215,12 @@ struct nfsd_cargs { NFSKERBKEY_T ncd_key; /* Session key */ }; +struct mountd_exports_list { + const char *mel_path; + size_t mel_nexports; + struct export_args *mel_exports; +}; + /* * Stats structure */ @@ -248,6 +270,7 @@ struct nfsstats { #define NFSSVC_GOTAUTH 0x040 #define NFSSVC_AUTHINFAIL 0x080 #define NFSSVC_MNTD 0x100 +#define NFSSVC_SETEXPORTSLIST 0x200 /* * fs.nfs sysctl(3) identifiers @@ -544,6 +567,17 @@ extern int nfs_numasync; ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0'))) #define HEXSTRTOI(p) \ ((HEXTOC(p[0]) << 4) + HEXTOC(p[1])) + +/* + * Structure holding information for a publicly exported filesystem + * (WebNFS). Currently the specs allow just for one such filesystem. + */ +struct nfs_public { + int np_valid; /* Do we hold valid information */ + fhandle_t np_handle; /* Filehandle for pub fs (internal) */ + struct mount *np_mount; /* Mountpoint of exported fs */ + char *np_index; /* Index file */ +}; #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ Index: sys/nfs/nfs_export.c =================================================================== RCS file: sys/nfs/nfs_export.c diff -N sys/nfs/nfs_export.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/nfs/nfs_export.c 23 Sep 2005 10:00:15 -0000 @@ -0,0 +1,723 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 1997, 1998, 2004, 2005 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * This code is derived from software contributed to The NetBSD Foundation + * by Julio M. Merino Vidal. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * 3. 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. + * + * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 + */ + +/* + * VFS exports list management. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include "opt_inet.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* XXX for AF_MAX */ + +#include + +#include + +#include +#include +#include +#include + +/* + * Network address lookup element. + */ +struct netcred { + struct radix_node netc_rnodes[2]; + int netc_refcnt; + int netc_exflags; + struct ucred netc_anon; +}; + +/* + * Network export information. + */ +struct netexport { + struct netcred ne_defexported; /* Default export */ + struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ +}; + +/* + * Structures to map between standard mount points to their corresponding + * network export information. + */ +struct mount_netexport_pair { + CIRCLEQ_ENTRY(mount_netexport_pair) mnp_entries; + const struct mount *mnp_mount; + struct netexport mnp_netexport; +}; +CIRCLEQ_HEAD(mount_netexport_map, mount_netexport_pair) + mount_netexport_map = CIRCLEQ_HEAD_INITIALIZER(mount_netexport_map); + +/* Malloc type used by the mount<->netexport map. */ +MALLOC_DEFINE(M_NFS_EXPORT, "nfs_export", "NFS export data"); + +/* Publicly exported file system. */ +struct nfs_public nfs_pub; + +/* + * Local prototypes. + */ +static int init_exports(struct mount *, struct mount_netexport_pair **); +static int hang_addrlist(struct mount *, struct netexport *, + const struct export_args *); +static int sacheck(struct sockaddr *); +static int free_netcred(struct radix_node *, void *); +static void clear_exports(struct mount *, struct netexport *); +static int export(struct mount *, struct netexport *, + const struct export_args *); +static int setpublicfs(struct mount *, struct netexport *, + const struct export_args *); +static struct netcred *export_lookup(struct mount *, struct netexport *, + struct mbuf *); + +/* + * PUBLIC INTERFACE + */ + +/* + * Declare and initialize the file system export hooks. + */ +static void nfs_export_unmount(struct mount *); + +struct vfs_hooks nfs_export_hooks = { + nfs_export_unmount +}; +VFS_HOOKS_ATTACH(nfs_export_hooks); + +/* + * VFS unmount hook for NFS exports. + * + * Releases NFS exports list resources if the given mount point has some. + * As allocation happens lazily, it may be that it doesn't has this + * information, although it theorically should. + */ +static void +nfs_export_unmount(struct mount *mp) +{ + boolean_t found; + struct mount_netexport_pair *mnp; + + KASSERT(mp != NULL); + + found = FALSE; + CIRCLEQ_FOREACH(mnp, &mount_netexport_map, mnp_entries) { + if (mnp->mnp_mount == mp) { + found = TRUE; + break; + } + } + + if (mp->mnt_op->vfs_vptofh == NULL || mp->mnt_op->vfs_fhtovp == NULL) + KASSERT(!found); + else if (found) { + if (mp->mnt_flag & MNT_EXPUBLIC) + setpublicfs(NULL, NULL, NULL); + + free(mnp, M_NFS_EXPORT); + } +} + +/* + * Atomically set the NFS exports list of the given file system, replacing + * it with a new list of entries. + * + * Returns zero on success or an appropriate error code otherwise. + * + * Helper function for the nfssvc(2) system call (NFSSVC_SETEXPORTSLIST + * command). + */ +int +mountd_set_exports_list(const struct mountd_exports_list *mel, struct proc *p) +{ + boolean_t found; + int error; +#ifdef notyet + /* XXX: See below to see the reason why this is disabled. */ + size_t i; +#endif + struct mount *mp; + struct mount_netexport_pair *mnp; + struct nameidata nd; + struct vnode *vp; + + if (suser(p->p_ucred, &p->p_acflag) != 0) + return EPERM; + + /* Lookup the file system path. */ + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, mel->mel_path, p); + error = namei(&nd); + if (error != 0) + return error; + vp = (struct vnode *)nd.ni_vp; + mp = (struct mount *)vp->v_mount; + + /* The selected file system may not support NFS exports, so ensure + * it does. */ + if (mp->mnt_op->vfs_vptofh == NULL && mp->mnt_op->vfs_fhtovp == NULL) { + error = EOPNOTSUPP; + goto out_locked; + } + KASSERT(mp->mnt_op->vfs_vptofh != NULL && + mp->mnt_op->vfs_fhtovp != NULL); + + /* Mark the file system busy. */ + error = vfs_busy(mp, LK_NOWAIT, NULL); + if (error != 0) + goto out_locked; + + found = FALSE; + CIRCLEQ_FOREACH(mnp, &mount_netexport_map, mnp_entries) { + if (mnp->mnp_mount == mp) { + found = TRUE; + break; + } + } + if (!found) { + error = init_exports(mp, &mnp); + if (error != 0) { + vfs_unbusy(mp); + goto out_locked; + } + } + + /* + * XXX: The part marked as 'notyet' works fine from the kernel's + * point of view, in the sense that it is able to atomically update + * the complete exports list for a file system. However, supporting + * this in mountd(8) requires a lot of work; so, for now, keep the + * old behavior of updating a single entry per call. + * + * When mountd(8) is fixed, just remove the second branch of this + * preprocessor conditional and enable the first one. + */ +#ifdef notyet + clear_exports(mp, &mnp->mnp_netexport); + for (i = 0; error == 0 && i < mel->mel_nexports; i++) + error = export(mp, &mnp->mnp_netexport, &mel->mel_exports[i]); +#else + if (mel->mel_nexports == 0) + clear_exports(mp, &mnp->mnp_netexport); + else if (mel->mel_nexports == 1) + error = export(mp, &mnp->mnp_netexport, &mel->mel_exports[0]); + else { + printf("mountd_set_exports_list: Cannot set more than one " + "entry at once (unimplemented)\n"); + error = EOPNOTSUPP; + } +#endif + + vfs_unbusy(mp); + +out_locked: + vput(vp); + + return 0; +} + +/* + * Check if the file system specified by the 'mp' mount structure is + * exported to a client with 'anon' anonymous credentials. The 'mb' + * argument is an mbuf containing the network address of the client. + * The return parameters for the export flags for the client are returned + * in the address specified by 'wh'. + * + * This function is used exclusively by the NFS server. It is generally + * invoked before VFS_FHTOVP to validate that client has access to the + * file system. + */ +int +nfs_check_export(struct mount *mp, struct mbuf *mb, int *wh, + struct ucred **anon) +{ + boolean_t found; + struct mount_netexport_pair *mnp; + struct netcred *np; + + found = FALSE; + CIRCLEQ_FOREACH(mnp, &mount_netexport_map, mnp_entries) { + if (mnp->mnp_mount == mp) { + found = TRUE; + break; + } + } + if (!found) + return EACCES; + + np = export_lookup(mp, &mnp->mnp_netexport, mb); + if (np != NULL) { + *wh = np->netc_exflags; + *anon = &np->netc_anon; + } + + return np == NULL ? EACCES : 0; +} + +/* + * INTERNAL FUNCTIONS + */ + +/* + * Initializes NFS exports for the file system given in 'mp' if it supports + * file handles; this is determined by checking whether mp's vfs_vptofh and + * vfs_fhtovp operations are NULL or not. + * + * If successful, returns 0 and sets *mnpp to the address of the new + * mount_netexport_pair item; otherwise returns and appropriate error code + * and *mnpp remains unmodified. + */ +static int +init_exports(struct mount *mp, struct mount_netexport_pair **mnpp) +{ + int error; + struct export_args ea; + struct mount_netexport_pair *mnp; + + KASSERT(mp != NULL); + KASSERT(mp->mnt_op->vfs_vptofh != NULL && + mp->mnt_op->vfs_fhtovp != NULL); + +#ifdef DIAGNOSTIC + /* Ensure that we do not already have this mount point. */ + CIRCLEQ_FOREACH(mnp, &mount_netexport_map, mnp_entries) { + if (mnp->mnp_mount == mp) + KASSERT(0); + } +#endif + + mnp = (struct mount_netexport_pair *) + malloc(sizeof(struct mount_netexport_pair), M_NFS_EXPORT, M_WAITOK); + KASSERT(mnp != NULL); + mnp->mnp_mount = mp; + memset(&mnp->mnp_netexport, 0, sizeof(mnp->mnp_netexport)); + + /* Set the default export entry. Handled internally by export upon + * first call. */ + memset(&ea, 0, sizeof(ea)); + ea.ex_root = -2; + if (mp->mnt_flag & MNT_RDONLY) + ea.ex_flags |= MNT_EXRDONLY; + error = export(mp, &mnp->mnp_netexport, &ea); + if (error != 0) + free(mnp, M_NFS_EXPORT); + else { + CIRCLEQ_INSERT_TAIL(&mount_netexport_map, mnp, mnp_entries); + *mnpp = mnp; + } + + return error; +} + +/* + * Build hash lists of net addresses and hang them off the mount point. + * Called by export() to set up a new entry in the lists of export + * addresses. + */ +static int +hang_addrlist(struct mount *mp, struct netexport *nep, + const struct export_args *argp) +{ + int error, i; + struct netcred *np, *enp; + struct radix_node_head *rnh; + struct sockaddr *saddr, *smask; + struct domain *dom; + + smask = NULL; + + if (argp->ex_addrlen == 0) { + if (mp->mnt_flag & MNT_DEFEXPORTED) + return EPERM; + np = &nep->ne_defexported; + np->netc_exflags = argp->ex_flags; + crcvt(&np->netc_anon, &argp->ex_anon); + np->netc_anon.cr_ref = 1; + mp->mnt_flag |= MNT_DEFEXPORTED; + return 0; + } + + if (argp->ex_addrlen > MLEN || argp->ex_masklen > MLEN) + return EINVAL; + + i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; + np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK); + memset((caddr_t)np, 0, i); + saddr = (struct sockaddr *)(np + 1); + error = copyin(argp->ex_addr, (caddr_t)saddr, argp->ex_addrlen); + if (error) + goto out; + if (saddr->sa_len > argp->ex_addrlen) + saddr->sa_len = argp->ex_addrlen; + if (sacheck(saddr) == -1) + return EINVAL; + if (argp->ex_masklen) { + smask = (struct sockaddr *)((caddr_t)saddr + argp->ex_addrlen); + error = copyin(argp->ex_mask, (caddr_t)smask, argp->ex_masklen); + if (error) + goto out; + if (smask->sa_len > argp->ex_masklen) + smask->sa_len = argp->ex_masklen; + if (smask->sa_family != saddr->sa_family) + return EINVAL; + if (sacheck(smask) == -1) + return EINVAL; + } + i = saddr->sa_family; + if ((rnh = nep->ne_rtable[i]) == 0) { + /* + * Seems silly to initialize every AF when most are not + * used, do so on demand here + */ + DOMAIN_FOREACH(dom) { + if (dom->dom_family == i && dom->dom_rtattach) { + dom->dom_rtattach((void **)&nep->ne_rtable[i], + dom->dom_rtoffset); + break; + } + } + if ((rnh = nep->ne_rtable[i]) == 0) { + error = ENOBUFS; + goto out; + } + } + + enp = (struct netcred *)(*rnh->rnh_addaddr)(saddr, smask, rnh, + np->netc_rnodes); + if (enp != np) { + if (enp == NULL) { + enp = (struct netcred *)(*rnh->rnh_lookup)(saddr, + smask, rnh); + if (enp == NULL) { + error = EPERM; + goto out; + } + } else + enp->netc_refcnt++; + + goto check; + } else + enp->netc_refcnt = 1; + + np->netc_exflags = argp->ex_flags; + crcvt(&np->netc_anon, &argp->ex_anon); + np->netc_anon.cr_ref = 1; + return 0; +check: + if (enp->netc_exflags != argp->ex_flags || + crcmp(&enp->netc_anon, &argp->ex_anon) != 0) + error = EPERM; + else + error = 0; +out: + free(np, M_NETADDR); + return error; +} + +/* + * Ensure that the address stored in 'sa' is valid. + * Returns zero on success, otherwise -1. + */ +static int +sacheck(struct sockaddr *sa) +{ + + switch (sa->sa_family) { +#ifdef INET + case AF_INET: { + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + char *p = (char *)sin->sin_zero; + size_t i; + + if (sin->sin_len != sizeof(*sin)) + return -1; + if (sin->sin_port != 0) + return -1; + for (i = 0; i < sizeof(sin->sin_zero); i++) + if (*p++ != '\0') + return -1; + return 0; + } +#endif +#ifdef INET6 + case AF_INET6: { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + + if (sin6->sin6_len != sizeof(*sin6)) + return -1; + if (sin6->sin6_port != 0) + return -1; + return 0; + } +#endif + default: + return -1; + } +} + +/* + * Free the netcred object pointed to by the 'rn' radix node. + * 'w' holds a pointer to the radix tree head. + */ +static int +free_netcred(struct radix_node *rn, void *w) +{ + struct radix_node_head *rnh = (struct radix_node_head *)w; + struct netcred *np = (struct netcred *)(void *)rn; + + (*rnh->rnh_deladdr)(rn->rn_key, rn->rn_mask, rnh); + if (--(np->netc_refcnt) <= 0) + free(np, M_NETADDR); + return 0; +} + +/* + * Clears the exports list for a given file system. + */ +static void +clear_exports(struct mount *mp, struct netexport *nep) +{ + int i; + struct radix_node_head *rnh; + + if (mp->mnt_flag & MNT_EXPUBLIC) { + setpublicfs(NULL, NULL, NULL); + mp->mnt_flag &= ~MNT_EXPUBLIC; + } + + for (i = 0; i <= AF_MAX; i++) { + if ((rnh = nep->ne_rtable[i]) != NULL) { + (*rnh->rnh_walktree)(rnh, free_netcred, rnh); + free((caddr_t)rnh, M_RTABLE); + nep->ne_rtable[i] = 0; + } + } + + mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); +} + +/* + * Add a new export entry (described by an export_args structure) to the + * given file system. + */ +static int +export(struct mount *mp, struct netexport *nep, const struct export_args *argp) +{ + int error; + + if (argp->ex_flags & MNT_EXPORTED) { + if (argp->ex_flags & MNT_EXPUBLIC) { + if ((error = setpublicfs(mp, nep, argp)) != 0) + return error; + mp->mnt_flag |= MNT_EXPUBLIC; + } + if ((error = hang_addrlist(mp, nep, argp)) != 0) + return error; + mp->mnt_flag |= MNT_EXPORTED; + } + return 0; +} + +/* + * Set the publicly exported filesystem (WebNFS). Currently, only + * one public filesystem is possible in the spec (RFC 2054 and 2055) + */ +static int +setpublicfs(struct mount *mp, struct netexport *nep, + const struct export_args *argp) +{ + char *cp; + int error; + struct vnode *rvp; + + /* + * mp == NULL -> invalidate the current info, the FS is + * no longer exported. May be called from either export + * or unmount, so check if it hasn't already been done. + */ + if (mp == NULL) { + if (nfs_pub.np_valid) { + nfs_pub.np_valid = 0; + if (nfs_pub.np_index != NULL) { + FREE(nfs_pub.np_index, M_TEMP); + nfs_pub.np_index = NULL; + } + } + return 0; + } + + /* + * Only one allowed at a time. + */ + if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount) + return EBUSY; + + /* + * Get real filehandle for root of exported FS. + */ + memset((caddr_t)&nfs_pub.np_handle, 0, sizeof(nfs_pub.np_handle)); + nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsidx; + + if ((error = VFS_ROOT(mp, &rvp))) + return error; + + if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid))) + return error; + + vput(rvp); + + /* + * If an indexfile was specified, pull it in. + */ + if (argp->ex_indexfile != NULL) { + MALLOC(nfs_pub.np_index, char *, MAXNAMLEN + 1, M_TEMP, + M_WAITOK); + error = copyinstr(argp->ex_indexfile, nfs_pub.np_index, + MAXNAMLEN, (size_t *)0); + if (!error) { + /* + * Check for illegal filenames. + */ + for (cp = nfs_pub.np_index; *cp; cp++) { + if (*cp == '/') { + error = EINVAL; + break; + } + } + } + if (error) { + FREE(nfs_pub.np_index, M_TEMP); + return error; + } + } + + nfs_pub.np_mount = mp; + nfs_pub.np_valid = 1; + return 0; +} + +/* + * Lookup an export entry in the exports list that matches the address + * stored in 'nam'. If no entry is found, the default one is used instead + * (if available). + */ +static struct netcred * +export_lookup(struct mount *mp, struct netexport *nep, struct mbuf *nam) +{ + struct netcred *np; + struct radix_node_head *rnh; + struct sockaddr *saddr; + + np = NULL; + if (mp->mnt_flag & MNT_EXPORTED) { + /* + * Lookup in the export list first. + */ + if (nam != NULL) { + saddr = mtod(nam, struct sockaddr *); + rnh = nep->ne_rtable[saddr->sa_family]; + if (rnh != NULL) { + np = (struct netcred *) + (*rnh->rnh_matchaddr)((caddr_t)saddr, + rnh); + if (np && np->netc_rnodes->rn_flags & RNF_ROOT) + np = NULL; + } + } + /* + * If no address match, use the default if it exists. + */ + if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED) + np = &nep->ne_defexported; + } + return np; +} Index: sys/nfs/nfs_subs.c =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs_subs.c,v retrieving revision 1.152 diff -u -u -p -r1.152 nfs_subs.c --- sys/nfs/nfs_subs.c 19 Sep 2005 00:53:55 -0000 1.152 +++ sys/nfs/nfs_subs.c 23 Sep 2005 10:00:18 -0000 @@ -2073,6 +2073,7 @@ nfs_cookieheuristic(vp, flagp, p, cred) } #endif /* NFS */ +#ifdef NFSSERVER /* * Set up nameidata for a lookup() call and do it. * @@ -2324,6 +2325,7 @@ out: PNBUF_PUT(cnp->cn_pnbuf); return (error); } +#endif /* NFSSERVER */ /* * A fiddled version of m_adj() that ensures null fill to a 32-bit @@ -2510,6 +2512,7 @@ nfsm_srvfattr(nfsd, vap, fp) } } +#ifdef NFSSERVER /* * nfsrv_fhtovp() - convert a fh to a vnode ptr (optionally locked) * - look up fsid in mount list (if not found ret error) @@ -2545,7 +2548,7 @@ nfsrv_fhtovp(fhp, lockflag, vpp, cred, s mp = vfs_getvfs(&fhp->fh_fsid); if (!mp) return (ESTALE); - error = VFS_CHECKEXP(mp, nam, &exflags, &credanon); + error = nfs_check_export(mp, nam, &exflags, &credanon); if (error) return (error); error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp); @@ -2611,6 +2614,7 @@ nfs_ispublicfh(fhp) return (FALSE); return (TRUE); } +#endif /* NFSSERVER */ /* * This function compares two net addresses by family and returns TRUE Index: sys/nfs/nfs_syscalls.c =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs_syscalls.c,v retrieving revision 1.81 diff -u -u -p -r1.81 nfs_syscalls.c --- sys/nfs/nfs_syscalls.c 11 Sep 2005 20:19:31 -0000 1.81 +++ sys/nfs/nfs_syscalls.c 23 Sep 2005 10:00:18 -0000 @@ -249,6 +249,31 @@ sys_nfssvc(l, v, retval) error = nfssvc_addsock(fp, nam); FILE_UNUSE(fp, NULL); #endif /* !NFSSERVER */ + } else if (SCARG(uap, flag) & NFSSVC_SETEXPORTSLIST) { +#ifndef NFSSERVER + error = ENOSYS; +#else + struct export_args *args; + struct mountd_exports_list mel; + + error = copyin(SCARG(uap, argp), &mel, sizeof(mel)); + if (error != 0) + return error; + + args = (struct export_args *)malloc(mel.mel_nexports * + sizeof(struct export_args), M_TEMP, M_WAITOK); + error = copyin(mel.mel_exports, args, mel.mel_nexports * + sizeof(struct export_args)); + if (error != 0) { + free(args, M_TEMP); + return error; + } + mel.mel_exports = args; + + error = mountd_set_exports_list(&mel, p); + + free(args, M_TEMP); +#endif /* !NFSSERVER */ } else { #ifndef NFSSERVER error = ENOSYS; Index: sys/nfs/nfs_var.h =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs_var.h,v retrieving revision 1.51 diff -u -u -p -r1.51 nfs_var.h --- sys/nfs/nfs_var.h 7 Jul 2005 02:05:03 -0000 1.51 +++ sys/nfs/nfs_var.h 23 Sep 2005 10:00:18 -0000 @@ -288,8 +288,6 @@ void nfsm_srvfattr __P((struct nfsrv_des struct nfs_fattr *)); int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *, struct nfssvc_sock *, struct mbuf *, int *, int, int)); -int nfsrv_setpublicfs __P((struct mount *, struct netexport *, - struct export_args *)); int nfs_ispublicfh __P((fhandle_t *)); int netaddr_match __P((int, union nethostaddr *, struct mbuf *)); @@ -332,4 +330,9 @@ int nfs_getnickauth __P((struct nfsmount char *, int)); int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, NFSKERBKEY_T, struct mbuf **, char **, struct mbuf *)); + +/* nfs_export.c */ +extern struct nfs_public nfs_pub; +int mountd_set_exports_list(const struct mountd_exports_list *, struct proc *); +int nfs_check_export(struct mount *, struct mbuf *, int *, struct ucred **); #endif /* _KERNEL */ Index: sys/nfs/nfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/nfs/nfs_vfsops.c,v retrieving revision 1.149 diff -u -u -p -r1.149 nfs_vfsops.c --- sys/nfs/nfs_vfsops.c 19 Sep 2005 00:49:52 -0000 1.149 +++ sys/nfs/nfs_vfsops.c 23 Sep 2005 10:00:18 -0000 @@ -109,9 +109,7 @@ struct vfsops nfs_vfsops = { nfs_vfs_init, nfs_vfs_reinit, nfs_vfs_done, - NULL, nfs_mountroot, - nfs_checkexp, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, nfs_vnodeopv_descs, @@ -1032,18 +1030,6 @@ nfs_fhtovp(mp, fhp, vpp) return (EINVAL); } -/* ARGSUSED */ -int -nfs_checkexp(mp, nam, exflagsp, credanonp) - struct mount *mp; - struct mbuf *nam; - int *exflagsp; - struct ucred **credanonp; -{ - - return (EINVAL); -} - /* * Vnode pointer to File handle, should never happen either */ Index: sys/nfs/nfsmount.h =================================================================== RCS file: /cvsroot/src/sys/nfs/nfsmount.h,v retrieving revision 1.34 diff -u -u -p -r1.34 nfsmount.h --- sys/nfs/nfsmount.h 18 Sep 2005 23:44:54 -0000 1.34 +++ sys/nfs/nfsmount.h 23 Sep 2005 10:00:18 -0000 @@ -195,8 +195,6 @@ int nfs_sync __P((struct mount *mp, int struct proc *p)); int nfs_vget __P((struct mount *, ino_t, struct vnode **)); int nfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp)); -int nfs_checkexp __P((struct mount *mp, struct mbuf *nam, int *exflagsp, - struct ucred **credanonp)); int nfs_vptofh __P((struct vnode *vp, struct fid *fhp)); int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *, struct proc *)); Index: sys/sys/fstypes.h =================================================================== RCS file: /cvsroot/src/sys/sys/fstypes.h,v retrieving revision 1.5 diff -u -u -p -r1.5 fstypes.h --- sys/sys/fstypes.h 23 Jun 2005 01:59:31 -0000 1.5 +++ sys/sys/fstypes.h 23 Sep 2005 10:00:18 -0000 @@ -70,6 +70,7 @@ typedef struct fhandle fhandle_t; * one of the __MNT_UNUSED flags. */ +#define __MNT_UNUSED3 0x00020000 #define __MNT_UNUSED4 0x00200000 #define __MNT_UNUSED5 0x01000000 #define __MNT_UNUSED6 0x02000000 @@ -170,14 +171,12 @@ typedef struct fhandle fhandle_t; * External filesystem control flags. */ #define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ -#define MNT_DELEXPORT 0x00020000 /* delete export host lists */ #define MNT_RELOAD 0x00040000 /* reload filesystem data */ #define MNT_FORCE 0x00080000 /* force unmount or readonly change */ #define MNT_GETARGS 0x00400000 /* retrieve file system specific args */ #define __MNT_EXTERNAL_FLAGS \ { MNT_UPDATE, 1, "being updated" }, \ - { MNT_DELEXPORT, 1, "delete export list" }, \ { MNT_RELOAD, 1, "reload filesystem data" }, \ { MNT_FORCE, 1, "force unmount or readonly change" }, \ { MNT_GETARGS, 1, "retrieve mount arguments" }, Index: sys/sys/mount.h =================================================================== RCS file: /cvsroot/src/sys/sys/mount.h,v retrieving revision 1.131 diff -u -u -p -r1.131 mount.h --- sys/sys/mount.h 13 Sep 2005 01:42:51 -0000 1.131 +++ sys/sys/mount.h 23 Sep 2005 10:00:18 -0000 @@ -197,10 +197,7 @@ struct vfsops { void (*vfs_init) (void); void (*vfs_reinit) (void); void (*vfs_done) (void); - int *vfs_wassysctl; /* @@@ no longer useful */ int (*vfs_mountroot)(void); - int (*vfs_checkexp) (struct mount *, struct mbuf *, int *, - struct ucred **); int (*vfs_snapshot) (struct mount *, struct vnode *, struct timespec *); int (*vfs_extattrctl) (struct mount *, int, @@ -223,41 +220,34 @@ struct vfsops { #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) #define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP) -#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \ - (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED) #define VFS_VPTOFH(VP, FIDP) (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) #define VFS_SNAPSHOT(MP, VP, TS) (*(MP)->mnt_op->vfs_snapshot)(MP, VP, TS) #define VFS_EXTATTRCTL(MP, C, VP, AS, AN, P) \ (*(MP)->mnt_op->vfs_extattrctl)(MP, C, VP, AS, AN, P) -#endif /* _KERNEL */ - -#ifdef _KERNEL -#include -#include /* XXX for AF_MAX */ -/* - * Network address lookup element - */ -struct netcred { - struct radix_node netc_rnodes[2]; - int netc_refcnt; - int netc_exflags; - struct ucred netc_anon; +struct vfs_hooks { + void (*vh_unmount)(struct mount *); }; +#define VFS_HOOKS_ATTACH(hooks) __link_set_add_rodata(vfs_hooks, hooks) + +void vfs_hooks_unmount(struct mount *); -/* - * Network export information - */ -struct netexport { - struct netcred ne_defexported; /* Default export */ - struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */ -}; #endif /* _KERNEL */ /* * Export arguments for local filesystem mount calls. + * + * This structure is deprecated and is only provided for compatibility + * reasons with old binary utilities; several file systems expose an + * instance of this structure in their mount arguments structure, thus + * needing a padding in place of the old values. This definition cannot + * change in the future due to this reason. + * XXX: We could drop this structure if we are able to version all other + * structures used as mount arguments. + * + * The current export_args structure can be found in nfs/nfs.h. */ -struct export_args { +struct compat_export_args { int ex_flags; /* export related flags */ uid_t ex_root; /* mapping for root uid */ struct uucred ex_anon; /* mapping for anonymous user */ @@ -268,17 +258,6 @@ struct export_args { char *ex_indexfile; /* index file for WebNFS URLs */ }; -/* - * Structure holding information for a publicly exported filesystem - * (WebNFS). Currently the specs allow just for one such filesystem. - */ -struct nfs_public { - int np_valid; /* Do we hold valid information */ - fhandle_t np_handle; /* Filehandle for pub fs (internal) */ - struct mount *np_mount; /* Mountpoint of exported fs */ - char *np_index; /* Index file */ -}; - #ifdef _KERNEL #include MALLOC_DECLARE(M_MOUNT); @@ -287,13 +266,6 @@ MALLOC_DECLARE(M_MOUNT); * exported VFS interface (see vfssubr(9)) */ struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */ -int vfs_export /* process mount export info */ - (struct mount *, struct netexport *, struct export_args *); -#define vfs_showexport(a, b, c) (void)memset((b), 0, sizeof(*(b))) -struct netcred *vfs_export_lookup /* lookup host in fs export list */ - (struct mount *, struct netexport *, struct mbuf *); -int vfs_setpublicfs /* set publicly exported fs */ - (struct mount *, struct netexport *, struct export_args *); int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */ int vfs_mountroot(void); void vfs_shutdown(void); /* unmount and sync file systems */ @@ -312,7 +284,6 @@ int vfs_stdextattrctl(struct mount *, in extern CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */ extern struct vfsops *vfssw[]; /* filesystem type table */ extern int nvfssw; -extern struct nfs_public nfs_pub; extern struct simplelock mountlist_slock; extern struct simplelock spechash_slock; long makefstype(const char *); Index: sys/ufs/ext2fs/ext2fs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v retrieving revision 1.90 diff -u -u -p -r1.90 ext2fs_vfsops.c --- sys/ufs/ext2fs/ext2fs_vfsops.c 12 Sep 2005 20:23:03 -0000 1.90 +++ sys/ufs/ext2fs/ext2fs_vfsops.c 23 Sep 2005 10:00:19 -0000 @@ -135,9 +135,7 @@ struct vfsops ext2fs_vfsops = { ext2fs_init, ext2fs_reinit, ext2fs_done, - NULL, ext2fs_mountroot, - ufs_check_export, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, ext2fs_vnodeopv_descs, @@ -263,7 +261,6 @@ ext2fs_mount(struct mount *mp, const cha if (ump == NULL) return EIO; args.fspec = NULL; - vfs_showexport(mp, &args.export, &ump->um_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof (struct ufs_args)); @@ -413,12 +410,8 @@ ext2fs_mount(struct mount *mp, const cha fs->e2fs.e2fs_state = E2FS_ERRORS; fs->e2fs_fmod = 1; } - if (args.fspec == 0) { - /* - * Process export requests. - */ - return (vfs_export(mp, &ump->um_export, &args.export)); - } + if (args.fspec == NULL) + return EINVAL; } error = set_statvfs_info(path, UIO_USERSPACE, args.fspec, Index: sys/ufs/ffs/ffs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vfsops.c,v retrieving revision 1.173 diff -u -u -p -r1.173 ffs_vfsops.c --- sys/ufs/ffs/ffs_vfsops.c 22 Sep 2005 14:04:29 -0000 1.173 +++ sys/ufs/ffs/ffs_vfsops.c 23 Sep 2005 10:00:19 -0000 @@ -104,9 +104,7 @@ struct vfsops ffs_vfsops = { ffs_init, ffs_reinit, ffs_done, - NULL, ffs_mountroot, - ufs_check_export, ffs_snapshot, ffs_extattrctl, ffs_vnodeopv_descs, @@ -190,7 +188,6 @@ ffs_mount(struct mount *mp, const char * if (ump == NULL) return EIO; args.fspec = NULL; - vfs_showexport(mp, &args.export, &ump->um_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof (struct ufs_args)); @@ -414,12 +411,8 @@ ffs_mount(struct mount *mp, const char * if (fs->fs_snapinum[0] != 0) ffs_snapshot_mount(mp); } - if (args.fspec == 0) { - /* - * Process export requests. - */ - return (vfs_export(mp, &ump->um_export, &args.export)); - } + if (args.fspec == NULL) + return EINVAL; if ((mp->mnt_flag & (MNT_SOFTDEP | MNT_ASYNC)) == (MNT_SOFTDEP | MNT_ASYNC)) { printf("%s fs uses soft updates, ignoring async mode\n", Index: sys/ufs/lfs/lfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/lfs/lfs_vfsops.c,v retrieving revision 1.186 diff -u -u -p -r1.186 lfs_vfsops.c --- sys/ufs/lfs/lfs_vfsops.c 23 Aug 2005 08:05:13 -0000 1.186 +++ sys/ufs/lfs/lfs_vfsops.c 23 Sep 2005 10:00:20 -0000 @@ -153,9 +153,7 @@ struct vfsops lfs_vfsops = { lfs_init, lfs_reinit, lfs_done, - NULL, lfs_mountroot, - ufs_check_export, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, lfs_vnodeopv_descs, @@ -357,7 +355,6 @@ lfs_mount(struct mount *mp, const char * if (ump == NULL) return EIO; args.fspec = NULL; - vfs_showexport(mp, &args.export, &ump->um_export); return copyout(&args, data, sizeof(args)); } error = copyin(data, &args, sizeof (struct ufs_args)); @@ -479,12 +476,8 @@ lfs_mount(struct mount *mp, const char * */ fs->lfs_ronly = 0; } - if (args.fspec == 0) { - /* - * Process export requests. - */ - return (vfs_export(mp, &ump->um_export, &args.export)); - } + if (args.fspec == NULL) + return EINVAL; } error = set_statvfs_info(path, UIO_USERSPACE, args.fspec, Index: sys/ufs/mfs/mfs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/mfs/mfs_vfsops.c,v retrieving revision 1.68 diff -u -u -p -r1.68 mfs_vfsops.c --- sys/ufs/mfs/mfs_vfsops.c 30 Aug 2005 22:01:12 -0000 1.68 +++ sys/ufs/mfs/mfs_vfsops.c 23 Sep 2005 10:00:20 -0000 @@ -100,8 +100,6 @@ struct vfsops mfs_vfsops = { mfs_reinit, mfs_done, NULL, - NULL, - ufs_check_export, (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp, vfs_stdextattrctl, mfs_vnodeopv_descs, @@ -268,7 +266,6 @@ mfs_mount(struct mount *mp, const char * return EIO; args.fspec = NULL; - vfs_showexport(mp, &args.export, &ump->um_export); args.base = mfsp->mfs_baseoff; args.size = mfsp->mfs_size; return copyout(&args, data, sizeof(args)); @@ -305,8 +302,8 @@ mfs_mount(struct mount *mp, const char * } if (fs->fs_ronly && (mp->mnt_iflag & IMNT_WANTRDWR)) fs->fs_ronly = 0; - if (args.fspec == 0) - return (vfs_export(mp, &ump->um_export, &args.export)); + if (args.fspec == NULL) + return EINVAL; return (0); } error = getnewvnode(VT_MFS, (struct mount *)0, mfs_vnodeop_p, &devvp); Index: sys/ufs/ufs/ufs_extern.h =================================================================== RCS file: /cvsroot/src/sys/ufs/ufs/ufs_extern.h,v retrieving revision 1.45 diff -u -u -p -r1.45 ufs_extern.h --- sys/ufs/ufs/ufs_extern.h 23 Jul 2005 12:18:41 -0000 1.45 +++ sys/ufs/ufs/ufs_extern.h 23 Sep 2005 10:00:20 -0000 @@ -158,7 +158,6 @@ int ufs_start(struct mount *, int, struc int ufs_root(struct mount *, struct vnode **); int ufs_quotactl(struct mount *, int, uid_t, void *, struct proc *); int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **); -int ufs_check_export(struct mount *, struct mbuf *, int *, struct ucred **); /* ufs_vnops.c */ void ufs_vinit(struct mount *, int (**)(void *), Index: sys/ufs/ufs/ufs_vfsops.c =================================================================== RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vfsops.c,v retrieving revision 1.24 diff -u -u -p -r1.24 ufs_vfsops.c --- sys/ufs/ufs/ufs_vfsops.c 10 Jul 2005 01:08:52 -0000 1.24 +++ sys/ufs/ufs/ufs_vfsops.c 23 Sep 2005 10:00:20 -0000 @@ -164,29 +164,6 @@ ufs_quotactl(struct mount *mp, int cmds, } /* - * Verify a remote client has export rights and return these rights via. - * exflagsp and credanonp. - */ -int -ufs_check_export(struct mount *mp, struct mbuf *nam, int *exflagsp, - struct ucred **credanonp) -{ - struct netcred *np; - struct ufsmount *ump = VFSTOUFS(mp); - - /* - * Get the export permission structure for this tuple. - */ - np = vfs_export_lookup(mp, &ump->um_export, nam); - if (np == NULL) - return (EACCES); - - *exflagsp = np->netc_exflags; - *credanonp = &np->netc_anon; - return (0); -} - -/* * This is the generic part of fhtovp called after the underlying * filesystem has validated the file handle. */ Index: sys/ufs/ufs/ufsmount.h =================================================================== RCS file: /cvsroot/src/sys/ufs/ufs/ufsmount.h,v retrieving revision 1.19 diff -u -u -p -r1.19 ufsmount.h --- sys/ufs/ufs/ufsmount.h 28 Aug 2005 19:37:59 -0000 1.19 +++ sys/ufs/ufs/ufsmount.h 23 Sep 2005 10:00:20 -0000 @@ -39,7 +39,6 @@ */ struct ufs_args { char *fspec; /* block special device to mount */ - struct export_args export; /* network export information */ }; /* @@ -47,7 +46,7 @@ struct ufs_args { */ struct mfs_args { char *fspec; /* name to export for statfs */ - struct export_args export; /* if exported MFSes are supported */ + struct compat_export_args _pad1; /* compat with old userland tools */ caddr_t base; /* base of file system in memory */ u_long size; /* size of file system */ }; @@ -67,7 +66,6 @@ struct timeval; struct ucred; struct uio; struct vnode; -struct netexport; /* This structure describes the UFS specific mount structure data. */ struct ufsmount { @@ -98,7 +96,6 @@ struct ufsmount { time_t um_btime[MAXQUOTAS]; /* block quota time limit */ time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ char um_qflags[MAXQUOTAS]; /* quota specific flags */ - struct netexport um_export; /* export information */ void *um_oldfscompat; /* save 4.2 rotbl */ TAILQ_HEAD(inodelst, inode) um_snapshots; /* list of active snapshots */ daddr_t *um_snapblklist; /* snapshot block hints list */ Index: sbin/fsck_ext2fs/main.c =================================================================== RCS file: /cvsroot/src/sbin/fsck_ext2fs/main.c,v retrieving revision 1.22 diff -u -u -p -r1.22 main.c --- sbin/fsck_ext2fs/main.c 19 Aug 2005 02:07:18 -0000 1.22 +++ sbin/fsck_ext2fs/main.c 23 Sep 2005 10:00:20 -0000 @@ -327,8 +327,6 @@ checkfilesys(const char *filesys, char * if (flags & MNT_RDONLY) { args.fspec = 0; - args.export.ex_flags = 0; - args.export.ex_root = 0; flags |= MNT_UPDATE | MNT_RELOAD; ret = mount(MOUNT_EXT2FS, "/", flags, &args); if (ret == 0) Index: sbin/fsck_ffs/main.c =================================================================== RCS file: /cvsroot/src/sbin/fsck_ffs/main.c,v retrieving revision 1.59 diff -u -u -p -r1.59 main.c --- sbin/fsck_ffs/main.c 19 Aug 2005 02:07:19 -0000 1.59 +++ sbin/fsck_ffs/main.c 23 Sep 2005 10:00:20 -0000 @@ -422,8 +422,6 @@ checkfilesys(const char *filesys, char * if (flags & MNT_RDONLY) { args.fspec = 0; - args.export.ex_flags = 0; - args.export.ex_root = 0; flags |= MNT_UPDATE | MNT_RELOAD; ret = mount(MOUNT_FFS, "/", flags, &args); if (ret == 0) Index: sbin/fsck_lfs/main.c =================================================================== RCS file: /cvsroot/src/sbin/fsck_lfs/main.c,v retrieving revision 1.26 diff -u -u -p -r1.26 main.c --- sbin/fsck_lfs/main.c 19 Aug 2005 02:07:19 -0000 1.26 +++ sbin/fsck_lfs/main.c 23 Sep 2005 10:00:21 -0000 @@ -286,8 +286,6 @@ checkfilesys(const char *filesys, char * if (flags & MNT_RDONLY) { args.fspec = 0; - args.export.ex_flags = 0; - args.export.ex_root = 0; flags |= MNT_UPDATE | MNT_RELOAD; ret = mount(MOUNT_LFS, "/", flags, &args); if (ret == 0) Index: sbin/mount_ados/mount_ados.c =================================================================== RCS file: /cvsroot/src/sbin/mount_ados/mount_ados.c,v retrieving revision 1.19 diff -u -u -p -r1.19 mount_ados.c --- sbin/mount_ados/mount_ados.c 5 Feb 2005 14:47:18 -0000 1.19 +++ sbin/mount_ados/mount_ados.c 23 Sep 2005 10:00:21 -0000 @@ -133,11 +133,6 @@ mount_ados(int argc, char **argv) } args.fspec = dev; - args.export.ex_root = -2; /* unchecked anyway on DOS fs */ - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; if (!set_gid || !set_uid || !set_mask) { if (stat(dir, &sb) == -1) err(1, "stat %s", dir); @@ -157,7 +152,6 @@ mount_ados(int argc, char **argv) err(1, "%s on %s", dev, dir); mntflags |= MNT_RDONLY; - args.export.ex_flags = MNT_EXRDONLY; if (mount(MOUNT_ADOSFS, dir, mntflags, &args) == -1) err(1, "%s on %s", dev, dir); Index: sbin/mount_cd9660/mount_cd9660.c =================================================================== RCS file: /cvsroot/src/sbin/mount_cd9660/mount_cd9660.c,v retrieving revision 1.20 diff -u -u -p -r1.20 mount_cd9660.c --- sbin/mount_cd9660/mount_cd9660.c 5 Feb 2005 14:49:36 -0000 1.20 +++ sbin/mount_cd9660/mount_cd9660.c 23 Sep 2005 10:00:21 -0000 @@ -156,9 +156,7 @@ mount_cd9660(int argc, char **argv) * ISO 9660 filesystems are not writable. */ mntflags |= MNT_RDONLY; - args.export.ex_flags = MNT_EXRDONLY; args.fspec = dev; - args.export.ex_root = DEFAULT_ROOTUID; args.flags = opts; if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) Index: sbin/mount_ext2fs/mount_ext2fs.c =================================================================== RCS file: /cvsroot/src/sbin/mount_ext2fs/mount_ext2fs.c,v retrieving revision 1.13 diff -u -u -p -r1.13 mount_ext2fs.c --- sbin/mount_ext2fs/mount_ext2fs.c 5 Feb 2005 14:51:16 -0000 1.13 +++ sbin/mount_ext2fs/mount_ext2fs.c 23 Sep 2005 10:00:21 -0000 @@ -120,13 +120,6 @@ mount_ext2fs(int argc, char *argv[]) warnx("using \"%s\" instead.", fs_name); } -#define DEFAULT_ROOTUID -2 - args.export.ex_root = DEFAULT_ROOTUID; - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; - if (mount(MOUNT_EXT2FS, fs_name, mntflags, &args) < 0) { switch (errno) { case EMFILE: Index: sbin/mount_ffs/mount_ffs.c =================================================================== RCS file: /cvsroot/src/sbin/mount_ffs/mount_ffs.c,v retrieving revision 1.17 diff -u -u -p -r1.17 mount_ffs.c --- sbin/mount_ffs/mount_ffs.c 5 Feb 2005 14:54:35 -0000 1.17 +++ sbin/mount_ffs/mount_ffs.c 23 Sep 2005 10:00:21 -0000 @@ -122,13 +122,6 @@ mount_ffs(int argc, char *argv[]) warnx("using \"%s\" instead.", fs_name); } -#define DEFAULT_ROOTUID -2 - args.export.ex_root = DEFAULT_ROOTUID; - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; - if (mount(MOUNT_FFS, fs_name, mntflags, &args) < 0) { switch (errno) { case EMFILE: Index: sbin/mount_filecore/mount_filecore.c =================================================================== RCS file: /cvsroot/src/sbin/mount_filecore/mount_filecore.c,v retrieving revision 1.11 diff -u -u -p -r1.11 mount_filecore.c --- sbin/mount_filecore/mount_filecore.c 5 Feb 2005 14:55:44 -0000 1.11 +++ sbin/mount_filecore/mount_filecore.c 23 Sep 2005 10:00:21 -0000 @@ -187,9 +187,7 @@ mount_filecore(int argc, char **argv) */ mntflags |= MNT_RDONLY; if (useuid) args.flags |= FILECOREMNT_USEUID; - args.export.ex_flags = MNT_EXRDONLY; args.fspec = dev; - args.export.ex_root = DEFAULT_ROOTUID; args.flags = opts; if (mount(MOUNT_FILECORE, dir, mntflags, &args) < 0) Index: sbin/mount_lfs/mount_lfs.c =================================================================== RCS file: /cvsroot/src/sbin/mount_lfs/mount_lfs.c,v retrieving revision 1.25 diff -u -u -p -r1.25 mount_lfs.c --- sbin/mount_lfs/mount_lfs.c 27 Jun 2005 02:56:20 -0000 1.25 +++ sbin/mount_lfs/mount_lfs.c 23 Sep 2005 10:00:21 -0000 @@ -149,14 +149,6 @@ mount_lfs(int argc, char *argv[]) warnx("using \"%s\" instead.", fs_name); } -#define DEFAULT_ROOTUID -2 - args.export.ex_root = DEFAULT_ROOTUID; - if (mntflags & MNT_RDONLY) { - args.export.ex_flags = MNT_EXRDONLY; - noclean = 1; - } else - args.export.ex_flags = 0; - /* * Record the previous status of this filesystem (if any) before * performing the mount, so we can know whether to start or Index: sbin/mount_msdos/mount_msdos.c =================================================================== RCS file: /cvsroot/src/sbin/mount_msdos/mount_msdos.c,v retrieving revision 1.36 diff -u -u -p -r1.36 mount_msdos.c --- sbin/mount_msdos/mount_msdos.c 5 Feb 2005 15:02:20 -0000 1.36 +++ sbin/mount_msdos/mount_msdos.c 23 Sep 2005 10:00:21 -0000 @@ -166,11 +166,6 @@ mount_msdos(int argc, char **argv) } args.fspec = dev; - args.export.ex_root = -2; /* unchecked anyway on DOS fs */ - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; if (!set_gid || !set_uid || !set_mask) { if (stat(dir, &sb) == -1) err(1, "stat %s", dir); Index: sbin/mount_ntfs/mount_ntfs.c =================================================================== RCS file: /cvsroot/src/sbin/mount_ntfs/mount_ntfs.c,v retrieving revision 1.12 diff -u -u -p -r1.12 mount_ntfs.c --- sbin/mount_ntfs/mount_ntfs.c 5 Feb 2005 15:06:15 -0000 1.12 +++ sbin/mount_ntfs/mount_ntfs.c 23 Sep 2005 10:00:21 -0000 @@ -138,11 +138,6 @@ mount_ntfs(int argc, char **argv) } args.fspec = dev; - args.export.ex_root = 65534; /* unchecked anyway on DOS fs */ - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; if (!set_gid || !set_uid || !set_mask) { if (stat(dir, &sb) == -1) err(EX_OSERR, "stat %s", dir); Index: sbin/mount_tmpfs/mount_tmpfs.c =================================================================== RCS file: /cvsroot/src/sbin/mount_tmpfs/mount_tmpfs.c,v retrieving revision 1.1 diff -u -u -p -r1.1 mount_tmpfs.c --- sbin/mount_tmpfs/mount_tmpfs.c 10 Sep 2005 19:20:51 -0000 1.1 +++ sbin/mount_tmpfs/mount_tmpfs.c 23 Sep 2005 10:00:21 -0000 @@ -159,13 +159,6 @@ mount_tmpfs(int argc, char *argv[]) /* NOTREACHED */ } - args.ta_fspec = "tmpfs"; - args.ta_export.ex_root = -2; /* Default root ID. */ - if (mntflags & MNT_RDONLY) - args.ta_export.ex_flags = MNT_EXRDONLY; - else - args.ta_export.ex_flags = 0; - if (realpath(argv[1], canon_dir) == NULL) { err(EXIT_FAILURE, "realpath %s", argv[0]); /* NOTREACHED */ Index: sbin/newfs/newfs.c =================================================================== RCS file: /cvsroot/src/sbin/newfs/newfs.c,v retrieving revision 1.85 diff -u -u -p -r1.85 newfs.c --- sbin/newfs/newfs.c 15 Nov 2004 12:21:29 -0000 1.85 +++ sbin/newfs/newfs.c 23 Sep 2005 10:00:22 -0000 @@ -674,11 +674,6 @@ main(int argc, char *argv[]) (void) close(2); (void) chdir("/"); - args.export.ex_root = -2; - if (mntflags & MNT_RDONLY) - args.export.ex_flags = MNT_EXRDONLY; - else - args.export.ex_flags = 0; args.base = membase; args.size = fssize * sectorsize; if (mount(MOUNT_MFS, argv[1], mntflags, &args) < 0) Index: usr.sbin/mountd/mountd.8 =================================================================== RCS file: /cvsroot/src/usr.sbin/mountd/mountd.8,v retrieving revision 1.30 diff -u -u -p -r1.30 mountd.8 --- usr.sbin/mountd/mountd.8 19 Sep 2005 22:43:13 -0000 1.30 +++ usr.sbin/mountd/mountd.8 23 Sep 2005 10:00:22 -0000 @@ -29,7 +29,7 @@ .\" .\" @(#)mountd.8 8.4 (Berkeley) 4/28/95 .\" -.Dd September 18, 2005 +.Dd September 23, 2005 .Dt MOUNTD 8 .Os .Sh NAME @@ -111,7 +111,7 @@ When is started, it loads the export host addresses and options into the kernel using the -.Xr mount 2 +.Xr nfssvc 2 system call. After changing the exports file, a hangup signal should be sent to the @@ -138,6 +138,7 @@ the pid of the currently running .El .Sh SEE ALSO .Xr nfsstat 1 , +.Xr nfssvc 2 , .Xr exports 5 , .Xr nfsd 8 , .Xr rpcbind 8 , Index: usr.sbin/mountd/mountd.c =================================================================== RCS file: /cvsroot/src/usr.sbin/mountd/mountd.c,v retrieving revision 1.97 diff -u -u -p -r1.97 mountd.c --- usr.sbin/mountd/mountd.c 19 Sep 2005 22:43:21 -0000 1.97 +++ usr.sbin/mountd/mountd.c 23 Sep 2005 10:00:22 -0000 @@ -72,11 +72,6 @@ __RCSID("$NetBSD: mountd.c,v 1.97 2005/0 #include #include -#include -#include -#include -#include - #include #include @@ -191,7 +186,7 @@ static int check_options __P((const char static int chk_host __P((struct dirlist *, struct sockaddr *, int *, int *)); static int del_mlist __P((char *, char *, struct sockaddr *)); static struct dirlist *dirp_search __P((struct dirlist *, char *)); -static int do_mount __P((const char *, size_t, struct exportlist *, +static int do_nfssvc __P((const char *, size_t, struct exportlist *, struct grouplist *, int, struct uucred *, char *, int, struct statvfs *)); static int do_opt __P((const char *, size_t, char **, char **, struct exportlist *, struct grouplist *, int *, int *, struct uucred *)); @@ -1008,38 +1003,18 @@ get_exportlist(n) /* * And delete exports that are in the kernel for all local * file systems. - * XXX: Should know how to handle all local exportable file systems - * instead of just MOUNT_FFS. */ num = getmntinfo(&fsp, MNT_NOWAIT); for (i = 0; i < num; i++) { - union { - struct ufs_args ua; - struct iso_args ia; - struct mfs_args ma; - struct msdosfs_args da; - struct adosfs_args aa; - } targs; - - if (!strncmp(fsp->f_fstypename, MOUNT_MFS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_FFS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_EXT2FS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_LFS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_MSDOS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_ADOSFS, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_NULL, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_UMAP, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_UNION, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_CD9660, MFSNAMELEN) || - !strncmp(fsp->f_fstypename, MOUNT_NTFS, MFSNAMELEN)) { - bzero((char *) &targs, sizeof(targs)); - targs.ua.fspec = NULL; - targs.ua.export.ex_flags = MNT_DELEXPORT; - if (mount(fsp->f_fstypename, fsp->f_mntonname, - fsp->f_flag | MNT_UPDATE, &targs) == -1) - syslog(LOG_ERR, "Can't delete exports for %s", - fsp->f_mntonname); - } + struct mountd_exports_list mel; + + /* Delete all entries from the export list. */ + mel.mel_path = fsp->f_mntonname; + mel.mel_nexports = 0; + if (nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1) + syslog(LOG_ERR, "Can't delete exports for %s", + fsp->f_mntonname); + fsp++; } @@ -1191,7 +1166,7 @@ get_exportlist(n) */ grp = tgrp; do { - if (do_mount(line, lineno, ep, grp, exflags, &anon, + if (do_nfssvc(line, lineno, ep, grp, exflags, &anon, dirp, dirplen, &fsb)) goto badline; } while (grp->gr_next && (grp = grp->gr_next)); @@ -2011,11 +1986,10 @@ estrdup(s) } /* - * Do the mount syscall with the update flag to push t