mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
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>
This commit is contained in:
parent
40afc1048e
commit
a13234bb35
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75934
@ -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
|
||||
@ -652,30 +650,6 @@ cd9660_fhtovp(mp, fhp, vpp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -931,24 +929,6 @@ msdosfs_fhtovp(mp, fhp, vpp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
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;
|
||||
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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? */
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -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? */
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -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
|
||||
@ -652,30 +650,6 @@ cd9660_fhtovp(mp, fhp, vpp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
@ -258,6 +258,23 @@ static int vfs_free_netcred __P((struct radix_node *rn, void *w));
|
||||
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.
|
||||
*/
|
||||
@ -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 @@ vaccess(type, file_mode, file_uid, file_gid, acc_mode, cred, privused)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
@ -258,6 +258,23 @@ static int vfs_free_netcred __P((struct radix_node *rn, void *w));
|
||||
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.
|
||||
*/
|
||||
@ -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 @@ vaccess(type, file_mode, file_uid, file_gid, acc_mode, cred, privused)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -931,24 +929,6 @@ msdosfs_fhtovp(mp, fhp, vpp)
|
||||
return (0);
|
||||
}
|
||||
|
||||
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;
|
||||
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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 *));
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 *));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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? */
|
||||
|
Loading…
Reference in New Issue
Block a user