summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_export.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2001-04-25 07:07:52 +0000
committerphk <phk@FreeBSD.org>2001-04-25 07:07:52 +0000
commitcdc83afc7f1e444c4646840f48592b7ff524fbea (patch)
tree1d205c2b7e9b1a72323178bdb64ac082cbe816a5 /sys/kern/vfs_export.c
parent3a77c500a93ed027c8d6959da8f6ecc3c7752441 (diff)
downloadFreeBSD-src-cdc83afc7f1e444c4646840f48592b7ff524fbea.zip
FreeBSD-src-cdc83afc7f1e444c4646840f48592b7ff524fbea.tar.gz
Move the netexport structure from the fs-specific mountstructure
to struct mount. This makes the "struct netexport *" paramter to the vfs_export and vfs_checkexport interface unneeded. Consequently that all non-stacking filesystems can use vfs_stdcheckexp(). At the same time, make it a pointer to a struct netexport in struct mount, so that we can remove the bogus AF_MAX and #include <net/radix.h> from <sys/mount.h>
Diffstat (limited to 'sys/kern/vfs_export.c')
-rw-r--r--sys/kern/vfs_export.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 352b83e..4bb58fe 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -73,7 +73,7 @@
#include <sys/vnode.h>
#include <machine/limits.h>
-
+#include <net/radix.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
@@ -259,6 +259,23 @@ static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep,
struct export_args *argp));
/*
+ * Network address lookup element
+ */
+struct netcred {
+ struct radix_node netc_rnodes[2];
+ 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 */
+};
+
+/*
* Initialize the vnode management data structures.
*/
static void
@@ -2448,22 +2465,31 @@ vfs_free_addrlist(nep)
* the structure is described in sys/mount.h
*/
int
-vfs_export(mp, nep, argp)
+vfs_export(mp, argp)
struct mount *mp;
- struct netexport *nep;
struct export_args *argp;
{
+ struct netexport *nep;
int error;
+ nep = mp->mnt_export;
if (argp->ex_flags & MNT_DELEXPORT) {
+ if (nep == NULL)
+ return (EINVAL);
if (mp->mnt_flag & MNT_EXPUBLIC) {
vfs_setpublicfs(NULL, NULL, NULL);
mp->mnt_flag &= ~MNT_EXPUBLIC;
}
vfs_free_addrlist(nep);
+ mp->mnt_export = NULL;
+ free(nep, M_MOUNT);
mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
}
if (argp->ex_flags & MNT_EXPORTED) {
+ if (nep == NULL) {
+ nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO);
+ mp->mnt_export = nep;
+ }
if (argp->ex_flags & MNT_EXPUBLIC) {
if ((error = vfs_setpublicfs(mp, nep, argp)) != 0)
return (error);
@@ -2563,15 +2589,18 @@ vfs_setpublicfs(mp, nep, argp)
* access rights (read/write/etc).
*/
struct netcred *
-vfs_export_lookup(mp, nep, nam)
+vfs_export_lookup(mp, nam)
register struct mount *mp;
- struct netexport *nep;
struct sockaddr *nam;
{
+ struct netexport *nep;
register struct netcred *np;
register struct radix_node_head *rnh;
struct sockaddr *saddr;
+ nep = mp->mnt_export;
+ if (nep == NULL)
+ return (NULL);
np = NULL;
if (mp->mnt_flag & MNT_EXPORTED) {
/*
@@ -3176,3 +3205,30 @@ privcheck:
return ((acc_mode & VADMIN) ? EPERM : EACCES);
}
+
+/*
+ * XXX: This comment comes from the deprecated ufs_check_export()
+ * XXX: and may not entirely apply, but lacking something better:
+ * This is the generic part of fhtovp called after the underlying
+ * filesystem has validated the file handle.
+ *
+ * Verify that a host should have access to a filesystem.
+ */
+
+int
+vfs_stdcheckexp(mp, nam, extflagsp, credanonp)
+ struct mount *mp;
+ struct sockaddr *nam;
+ int *extflagsp;
+ struct ucred **credanonp;
+{
+ struct netcred *np;
+
+ np = vfs_export_lookup(mp, nam);
+ if (np == NULL)
+ return (EACCES);
+ *extflagsp = np->netc_exflags;
+ *credanonp = &np->netc_anon;
+ return (0);
+}
+
OpenPOWER on IntegriCloud