Subject: Making file handles useful outside of NFS
To: None <tech-kern@netbsd.org>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: tech-kern
Date: 02/25/1999 16:39:58
For one of the projects I'm working on, we want to use file handles to
access files (*). Right now, though, all the vfs_fhtovp calls contain
checks regarding the export status of the underlying filesystem. We want
to be able to use file handles outside of a file server context. We also
want to be able to use them from userland, which I'll discuss in another
EMail.
So I propose we split the current vfs_fhtovp VFS call into two calls, one
to do the export verification, and another to do the filehandle to vnode
conversion. Any code which calls the current vfs_fhtovp (currently only in
nfs_subs.c:nfsrv_fhtovp() ) just become a call to VFS_CHKEXP then
VFS_FHTOVP (assuming no errors).
Below I'm attaching patches which make this change for all the file
systems I saw in sys/conf/files: ffs, lfs, mfs, ext2fs, nfs, adosfs,
cd9660fs, msdosfs, fdescfs, kernfs, portalfs, procfs, nullfs, umapfs,
unionfs, coda, and filecorefs.
Thoughts?
Take care,
Bill
(*) We are experimenting with having userland daemons assist various vnode
ops. As such, we only have a vnode, not a path. We can readily turn the
vnode into a filehandle, but userland will need to then be able to use the
filehandle.
Index: adosfs/advfsops.c
===================================================================
RCS file: /cvs-src/src/sys/adosfs/advfsops.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 advfsops.c
--- advfsops.c 1999/02/16 22:53:45 1.1.1.2
+++ advfsops.c 1999/02/25 22:05:57
@@ -62,8 +62,9 @@
int adosfs_statfs __P((struct mount *, struct statfs *, 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 mbuf *,
- struct vnode **, int *, struct ucred **));
+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 *));
@@ -675,20 +676,15 @@
};
int
-adosfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+adosfs_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
struct ifid *ifhp = (struct ifid *)fhp;
- struct adosfsmount *amp = VFSTOADOSFS(mp);
#if 0
struct anode *ap;
#endif
- struct netcred *np;
struct vnode *nvp;
int error;
@@ -696,13 +692,6 @@
printf("adfhtovp(%x, %x, %x)\n", mp, fhp, vpp);
#endif
- /*
- * Get the export permission structure for this <mp, client> tuple.
- */
- np = vfs_export_lookup(mp, &->export, nam);
- if (np == NULL)
- return (EACCES);
-
if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) {
*vpp = NULLVP;
return (error);
@@ -716,6 +705,33 @@
}
#endif
*vpp = nvp;
+ return(0);
+}
+
+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);
@@ -814,5 +830,6 @@
adosfs_init,
adosfs_sysctl,
NULL, /* vfs_mountroot */
+ adosfs_checkexp,
adosfs_vnodeopv_descs,
};
Index: coda/coda_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/coda/coda_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 coda_vfsops.c
--- coda_vfsops.c 1998/12/21 18:14:07 1.1.1.1
+++ coda_vfsops.c 1999/02/24 19:55:00
@@ -257,13 +257,14 @@
coda_nb_statfs,
coda_sync,
coda_vget,
- (int (*) (struct mount *, struct fid *, struct mbuf *, struct vnode **,
- int *, struct ucred **))
+ (int (*) (struct mount *, struct fid *, struct vnode ** ))
eopnotsupp,
(int (*) (struct vnode *, struct fid *)) eopnotsupp,
coda_init,
coda_sysctl,
(int (*)(void)) eopnotsupp,
+ (int (*)(struct mount *, struct mbuf *, int *, struct ucred **))
+ eopnotsupp,
coda_vnodeopv_descs,
0
};
Index: filecorefs/filecore_extern.h
===================================================================
RCS file: /cvs-src/src/sys/filecorefs/filecore_extern.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 filecore_extern.h
--- filecore_extern.h 1998/12/21 18:14:05 1.1.1.1
+++ filecore_extern.h 1999/02/25 22:09:18
@@ -81,8 +81,9 @@
int filecore_statfs __P((struct mount *, struct statfs *, struct proc *));
int filecore_sync __P((struct mount *, int, struct ucred *, struct proc *));
int filecore_vget __P((struct mount *, ino_t, struct vnode **));
-int filecore_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int filecore_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int filecore_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int filecore_vptofh __P((struct vnode *, struct fid *));
void filecore_init __P((void));
int filecore_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
Index: filecorefs/filecore_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/filecorefs/filecore_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 filecore_vfsops.c
--- filecore_vfsops.c 1998/12/21 18:14:06 1.1.1.1
+++ filecore_vfsops.c 1999/02/25 22:15:57
@@ -81,6 +81,7 @@
filecore_init,
filecore_sysctl,
NULL, /* filecore_mountroot */
+ filecore_checkexp,
filecore_vnodeopv_descs,
};
@@ -492,28 +493,16 @@
/* ARGSUSED */
int
-filecore_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+filecore_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
struct ifid *ifhp = (struct ifid *)fhp;
- struct netcred *np;
- struct filecore_mnt *fcmp = VFSTOFILECORE(mp);
struct vnode *nvp;
struct filecore_node *ip;
int error;
- /*
- * Get the export permission structure for this <mp, client> tuple.
- */
- np = vfs_export_lookup(mp, &fcmp->fc_export, nam);
- if (np == NULL)
- return (EACCES);
-
if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) {
*vpp = NULLVP;
return (error);
@@ -523,7 +512,29 @@
vput(nvp);
*vpp = NULLVP;
return (ESTALE);
- } *vpp = nvp;
+ }
+ *vpp = nvp;
+ 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);
Index: isofs/cd9660/cd9660_extern.h
===================================================================
RCS file: /cvs-src/src/sys/isofs/cd9660/cd9660_extern.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cd9660_extern.h
--- cd9660_extern.h 1998/12/21 18:12:41 1.1.1.1
+++ cd9660_extern.h 1999/02/24 19:59:16
@@ -92,8 +92,9 @@
int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
int cd9660_sync __P((struct mount *, int, struct ucred *, struct proc *));
int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
-int cd9660_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int cd9660_check_export __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int cd9660_vptofh __P((struct vnode *, struct fid *));
void cd9660_init __P((void));
int cd9660_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
Index: isofs/cd9660/cd9660_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/isofs/cd9660/cd9660_vfsops.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 cd9660_vfsops.c
--- cd9660_vfsops.c 1999/01/11 02:09:09 1.1.1.2
+++ cd9660_vfsops.c 1999/02/24 20:04:11
@@ -95,6 +95,7 @@
cd9660_init,
cd9660_sysctl,
cd9660_mountroot,
+ cd9660_check_export,
cd9660_vnodeopv_descs,
};
@@ -561,18 +562,13 @@
/* ARGSUSED */
int
-cd9660_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+cd9660_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
struct ifid *ifhp = (struct ifid *)fhp;
register struct iso_node *ip;
- register struct netcred *np;
- register struct iso_mnt *imp = VFSTOISOFS(mp);
struct vnode *nvp;
int error;
@@ -581,13 +577,6 @@
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);
-
if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) {
*vpp = NULLVP;
return (error);
@@ -599,6 +588,32 @@
return (ESTALE);
}
*vpp = nvp;
+ return (0);
+}
+
+/* ARGSUSED */
+int
+cd9660_check_export(mp, nam, exflagsp, credanonp)
+ register struct mount *mp;
+ struct mbuf *nam;
+ int *exflagsp;
+ struct ucred **credanonp;
+{
+ register struct netcred *np;
+ register 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);
Index: miscfs/fdesc/fdesc_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/fdesc/fdesc_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 fdesc_vfsops.c
--- fdesc_vfsops.c 1998/12/21 18:13:16 1.1.1.1
+++ fdesc_vfsops.c 1999/02/24 20:14:50
@@ -71,8 +71,9 @@
int fdesc_statfs __P((struct mount *, struct statfs *, struct proc *));
int fdesc_sync __P((struct mount *, int, struct ucred *, struct proc *));
int fdesc_vget __P((struct mount *, ino_t, struct vnode **));
-int fdesc_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int fdesc_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int fdesc_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int fdesc_vptofh __P((struct vnode *, struct fid *));
int fdesc_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -280,11 +281,20 @@
/*ARGSUSED*/
int
-fdesc_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+fdesc_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+/*ARGSUSED*/
+int
+fdesc_checkexp(mp, nam, exflagsp, credanonp)
+ struct mount *mp;
+ struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
{
@@ -336,5 +346,6 @@
fdesc_init,
fdesc_sysctl,
NULL, /* vfs_mountroot */
+ fdesc_checkexp,
fdesc_vnodeopv_descs,
};
Index: miscfs/kernfs/kernfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/kernfs/kernfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 kernfs_vfsops.c
--- kernfs_vfsops.c 1998/12/21 18:13:17 1.1.1.1
+++ kernfs_vfsops.c 1999/02/24 21:01:40
@@ -73,8 +73,9 @@
struct proc *));
int kernfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int kernfs_vget __P((struct mount *, ino_t, struct vnode **));
-int kernfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int kernfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int kernfs_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int kernfs_vptofh __P((struct vnode *, struct fid *));
int kernfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -310,11 +311,20 @@
/*ARGSUSED*/
int
-kernfs_fhtovp(mp, fhp, mb, vpp, what, anon)
+kernfs_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *mb;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+/*ARGSUSED*/
+int
+kernfs_checkexp(mp, mb, what, anon)
+ struct mount *mp;
+ struct mbuf *mb;
int *what;
struct ucred **anon;
{
@@ -367,5 +377,6 @@
kernfs_init,
kernfs_sysctl,
NULL, /* vfs_mountroot */
+ kernfs_checkexp,
kernfs_vnodeopv_descs,
};
Index: miscfs/nullfs/null_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/nullfs/null_vfsops.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 null_vfsops.c
--- null_vfsops.c 1999/01/25 01:07:22 1.1.1.2
+++ null_vfsops.c 1999/02/24 21:02:27
@@ -66,8 +66,9 @@
int nullfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int nullfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int nullfs_vget __P((struct mount *, ino_t, struct vnode **));
-int nullfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int nullfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int nullfs_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int nullfs_vptofh __P((struct vnode *, struct fid *));
int nullfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -344,11 +345,19 @@
}
int
-nullfs_fhtovp(mp, fidp, nam, vpp, exflagsp, credanonp)
+nullfs_fhtovp(mp, fidp, vpp)
struct mount *mp;
struct fid *fidp;
- struct mbuf *nam;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+int
+nullfs_checkexp(mp, nam, exflagsp, credanonp)
+ struct mount *mp;
+ struct mbuf *nam;
int *exflagsp;
struct ucred**credanonp;
{
@@ -400,5 +409,6 @@
nullfs_init,
nullfs_sysctl,
NULL, /* vfs_mountroot */
+ nullfs_checkexp,
nullfs_vnodeopv_descs,
};
Index: miscfs/portal/portal_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/portal/portal_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 portal_vfsops.c
--- portal_vfsops.c 1998/12/21 18:13:18 1.1.1.1
+++ portal_vfsops.c 1999/02/24 20:49:05
@@ -77,8 +77,9 @@
int portal_statfs __P((struct mount *, struct statfs *, struct proc *));
int portal_sync __P((struct mount *, int, struct ucred *, struct proc *));
int portal_vget __P((struct mount *, ino_t, struct vnode **));
-int portal_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int portal_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int portal_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int portal_vptofh __P((struct vnode *, struct fid *));
int portal_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -295,11 +296,19 @@
}
int
-portal_fhtovp(mp, fhp, mb, vpp, what, anon)
+portal_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *mb;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+int
+portal_checkexp(mp, mb, what, anon)
+ struct mount *mp;
+ struct mbuf *mb;
int *what;
struct ucred **anon;
{
@@ -351,5 +360,6 @@
portal_init,
portal_sysctl,
NULL, /* vfs_mountroot */
+ portal_checkexp,
portal_vnodeopv_descs,
};
Index: miscfs/procfs/procfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/procfs/procfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 procfs_vfsops.c
--- procfs_vfsops.c 1998/12/21 18:13:19 1.1.1.1
+++ procfs_vfsops.c 1999/02/24 21:04:30
@@ -70,8 +70,9 @@
int procfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int procfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int procfs_vget __P((struct mount *, ino_t, struct vnode **));
-int procfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int procfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int procfs_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int procfs_vptofh __P((struct vnode *, struct fid *));
int procfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -220,11 +221,20 @@
/*ARGSUSED*/
int
-procfs_fhtovp(mp, fhp, mb, vpp, what, anon)
+procfs_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *mb;
struct vnode **vpp;
+{
+
+ return (EINVAL);
+}
+
+/*ARGSUSED*/
+int
+procfs_checkexp(mp, mb, what, anon)
+ struct mount *mp;
+ struct mbuf *mb;
int *what;
struct ucred **anon;
{
@@ -282,5 +292,6 @@
procfs_init,
procfs_sysctl,
NULL, /* vfs_mountroot */
+ procfs_checkexp,
procfs_vnodeopv_descs,
};
Index: miscfs/umapfs/umap_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/umapfs/umap_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 umap_vfsops.c
--- umap_vfsops.c 1998/12/21 18:13:20 1.1.1.1
+++ umap_vfsops.c 1999/02/24 21:00:24
@@ -65,8 +65,9 @@
int umapfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int umapfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int umapfs_vget __P((struct mount *, ino_t, struct vnode **));
-int umapfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int umapfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int umapfs_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int umapfs_vptofh __P((struct vnode *, struct fid *));
int umapfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -386,11 +387,19 @@
}
int
-umapfs_fhtovp(mp, fidp, nam, vpp, exflagsp, credanonp)
+umapfs_fhtovp(mp, fidp, vpp)
struct mount *mp;
struct fid *fidp;
- struct mbuf *nam;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+int
+umapfs_checkexp(mp, nam, exflagsp, credanonp)
+ struct mount *mp;
+ struct mbuf *nam;
int *exflagsp;
struct ucred**credanonp;
{
@@ -442,5 +451,6 @@
umapfs_init,
umapfs_sysctl,
NULL, /* vfs_mountroot */
+ umapfs_checkexp,
umapfs_vnodeopv_descs,
};
Index: miscfs/union/union_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/miscfs/union/union_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 union_vfsops.c
--- union_vfsops.c 1998/12/21 18:13:21 1.1.1.1
+++ union_vfsops.c 1999/02/24 21:00:42
@@ -67,8 +67,9 @@
int union_statfs __P((struct mount *, struct statfs *, struct proc *));
int union_sync __P((struct mount *, int, struct ucred *, struct proc *));
int union_vget __P((struct mount *, ino_t, struct vnode **));
-int union_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int union_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int union_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int union_vptofh __P((struct vnode *, struct fid *));
int union_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -511,13 +512,22 @@
/*ARGSUSED*/
int
-union_fhtovp(mp, fidp, nam, vpp, exflagsp, credanonp)
+union_fhtovp(mp, fidp, vpp)
struct mount *mp;
struct fid *fidp;
- struct mbuf *nam;
struct vnode **vpp;
+{
+
+ return (EOPNOTSUPP);
+}
+
+/*ARGSUSED*/
+int
+union_checkexp(mp, nam, exflagsp, credanonp)
+ struct mount *mp;
+ struct mbuf *nam;
int *exflagsp;
- struct ucred **credanonp;
+ struct ucred**credanonp;
{
return (EOPNOTSUPP);
@@ -568,5 +578,6 @@
union_init,
union_sysctl,
NULL, /* vfs_mountroot */
+ union_checkexp,
union_vnodeopv_descs,
};
Index: msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 msdosfs_vfsops.c
--- msdosfs_vfsops.c 1998/12/21 18:13:22 1.1.1.1
+++ msdosfs_vfsops.c 1999/02/24 21:11:37
@@ -86,8 +86,9 @@
int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int msdosfs_vget __P((struct mount *, ino_t, struct vnode **));
-int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int msdosfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int msdosfs_checkexp __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
int msdosfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
@@ -121,6 +122,7 @@
msdosfs_init,
msdosfs_sysctl,
msdosfs_mountroot,
+ msdosfs_checkexp,
msdosfs_vnodeopv_descs,
};
@@ -913,29 +915,38 @@
}
int
-msdosfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+msdosfs_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
struct defid *defhp = (struct defid *) fhp;
struct denode *dep;
- struct netcred *np;
int error;
- np = vfs_export_lookup(mp, &pmp->pm_export, nam);
- if (np == NULL)
- return (EACCES);
error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep);
if (error) {
*vpp = NULLVP;
return (error);
}
*vpp = DETOV(dep);
+ return (0);
+}
+
+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);
Index: msdosfs/msdosfsmount.h
===================================================================
RCS file: /cvs-src/src/sys/msdosfs/msdosfsmount.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 msdosfsmount.h
--- msdosfsmount.h 1998/12/21 18:13:22 1.1.1.1
+++ msdosfsmount.h 1999/02/24 21:48:42
@@ -214,7 +214,8 @@
int msdosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
-int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
+int msdosfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
+int msdosfs_checkexp __P((struct mount *, struct mbuf *, int *, struct ucred **));
int msdosfs_vptofh __P((struct vnode *, struct fid *));
void msdosfs_init __P((void));
Index: nfs/nfs_subs.c
===================================================================
RCS file: /cvs-src/src/sys/nfs/nfs_subs.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 nfs_subs.c
--- nfs_subs.c 1998/12/21 18:13:46 1.1.1.1
+++ nfs_subs.c 1999/02/24 21:59:28
@@ -2217,7 +2217,10 @@
mp = vfs_getvfs(&fhp->fh_fsid);
if (!mp)
return (ESTALE);
- error = VFS_FHTOVP(mp, &fhp->fh_fid, nam, vpp, &exflags, &credanon);
+ error = VFS_CHKEXP(mp, nam, &exflags, &credanon);
+ if (error)
+ return (error);
+ error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
if (error)
return (error);
Index: nfs/nfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/nfs/nfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 nfs_vfsops.c
--- nfs_vfsops.c 1998/12/21 18:13:46 1.1.1.1
+++ nfs_vfsops.c 1999/02/24 22:50:41
@@ -109,6 +109,7 @@
nfs_vfs_init,
nfs_sysctl,
nfs_mountroot,
+ nfs_checkexp,
nfs_vnodeopv_descs,
};
@@ -990,11 +991,20 @@
*/
/* ARGSUSED */
int
-nfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+nfs_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
+{
+
+ return (EINVAL);
+}
+
+/* ARGSUSED */
+int
+nfs_checkexp(mp, nam, exflagsp, credanonp)
+ register struct mount *mp;
+ struct mbuf *nam;
int *exflagsp;
struct ucred **credanonp;
{
Index: nfs/nfsmount.h
===================================================================
RCS file: /cvs-src/src/sys/nfs/nfsmount.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 nfsmount.h
--- nfsmount.h 1998/12/21 18:13:46 1.1.1.1
+++ nfsmount.h 1999/02/24 22:00:57
@@ -184,8 +184,9 @@
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 mbuf *nam,
- struct vnode **vpp, int *exflagsp, struct ucred **credanonp));
+int nfs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp));
+int nfs_checkexp __P((struct mount *mp, struct mbuf *nam, int *exflagsp,
+ struct ucred **credanonp));
int nfs_vptofh __P((struct vnode *vp, struct fid *fhp));
int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
struct proc *));
Index: sys/mount.h
===================================================================
RCS file: /cvs-src/src/sys/sys/mount.h,v
retrieving revision 1.2
diff -u -r1.2 mount.h
--- mount.h 1999/01/26 22:51:01 1.2
+++ mount.h 1999/02/24 22:54:05
@@ -293,13 +293,14 @@
int (*vfs_vget) __P((struct mount *mp, ino_t ino,
struct vnode **vpp));
int (*vfs_fhtovp) __P((struct mount *mp, struct fid *fhp,
- struct mbuf *nam, struct vnode **vpp,
- int *exflagsp, struct ucred **credanonp));
+ struct vnode **vpp));
int (*vfs_vptofh) __P((struct vnode *vp, struct fid *fhp));
void (*vfs_init) __P((void));
int (*vfs_sysctl) __P((int *, u_int, void *, size_t *, void *,
size_t, struct proc *));
int (*vfs_mountroot) __P((void));
+ int (*vfs_checkexp) __P((struct mount *mp, struct mbuf *nam,
+ int *extflagsp, struct ucred **credanonp));
struct vnodeopv_desc **vfs_opv_descs;
int vfs_refcount;
LIST_ENTRY(vfsops) vfs_list;
@@ -314,8 +315,9 @@
#define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
#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, NAM, VPP, EXFLG, CRED) \
- (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, NAM, VPP, EXFLG, CRED)
+#define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
+#define VFS_CHKEXP(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)
#endif /* _KERNEL */
Index: ufs/ext2fs/ext2fs_extern.h
===================================================================
RCS file: /cvs-src/src/sys/ufs/ext2fs/ext2fs_extern.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ext2fs_extern.h
--- ext2fs_extern.h 1998/12/21 18:13:56 1.1.1.1
+++ ext2fs_extern.h 1999/02/25 19:01:27
@@ -110,8 +110,7 @@
int ext2fs_statfs __P((struct mount *, struct statfs *, struct proc *));
int ext2fs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int ext2fs_vget __P((struct mount *, ino_t, struct vnode **));
-int ext2fs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int ext2fs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
int ext2fs_vptofh __P((struct vnode *, struct fid *));
int ext2fs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
Index: ufs/ext2fs/ext2fs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 ext2fs_vfsops.c
--- ext2fs_vfsops.c 1999/02/16 23:17:08 1.1.1.2
+++ ext2fs_vfsops.c 1999/02/25 19:02:26
@@ -74,8 +74,6 @@
extern struct lock ufs_hashlock;
int ext2fs_sbupdate __P((struct ufsmount *, int));
-int ext2fs_check_export __P((struct mount *, struct ufid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
extern struct vnodeopv_desc ext2fs_vnodeop_opv_desc;
extern struct vnodeopv_desc ext2fs_specop_opv_desc;
@@ -103,6 +101,7 @@
ext2fs_init,
ext2fs_sysctl,
ext2fs_mountroot,
+ ufs_check_export,
ext2fs_vnodeopv_descs,
};
@@ -123,53 +122,7 @@
M_EXT2FSNODE);
}
-/*
- * 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, and if so
- * return a vnode for the presented file handle.
- */
-int
-ext2fs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp)
- register struct mount *mp;
- struct ufid *ufhp;
- struct mbuf *nam;
- struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
-{
- register struct inode *ip;
- register struct netcred *np;
- register struct ufsmount *ump = VFSTOUFS(mp);
- struct vnode *nvp;
- int error;
- /*
- * Get the export permission structure for this <mp, client> tuple.
- */
- np = vfs_export_lookup(mp, &ump->um_export, nam);
- if (np == NULL)
- return (EACCES);
-
- if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
- ip = VTOI(nvp);
- if (ip->i_e2fs_mode == 0 || ip->i_e2fs_dtime != 0 ||
- ip->i_e2fs_gen != ufhp->ufid_gen) {
- vput(nvp);
- *vpp = NULLVP;
- return (ESTALE);
- }
- *vpp = nvp;
- *exflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
- return (0);
-}
-
-
/*
* Called by main() when ext2fs is going to be mounted as root.
*
@@ -971,18 +924,16 @@
* - check that the inode number is valid
* - call ext2fs_vget() to get the locked inode
* - check for an unallocated inode (i_mode == 0)
- * - check that the given client host has export rights and return
- * those rights via. exflagsp and credanonp
*/
int
-ext2fs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+ext2fs_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
+ register struct inode *ip;
+ struct vnode *nvp;
+ int error;
register struct ufid *ufhp;
struct m_ext2fs *fs;
@@ -990,8 +941,21 @@
fs = VFSTOUFS(mp)->um_e2fs;
if ((ufhp->ufid_ino < EXT2_FIRSTINO && ufhp->ufid_ino != EXT2_ROOTINO) ||
ufhp->ufid_ino >= fs->e2fs_ncg * fs->e2fs.e2fs_ipg)
+ return (ESTALE);
+
+ if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) {
+ *vpp = NULLVP;
+ return (error);
+ }
+ ip = VTOI(nvp);
+ if (ip->i_e2fs_mode == 0 || ip->i_e2fs_dtime != 0 ||
+ ip->i_e2fs_gen != ufhp->ufid_gen) {
+ vput(nvp);
+ *vpp = NULLVP;
return (ESTALE);
- return (ext2fs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp));
+ }
+ *vpp = nvp;
+ return (0);
}
/*
Index: ufs/ffs/ffs_extern.h
===================================================================
RCS file: /cvs-src/src/sys/ufs/ffs/ffs_extern.h,v
retrieving revision 1.3
diff -u -r1.3 ffs_extern.h
--- ffs_extern.h 1999/01/29 05:31:51 1.3
+++ ffs_extern.h 1999/02/25 19:04:54
@@ -121,8 +121,7 @@
int ffs_statfs __P((struct mount *, struct statfs *, struct proc *));
int ffs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int ffs_vget __P((struct mount *, ino_t, struct vnode **));
-int ffs_fhtovp __P((struct mount *, struct fid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int ffs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
int ffs_vptofh __P((struct vnode *, struct fid *));
int ffs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
Index: ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.3
diff -u -r1.3 ffs_vfsops.c
--- ffs_vfsops.c 1999/02/17 00:52:46 1.3
+++ ffs_vfsops.c 1999/02/23 21:33:59
@@ -104,6 +104,7 @@
ffs_init,
ffs_sysctl,
ffs_mountroot,
+ ufs_check_export,
ffs_vnodeopv_descs,
};
@@ -1015,13 +1016,10 @@
* those rights via. exflagsp and credanonp
*/
int
-ffs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+ffs_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
register struct ufid *ufhp;
struct fs *fs;
@@ -1031,7 +1029,7 @@
if (ufhp->ufid_ino < ROOTINO ||
ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg)
return (ESTALE);
- return (ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp));
+ return (ufs_fhtovp(mp, ufhp, vpp));
}
/*
Index: ufs/lfs/lfs_extern.h
===================================================================
RCS file: /cvs-src/src/sys/ufs/lfs/lfs_extern.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 lfs_extern.h
--- lfs_extern.h 1998/12/21 18:13:58 1.1.1.1
+++ lfs_extern.h 1999/02/25 19:06:30
@@ -119,7 +119,7 @@
int lfs_statfs __P((struct mount *, struct statfs *, struct proc *));
int lfs_sync __P((struct mount *, int, struct ucred *, struct proc *));
int lfs_vget __P((struct mount *, ino_t, struct vnode **));
-int lfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **));
+int lfs_fhtovp __P((struct mount *, struct fid *, struct vnode **));
int lfs_vptofh __P((struct vnode *, struct fid *));
int lfs_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
struct proc *));
Index: ufs/lfs/lfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/ufs/lfs/lfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 lfs_vfsops.c
--- lfs_vfsops.c 1998/12/21 18:13:59 1.1.1.1
+++ lfs_vfsops.c 1999/02/23 21:21:34
@@ -94,6 +94,7 @@
lfs_init,
lfs_sysctl,
NULL,
+ ufs_check_export,
lfs_vnodeopv_descs,
};
@@ -630,8 +631,6 @@
* - check that the inode number is valid
* - call lfs_vget() to get the locked inode
* - check for an unallocated inode (i_mode == 0)
- * - check that the given client host has export rights and return
- * those rights via. exflagsp and credanonp
*
* XXX
* use ifile to see if inode is allocated instead of reading off disk
@@ -639,20 +638,17 @@
* generational number.
*/
int
-lfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
+lfs_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
- struct mbuf *nam;
struct vnode **vpp;
- int *exflagsp;
- struct ucred **credanonp;
{
register struct ufid *ufhp;
ufhp = (struct ufid *)fhp;
if (ufhp->ufid_ino < ROOTINO)
return (ESTALE);
- return (ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp));
+ return (ufs_fhtovp(mp, ufhp, vpp));
}
/*
Index: ufs/mfs/mfs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/ufs/mfs/mfs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mfs_vfsops.c
--- mfs_vfsops.c 1998/12/21 18:13:59 1.1.1.1
+++ mfs_vfsops.c 1999/02/25 19:08:45
@@ -94,6 +94,7 @@
mfs_init,
ffs_sysctl,
NULL,
+ ufs_check_export,
mfs_vnodeopv_descs,
};
Index: ufs/ufs/ufs_extern.h
===================================================================
RCS file: /cvs-src/src/sys/ufs/ufs/ufs_extern.h,v
retrieving revision 1.3
diff -u -r1.3 ufs_extern.h
--- ufs_extern.h 1999/01/29 05:31:52 1.3
+++ ufs_extern.h 1999/02/23 21:18:38
@@ -155,8 +155,9 @@
int ufs_start __P((struct mount *, int, struct proc *));
int ufs_root __P((struct mount *, struct vnode **));
int ufs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
-int ufs_check_export __P((struct mount *, struct ufid *, struct mbuf *,
- struct vnode **, int *, struct ucred **));
+int ufs_fhtovp __P((struct mount *, struct ufid *, struct vnode **));
+int ufs_check_export __P((struct mount *, struct mbuf *, int *,
+ struct ucred **));
/* ufs_vnops.c */
int ufs_vinit __P((struct mount *, int (**) __P((void *)),
Index: ufs/ufs/ufs_vfsops.c
===================================================================
RCS file: /cvs-src/src/sys/ufs/ufs/ufs_vfsops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ufs_vfsops.c
--- ufs_vfsops.c 1998/12/21 18:14:00 1.1.1.1
+++ ufs_vfsops.c 1999/02/25 19:09:46
@@ -163,26 +163,18 @@
}
/*
- * 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, and if so
- * return a vnode for the presented file handle.
+ * Verify a remote client has export rights and return these rights via.
+ * exflagsp and credanonp.
*/
int
-ufs_check_export(mp, ufhp, nam, vpp, exflagsp, credanonp)
+ufs_check_export(mp, nam, exflagsp, credanonp)
register struct mount *mp;
- struct ufid *ufhp;
struct mbuf *nam;
- struct vnode **vpp;
int *exflagsp;
struct ucred **credanonp;
{
- register struct inode *ip;
register struct netcred *np;
register struct ufsmount *ump = VFSTOUFS(mp);
- struct vnode *nvp;
- int error;
/*
* Get the export permission structure for this <mp, client> tuple.
@@ -191,6 +183,25 @@
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.
+ */
+int
+ufs_fhtovp(mp, ufhp, vpp)
+ register struct mount *mp;
+ struct ufid *ufhp;
+ struct vnode **vpp;
+{
+ struct vnode *nvp;
+ register struct inode *ip;
+ int error;
+
if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) {
*vpp = NULLVP;
return (error);
@@ -202,8 +213,6 @@
return (ESTALE);
}
*vpp = nvp;
- *exflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
return (0);
}