proc->thread stage 4: rework the VFS and DEVICE subsystems to take thread
[dragonfly.git] / sys / emulation / ibcs2 / i386 / ibcs2_util.c
index 50260a5..8a6fcbb 100644 (file)
  *
  *     from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
  * $FreeBSD: src/sys/i386/ibcs2/ibcs2_util.c,v 1.7 1999/12/15 23:01:45 eivind Exp $
- * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_util.c,v 1.3 2003/06/23 17:55:38 dillon Exp $
+ * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_util.c,v 1.4 2003/06/25 03:55:53 dillon Exp $
  */
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/proc.h>
 #include <sys/namei.h>
 #include <sys/malloc.h>
 #include <sys/vnode.h>
@@ -59,7 +60,8 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
        char            **pbuf;
        int               cflag;
 {
-       struct proc      *p = curproc;
+       struct thread    *td = curthread;       /* XXX */
+       struct ucred    *cred;
        struct nameidata         nd;
        struct nameidata         ndroot;
        struct vattr             vat;
@@ -68,6 +70,9 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
        char                    *ptr, *buf, *cp;
        size_t                   sz, len;
 
+       KKASSERT(td->td_proc);
+       cred = td->td_proc->p_ucred;
+
        buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
        *pbuf = path;
 
@@ -106,7 +111,7 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
                for (cp = &ptr[len] - 1; *cp != '/'; cp--);
                *cp = '\0';
 
-               NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
+               NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
 
                if ((error = namei(&nd)) != 0) {
                        free(buf, M_TEMP);
@@ -116,7 +121,7 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
                *cp = '/';
        }
        else {
-               NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
+               NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
 
                if ((error = namei(&nd)) != 0) {
                        free(buf, M_TEMP);
@@ -131,8 +136,8 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
                 * root directory and never finding it, because "/" resolves
                 * to the emulation root directory. This is expensive :-(
                 */
-               NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, ibcs2_emul_path,
-                      p);
+               NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE,
+                       ibcs2_emul_path, td);
 
                if ((error = namei(&ndroot)) != 0) {
                        /* Cannot happen! */
@@ -142,11 +147,11 @@ ibcs2_emul_find(sgp, prefix, path, pbuf, cflag)
                        return error;
                }
 
-               if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
+               if ((error = VOP_GETATTR(nd.ni_vp, &vat, cred, td)) != 0) {
                        goto done;
                }
 
-               if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
+               if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, cred, td))
                    != 0) {
                        goto done;
                }