summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c30
-rw-r--r--sys/fs/cd9660/iso.h1
-rw-r--r--sys/fs/hpfs/hpfs.h2
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c17
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c24
-rw-r--r--sys/fs/msdosfs/msdosfsmount.h1
-rw-r--r--sys/fs/ntfs/ntfs.h2
-rw-r--r--sys/fs/ntfs/ntfs_vfsops.c18
-rw-r--r--sys/gnu/ext2fs/ext2_mount.h2
-rw-r--r--sys/gnu/ext2fs/ext2_vfsops.c4
-rw-r--r--sys/gnu/fs/ext2fs/ext2_mount.h2
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vfsops.c4
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c30
-rw-r--r--sys/isofs/cd9660/iso.h1
-rw-r--r--sys/kern/vfs_default.c10
-rw-r--r--sys/kern/vfs_export.c66
-rw-r--r--sys/kern/vfs_subr.c66
-rw-r--r--sys/msdosfs/msdosfs_vfsops.c24
-rw-r--r--sys/msdosfs/msdosfsmount.h1
-rw-r--r--sys/ntfs/ntfs.h2
-rw-r--r--sys/ntfs/ntfs_vfsops.c18
-rw-r--r--sys/sys/mount.h31
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c4
-rw-r--r--sys/ufs/ifs/ifs_vfsops.c2
-rw-r--r--sys/ufs/mfs/mfs_vfsops.c4
-rw-r--r--sys/ufs/ufs/ufs_extern.h3
-rw-r--r--sys/ufs/ufs/ufs_vfsops.c29
-rw-r--r--sys/ufs/ufs/ufsmount.h2
28 files changed, 174 insertions, 226 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index 0228988..276718f 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -73,8 +73,6 @@ static int cd9660_root __P((struct mount *, struct vnode **));
static int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
static int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
static int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **));
-static int cd9660_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
static int cd9660_vptofh __P((struct vnode *, struct fid *));
static struct vfsops cd9660_vfsops = {
@@ -87,7 +85,7 @@ static struct vfsops cd9660_vfsops = {
vfs_stdsync,
cd9660_vget,
cd9660_fhtovp,
- cd9660_checkexp,
+ vfs_stdcheckexp,
cd9660_vptofh,
cd9660_init,
cd9660_uninit,
@@ -207,7 +205,7 @@ cd9660_mount(mp, path, data, ndp, p)
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOISOFS(mp);
if (args.fspec == 0)
- return (vfs_export(mp, &imp->im_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
/*
* Not an update, or updating the name: look up the name
@@ -653,30 +651,6 @@ cd9660_fhtovp(mp, fhp, vpp)
}
int
-cd9660_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
- register struct netcred *np;
- register struct iso_mnt *imp;
-
- imp = VFSTOISOFS(mp);
-
- /*
- * 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;
ino_t ino;
diff --git a/sys/fs/cd9660/iso.h b/sys/fs/cd9660/iso.h
index 2da3d82..b62c723 100644
--- a/sys/fs/cd9660/iso.h
+++ b/sys/fs/cd9660/iso.h
@@ -235,7 +235,6 @@ struct iso_mnt {
int im_bmask;
int volume_space_size;
- struct netexport im_export;
char root[ISODCL (157, 190)];
int root_extent;
diff --git a/sys/fs/hpfs/hpfs.h b/sys/fs/hpfs/hpfs.h
index 0f07880..f354b6b 100644
--- a/sys/fs/hpfs/hpfs.h
+++ b/sys/fs/hpfs/hpfs.h
@@ -310,7 +310,9 @@ struct cpisec {
struct hpfsmount {
struct sublock hpm_su;
struct spblock hpm_sp;
+#if !defined(__FreeBSD__)
struct netexport hpm_export;
+#endif
struct mount * hpm_mp;
struct vnode * hpm_devvp;
dev_t hpm_dev;
diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c
index 2d40b2d..ec68f86 100644
--- a/sys/fs/hpfs/hpfs_vfsops.c
+++ b/sys/fs/hpfs/hpfs_vfsops.c
@@ -88,8 +88,6 @@ static int hpfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
static int hpfs_init __P((struct vfsconf *));
static int hpfs_uninit __P((struct vfsconf *));
-static int hpfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
#else /* defined(__NetBSD__) */
static int hpfs_mount __P((struct mount *, const char *, void *,
struct nameidata *, struct proc *));
@@ -101,20 +99,14 @@ static int hpfs_checkexp __P((struct mount *, struct mbuf *,
int *, struct ucred **));
#endif
+#if !defined(__FreeBSD__)
/*ARGSUSED*/
static int
hpfs_checkexp(mp, nam, exflagsp, credanonp)
-#if defined(__FreeBSD__)
- register struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-#else /* defined(__NetBSD__) */
register struct mount *mp;
struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
-#endif
{
register struct netcred *np;
register struct hpfsmount *hpm = VFSTOHPFS(mp);
@@ -130,6 +122,7 @@ hpfs_checkexp(mp, nam, exflagsp, credanonp)
*credanonp = &np->netc_anon;
return (0);
}
+#endif
#if !defined(__FreeBSD__)
/*ARGSUSED*/
@@ -222,7 +215,11 @@ hpfs_mount (
if (args.fspec == 0) {
dprintf(("export 0x%x\n",args.export.ex_flags));
+#if defined(__FreeBSD__)
+ err = vfs_export(mp, &args.export);
+#else /* defined(__NetBSD__) */
err = vfs_export(mp, &hpmp->hpm_export, &args.export);
+#endif
if (err) {
printf("hpfs_mount: vfs_export failed %d\n",
err);
@@ -741,7 +738,7 @@ static struct vfsops hpfs_vfsops = {
vfs_stdsync,
hpfs_vget,
hpfs_fhtovp,
- hpfs_checkexp,
+ vfs_stdcheckexp,
hpfs_vptofh,
hpfs_init,
hpfs_uninit,
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index 6cda3bd..2f04def 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -93,8 +93,6 @@ static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp,
struct proc *p, struct msdosfs_args *argp));
static int msdosfs_fhtovp __P((struct mount *, struct fid *,
struct vnode **));
-static int msdosfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
static int msdosfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
static int msdosfs_root __P((struct mount *, struct vnode **));
@@ -292,7 +290,7 @@ msdosfs_mount(mp, path, data, ndp, p)
/*
* Process export requests.
*/
- return (vfs_export(mp, &pmp->pm_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
}
/*
@@ -932,24 +930,6 @@ msdosfs_fhtovp(mp, fhp, vpp)
}
static int
-msdosfs_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *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);
-}
-
-static int
msdosfs_vptofh(vp, fhp)
struct vnode *vp;
struct fid *fhp;
@@ -976,7 +956,7 @@ static struct vfsops msdosfs_vfsops = {
msdosfs_sync,
vfs_stdvget,
msdosfs_fhtovp,
- msdosfs_checkexp,
+ vfs_stdcheckexp,
msdosfs_vptofh,
msdosfs_init,
msdosfs_uninit,
diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h
index da49190..1c9a890 100644
--- a/sys/fs/msdosfs/msdosfsmount.h
+++ b/sys/fs/msdosfs/msdosfsmount.h
@@ -92,7 +92,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 */
u_int16_t pm_u2w[128]; /* Local->Unicode table */
u_int8_t pm_ul[128]; /* Local upper->lower table */
u_int8_t pm_lu[128]; /* Local lower->upper table */
diff --git a/sys/fs/ntfs/ntfs.h b/sys/fs/ntfs/ntfs.h
index 9bf7751..d74fe6f 100644
--- a/sys/fs/ntfs/ntfs.h
+++ b/sys/fs/ntfs/ntfs.h
@@ -255,7 +255,9 @@ struct ntfsmount {
cn_t ntm_cfree;
struct ntvattrdef *ntm_ad;
int ntm_adnum;
+#if !defined(__FreeBSD__)
struct netexport ntm_export; /* export information */
+#endif
};
#define ntm_mftcn ntm_bootfile.bf_mftcn
diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c
index 89a7dd7..b6fde8e 100644
--- a/sys/fs/ntfs/ntfs_vfsops.c
+++ b/sys/fs/ntfs/ntfs_vfsops.c
@@ -99,8 +99,6 @@ struct sockaddr;
static int ntfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
static int ntfs_init __P((struct vfsconf *));
-static int ntfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
#elif defined(__NetBSD__)
static int ntfs_mount __P((struct mount *, const char *, void *,
struct nameidata *, struct proc *));
@@ -116,19 +114,13 @@ static int ntfs_checkexp __P((struct mount *, struct mbuf *,
* Verify a remote client has export rights and return these rights via.
* exflagsp and credanonp.
*/
+#if !defined(__FreeBSD__)
static int
ntfs_checkexp(mp, nam, exflagsp, credanonp)
-#if defined(__FreeBSD__)
- register struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-#else /* defined(__NetBSD__) */
register struct mount *mp;
struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
-#endif
{
register struct netcred *np;
register struct ntfsmount *ntm = VFSTONTFS(mp);
@@ -139,11 +131,11 @@ ntfs_checkexp(mp, nam, exflagsp, credanonp)
np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
if (np == NULL)
return (EACCES);
-
*exflagsp = np->netc_exflags;
*credanonp = &np->netc_anon;
return (0);
}
+#endif
#if defined(__NetBSD__)
/*ARGSUSED*/
@@ -306,8 +298,12 @@ ntfs_mount (
* Process export requests. Jumping to "success"
* will return the vfs_export() error code.
*/
+#if defined(__FreeBSD__)
+ err = vfs_export(mp, &args.export);
+#else /* defined(__NetBSD__) */
struct ntfsmount *ntm = VFSTONTFS(mp);
err = vfs_export(mp, &ntm->ntm_export, &args.export);
+#endif
goto success;
}
@@ -1007,7 +1003,7 @@ static struct vfsops ntfs_vfsops = {
vfs_stdsync,
ntfs_vget,
ntfs_fhtovp,
- ntfs_checkexp,
+ vfs_stdcheckexp,
ntfs_vptofh,
ntfs_init,
ntfs_uninit,
diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h
index 900c81e..f5b93f5 100644
--- a/sys/gnu/ext2fs/ext2_mount.h
+++ b/sys/gnu/ext2fs/ext2_mount.h
@@ -68,7 +68,6 @@ struct timeval;
struct ucred;
struct uio;
struct vnode;
-struct netexport;
struct ufs_extattr_per_mount;
/* This structure describes the UFS specific mount structure data. */
@@ -94,7 +93,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 */
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c
index 263db6d..5f7118e 100644
--- a/sys/gnu/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/ext2fs/ext2_vfsops.c
@@ -96,7 +96,7 @@ static struct vfsops ext2fs_vfsops = {
ext2_sync,
ext2_vget,
ext2_fhtovp,
- ufs_check_export,
+ vfs_stdcheckexp,
ext2_vptofh,
ext2_init,
vfs_stduninit,
@@ -264,7 +264,7 @@ ext2_mount(mp, path, data, ndp, p)
/*
* Process export requests.
*/
- return (vfs_export(mp, &ump->um_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
}
/*
diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h
index 900c81e..f5b93f5 100644
--- a/sys/gnu/fs/ext2fs/ext2_mount.h
+++ b/sys/gnu/fs/ext2fs/ext2_mount.h
@@ -68,7 +68,6 @@ struct timeval;
struct ucred;
struct uio;
struct vnode;
-struct netexport;
struct ufs_extattr_per_mount;
/* This structure describes the UFS specific mount structure data. */
@@ -94,7 +93,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 */
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c
index 263db6d..5f7118e 100644
--- a/sys/gnu/fs/ext2fs/ext2_vfsops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c
@@ -96,7 +96,7 @@ static struct vfsops ext2fs_vfsops = {
ext2_sync,
ext2_vget,
ext2_fhtovp,
- ufs_check_export,
+ vfs_stdcheckexp,
ext2_vptofh,
ext2_init,
vfs_stduninit,
@@ -264,7 +264,7 @@ ext2_mount(mp, path, data, ndp, p)
/*
* Process export requests.
*/
- return (vfs_export(mp, &ump->um_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
}
/*
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index 0228988..276718f 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -73,8 +73,6 @@ static int cd9660_root __P((struct mount *, struct vnode **));
static int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
static int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
static int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **));
-static int cd9660_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
static int cd9660_vptofh __P((struct vnode *, struct fid *));
static struct vfsops cd9660_vfsops = {
@@ -87,7 +85,7 @@ static struct vfsops cd9660_vfsops = {
vfs_stdsync,
cd9660_vget,
cd9660_fhtovp,
- cd9660_checkexp,
+ vfs_stdcheckexp,
cd9660_vptofh,
cd9660_init,
cd9660_uninit,
@@ -207,7 +205,7 @@ cd9660_mount(mp, path, data, ndp, p)
if (mp->mnt_flag & MNT_UPDATE) {
imp = VFSTOISOFS(mp);
if (args.fspec == 0)
- return (vfs_export(mp, &imp->im_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
/*
* Not an update, or updating the name: look up the name
@@ -653,30 +651,6 @@ cd9660_fhtovp(mp, fhp, vpp)
}
int
-cd9660_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
- register struct netcred *np;
- register struct iso_mnt *imp;
-
- imp = VFSTOISOFS(mp);
-
- /*
- * 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;
ino_t ino;
diff --git a/sys/isofs/cd9660/iso.h b/sys/isofs/cd9660/iso.h
index 2da3d82..b62c723 100644
--- a/sys/isofs/cd9660/iso.h
+++ b/sys/isofs/cd9660/iso.h
@@ -235,7 +235,6 @@ struct iso_mnt {
int im_bmask;
int volume_space_size;
- struct netexport im_export;
char root[ISODCL (157, 190)];
int root_extent;
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 1341129..f1dd5e9 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -708,16 +708,6 @@ vfs_stdfhtovp (mp, fhp, vpp)
return (EOPNOTSUPP);
}
-int
-vfs_stdcheckexp (mp, nam, extflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *extflagsp;
- struct ucred **credanonp;
-{
- return (EOPNOTSUPP);
-}
-
int
vfs_stdinit (vfsp)
struct vfsconf *vfsp;
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);
+}
+
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 352b83e..4bb58fe 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.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);
+}
+
diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c
index 6cda3bd..2f04def 100644
--- a/sys/msdosfs/msdosfs_vfsops.c
+++ b/sys/msdosfs/msdosfs_vfsops.c
@@ -93,8 +93,6 @@ static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp,
struct proc *p, struct msdosfs_args *argp));
static int msdosfs_fhtovp __P((struct mount *, struct fid *,
struct vnode **));
-static int msdosfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
static int msdosfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
static int msdosfs_root __P((struct mount *, struct vnode **));
@@ -292,7 +290,7 @@ msdosfs_mount(mp, path, data, ndp, p)
/*
* Process export requests.
*/
- return (vfs_export(mp, &pmp->pm_export, &args.export));
+ return (vfs_export(mp, &args.export));
}
}
/*
@@ -932,24 +930,6 @@ msdosfs_fhtovp(mp, fhp, vpp)
}
static int
-msdosfs_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *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);
-}
-
-static int
msdosfs_vptofh(vp, fhp)
struct vnode *vp;
struct fid *fhp;
@@ -976,7 +956,7 @@ static struct vfsops msdosfs_vfsops = {
msdosfs_sync,
vfs_stdvget,
msdosfs_fhtovp,
- msdosfs_checkexp,
+ vfs_stdcheckexp,
msdosfs_vptofh,
msdosfs_init,
msdosfs_uninit,
diff --git a/sys/msdosfs/msdosfsmount.h b/sys/msdosfs/msdosfsmount.h
index da49190..1c9a890 100644
--- a/sys/msdosfs/msdosfsmount.h
+++ b/sys/msdosfs/msdosfsmount.h
@@ -92,7 +92,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 */
u_int16_t pm_u2w[128]; /* Local->Unicode table */
u_int8_t pm_ul[128]; /* Local upper->lower table */
u_int8_t pm_lu[128]; /* Local lower->upper table */
diff --git a/sys/ntfs/ntfs.h b/sys/ntfs/ntfs.h
index 9bf7751..d74fe6f 100644
--- a/sys/ntfs/ntfs.h
+++ b/sys/ntfs/ntfs.h
@@ -255,7 +255,9 @@ struct ntfsmount {
cn_t ntm_cfree;
struct ntvattrdef *ntm_ad;
int ntm_adnum;
+#if !defined(__FreeBSD__)
struct netexport ntm_export; /* export information */
+#endif
};
#define ntm_mftcn ntm_bootfile.bf_mftcn
diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c
index 89a7dd7..b6fde8e 100644
--- a/sys/ntfs/ntfs_vfsops.c
+++ b/sys/ntfs/ntfs_vfsops.c
@@ -99,8 +99,6 @@ struct sockaddr;
static int ntfs_mount __P((struct mount *, char *, caddr_t,
struct nameidata *, struct proc *));
static int ntfs_init __P((struct vfsconf *));
-static int ntfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
#elif defined(__NetBSD__)
static int ntfs_mount __P((struct mount *, const char *, void *,
struct nameidata *, struct proc *));
@@ -116,19 +114,13 @@ static int ntfs_checkexp __P((struct mount *, struct mbuf *,
* Verify a remote client has export rights and return these rights via.
* exflagsp and credanonp.
*/
+#if !defined(__FreeBSD__)
static int
ntfs_checkexp(mp, nam, exflagsp, credanonp)
-#if defined(__FreeBSD__)
- register struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-#else /* defined(__NetBSD__) */
register struct mount *mp;
struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
-#endif
{
register struct netcred *np;
register struct ntfsmount *ntm = VFSTONTFS(mp);
@@ -139,11 +131,11 @@ ntfs_checkexp(mp, nam, exflagsp, credanonp)
np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
if (np == NULL)
return (EACCES);
-
*exflagsp = np->netc_exflags;
*credanonp = &np->netc_anon;
return (0);
}
+#endif
#if defined(__NetBSD__)
/*ARGSUSED*/
@@ -306,8 +298,12 @@ ntfs_mount (
* Process export requests. Jumping to "success"
* will return the vfs_export() error code.
*/
+#if defined(__FreeBSD__)
+ err = vfs_export(mp, &args.export);
+#else /* defined(__NetBSD__) */
struct ntfsmount *ntm = VFSTONTFS(mp);
err = vfs_export(mp, &ntm->ntm_export, &args.export);
+#endif
goto success;
}
@@ -1007,7 +1003,7 @@ static struct vfsops ntfs_vfsops = {
vfs_stdsync,
ntfs_vget,
ntfs_fhtovp,
- ntfs_checkexp,
+ vfs_stdcheckexp,
ntfs_vptofh,
ntfs_init,
ntfs_uninit,
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index c522c18..aef5ac5 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -43,6 +43,9 @@
#include <sys/lock.h>
#endif
+struct netcred;
+struct netexport;
+
typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
/*
@@ -118,6 +121,7 @@ struct mount {
qaddr_t mnt_data; /* private data */
time_t mnt_time; /* last time written*/
u_int mnt_iosize_max; /* max IO request size */
+ struct netexport *mnt_export; /* export list */
};
#endif /* _KERNEL */
@@ -378,27 +382,6 @@ struct vfsops {
}; \
DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
-#include <net/radix.h>
-
-#define AF_MAX 35 /* XXX */
-
-/*
- * 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 */
-};
-
extern char *mountrootfsname;
/*
@@ -413,10 +396,10 @@ int vfs_lock __P((struct mount *)); /* lock a vfs */
void vfs_msync __P((struct mount *, int));
void vfs_unlock __P((struct mount *)); /* unlock a vfs */
int vfs_busy __P((struct mount *, int, struct mtx *, struct proc *));
-int vfs_export /* process mount export info */
- __P((struct mount *, struct netexport *, struct export_args *));
+int vfs_export /* process mount export info */
+ __P((struct mount *, struct export_args *));
struct netcred *vfs_export_lookup /* lookup host in fs export list */
- __P((struct mount *, struct netexport *, struct sockaddr *));
+ __P((struct mount *, struct sockaddr *));
int vfs_allocate_syncvnode __P((struct mount *));
void vfs_getnewfsid __P((struct mount *));
dev_t vfs_getrootfsid __P((struct mount *));
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 58a2dfc..7d48fdb 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -83,7 +83,7 @@ static struct vfsops ufs_vfsops = {
ffs_sync,
ffs_vget,
ffs_fhtovp,
- ufs_check_export,
+ vfs_stdcheckexp,
ffs_vptofh,
ffs_init,
vfs_stduninit,
@@ -268,7 +268,7 @@ ffs_mount(mp, path, data, ndp, p)
* If not updating name, process export requests.
*/
if (args.fspec == 0)
- return (vfs_export(mp, &ump->um_export, &args.export));
+ return (vfs_export(mp, &args.export));
/*
* If this is a snapshot request, take the snapshot.
*/
diff --git a/sys/ufs/ifs/ifs_vfsops.c b/sys/ufs/ifs/ifs_vfsops.c
index f0e2e8c..41b1d5f 100644
--- a/sys/ufs/ifs/ifs_vfsops.c
+++ b/sys/ufs/ifs/ifs_vfsops.c
@@ -85,7 +85,7 @@ static struct vfsops ifs_vfsops = {
ffs_sync,
ifs_vget,
ffs_fhtovp,
- ufs_check_export,
+ vfs_stdcheckexp,
ffs_vptofh,
ifs_init,
vfs_stduninit,
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c
index 2f56b1a..4ac0002 100644
--- a/sys/ufs/mfs/mfs_vfsops.c
+++ b/sys/ufs/mfs/mfs_vfsops.c
@@ -109,7 +109,7 @@ static struct vfsops mfs_vfsops = {
ffs_sync,
ffs_vget,
ffs_fhtovp,
- ufs_check_export,
+ vfs_stdcheckexp,
ffs_vptofh,
mfs_init,
vfs_stduninit,
@@ -230,7 +230,7 @@ mfs_mount(mp, path, data, ndp, p)
* Process export requests. Jumping to "success"
* will return the vfs_export() error code.
*/
- err = vfs_export(mp, &ump->um_export, &args.export);
+ err = vfs_export(mp, &args.export);
goto success;
}
diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h
index 82704b6..251d4a0 100644
--- a/sys/ufs/ufs/ufs_extern.h
+++ b/sys/ufs/ufs/ufs_extern.h
@@ -42,6 +42,7 @@ struct direct;
struct indir;
struct inode;
struct mount;
+struct netcred;
struct proc;
struct sockaddr;
struct ucred;
@@ -61,8 +62,6 @@ int ufs_vnoperatespec __P((struct vop_generic_args *));
int ufs_bmap __P((struct vop_bmap_args *));
int ufs_bmaparray __P((struct vnode *, daddr_t, daddr_t *, struct indir *,
int *, int *, int *));
-int ufs_check_export __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
int ufs_fhtovp(register struct mount *, struct ufid *, struct vnode **);
int ufs_checkpath __P((struct inode *, struct inode *, struct ucred *));
void ufs_dirbad __P((struct inode *, doff_t, char *));
diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c
index 33346cf..73f8237 100644
--- a/sys/ufs/ufs/ufs_vfsops.c
+++ b/sys/ufs/ufs/ufs_vfsops.c
@@ -214,32 +214,3 @@ ufs_fhtovp(mp, ufhp, vpp)
return (0);
}
-
-/*
- * 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
-ufs_check_export(mp, nam, exflagsp, credanonp)
- register struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
- register struct netcred *np;
- register struct ufsmount *ump;;
-
- 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);
-}
diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h
index 900c81e..f5b93f5 100644
--- a/sys/ufs/ufs/ufsmount.h
+++ b/sys/ufs/ufs/ufsmount.h
@@ -68,7 +68,6 @@ struct timeval;
struct ucred;
struct uio;
struct vnode;
-struct netexport;
struct ufs_extattr_per_mount;
/* This structure describes the UFS specific mount structure data. */
@@ -94,7 +93,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 */
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int um_i_effnlink_valid; /* i_effnlink valid? */
OpenPOWER on IntegriCloud