proc->thread stage 4: rework the VFS and DEVICE subsystems to take thread
[dragonfly.git] / sys / vfs / msdosfs / msdosfs_vnops.c
index be1601e..58d2a7b 100644 (file)
@@ -1,5 +1,5 @@
 /* $FreeBSD: src/sys/msdosfs/msdosfs_vnops.c,v 1.95.2.4 2003/06/13 15:05:47 trhodes Exp $ */
-/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vnops.c,v 1.4 2003/06/23 17:55:45 dillon Exp $ */
+/* $DragonFly: src/sys/vfs/msdosfs/msdosfs_vnops.c,v 1.5 2003/06/25 03:56:01 dillon Exp $ */
 /*     $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $   */
 
 /*-
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/namei.h>
 #include <sys/resourcevar.h>   /* defines plimit structure in proc struct */
 #include <sys/kernel.h>
 #include <sys/stat.h>
 #include <sys/buf.h>
 #include <sys/proc.h>
+#include <sys/namei.h>
 #include <sys/mount.h>
 #include <sys/unistd.h>
 #include <sys/vnode.h>
@@ -227,7 +227,7 @@ msdosfs_close(ap)
                struct vnode *a_vp;
                int a_fflag;
                struct ucred *a_cred;
-               struct proc *a_p;
+               struct thread *a_td;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
@@ -249,7 +249,7 @@ msdosfs_access(ap)
                struct vnode *a_vp;
                int a_mode;
                struct ucred *a_cred;
-               struct proc *a_p;
+               struct thread *a_td;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
@@ -327,7 +327,7 @@ msdosfs_getattr(ap)
                struct vnode *a_vp;
                struct vattr *a_vap;
                struct ucred *a_cred;
-               struct proc *a_p;
+               struct thread *a_td;
        } */ *ap;
 {
        struct denode *dep = VTODE(ap->a_vp);
@@ -393,7 +393,7 @@ msdosfs_setattr(ap)
                struct vnode *a_vp;
                struct vattr *a_vap;
                struct ucred *a_cred;
-               struct proc *a_p;
+               struct thread *a_td;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
@@ -405,7 +405,7 @@ msdosfs_setattr(ap)
 
 #ifdef MSDOSFS_DEBUG
        printf("msdosfs_setattr(): vp %p, vap %p, cred %p, p %p\n",
-           ap->a_vp, vap, cred, ap->a_p);
+           ap->a_vp, vap, cred, ap->a_td);
 #endif
 
        /*
@@ -430,7 +430,7 @@ msdosfs_setattr(ap)
                if (vp->v_mount->mnt_flag & MNT_RDONLY)
                        return (EROFS);
                if (cred->cr_uid != pmp->pm_uid &&
-                   (error = suser_xxx(cred, PRISON_ROOT)))
+                   (error = suser_cred(cred, PRISON_ROOT)))
                        return (error);
                /*
                 * We are very inconsistent about handling unsupported
@@ -471,7 +471,7 @@ msdosfs_setattr(ap)
                        gid = pmp->pm_gid;
                if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid ||
                    (gid != pmp->pm_gid && !groupmember(gid, cred))) &&
-                   (error = suser_xxx(cred, PRISON_ROOT)))
+                   (error = suser_cred(cred, PRISON_ROOT)))
                        return error;
                if (uid != pmp->pm_uid || gid != pmp->pm_gid)
                        return EINVAL;
@@ -495,7 +495,7 @@ msdosfs_setattr(ap)
                default:
                        break;
                }
-               error = detrunc(dep, vap->va_size, 0, cred, ap->a_p);
+               error = detrunc(dep, vap->va_size, 0, cred, ap->a_td);
                if (error)
                        return error;
        }
@@ -503,9 +503,9 @@ msdosfs_setattr(ap)
                if (vp->v_mount->mnt_flag & MNT_RDONLY)
                        return (EROFS);
                if (cred->cr_uid != pmp->pm_uid &&
-                   (error = suser_xxx(cred, PRISON_ROOT)) &&
+                   (error = suser_cred(cred, PRISON_ROOT)) &&
                    ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
-                   (error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_p))))
+                   (error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_td))))
                        return (error);
                if (vp->v_type != VDIR) {
                        if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 &&
@@ -532,7 +532,7 @@ msdosfs_setattr(ap)
                if (vp->v_mount->mnt_flag & MNT_RDONLY)
                        return (EROFS);
                if (cred->cr_uid != pmp->pm_uid &&
-                   (error = suser_xxx(cred, PRISON_ROOT)))
+                   (error = suser_cred(cred, PRISON_ROOT)))
                        return (error);
                if (vp->v_type != VDIR) {
                        /* We ignore the read and execute bits. */
@@ -662,12 +662,13 @@ msdosfs_write(ap)
        struct buf *bp;
        int ioflag = ap->a_ioflag;
        struct uio *uio = ap->a_uio;
-       struct proc *p = uio->uio_procp;
+       struct thread *td = uio->uio_td;
        struct vnode *vp = ap->a_vp;
        struct vnode *thisvp;
        struct denode *dep = VTODE(vp);
        struct msdosfsmount *pmp = dep->de_pmp;
        struct ucred *cred = ap->a_cred;
+       struct proc *p = td->td_proc;
 
 #ifdef MSDOSFS_DEBUG
        printf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n",
@@ -854,7 +855,7 @@ msdosfs_fsync(ap)
                struct vnode *a_vp;
                struct ucred *a_cred;
                int a_waitfor;
-               struct proc *a_p;
+               struct thread *a_td;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
@@ -997,7 +998,7 @@ msdosfs_rename(ap)
        struct vnode *tvp = ap->a_tvp;
        struct componentname *tcnp = ap->a_tcnp;
        struct componentname *fcnp = ap->a_fcnp;
-       struct proc *p = fcnp->cn_proc;
+       struct thread *td = fcnp->cn_td;
        struct denode *ip, *xp, *dp, *zp;
        u_char toname[11], oldname[11];
        u_long from_diroffset, to_diroffset;
@@ -1047,7 +1048,7 @@ abortit:
                goto abortit;
        }
 
-       error = vn_lock(fvp, LK_EXCLUSIVE, p);
+       error = vn_lock(fvp, LK_EXCLUSIVE, td);
        if (error)
                goto abortit;
        dp = VTODE(fdvp);
@@ -1068,7 +1069,7 @@ abortit:
                    (fcnp->cn_flags & ISDOTDOT) ||
                    (tcnp->cn_flags & ISDOTDOT) ||
                    (ip->de_flag & DE_RENAME)) {
-                       VOP_UNLOCK(fvp, 0, p);
+                       VOP_UNLOCK(fvp, 0, td);
                        error = EINVAL;
                        goto abortit;
                }
@@ -1098,8 +1099,8 @@ abortit:
         * to namei, as the parent directory is unlocked by the
         * call to doscheckpath().
         */
-       error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
-       VOP_UNLOCK(fvp, 0, p);
+       error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_td);
+       VOP_UNLOCK(fvp, 0, td);
        if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
                newparent = 1;
        if (doingdirectory && newparent) {
@@ -1168,7 +1169,7 @@ abortit:
        if ((fcnp->cn_flags & SAVESTART) == 0)
                panic("msdosfs_rename: lost from startdir");
        if (!newparent)
-               VOP_UNLOCK(tdvp, 0, p);
+               VOP_UNLOCK(tdvp, 0, td);
        if (relookup(fdvp, &fvp, fcnp) == 0)
                vrele(fdvp);
        if (fvp == NULL) {
@@ -1179,7 +1180,7 @@ abortit:
                        panic("rename: lost dir entry");
                vrele(ap->a_fvp);
                if (newparent)
-                       VOP_UNLOCK(tdvp, 0, p);
+                       VOP_UNLOCK(tdvp, 0, td);
                vrele(tdvp);
                return 0;
        }
@@ -1199,9 +1200,9 @@ abortit:
                if (doingdirectory)
                        panic("rename: lost dir entry");
                vrele(ap->a_fvp);
-               VOP_UNLOCK(fvp, 0, p);
+               VOP_UNLOCK(fvp, 0, td);
                if (newparent)
-                       VOP_UNLOCK(fdvp, 0, p);
+                       VOP_UNLOCK(fdvp, 0, td);
                xp = NULL;
        } else {
                vrele(fvp);
@@ -1223,8 +1224,8 @@ abortit:
                if (error) {
                        bcopy(oldname, ip->de_Name, 11);
                        if (newparent)
-                               VOP_UNLOCK(fdvp, 0, p);
-                       VOP_UNLOCK(fvp, 0, p);
+                               VOP_UNLOCK(fdvp, 0, td);
+                       VOP_UNLOCK(fvp, 0, td);
                        goto bad;
                }
                ip->de_refcnt++;
@@ -1233,8 +1234,8 @@ abortit:
                if (error) {
                        /* XXX should really panic here, fs is corrupt */
                        if (newparent)
-                               VOP_UNLOCK(fdvp, 0, p);
-                       VOP_UNLOCK(fvp, 0, p);
+                               VOP_UNLOCK(fdvp, 0, td);
+                       VOP_UNLOCK(fvp, 0, td);
                        goto bad;
                }
                if (!doingdirectory) {
@@ -1243,8 +1244,8 @@ abortit:
                        if (error) {
                                /* XXX should really panic here, fs is corrupt */
                                if (newparent)
-                                       VOP_UNLOCK(fdvp, 0, p);
-                               VOP_UNLOCK(fvp, 0, p);
+                                       VOP_UNLOCK(fdvp, 0, td);
+                               VOP_UNLOCK(fvp, 0, td);
                                goto bad;
                        }
                        if (ip->de_dirclust == MSDOSFSROOT)
@@ -1254,7 +1255,7 @@ abortit:
                }
                reinsert(ip);
                if (newparent)
-                       VOP_UNLOCK(fdvp, 0, p);
+                       VOP_UNLOCK(fdvp, 0, td);
        }
 
        /*
@@ -1273,7 +1274,7 @@ abortit:
                if (error) {
                        /* XXX should really panic here, fs is corrupt */
                        brelse(bp);
-                       VOP_UNLOCK(fvp, 0, p);
+                       VOP_UNLOCK(fvp, 0, td);
                        goto bad;
                }
                dotdotp = (struct direntry *)bp->b_data + 1;
@@ -1283,12 +1284,12 @@ abortit:
                error = bwrite(bp);
                if (error) {
                        /* XXX should really panic here, fs is corrupt */
-                       VOP_UNLOCK(fvp, 0, p);
+                       VOP_UNLOCK(fvp, 0, td);
                        goto bad;
                }
        }
 
-       VOP_UNLOCK(fvp, 0, p);
+       VOP_UNLOCK(fvp, 0, td);
 bad:
        if (xp)
                vput(tvp);
@@ -1448,11 +1449,11 @@ msdosfs_rmdir(ap)
                struct componentname *a_cnp;
        } */ *ap;
 {
-       register struct vnode *vp = ap->a_vp;
-       register struct vnode *dvp = ap->a_dvp;
-       register struct componentname *cnp = ap->a_cnp;
-       register struct denode *ip, *dp;
-       struct proc *p = cnp->cn_proc;
+       struct vnode *vp = ap->a_vp;
+       struct vnode *dvp = ap->a_dvp;
+       struct componentname *cnp = ap->a_cnp;
+       struct denode *ip, *dp;
+       struct thread *td = cnp->cn_td;
        int error;
        
        ip = VTODE(vp);
@@ -1487,14 +1488,14 @@ msdosfs_rmdir(ap)
         * the name cache.
         */
        cache_purge(dvp);
-       VOP_UNLOCK(dvp, 0, p);
+       VOP_UNLOCK(dvp, 0, td);
        /*
         * Truncate the directory that is being deleted.
         */
-       error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, p);
+       error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, td);
        cache_purge(vp);
 
-       vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
+       vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td);
 out:
        return (error);
 }