diff options
| author | jmmv <jmmv@NetBSD.org> | 2005-09-23 12:10:31 +0000 |
|---|---|---|
| committer | jmmv <jmmv@NetBSD.org> | 2005-09-23 12:10:31 +0000 |
| commit | 2a3e5eeb7c33daf98dff2ff04f324a4d0dac3f8f (patch) | |
| tree | 342a37e6145db64e2c8df120aeb2f5fc5c387f69 | |
| parent | 992367dcfc1c1310e9196564c7569c5263f01004 (diff) | |
Apply the NFS exports list rototill patch:
- Remove all NFS related stuff from file system specific code.
- Drop the vfs_checkexp hook and generalize it in the new nfs_check_export
function, thus removing redundancy from all file systems.
- Move all NFS export-related stuff from kern/vfs_subr.c to the new
file sys/nfs/nfs_export.c. The former was becoming large and its code
is always compiled, regardless of the build options. Using the latter,
the code is only compiled in when NFSSERVER is enabled. While doing this,
also make some functions in nfs_subs.c conditional to NFSSERVER.
- Add a new command in nfssvc(2), called NFSSVC_SETEXPORTSLIST, that takes a
path and a set of export entries. At the moment it can only clear the
exports list or append entries, one by one, but it is done in a way that
allows setting the whole set of entries atomically in the future (see the
comment in mountd_set_exports_list or in doc/TODO).
- Change mountd(8) to use the nfssvc(2) system call instead of mount(2) so
that it becomes file system agnostic. In fact, all this whole thing was
done to remove a 'XXX' block from this utility!
- Change the mount*, newfs and fsck* userland utilities to not deal with NFS
exports initialization; done internally by the kernel when initializing
the NFS support for each file system.
- Implement an interface for VFS (called VFS hooks) so that several kernel
subsystems can run arbitrary code upon receipt of specific VFS events.
At the moment, this only provides support for unmount and is used to
destroy NFS exports lists from the file systems being unmounted, though it
has room for extension.
Thanks go to yamt@, chs@, thorpej@, wrstuden@ and others for their comments
and advice in the development of this patch.
75 files changed, 1324 insertions, 1312 deletions
diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 3985940a1c2..3b7cc302f68 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.816 2005/09/19 03:16:40 simonb Exp $ +# $NetBSD: mi,v 1.817 2005/09/23 12:10:32 jmmv Exp $ ./etc/mtree/set.comp comp-sys-root ./usr/bin/addr2line comp-debug-bin bfd ./usr/bin/ar comp-util-bin bfd @@ -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 diff --git a/doc/CHANGES b/doc/CHANGES index 1dac0725331..672fd1123c7 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,4 +1,4 @@ -LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.524 $> +LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.525 $> [Note: This file does not mention every change made to the NetBSD source tree. @@ -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] @@ -1,4 +1,4 @@ -# $NetBSD: TODO,v 1.12 2004/11/29 09:48:03 agc Exp $ +# $NetBSD: TODO,v 1.13 2005/09/23 12:10:32 jmmv Exp $ THINGS TO BE DONE: @@ -93,4 +93,7 @@ This is a list of suggested smaller projects (in no particular order): 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). diff --git a/lib/libc/sys/nfssvc.2 b/lib/libc/sys/nfssvc.2 index a8e618fab2f..fcbc6d5c366 100644 --- a/lib/libc/sys/nfssvc.2 +++ b/lib/libc/sys/nfssvc.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: nfssvc.2,v 1.20 2004/05/13 10:20:58 wiz Exp $ +.\" $NetBSD: nfssvc.2,v 1.21 2005/09/23 12:10:32 jmmv Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -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 diff --git a/sbin/fsck_ext2fs/main.c b/sbin/fsck_ext2fs/main.c index 98e6a2345ef..3769a122869 100644 --- a/sbin/fsck_ext2fs/main.c +++ b/sbin/fsck_ext2fs/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.22 2005/08/19 02:07:18 christos Exp $ */ +/* $NetBSD: main.c,v 1.23 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #else -__RCSID("$NetBSD: main.c,v 1.22 2005/08/19 02:07:18 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.23 2005/09/23 12:10:34 jmmv Exp $"); #endif #endif /* not lint */ @@ -327,8 +327,6 @@ checkfilesys(const char *filesys, char *mntpt, long auxdata, int child) 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) diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 25b305f67fd..e00037f95e6 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.59 2005/08/19 02:07:19 christos Exp $ */ +/* $NetBSD: main.c,v 1.60 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95"; #else -__RCSID("$NetBSD: main.c,v 1.59 2005/08/19 02:07:19 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.60 2005/09/23 12:10:34 jmmv Exp $"); #endif #endif /* not lint */ @@ -422,8 +422,6 @@ checkfilesys(const char *filesys, char *mntpt, long auxdata, int child) 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) diff --git a/sbin/fsck_lfs/main.c b/sbin/fsck_lfs/main.c index ef4247b8ea5..28ab048537f 100644 --- a/sbin/fsck_lfs/main.c +++ b/sbin/fsck_lfs/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.26 2005/08/19 02:07:19 christos Exp $ */ +/* $NetBSD: main.c,v 1.27 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -286,8 +286,6 @@ checkfilesys(const char *filesys, char *mntpt, long auxdata, int child) 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) diff --git a/sbin/mount_ados/mount_ados.c b/sbin/mount_ados/mount_ados.c index 1478997a4ca..f715d28dbfd 100644 --- a/sbin/mount_ados/mount_ados.c +++ b/sbin/mount_ados/mount_ados.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_ados.c,v 1.19 2005/02/05 14:47:18 xtraeme Exp $ */ +/* $NetBSD: mount_ados.c,v 1.20 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mount_ados.c,v 1.19 2005/02/05 14:47:18 xtraeme Exp $"); +__RCSID("$NetBSD: mount_ados.c,v 1.20 2005/09/23 12:10:34 jmmv Exp $"); #endif /* not lint */ #include <sys/cdefs.h> @@ -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); diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c index ebc86ba6027..0c8af814859 100644 --- a/sbin/mount_cd9660/mount_cd9660.c +++ b/sbin/mount_cd9660/mount_cd9660.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_cd9660.c,v 1.20 2005/02/05 14:49:36 xtraeme Exp $ */ +/* $NetBSD: mount_cd9660.c,v 1.21 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1994 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: mount_cd9660.c,v 1.20 2005/02/05 14:49:36 xtraeme Exp $"); +__RCSID("$NetBSD: mount_cd9660.c,v 1.21 2005/09/23 12:10:34 jmmv Exp $"); #endif #endif /* not lint */ @@ -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) diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c index ed0a35afbc9..8247fa1064a 100644 --- a/sbin/mount_ext2fs/mount_ext2fs.c +++ b/sbin/mount_ext2fs/mount_ext2fs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_ext2fs.c,v 1.13 2005/02/05 14:51:16 xtraeme Exp $ */ +/* $NetBSD: mount_ext2fs.c,v 1.14 2005/09/23 12:10:34 jmmv Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95"; #else -__RCSID("$NetBSD: mount_ext2fs.c,v 1.13 2005/02/05 14:51:16 xtraeme Exp $"); +__RCSID("$NetBSD: mount_ext2fs.c,v 1.14 2005/09/23 12:10:34 jmmv Exp $"); #endif #endif /* not lint */ @@ -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: diff --git a/sbin/mount_ffs/mount_ffs.c b/sbin/mount_ffs/mount_ffs.c index 93ad67064e4..7d353c98470 100644 --- a/sbin/mount_ffs/mount_ffs.c +++ b/sbin/mount_ffs/mount_ffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_ffs.c,v 1.17 2005/02/05 14:54:35 xtraeme Exp $ */ +/* $NetBSD: mount_ffs.c,v 1.18 2005/09/23 12:10:35 jmmv Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95"; #else -__RCSID("$NetBSD: mount_ffs.c,v 1.17 2005/02/05 14:54:35 xtraeme Exp $"); +__RCSID("$NetBSD: mount_ffs.c,v 1.18 2005/09/23 12:10:35 jmmv Exp $"); #endif #endif /* not lint */ @@ -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: diff --git a/sbin/mount_filecore/mount_filecore.c b/sbin/mount_filecore/mount_filecore.c index 7d7cbf8010b..ee201f6bf77 100644 --- a/sbin/mount_filecore/mount_filecore.c +++ b/sbin/mount_filecore/mount_filecore.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_filecore.c,v 1.11 2005/02/05 14:55:44 xtraeme Exp $ */ +/* $NetBSD: mount_filecore.c,v 1.12 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1994 The Regents of the University of California. @@ -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) diff --git a/sbin/mount_lfs/mount_lfs.c b/sbin/mount_lfs/mount_lfs.c index dfd01151526..5aa724d1a30 100644 --- a/sbin/mount_lfs/mount_lfs.c +++ b/sbin/mount_lfs/mount_lfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_lfs.c,v 1.25 2005/06/27 02:56:20 christos Exp $ */ +/* $NetBSD: mount_lfs.c,v 1.26 2005/09/23 12:10:35 jmmv Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)mount_lfs.c 8.4 (Berkeley) 4/26/95"; #else -__RCSID("$NetBSD: mount_lfs.c,v 1.25 2005/06/27 02:56:20 christos Exp $"); +__RCSID("$NetBSD: mount_lfs.c,v 1.26 2005/09/23 12:10:35 jmmv Exp $"); #endif #endif /* not lint */ @@ -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 diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c index 4249a727e6c..97fa62531ff 100644 --- a/sbin/mount_msdos/mount_msdos.c +++ b/sbin/mount_msdos/mount_msdos.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_msdos.c,v 1.36 2005/02/05 15:02:20 xtraeme Exp $ */ +/* $NetBSD: mount_msdos.c,v 1.37 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mount_msdos.c,v 1.36 2005/02/05 15:02:20 xtraeme Exp $"); +__RCSID("$NetBSD: mount_msdos.c,v 1.37 2005/09/23 12:10:35 jmmv Exp $"); #endif /* not lint */ #include <sys/cdefs.h> @@ -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); diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c index 4da9c242b3e..911baab6d6e 100644 --- a/sbin/mount_ntfs/mount_ntfs.c +++ b/sbin/mount_ntfs/mount_ntfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_ntfs.c,v 1.12 2005/02/05 15:06:15 xtraeme Exp $ */ +/* $NetBSD: mount_ntfs.c,v 1.13 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mount_ntfs.c,v 1.12 2005/02/05 15:06:15 xtraeme Exp $"); +__RCSID("$NetBSD: mount_ntfs.c,v 1.13 2005/09/23 12:10:35 jmmv Exp $"); #endif #include <sys/cdefs.h> @@ -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); diff --git a/sbin/mount_tmpfs/mount_tmpfs.c b/sbin/mount_tmpfs/mount_tmpfs.c index 87aeab24f14..3c650f928f3 100644 --- a/sbin/mount_tmpfs/mount_tmpfs.c +++ b/sbin/mount_tmpfs/mount_tmpfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: mount_tmpfs.c,v 1.1 2005/09/10 19:20:51 jmmv Exp $ */ +/* $NetBSD: mount_tmpfs.c,v 1.2 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mount_tmpfs.c,v 1.1 2005/09/10 19:20:51 jmmv Exp $"); +__RCSID("$NetBSD: mount_tmpfs.c,v 1.2 2005/09/23 12:10:35 jmmv Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -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 */ diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index 254ddfff3df..1874efae3d9 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: newfs.c,v 1.85 2004/11/15 12:21:29 he Exp $ */ +/* $NetBSD: newfs.c,v 1.86 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 1983, 1989, 1993, 1994 @@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: newfs.c,v 1.85 2004/11/15 12:21:29 he Exp $"); +__RCSID("$NetBSD: newfs.c,v 1.86 2005/09/23 12:10:35 jmmv Exp $"); #endif #endif /* not lint */ @@ -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) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index df0cb99726c..73603bc5aba 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.176 2005/09/10 19:20:48 jmmv Exp $ +# $NetBSD: Makefile,v 1.177 2005/09/23 12:10:32 jmmv Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -36,7 +36,7 @@ MAN= altq.9 arc4random.9 arp.9 audio.9 autoconf.9 \ 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 \ diff --git a/share/man/man9/vfs_hooks.9 b/share/man/man9/vfs_hooks.9 new file mode 100644 index 00000000000..29fe52c2c63 --- /dev/null +++ b/share/man/man9/vfs_hooks.9 @@ -0,0 +1,110 @@ +.\" $NetBSD: vfs_hooks.9,v 1.1 2005/09/23 12:10:32 jmmv Exp $ +.\" +.\" 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 VFS_HOOKS 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 . diff --git a/share/man/man9/vfsops.9 b/share/man/man9/vfsops.9 index 456d1d2f061..45bbeef1310 100644 --- a/share/man/man9/vfsops.9 +++ b/share/man/man9/vfsops.9 @@ -1,4 +1,4 @@ -.\" $NetBSD: vfsops.9,v 1.21 2005/07/20 12:55:14 wiz Exp $ +.\" $NetBSD: vfsops.9,v 1.22 2005/09/23 12:10:32 jmmv Exp $ .\" .\" Copyright (c) 2001 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -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 system 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 member function pointer to a 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 diff --git a/share/man/man9/vfssubr.9 b/share/man/man9/vfssubr.9 index 9d2b9d6b130..226f1007e46 100644 --- a/share/man/man9/vfssubr.9 +++ b/share/man/man9/vfssubr.9 @@ -1,4 +1,4 @@ -.\" $NetBSD: vfssubr.9,v 1.10 2004/04/21 01:05:35 christos Exp $ +.\" $NetBSD: vfssubr.9,v 1.11 2005/09/23 12:10:32 jmmv Exp $ .\" .\" Copyright (c) 2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -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 diff --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index 03903f8bb9a..dc932f38f31 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: coda_vfsops.c,v 1.45 2005/08/30 22:24:11 xtraeme Exp $ */ +/* $NetBSD: coda_vfsops.c,v 1.46 2005/09/23 12:10:32 jmmv Exp $ */ /* * @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.45 2005/08/30 22:24:11 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.46 2005/09/23 12:10:32 jmmv Exp $"); #ifdef _LKM #define NVCODA 4 @@ -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, diff --git a/sys/conf/files b/sys/conf/files index 56ff1b02ea5..b9888f3334a 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $NetBSD: files,v 1.731 2005/09/17 14:38:40 yamt Exp $ +# $NetBSD: files,v 1.732 2005/09/23 12:10:31 jmmv Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -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 diff --git a/sys/fs/adosfs/adosfs.h b/sys/fs/adosfs/adosfs.h index 4c15c6a0f37..9ce1d17856b 100644 --- a/sys/fs/adosfs/adosfs.h +++ b/sys/fs/adosfs/adosfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: adosfs.h,v 1.5 2005/02/26 22:58:54 perry Exp $ */ +/* $NetBSD: adosfs.h,v 1.6 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -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 */ diff --git a/sys/fs/adosfs/advfsops.c b/sys/fs/adosfs/advfsops.c index 4685102ea9c..b0fec819bcc 100644 --- a/sys/fs/adosfs/advfsops.c +++ b/sys/fs/adosfs/advfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.24 2005/08/19 04:15:02 christos Exp $ */ +/* $NetBSD: advfsops.c,v 1.25 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.24 2005/08/19 04:15:02 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.25 2005/09/23 12:10:32 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -70,8 +70,6 @@ int adosfs_statvfs __P((struct mount *, struct statvfs *, struct proc *)); 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 <mp, client> 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, diff --git a/sys/fs/cd9660/cd9660_extern.h b/sys/fs/cd9660/cd9660_extern.h index eedfa3a9183..7dbd601eff5 100644 --- a/sys/fs/cd9660/cd9660_extern.h +++ b/sys/fs/cd9660/cd9660_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_extern.h,v 1.14 2005/08/30 18:47:19 xtraeme Exp $ */ +/* $NetBSD: cd9660_extern.h,v 1.15 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1994 @@ -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 *, struct statvfs *, struct proc *); 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); diff --git a/sys/fs/cd9660/cd9660_mount.h b/sys/fs/cd9660/cd9660_mount.h index 5b0c62ca022..8e71ebb0848 100644 --- a/sys/fs/cd9660/cd9660_mount.h +++ b/sys/fs/cd9660/cd9660_mount.h @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_mount.h,v 1.3 2003/10/03 16:34:31 yamt Exp $ */ +/* $NetBSD: cd9660_mount.h,v 1.4 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 1995 * The Regents of the University of California. All rights reserved. @@ -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.*/ diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 7170ced5bc1..1c22001c355 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.26 2005/08/30 18:47:19 xtraeme Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.27 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.26 2005/08/30 18:47:19 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.27 2005/09/23 12:10:32 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -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 <mp, client> 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; diff --git a/sys/fs/filecorefs/filecore_extern.h b/sys/fs/filecorefs/filecore_extern.h index 182e813ffae..e09dfe211ac 100644 --- a/sys/fs/filecorefs/filecore_extern.h +++ b/sys/fs/filecorefs/filecore_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_extern.h,v 1.9 2004/05/20 06:34:26 atatat Exp $ */ +/* $NetBSD: filecore_extern.h,v 1.10 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -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; }; diff --git a/sys/fs/filecorefs/filecore_mount.h b/sys/fs/filecorefs/filecore_mount.h index fc49932c889..1639ed0b242 100644 --- a/sys/fs/filecorefs/filecore_mount.h +++ b/sys/fs/filecorefs/filecore_mount.h @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_mount.h,v 1.3 2003/10/03 16:34:31 yamt Exp $ */ +/* $NetBSD: filecore_mount.h,v 1.4 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 1995 The Regents of the University of California. @@ -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 */ diff --git a/sys/fs/filecorefs/filecore_vfsops.c b/sys/fs/filecorefs/filecore_vfsops.c index 16dcf1c6c7d..e92758c0179 100644 --- a/sys/fs/filecorefs/filecore_vfsops.c +++ b/sys/fs/filecorefs/filecore_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_vfsops.c,v 1.20 2005/06/28 09:30:37 yamt Exp $ */ +/* $NetBSD: filecore_vfsops.c,v 1.21 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.20 2005/06/28 09:30:37 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.21 2005/09/23 12:10:32 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -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 <mp, client> 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 diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index cb034d94e5b..d37996f1155 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.27 2005/09/10 17:33:45 christos Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.28 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.27 2005/09/10 17:33:45 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.28 2005/09/23 12:10:32 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -95,8 +95,6 @@ int msdosfs_statvfs(struct mount *, struct statvfs *, struct proc *); 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; diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h index e32719c0560..4a3d2e3147f 100644 --- a/sys/fs/msdosfs/msdosfsmount.h +++ b/sys/fs/msdosfs/msdosfsmount.h @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfsmount.h,v 1.8 2005/08/30 18:49:19 xtraeme Exp $ */ +/* $NetBSD: msdosfsmount.h,v 1.9 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -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) diff --git a/sys/fs/ntfs/ntfs.h b/sys/fs/ntfs/ntfs.h index 49087f54207..48839f44661 100644 --- a/sys/fs/ntfs/ntfs.h +++ b/sys/fs/ntfs/ntfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs.h,v 1.9 2005/08/30 19:01:29 xtraeme Exp $ */ +/* $NetBSD: ntfs.h,v 1.10 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko @@ -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 */ diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index c014a57a42d..3af99d661ea 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_vfsops.c,v 1.33 2005/08/30 19:01:30 xtraeme Exp $ */ +/* $NetBSD: ntfs_vfsops.c,v 1.34 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.33 2005/08/30 19:01:30 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.34 2005/09/23 12:10:32 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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_genfsops = { }; #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 <mp, client> 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, diff --git a/sys/fs/ntfs/ntfsmount.h b/sys/fs/ntfs/ntfsmount.h index 7a81aa7eb1f..477b8022f36 100644 --- a/sys/fs/ntfs/ntfsmount.h +++ b/sys/fs/ntfs/ntfsmount.h @@ -1,4 +1,4 @@ -/* $NetBSD: ntfsmount.h,v 1.2 2003/10/03 16:34:31 yamt Exp $ */ +/* $NetBSD: ntfsmount.h,v 1.3 2005/09/23 12:10:32 jmmv Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko @@ -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 */ diff --git a/sys/fs/ptyfs/ptyfs_vfsops.c b/sys/fs/ptyfs/ptyfs_vfsops.c index c384d4abed7..1696bdc9ecd 100644 --- a/sys/fs/ptyfs/ptyfs_vfsops.c +++ b/sys/fs/ptyfs/ptyfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ptyfs_vfsops.c,v 1.8 2005/05/29 21:00:29 christos Exp $ */ +/* $NetBSD: ptyfs_vfsops.c,v 1.9 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.8 2005/05/29 21:00:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.9 2005/09/23 12:10:32 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -72,9 +72,6 @@ int ptyfs_statvfs(struct mount *, struct statvfs *, struct proc *); 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, struct vnode **vpp) 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, "sysctl vfs.ptyfs subtree setup") } -/*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, diff --git a/sys/fs/smbfs/smbfs.h b/sys/fs/smbfs/smbfs.h index f8bccaec48c..88216f92446 100644 --- a/sys/fs/smbfs/smbfs.h +++ b/sys/fs/smbfs/smbfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs.h,v 1.10 2005/02/26 22:58:55 perry Exp $ */ +/* $NetBSD: smbfs.h,v 1.11 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 2000-2001, Boris Popov @@ -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 diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c index 69f7ab48e5f..e1ea51e43b6 100644 --- a/sys/fs/smbfs/smbfs_vfsops.c +++ b/sys/fs/smbfs/smbfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs_vfsops.c,v 1.49 2005/06/20 02:49:19 atatat Exp $ */ +/* $NetBSD: smbfs_vfsops.c,v 1.50 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 2000-2001, Boris Popov @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.49 2005/06/20 02:49:19 atatat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.50 2005/09/23 12:10:32 jmmv Exp $"); #ifdef _KERNEL_OPT #include "opt_quota.h" @@ -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 */ diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 4f98f11e12e..0aaa22e3637 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.4 2005/09/15 12:34:35 yamt Exp $ */ +/* $NetBSD: tmpfs.h,v 1.5 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -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; }; diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 568161227d5..10aea3df5b3 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.3 2005/09/13 21:30:52 jmmv Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.4 2005/09/23 12:10:32 jmmv Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.3 2005/09/13 21:30:52 jmmv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.4 2005/09/23 12:10:32 jmmv Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -70,8 +70,6 @@ static int tmpfs_statvfs(struct mount *, struct statvfs *, struct proc *); 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 *path, void *data, 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 *path, void *data, 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 *path, void *data, 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 *path, void *data, 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, diff --git a/sys/fs/union/union_vfsops.c b/sys/fs/union/union_vfsops.c index b8370c48185..a439227a30c 100644 --- a/sys/fs/union/union_vfsops.c +++ b/sys/fs/union/union_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: union_vfsops.c,v 1.29 2005/08/30 19:11:43 xtraeme Exp $ */ +/* $NetBSD: union_vfsops.c,v 1.30 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.29 2005/08/30 19:11:43 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.30 2005/09/23 12:10:33 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -103,10 +103,6 @@ int union_quotactl(struct mount *, int, uid_t, void *, struct proc *); 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, diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 6331c277ce8..fce85aa0fb3 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.92 2005/07/23 18:54:07 cube Exp $ */ +/* $NetBSD: kern_time.c,v 1.93 2005/09/23 12:10:33 jmmv Exp $ */ /*- * Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.92 2005/07/23 18:54:07 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.93 2005/09/23 12:10:33 jmmv Exp $"); #include "fs_nfs.h" #include "opt_nfs.h" @@ -94,6 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.92 2005/07/23 18:54:07 cube Exp $"); #if defined(NFS) || defined(NFSSERVER) #include <nfs/rpcv2.h> #include <nfs/nfsproto.h> +#include <nfs/nfs.h> #include <nfs/nfs_var.h> #endif diff --git a/sys/kern/vfs_hooks.c b/sys/kern/vfs_hooks.c new file mode 100644 index 00000000000..76cbdc17b27 --- /dev/null +++ b/sys/kern/vfs_hooks.c @@ -0,0 +1,115 @@ +/* $NetBSD: vfs_hooks.c,v 1.1 2005/09/23 12:10:33 jmmv Exp $ */ + +/*- + * 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 <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,v 1.1 2005/09/23 12:10:33 jmmv Exp $"); + +#include <sys/param.h> +#include <sys/mount.h> + +/* + * 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)); +} +*/ diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index dc8d4f1c0eb..56953ed88a0 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.253 2005/09/13 01:45:14 christos Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.254 2005/09/23 12:10:33 jmmv Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.253 2005/09/13 01:45:14 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.254 2005/09/23 12:10:33 jmmv Exp $"); #include "opt_inet.h" #include "opt_ddb.h" @@ -92,8 +92,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.253 2005/09/13 01:45:14 christos Exp #include <sys/proc.h> #include <sys/kernel.h> #include <sys/mount.h> -#include <sys/time.h> -#include <sys/event.h> #include <sys/fcntl.h> #include <sys/vnode.h> #include <sys/stat.h> @@ -107,20 +105,15 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.253 2005/09/13 01:45:14 christos Exp #include <sys/sa.h> #include <sys/syscallargs.h> #include <sys/device.h> -#include <sys/dirent.h> #include <sys/filedesc.h> #include <miscfs/specfs/specdev.h> #include <miscfs/genfs/genfs.h> #include <miscfs/syncfs/syncfs.h> -#include <netinet/in.h> - #include <uvm/uvm.h> #include <uvm/uvm_ddb.h> -#include <netinet/in.h> - #include <sys/sysctl.h> const enum vtype iftovt_tab[16] = { @@ -154,8 +147,6 @@ struct mntlist mountlist = /* mounted filesystem list */ 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 **, enum vtype); 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, diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index b8b00716252..9c810300343 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.230 2005/08/30 09:37:41 jmmv Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.231 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.230 2005/08/30 09:37:41 jmmv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.231 2005/09/23 12:10:33 jmmv Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_43.h" @@ -541,8 +541,6 @@ dounmount(struct mount *mp, int flags, struct proc *p) 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, struct proc *p) 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, register_t *retval) 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, register_t *retval) 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, register_t *retval) 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, register_t *retval) 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; diff --git a/sys/miscfs/fdesc/fdesc_vfsops.c b/sys/miscfs/fdesc/fdesc_vfsops.c index dee6082965f..788245edd2f 100644 --- a/sys/miscfs/fdesc/fdesc_vfsops.c +++ b/sys/miscfs/fdesc/fdesc_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vfsops.c,v 1.56 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: fdesc_vfsops.c,v 1.57 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.56 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.57 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -70,10 +70,6 @@ int fdesc_quotactl(struct mount *, int, uid_t, void *, 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, diff --git a/sys/miscfs/genfs/layer.h b/sys/miscfs/genfs/layer.h index 0faaf71a72c..16c2af59eb2 100644 --- a/sys/miscfs/genfs/layer.h +++ b/sys/miscfs/genfs/layer.h @@ -1,4 +1,4 @@ -/* $NetBSD: layer.h,v 1.8 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: layer.h,v 1.9 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -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_node); 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 */ diff --git a/sys/miscfs/genfs/layer_extern.h b/sys/miscfs/genfs/layer_extern.h index 87e0b09eac2..62aa70bb7d4 100644 --- a/sys/miscfs/genfs/layer_extern.h +++ b/sys/miscfs/genfs/layer_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: layer_extern.h,v 1.18 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: layer_extern.h,v 1.19 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -90,8 +90,6 @@ int layerfs_statvfs(struct mount *, struct statvfs *, struct proc *); 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 *); diff --git a/sys/miscfs/genfs/layer_vfsops.c b/sys/miscfs/genfs/layer_vfsops.c index 5f2db408ec5..52b80a5f1e5 100644 --- a/sys/miscfs/genfs/layer_vfsops.c +++ b/sys/miscfs/genfs/layer_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.20 2005/07/24 17:33:24 erh Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.21 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.20 2005/07/24 17:33:24 erh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.21 2005/09/23 12:10:33 jmmv Exp $"); #include <sys/param.h> #include <sys/sysctl.h> @@ -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 <mp, client> 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; diff --git a/sys/miscfs/kernfs/kernfs_vfsops.c b/sys/miscfs/kernfs/kernfs_vfsops.c index e2cf9ecedae..38474d2794d 100644 --- a/sys/miscfs/kernfs/kernfs_vfsops.c +++ b/sys/miscfs/kernfs/kernfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vfsops.c,v 1.68 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: kernfs_vfsops.c,v 1.69 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.68 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.69 2005/09/23 12:10:33 jmmv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -77,10 +77,6 @@ int kernfs_quotactl(struct mount *, int, uid_t, void *, 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, diff --git a/sys/miscfs/nullfs/null_vfsops.c b/sys/miscfs/nullfs/null_vfsops.c index 5ec549231cc..540ad2f0829 100644 --- a/sys/miscfs/nullfs/null_vfsops.c +++ b/sys/miscfs/nullfs/null_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: null_vfsops.c,v 1.56 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: null_vfsops.c,v 1.57 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.56 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.57 2005/09/23 12:10:33 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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, diff --git a/sys/miscfs/overlay/overlay_vfsops.c b/sys/miscfs/overlay/overlay_vfsops.c index 291152c36fe..5b7646f8aa7 100644 --- a/sys/miscfs/overlay/overlay_vfsops.c +++ b/sys/miscfs/overlay/overlay_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: overlay_vfsops.c,v 1.31 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: overlay_vfsops.c,v 1.32 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1999, 2000 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.31 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.32 2005/09/23 12:10:33 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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, diff --git a/sys/miscfs/portal/portal_vfsops.c b/sys/miscfs/portal/portal_vfsops.c index 322c6097510..54d6b11d672 100644 --- a/sys/miscfs/portal/portal_vfsops.c +++ b/sys/miscfs/portal/portal_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: portal_vfsops.c,v 1.52 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: portal_vfsops.c,v 1.53 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.52 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: portal_vfsops.c,v 1.53 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -78,10 +78,6 @@ int portal_quotactl(struct mount *, int, uid_t, void *, 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, diff --git a/sys/miscfs/procfs/procfs_vfsops.c b/sys/miscfs/procfs/procfs_vfsops.c index fe3fa4cac0b..edf8c20f47a 100644 --- a/sys/miscfs/procfs/procfs_vfsops.c +++ b/sys/miscfs/procfs/procfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_vfsops.c,v 1.61 2005/08/30 20:08:01 xtraeme Exp $ */ +/* $NetBSD: procfs_vfsops.c,v 1.62 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1993 @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.61 2005/08/30 20:08:01 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.62 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -112,10 +112,6 @@ int procfs_quotactl(struct mount *, int, uid_t, void *, 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, diff --git a/sys/miscfs/umapfs/umap_vfsops.c b/sys/miscfs/umapfs/umap_vfsops.c index eaab2c5861e..5ae3d2a42e6 100644 --- a/sys/miscfs/umapfs/umap_vfsops.c +++ b/sys/miscfs/umapfs/umap_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: umap_vfsops.c,v 1.54 2005/08/30 20:08:02 xtraeme Exp $ */ +/* $NetBSD: umap_vfsops.c,v 1.55 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.54 2005/08/30 20:08:02 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.55 2005/09/23 12:10:33 jmmv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -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, diff --git a/sys/nfs/files.nfs b/sys/nfs/files.nfs index 46fb9820b60..bd73586b87c 100644 --- a/sys/nfs/files.nfs +++ b/sys/nfs/files.nfs @@ -1,4 +1,4 @@ -# $NetBSD: files.nfs,v 1.5 2005/02/26 22:39:50 perry Exp $ +# $NetBSD: files.nfs,v 1.6 2005/09/23 12:10:33 jmmv Exp $ deffs fs_nfs.h NFS @@ -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 diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h index 92cb28fa389..548d114c848 100644 --- a/sys/nfs/nfs.h +++ b/sys/nfs/nfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.h,v 1.49 2005/09/18 23:44:54 christos Exp $ */ +/* $NetBSD: nfs.h,v 1.50 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993, 1995 * The Regents of the University of California. All rights reserved. @@ -165,8 +165,24 @@ extern int nfs_niothreads; /* Number of async_daemons desired */ (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 */ diff --git a/sys/nfs/nfs_export.c b/sys/nfs/nfs_export.c new file mode 100644 index 00000000000..79a18934c98 --- /dev/null +++ b/sys/nfs/nfs_export.c @@ -0,0 +1,723 @@ +/* $NetBSD: nfs_export.c,v 1.1 2005/09/23 12:10:33 jmmv Exp $ */ + +/*- + * 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 <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.1 2005/09/23 12:10:33 jmmv Exp $"); + +#include "opt_inet.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/queue.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/vnode.h> +#include <sys/namei.h> +#include <sys/errno.h> +#include <sys/malloc.h> +#include <sys/domain.h> +#include <sys/mbuf.h> +#include <sys/dirent.h> +#include <sys/socket.h> /* XXX for AF_MAX */ + +#include <net/radix.h> + +#include <netinet/in.h> + +#include <nfs/rpcv2.h> +#include <nfs/nfsproto.h> +#include <nfs/nfs.h> +#include <nfs/nfs_var.h> + +/* + * 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; +} diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c index 4f4f2ae8d6b..f8efb004b57 100644 --- a/sys/nfs/nfs_subs.c +++ b/sys/nfs/nfs_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_subs.c,v 1.152 2005/09/19 00:53:55 christos Exp $ */ +/* $NetBSD: nfs_subs.c,v 1.153 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993 @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.152 2005/09/19 00:53:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.153 2005/09/23 12:10:33 jmmv Exp $"); #include "fs_nfs.h" #include "opt_nfs.h" @@ -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, slp, nam, rdonlyp, kerbflag, pubflag) 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 diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 555b26e40d9..fdfb3021235 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_syscalls.c,v 1.81 2005/09/11 20:19:31 rpaulo Exp $ */ +/* $NetBSD: nfs_syscalls.c,v 1.82 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.81 2005/09/11 20:19:31 rpaulo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.82 2005/09/23 12:10:33 jmmv Exp $"); #include "fs_nfs.h" #include "opt_nfs.h" @@ -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; diff --git a/sys/nfs/nfs_var.h b/sys/nfs/nfs_var.h index 9a18c132748..03bfb2ef29c 100644 --- a/sys/nfs/nfs_var.h +++ b/sys/nfs/nfs_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_var.h,v 1.51 2005/07/07 02:05:03 christos Exp $ */ +/* $NetBSD: nfs_var.h,v 1.52 2005/09/23 12:10:33 jmmv Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -288,8 +288,6 @@ void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *, 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 *, struct ucred *, char **, int *, 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 */ diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index c84d18769c3..38a63cd6528 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vfsops.c,v 1.149 2005/09/19 00:49:52 christos Exp $ */ +/* $NetBSD: nfs_vfsops.c,v 1.150 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993, 1995 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.149 2005/09/19 00:49:52 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.150 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -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 */ diff --git a/sys/nfs/nfsmount.h b/sys/nfs/nfsmount.h index 77958926d04..2a4e1b0de43 100644 --- a/sys/nfs/nfsmount.h +++ b/sys/nfs/nfsmount.h @@ -1,4 +1,4 @@ -/* $NetBSD: nfsmount.h,v 1.34 2005/09/18 23:44:54 christos Exp $ */ +/* $NetBSD: nfsmount.h,v 1.35 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1993 @@ -195,8 +195,6 @@ int nfs_sync __P((struct mount *mp, int waitfor, struct ucred *cred, 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 *)); diff --git a/sys/sys/fstypes.h b/sys/sys/fstypes.h index 2c00eb60c14..2986be21205 100644 --- a/sys/sys/fstypes.h +++ b/sys/sys/fstypes.h @@ -1,4 +1,4 @@ -/* $NetBSD: fstypes.h,v 1.5 2005/06/23 01:59:31 christos Exp $ */ +/* $NetBSD: fstypes.h,v 1.6 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -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" }, diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 7a76b868df1..fc68eea561a 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $NetBSD: mount.h,v 1.131 2005/09/13 01:42:51 christos Exp $ */ +/* $NetBSD: mount.h,v 1.132 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -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 <net/radix.h> -#include <sys/socket.h> /* 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 <sys/mallocvar.h> 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 *, int, struct vnode *, 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 *); diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 59da766298c..4167f6ee445 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.90 2005/09/12 20:23:03 christos Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.91 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.90 2005/09/12 20:23:03 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.91 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -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 char *path, void *data, 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 char *path, void *data, 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, diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 9537a01fbfb..d35fc444090 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.173 2005/09/22 14:04:29 rpaulo Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.174 2005/09/23 12:10:33 jmmv Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.173 2005/09/22 14:04:29 rpaulo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.174 2005/09/23 12:10:33 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -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 *path, void *data, 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 *path, void *data, 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", diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index b3e4ce6ccbf..3f1724bc1e9 100644 --- a/sys/ufs/lfs/lfs_vfsops.c +++ b/sys/ufs/lfs/lfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.186 2005/08/23 08:05:13 christos Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.187 2005/09/23 12:10:34 jmmv Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.186 2005/08/23 08:05:13 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.187 2005/09/23 12:10:34 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -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 *path, void *data, struct nameidata *ndp, 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 *path, void *data, struct nameidata *ndp, */ 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, diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index b9be73463c7..011cf0f2728 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: mfs_vfsops.c,v 1.68 2005/08/30 22:01:12 xtraeme Exp $ */ +/* $NetBSD: mfs_vfsops.c,v 1.69 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1989, 1990, 1993, 1994 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.68 2005/08/30 22:01:12 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.69 2005/09/23 12:10:34 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -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 *path, void *data, 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 *path, void *data, } 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); diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index a4d7c6793b3..5accdc9b247 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.45 2005/07/23 12:18:41 yamt Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.46 2005/09/23 12:10:34 jmmv Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -158,7 +158,6 @@ int ufs_start(struct mount *, int, struct proc *); 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 *), diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 01d7e1c6c01..4c02d13aef2 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vfsops.c,v 1.24 2005/07/10 01:08:52 thorpej Exp $ */ +/* $NetBSD: ufs_vfsops.c,v 1.25 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.24 2005/07/10 01:08:52 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.25 2005/09/23 12:10:34 jmmv Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -164,29 +164,6 @@ ufs_quotactl(struct mount *mp, int cmds, uid_t uid, void *arg, struct proc *p) } /* - * 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 <mp, client> 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. */ diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 59f4f3710b2..00800fe3112 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -1,4 +1,4 @@ -/* $NetBSD: ufsmount.h,v 1.19 2005/08/28 19:37:59 thorpej Exp $ */ +/* $NetBSD: ufsmount.h,v 1.20 2005/09/23 12:10:34 jmmv Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -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 */ diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8 index 5bd8e879899..0c0272ecbbe 100644 --- a/usr.sbin/mountd/mountd.8 +++ b/usr.sbin/mountd/mountd.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: mountd.8,v 1.30 2005/09/19 22:43:13 wiz Exp $ +.\" $NetBSD: mountd.8,v 1.31 2005/09/23 12:10:35 jmmv Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -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 , diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 50943fd11d3..19ef945b9ba 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $NetBSD: mountd.c,v 1.97 2005/09/19 22:43:21 wiz Exp $ */ +/* $NetBSD: mountd.c,v 1.98 2005/09/23 12:10:35 jmmv Exp $ */ /* * Copyright (c) 1989, 1993 @@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: mountd.c,v 1.97 2005/09/19 22:43:21 wiz Exp $"); +__RCSID("$NetBSD: mountd.c,v 1.98 2005/09/23 12:10:35 jmmv Exp $"); #endif #endif /* not lint */ @@ -72,11 +72,6 @@ __RCSID("$NetBSD: mountd.c,v 1.97 2005/09/19 22:43:21 wiz Exp $"); #include <nfs/nfs.h> #include <nfs/nfsmount.h> -#include <ufs/ufs/ufsmount.h> -#include <isofs/cd9660/cd9660_mount.h> -#include <msdosfs/msdosfsmount.h> -#include <adosfs/adosfs.h> - #include <arpa/inet.h> #include <ctype.h> @@ -191,7 +186,7 @@ static int check_options __P((const char *, size_t, struct dirlist *)); 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 the export info into - * the kernel. + * Do the nfssvc syscall to push the export info into the kernel. */ static int -do_mount(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) +do_nfssvc(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) const char *line; size_t lineno; struct exportlist *ep; @@ -2033,18 +2007,11 @@ do_mount(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) char *cp = NULL; int done; char savedc = '\0'; - union { - struct ufs_args ua; - struct iso_args ia; - struct mfs_args ma; - struct msdosfs_args da; - struct adosfs_args aa; - } args; - - args.ua.fspec = 0; - args.ua.export.ex_flags = exflags; - args.ua.export.ex_anon = *anoncrp; - args.ua.export.ex_indexfile = ep->ex_indexfile; + struct export_args export; + + export.ex_flags = exflags; + export.ex_anon = *anoncrp; + export.ex_indexfile = ep->ex_indexfile; if (grp->gr_type == GT_HOST) { ai = grp->gr_ptr.gt_addrinfo; addrp = ai->ai_addr; @@ -2061,21 +2028,20 @@ do_mount(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) if (addrp != NULL && addrp->sa_family == AF_INET6 && have_v6 == 0) goto skip; - args.ua.export.ex_addr = addrp; - args.ua.export.ex_addrlen = addrlen; - args.ua.export.ex_masklen = 0; + export.ex_addr = addrp; + export.ex_addrlen = addrlen; + export.ex_masklen = 0; break; case GT_NET: - args.ua.export.ex_addr = (struct sockaddr *) + export.ex_addr = (struct sockaddr *) &grp->gr_ptr.gt_net.nt_net; - if (args.ua.export.ex_addr->sa_family == AF_INET6 && + if (export.ex_addr->sa_family == AF_INET6 && have_v6 == 0) goto skip; - args.ua.export.ex_addrlen = - args.ua.export.ex_addr->sa_len; + export.ex_addrlen = export.ex_addr->sa_len; memset(&ss, 0, sizeof ss); - ss.ss_family = args.ua.export.ex_addr->sa_family; - ss.ss_len = args.ua.export.ex_addr->sa_len; + ss.ss_family = export.ex_addr->sa_family; + ss.ss_len = export.ex_addr->sa_len; if (allones(&ss, grp->gr_ptr.gt_net.nt_len) != 0) { syslog(LOG_ERR, "\"%s\", line %ld: Bad network flag", @@ -2084,16 +2050,16 @@ do_mount(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) *cp = savedc; return (1); } - args.ua.export.ex_mask = (struct sockaddr *)&ss; - args.ua.export.ex_masklen = ss.ss_len; + export.ex_mask = (struct sockaddr *)&ss; + export.ex_masklen = ss.ss_len; break; #ifdef ISO case GT_ISO: - args.ua.export.ex_addr = + export.ex_addr = (struct sockaddr *) grp->gr_ptr.gt_isoaddr; - args.ua.export.ex_addrlen = + export.ex_addrlen = sizeof(struct sockaddr_iso); - args.ua.export.ex_masklen = 0; + export.ex_masklen = 0; break; #endif /* ISO */ default: @@ -2108,11 +2074,17 @@ do_mount(line, lineno, ep, grp, exflags, anoncrp, dirp, dirplen, fsb) * XXX: * Maybe I should just use the fsb->f_mntonname path instead * of looping back up the dirp to the mount point?? - * Also, needs to know how to export all types of local - * exportable file systems and not just MOUNT_FFS. */ - while (mount(fsb->f_fstypename, dirp, - fsb->f_flag | MNT_UPDATE, &args) == -1) { + for (;;) { + struct mountd_exports_list mel; + + mel.mel_path = dirp; + mel.mel_nexports = 1; + mel.mel_exports = &export; + + if (nfssvc(NFSSVC_SETEXPORTSLIST, &mel) != -1) + break; + if (cp) *cp-- = savedc; else |
