summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-09-12 23:39:36 +0000
committerjhb <jhb@FreeBSD.org>2001-09-12 23:39:36 +0000
commitb6c24ae1e6e6d98053fb440433d7d3059cc97b7a (patch)
tree1c01fbd604d3b4f845d7b47d937b94d6934bfd7d /sys/fs
parentc1c40c6cffa3a5263bd8a06d2e2e39fc0d743545 (diff)
downloadFreeBSD-src-b6c24ae1e6e6d98053fb440433d7d3059cc97b7a.zip
FreeBSD-src-b6c24ae1e6e6d98053fb440433d7d3059cc97b7a.tar.gz
Restore these files to being portable:
- Use some simple #define's at the top of the files for proc -> thread changes instead of having lots of needless #ifdef's in the code. - Don't try to use struct thread in !FreeBSD code. - Don't use a few struct lwp's in some of the NetBSD code since it isn't in their HEAD. The new diff relative to before KSE is now signficantly smaller and easier to maintain.
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c86
-rw-r--r--sys/fs/hpfs/hpfs_vnops.c48
2 files changed, 73 insertions, 61 deletions
diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c
index e83f356..b364a60 100644
--- a/sys/fs/hpfs/hpfs_vfsops.c
+++ b/sys/fs/hpfs/hpfs_vfsops.c
@@ -60,26 +60,30 @@
#if defined(__FreeBSD__)
MALLOC_DEFINE(M_HPFSMNT, "HPFS mount", "HPFS mount structure");
MALLOC_DEFINE(M_HPFSNO, "HPFS node", "HPFS node structure");
+
+#define a_p a_td
+#define cn_proc cn_thread
+#define proc thread
#endif
static int hpfs_root __P((struct mount *, struct vnode **));
static int hpfs_statfs __P((struct mount *, struct statfs *,
- struct thread *));
-static int hpfs_unmount __P((struct mount *, int, struct thread *));
+ struct proc *));
+static int hpfs_unmount __P((struct mount *, int, struct proc *));
static int hpfs_vget __P((struct mount *mp, ino_t ino,
struct vnode **vpp));
static int hpfs_mountfs __P((register struct vnode *, struct mount *,
- struct hpfs_args *, struct thread *));
+ struct hpfs_args *, struct proc *));
static int hpfs_vptofh __P((struct vnode *, struct fid *));
static int hpfs_fhtovp __P((struct mount *, struct fid *,
struct vnode **));
#if !defined(__FreeBSD__)
static int hpfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
- struct lwp *));
-static int hpfs_start __P((struct mount *, int, struct lwp *));
+ struct proc *));
+static int hpfs_start __P((struct mount *, int, struct proc *));
static int hpfs_sync __P((struct mount *, int, struct ucred *,
- struct lwp *));
+ struct proc *));
#endif
#if defined(__FreeBSD__)
@@ -90,11 +94,11 @@ static int hpfs_init __P((struct vfsconf *));
static int hpfs_uninit __P((struct vfsconf *));
#else /* defined(__NetBSD__) */
static int hpfs_mount __P((struct mount *, const char *, void *,
- struct nameidata *, struct thread *));
+ struct nameidata *, struct proc *));
static void hpfs_init __P((void));
static int hpfs_mountroot __P((void));
static int hpfs_sysctl __P((int *, u_int, void *, size_t *, void *,
- size_t, struct thread *));
+ size_t, struct proc *));
static int hpfs_checkexp __P((struct mount *, struct mbuf *,
int *, struct ucred **));
#endif
@@ -127,14 +131,14 @@ hpfs_checkexp(mp, nam, exflagsp, credanonp)
#if !defined(__FreeBSD__)
/*ARGSUSED*/
static int
-hpfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, td)
+hpfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
int *name;
u_int namelen;
void *oldp;
size_t *oldlenp;
void *newp;
size_t newlen;
- struct lwp *td;
+ struct proc *p;
{
return (EINVAL);
}
@@ -179,14 +183,12 @@ hpfs_mount (
#if defined(__FreeBSD__)
char *path,
caddr_t data,
- struct nameidata *ndp,
- struct thread *td )
#else /* defined(__NetBSD__) */
const char *path,
void *data,
- struct nameidata *ndp,
- struct lwp *l )
#endif
+ struct nameidata *ndp,
+ struct proc *p )
{
u_int size;
int err = 0;
@@ -239,11 +241,7 @@ hpfs_mount (
* Not an update, or updating the name: look up the name
* and verify that it refers to a sensible block device.
*/
-#ifdef __FreeBSD__
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td);
-#else
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, l);
-#endif
+ NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
err = namei(ndp);
if (err) {
/* can't get devvp!*/
@@ -288,7 +286,7 @@ hpfs_mount (
&size); /* real size*/
bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- err = hpfs_mountfs(devvp, mp, &args, td);
+ err = hpfs_mountfs(devvp, mp, &args, p);
if (err)
goto error_2;
@@ -298,7 +296,7 @@ hpfs_mount (
*
* This code is common to root and non-root mounts
*/
- (void)VFS_STATFS(mp, &mp->mnt_stat, td);
+ (void)VFS_STATFS(mp, &mp->mnt_stat, p);
goto success;
@@ -318,11 +316,11 @@ success:
* Common code for mount and mountroot
*/
int
-hpfs_mountfs(devvp, mp, argsp, td)
+hpfs_mountfs(devvp, mp, argsp, p)
register struct vnode *devvp;
struct mount *mp;
struct hpfs_args *argsp;
- struct thread *td;
+ struct proc *p;
{
int error, ncount, ronly;
struct sublock *sup;
@@ -351,19 +349,19 @@ hpfs_mountfs(devvp, mp, argsp, td)
return (EBUSY);
#if defined(__FreeBSD__)
- VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
- error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0);
- VOP__UNLOCK(devvp, 0, td);
+ VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
+ error = vinvalbuf(devvp, V_SAVE, p->td_proc->p_ucred, p, 0, 0);
+ VOP__UNLOCK(devvp, 0, p);
#else
- error = vinvalbuf(devvp, V_SAVE, td->td_proc->p_ucred, td, 0, 0);
+ error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
#endif
if (error)
return (error);
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, td);
- error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, td);
- VOP__UNLOCK(devvp, 0, td);
+ VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
+ error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
+ VOP__UNLOCK(devvp, 0, p);
if (error)
return (error);
@@ -449,7 +447,7 @@ failed:
#else
devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
- (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, td);
+ (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
return (error);
}
@@ -458,7 +456,7 @@ static int
hpfs_start (
struct mount *mp,
int flags,
- struct lwp *td )
+ struct proc *p )
{
return (0);
}
@@ -468,7 +466,7 @@ static int
hpfs_unmount(
struct mount *mp,
int mntflags,
- struct thread *td)
+ struct proc *p)
{
int error, flags, ronly;
register struct hpfsmount *hpmp = VFSTOHPFS(mp);
@@ -495,9 +493,9 @@ hpfs_unmount(
hpmp->hpm_devvp->v_specflags &= ~SI_MOUNTEDON;
#endif
- vinvalbuf(hpmp->hpm_devvp, V_SAVE, NOCRED, td, 0, 0);
+ vinvalbuf(hpmp->hpm_devvp, V_SAVE, NOCRED, p, 0, 0);
error = VOP_CLOSE(hpmp->hpm_devvp, ronly ? FREAD : FREAD|FWRITE,
- NOCRED, td);
+ NOCRED, p);
vrele(hpmp->hpm_devvp);
@@ -533,7 +531,7 @@ static int
hpfs_statfs(
struct mount *mp,
struct statfs *sbp,
- struct thread *td)
+ struct proc *p)
{
struct hpfsmount *hpmp = VFSTOHPFS(mp);
@@ -568,7 +566,7 @@ hpfs_sync (
struct mount *mp,
int waitfor,
struct ucred *cred,
- struct lwp *td)
+ struct proc *p)
{
return (0);
}
@@ -579,7 +577,7 @@ hpfs_quotactl (
int cmds,
uid_t uid,
caddr_t arg,
- struct lwp *td)
+ struct proc *p)
{
printf("hpfs_quotactl():\n");
return (EOPNOTSUPP);
@@ -634,7 +632,11 @@ hpfs_vget(
struct vnode *vp;
struct hpfsnode *hp;
struct buf *bp;
- struct thread *td = curthread; /* XXX */
+#if defined(__FreeBSD__)
+ struct thread *p = curthread; /* XXX */
+#else
+ struct proc *p = curproc; /* XXX */
+#endif
int error;
dprintf(("hpfs_vget(0x%x): ",ino));
@@ -643,7 +645,7 @@ hpfs_vget(
hp = NULL;
vp = NULL;
- if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, td)) != NULL) {
+ if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, p)) != NULL) {
dprintf(("hashed\n"));
return (0);
}
@@ -692,14 +694,14 @@ hpfs_vget(
hp->h_devvp = hpmp->hpm_devvp;
VREF(hp->h_devvp);
- error = VN_LOCK(vp, LK_EXCLUSIVE, td);
+ error = VN_LOCK(vp, LK_EXCLUSIVE, p);
if (error) {
vput(vp);
return (error);
}
do {
- if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, td)) != NULL) {
+ if ((*vpp = hpfs_hphashvget(hpmp->hpm_dev, ino, p)) != NULL) {
dprintf(("hashed2\n"));
vput(vp);
return (0);
diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c
index e612a24..09c83d6 100644
--- a/sys/fs/hpfs/hpfs_vnops.c
+++ b/sys/fs/hpfs/hpfs_vnops.c
@@ -67,6 +67,12 @@
#include <fs/hpfs/hpfs_subr.h>
#include <fs/hpfs/hpfs_ioctl.h>
+#if defined(__FreeBSD__)
+#define a_p a_td
+#define cn_proc cn_thread
+#define proc thread
+#endif
+
static int hpfs_de_uiomove __P((struct hpfsmount *, struct hpfsdirent *,
struct uio *));
static int hpfs_ioctl __P((struct vop_ioctl_args *ap));
@@ -153,7 +159,7 @@ hpfs_ioctl (
caddr_t a_data;
int a_fflag;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap)
{
register struct vnode *vp = ap->a_vp;
@@ -465,7 +471,7 @@ hpfs_getattr(ap)
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap;
{
register struct vnode *vp = ap->a_vp;
@@ -517,14 +523,14 @@ hpfs_setattr(ap)
struct vnode *a_vp;
struct vattr *a_vap;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap;
{
struct vnode *vp = ap->a_vp;
struct hpfsnode *hp = VTOHP(vp);
struct vattr *vap = ap->a_vap;
struct ucred *cred = ap->a_cred;
- struct thread *td = ap->a_td;
+ struct proc *p = ap->a_p;
int error;
dprintf(("hpfs_setattr(0x%x):\n", hp->h_no));
@@ -563,9 +569,13 @@ hpfs_setattr(ap)
if (vp->v_mount->mnt_flag & MNT_RDONLY)
return (EROFS);
if (cred->cr_uid != hp->h_uid &&
- (error = suser_xxx(cred, td->td_proc, PRISON_ROOT)) &&
+#if defined(__FreeBSD__)
+ (error = suser_xxx(cred, p->td_proc, PRISON_ROOT)) &&
+#else
+ (error = suser_xxx(cred, p, PRISON_ROOT)) &&
+#endif
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
- (error = VOP_ACCESS(vp, VWRITE, cred, td))))
+ (error = VOP_ACCESS(vp, VWRITE, cred, p))))
return (error);
if (vap->va_atime.tv_sec != VNOVAL)
hp->h_atime = vap->va_atime.tv_sec;
@@ -590,7 +600,7 @@ hpfs_setattr(ap)
if (vap->va_size < hp->h_fn.fn_size) {
#if defined(__FreeBSD__)
- error = vtruncbuf(vp, cred, td, vap->va_size, DEV_BSIZE);
+ error = vtruncbuf(vp, cred, p, vap->va_size, DEV_BSIZE);
if (error)
return (error);
#else /* defined(__NetBSD__) */
@@ -646,7 +656,7 @@ hpfs_inactive(ap)
vprint("hpfs_inactive: pushing active", vp);
if (hp->h_flag & H_INVAL) {
- VOP__UNLOCK(vp,0,ap->a_td);
+ VOP__UNLOCK(vp,0,ap->a_p);
#if defined(__FreeBSD__)
vrecycle(vp, NULL, ap->a_td);
#else /* defined(__NetBSD__) */
@@ -655,7 +665,7 @@ hpfs_inactive(ap)
return (0);
}
- VOP__UNLOCK(vp,0,ap->a_td);
+ VOP__UNLOCK(vp,0,ap->a_p);
return (0);
}
@@ -759,7 +769,7 @@ hpfs_access(ap)
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap;
{
struct vnode *vp = ap->a_vp;
@@ -800,7 +810,7 @@ hpfs_open(ap)
struct vnode *a_vp;
int a_mode;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap;
{
#if HPFS_DEBUG
@@ -829,7 +839,7 @@ hpfs_close(ap)
struct vnode *a_vp;
int a_fflag;
struct ucred *a_cred;
- struct thread *a_td;
+ struct proc *a_p;
} */ *ap;
{
#if HPFS_DEBUG
@@ -1131,7 +1141,7 @@ hpfs_lookup(ap)
return (EOPNOTSUPP);
}
- error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_thread);
+ error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_proc);
if(error)
return (error);
@@ -1148,17 +1158,17 @@ hpfs_lookup(ap)
dprintf(("hpfs_lookup(0x%x,...): .. faked (0x%x)\n",
dhp->h_no, dhp->h_fn.fn_parent));
- VOP__UNLOCK(dvp,0,cnp->cn_thread);
+ VOP__UNLOCK(dvp,0,cnp->cn_proc);
error = VFS_VGET(hpmp->hpm_mp,
dhp->h_fn.fn_parent, ap->a_vpp);
if(error) {
- VOP__LOCK(dvp, 0, cnp->cn_thread);
+ VOP__LOCK(dvp, 0, cnp->cn_proc);
return(error);
}
if( lockparent && (flags & ISLASTCN) &&
- (error = VOP__LOCK(dvp, 0, cnp->cn_thread)) ) {
+ (error = VOP__LOCK(dvp, 0, cnp->cn_proc)) ) {
vput( *(ap->a_vpp) );
return (error);
}
@@ -1174,7 +1184,7 @@ hpfs_lookup(ap)
if ((error == ENOENT) && (flags & ISLASTCN) &&
(nameiop == CREATE || nameiop == RENAME)) {
if(!lockparent)
- VOP__UNLOCK(dvp, 0, cnp->cn_thread);
+ VOP__UNLOCK(dvp, 0, cnp->cn_proc);
cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
@@ -1186,7 +1196,7 @@ hpfs_lookup(ap)
dep->de_fnode, dep->de_cpid));
if (nameiop == DELETE && (flags & ISLASTCN)) {
- error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_thread);
+ error = VOP_ACCESS(dvp, VWRITE, cred, cnp->cn_proc);
if (error) {
brelse(bp);
return (error);
@@ -1220,7 +1230,7 @@ hpfs_lookup(ap)
brelse(bp);
if(!lockparent || !(flags & ISLASTCN))
- VOP__UNLOCK(dvp, 0, cnp->cn_thread);
+ VOP__UNLOCK(dvp, 0, cnp->cn_proc);
if ((flags & MAKEENTRY) &&
(!(flags & ISLASTCN) ||
(nameiop != DELETE && nameiop != CREATE)))
OpenPOWER on IntegriCloud