Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys move dupfd from struct proc to struct lwp - it's per-LWP...



details:   https://anonhg.NetBSD.org/src/rev/59f8a135cc38
branches:  trunk
changeset: 551859:59f8a135cc38
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat Sep 13 08:32:10 2003 +0000

description:
move dupfd from struct proc to struct lwp - it's per-LWP, not per-process; we
use curlwp where the lwp is not directly available, i.e. in device open
routines

briefly discussed on tech-kern

diffstat:

 sys/compat/darwin/darwin_sysctl.c |   6 +++---
 sys/compat/svr4/svr4_net.c        |  10 +++++-----
 sys/dev/dmover/dmover_io.c        |   6 +++---
 sys/kern/kern_descrip.c           |   8 ++++----
 sys/kern/kern_systrace.c          |   6 +++---
 sys/kern/vfs_syscalls.c           |  12 ++++++------
 sys/miscfs/fdesc/fdesc_vnops.c    |   8 ++++----
 sys/miscfs/portal/portal_vnops.c  |  10 +++++-----
 sys/sys/lwp.h                     |   3 ++-
 9 files changed, 35 insertions(+), 34 deletions(-)

diffs (297 lines):

diff -r 689a832ef025 -r 59f8a135cc38 sys/compat/darwin/darwin_sysctl.c
--- a/sys/compat/darwin/darwin_sysctl.c Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/compat/darwin/darwin_sysctl.c Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: darwin_sysctl.c,v 1.15 2003/09/07 08:05:48 manu Exp $ */
+/*     $NetBSD: darwin_sysctl.c,v 1.16 2003/09/13 08:32:11 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.15 2003/09/07 08:05:48 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: darwin_sysctl.c,v 1.16 2003/09/13 08:32:11 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -617,7 +617,7 @@
        dep->p_stat = p->p_stat; /* XXX Neary the same */
        dep->p_pid = p->p_pid;
        dep->p_oppid = p->p_opptr->p_pid;
-       dep->p_dupfd = p->p_dupfd;
+       dep->p_dupfd = curlwp->l_dupfd; /* XXX */
        /* dep->userstack */
        /* dep->exit_thread */
        /* dep->p_debugger */
diff -r 689a832ef025 -r 59f8a135cc38 sys/compat/svr4/svr4_net.c
--- a/sys/compat/svr4/svr4_net.c        Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/compat/svr4/svr4_net.c        Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_net.c,v 1.34 2003/09/13 08:15:26 jdolecek Exp $   */
+/*     $NetBSD: svr4_net.c,v 1.35 2003/09/13 08:32:10 jdolecek Exp $   */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.34 2003/09/13 08:15:26 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.35 2003/09/13 08:32:10 jdolecek Exp $");
 
 #define COMPAT_SVR4 1
 
@@ -142,7 +142,7 @@
 
        DPRINTF(("netopen("));
 
-       if (p->p_dupfd >= 0)
+       if (curlwp->l_dupfd >= 0)       /* XXX */
                return ENODEV;
 
        switch (minor(dev)) {
@@ -220,7 +220,7 @@
 
        DPRINTF(("ok);\n"));
 
-       p->p_dupfd = fd;
+       curlwp->l_dupfd = fd;   /* XXX */
        FILE_SET_MATURE(fp);
        FILE_UNUSE(fp, p);
        return ENXIO;
@@ -283,7 +283,7 @@
                case ENXIO:
                        return error;
                case 0:
-                       p->p_dupfd = fd;
+                       curlwp->l_dupfd = fd;   /* XXX */
                        return ENXIO;
                default:
                        if (ttynumbers[++n] == '\0') {
diff -r 689a832ef025 -r 59f8a135cc38 sys/dev/dmover/dmover_io.c
--- a/sys/dev/dmover/dmover_io.c        Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/dev/dmover/dmover_io.c        Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dmover_io.c,v 1.12 2003/07/19 02:00:18 thorpej Exp $   */
+/*     $NetBSD: dmover_io.c,v 1.13 2003/09/13 08:32:12 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.12 2003/07/19 02:00:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.13 2003/09/13 08:32:12 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -743,7 +743,7 @@
        fp->f_ops = &dmio_fileops;
        fp->f_data = (caddr_t) ds;
 
-       p->p_dupfd = fd;
+       curlwp->l_dupfd = fd;   /* XXX */
        FILE_SET_MATURE(fp);
        FILE_UNUSE(fp, p);
 
diff -r 689a832ef025 -r 59f8a135cc38 sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c   Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/kern/kern_descrip.c   Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_descrip.c,v 1.111 2003/08/07 16:31:43 agc Exp $   */
+/*     $NetBSD: kern_descrip.c,v 1.112 2003/09/13 08:32:13 jdolecek Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.111 2003/08/07 16:31:43 agc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.112 2003/09/13 08:32:13 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1294,14 +1294,14 @@
 {
 
        /*
-        * XXX Kludge: set p->p_dupfd to contain the value of the
+        * XXX Kludge: set dupfd to contain the value of the
         * the file descriptor being sought for duplication. The error
         * return ensures that the vnode for this device will be released
         * by vn_open. Open will detect this special error and take the
         * actions in dupfdopen below. Other callers of vn_open or VOP_OPEN
         * will simply report the error.
         */
-       p->p_dupfd = minor(dev);
+       curlwp->l_dupfd = minor(dev);   /* XXX */
        return (ENODEV);
 }
 
diff -r 689a832ef025 -r 59f8a135cc38 sys/kern/kern_systrace.c
--- a/sys/kern/kern_systrace.c  Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/kern/kern_systrace.c  Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_systrace.c,v 1.31 2003/08/25 09:12:44 cb Exp $    */
+/*     $NetBSD: kern_systrace.c,v 1.32 2003/09/13 08:32:14 jdolecek Exp $      */
 
 /*
  * Copyright 2002, 2003 Niels Provos <provos%citi.umich.edu@localhost>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.31 2003/08/25 09:12:44 cb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.32 2003/09/13 08:32:14 jdolecek Exp $");
 
 #include "opt_systrace.h"
 
@@ -600,7 +600,7 @@
        fp->f_ops = &systracefops;
        fp->f_data = (caddr_t) fst;
 
-       p->p_dupfd = fd;
+       curlwp->l_dupfd = fd;   /* XXX */
        FILE_SET_MATURE(fp);
        FILE_UNUSE(fp, p);
 
diff -r 689a832ef025 -r 59f8a135cc38 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/kern/vfs_syscalls.c   Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.193 2003/09/11 17:33:42 christos Exp $      */
+/*     $NetBSD: vfs_syscalls.c,v 1.194 2003/09/13 08:32:14 jdolecek Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.193 2003/09/11 17:33:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.194 2003/09/13 08:32:14 jdolecek Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_43.h"
@@ -1096,14 +1096,14 @@
                return (error);
        cmode = ((SCARG(uap, mode) &~ cwdi->cwdi_cmask) & ALLPERMS) &~ S_ISTXT;
        NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
-       p->p_dupfd = -indx - 1;                 /* XXX check for fdopen */
+       l->l_dupfd = -indx - 1;                 /* XXX check for fdopen */
        if ((error = vn_open(&nd, flags, cmode)) != 0) {
                FILE_UNUSE(fp, p);
                ffree(fp);
                if ((error == ENODEV || error == ENXIO) &&
-                   p->p_dupfd >= 0 &&                  /* XXX from fdopen */
+                   l->l_dupfd >= 0 &&                  /* XXX from fdopen */
                    (error =
-                       dupfdopen(p, indx, p->p_dupfd, flags, error)) == 0) {
+                       dupfdopen(p, indx, l->l_dupfd, flags, error)) == 0) {
                        *retval = indx;
                        return (0);
                }
@@ -1112,7 +1112,7 @@
                fdremove(fdp, indx);
                return (error);
        }
-       p->p_dupfd = 0;
+       l->l_dupfd = 0;
        vp = nd.ni_vp;
        fp->f_flag = flags & FMASK;
        fp->f_type = DTYPE_VNODE;
diff -r 689a832ef025 -r 59f8a135cc38 sys/miscfs/fdesc/fdesc_vnops.c
--- a/sys/miscfs/fdesc/fdesc_vnops.c    Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/miscfs/fdesc/fdesc_vnops.c    Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdesc_vnops.c,v 1.78 2003/08/07 16:32:33 agc Exp $     */
+/*     $NetBSD: fdesc_vnops.c,v 1.79 2003/09/13 08:32:16 jdolecek Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.78 2003/08/07 16:32:33 agc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdesc_vnops.c,v 1.79 2003/09/13 08:32:16 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -442,14 +442,14 @@
        switch (VTOFDESC(vp)->fd_type) {
        case Fdesc:
                /*
-                * XXX Kludge: set p->p_dupfd to contain the value of the
+                * XXX Kludge: set dupfd to contain the value of the
                 * the file descriptor being sought for duplication. The error 
                 * return ensures that the vnode for this device will be
                 * released by vn_open. Open will detect this special error and
                 * take the actions in dupfdopen.  Other callers of vn_open or
                 * VOP_OPEN will simply report the error.
                 */
-               ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
+               curlwp->l_dupfd = VTOFDESC(vp)->fd_fd;  /* XXX */
                return (ENODEV);
 
        case Fctty:
diff -r 689a832ef025 -r 59f8a135cc38 sys/miscfs/portal/portal_vnops.c
--- a/sys/miscfs/portal/portal_vnops.c  Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/miscfs/portal/portal_vnops.c  Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: portal_vnops.c,v 1.49 2003/09/04 04:30:25 matt Exp $   */
+/*     $NetBSD: portal_vnops.c,v 1.50 2003/09/13 08:32:17 jdolecek Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.49 2003/09/04 04:30:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portal_vnops.c,v 1.50 2003/09/13 08:32:17 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -334,9 +334,9 @@
        /*
         * Can't be opened unless the caller is set up
         * to deal with the side effects.  Check for this
-        * by testing whether the p_dupfd has been set.
+        * by testing whether the dupfd has been set.
         */
-       if (p->p_dupfd >= 0)
+       if (curlwp->l_dupfd >= 0)       /* XXX */
                return (ENODEV);
 
        pt = VTOPORTAL(vp);
@@ -513,7 +513,7 @@
         * special error code (ENXIO) which causes magic things to
         * happen in vn_open.  The whole concept is, well, hmmm.
         */
-       p->p_dupfd = fd;
+       curlwp->l_dupfd = fd;   /* XXX */
        error = ENXIO;
 
 bad:;
diff -r 689a832ef025 -r 59f8a135cc38 sys/sys/lwp.h
--- a/sys/sys/lwp.h     Sat Sep 13 08:22:51 2003 +0000
+++ b/sys/sys/lwp.h     Sat Sep 13 08:32:10 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lwp.h,v 1.9 2003/09/13 07:56:03 jdolecek Exp $ */
+/*     $NetBSD: lwp.h,v 1.10 2003/09/13 08:32:18 jdolecek Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -73,6 +73,7 @@
        const char *l_wmesg;    /* Reason for sleep. */
        int     l_holdcnt;      /* If non-zero, don't swap. */
        void    *l_ctxlink;     /* uc_link {get,set}context */
+       int     l_dupfd;        /* Sideways return value from cloning devices XXX */
 
 #define l_endzero l_priority
 



Home | Main Index | Thread Index | Old Index