more-or-less working with new proc & user structs
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Mon, 18 Mar 1991 07:42:22 +0000 (23:42 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Mon, 18 Mar 1991 07:42:22 +0000 (23:42 -0800)
SCCS-vsn: sys/kern/tty_tty.c 7.10
SCCS-vsn: sys/kern/tty_subr.c 7.6
SCCS-vsn: sys/kern/tty.c 7.38
SCCS-vsn: sys/kern/kern_acct.c 7.15
SCCS-vsn: sys/kern/vfs_bio.c 7.34
SCCS-vsn: sys/kern/vfs_cluster.c 7.34
SCCS-vsn: sys/kern/kern_sysctl.c 7.13

usr/src/sys/kern/kern_acct.c
usr/src/sys/kern/kern_sysctl.c
usr/src/sys/kern/tty.c
usr/src/sys/kern/tty_subr.c
usr/src/sys/kern/tty_tty.c
usr/src/sys/kern/vfs_bio.c
usr/src/sys/kern/vfs_cluster.c

index 3426f66..034cdc1 100644 (file)
@@ -3,23 +3,22 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)kern_acct.c 7.14 (Berkeley) %G%
+ *     @(#)kern_acct.c 7.15 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "systm.h"
  */
 
 #include "param.h"
 #include "systm.h"
-#include "time.h"
+#include "namei.h"
+#include "resourcevar.h"
 #include "proc.h"
 #include "ioctl.h"
 #include "termios.h"
 #include "tty.h"
 #include "proc.h"
 #include "ioctl.h"
 #include "termios.h"
 #include "tty.h"
-#include "user.h"
 #include "vnode.h"
 #include "mount.h"
 #include "kernel.h"
 #include "file.h"
 #include "acct.h"
 #include "vnode.h"
 #include "mount.h"
 #include "kernel.h"
 #include "file.h"
 #include "acct.h"
-#include "uio.h"
 #include "syslog.h"
 
 /*
 #include "syslog.h"
 
 /*
@@ -47,12 +46,12 @@ sysacct(p, uap, retval)
        int *retval;
 {
        register struct vnode *vp;
        int *retval;
 {
        register struct vnode *vp;
-       register struct nameidata *ndp = &u.u_nd;
        extern int acctwatch();
        struct vnode *oacctp;
        int error;
        extern int acctwatch();
        struct vnode *oacctp;
        int error;
+       struct nameidata nd;
 
 
-       if (error = suser(u.u_cred, &u.u_acflag))
+       if (error = suser(p->p_ucred, &p->p_acflag))
                return (error);
        if (savacctp) {
                acctp = savacctp;
                return (error);
        if (savacctp) {
                acctp = savacctp;
@@ -66,11 +65,11 @@ sysacct(p, uap, retval)
                }
                return (0);
        }
                }
                return (0);
        }
-       ndp->ni_segflg = UIO_USERSPACE;
-       ndp->ni_dirp = uap->fname;
-       if (error = vn_open(ndp, FWRITE, 0644))
+       nd.ni_segflg = UIO_USERSPACE;
+       nd.ni_dirp = uap->fname;
+       if (error = vn_open(&nd, p, FWRITE, 0644))
                return (error);
                return (error);
-       vp = ndp->ni_vp;
+       vp = nd.ni_vp;
        if (vp->v_type != VREG) {
                vrele(vp);
                return (EACCES);
        if (vp->v_type != VREG) {
                vrele(vp);
                return (EACCES);
@@ -128,7 +127,7 @@ acct(p)
        if ((vp = acctp) == NULL)
                return (0);
        bcopy(p->p_comm, ap->ac_comm, sizeof(ap->ac_comm));
        if ((vp = acctp) == NULL)
                return (0);
        bcopy(p->p_comm, ap->ac_comm, sizeof(ap->ac_comm));
-       ru = &u.u_ru;
+       ru = &p->p_stats->p_ru;
        s = splclock();
        ut = p->p_utime;
        st = p->p_stime;
        s = splclock();
        ut = p->p_utime;
        st = p->p_stime;
@@ -136,15 +135,15 @@ acct(p)
        splx(s);
        ap->ac_utime = compress(ut.tv_sec, ut.tv_usec);
        ap->ac_stime = compress(st.tv_sec, st.tv_usec);
        splx(s);
        ap->ac_utime = compress(ut.tv_sec, ut.tv_usec);
        ap->ac_stime = compress(st.tv_sec, st.tv_usec);
-       timevalsub(&t, &u.u_start);
+       timevalsub(&t, &p->p_stats->p_start);
        ap->ac_etime = compress(t.tv_sec, t.tv_usec);
        ap->ac_etime = compress(t.tv_sec, t.tv_usec);
-       ap->ac_btime = u.u_start.tv_sec;
-       ap->ac_uid = p->p_ruid;
-       ap->ac_gid = p->p_rgid;
+       ap->ac_btime = p->p_stats->p_start.tv_sec;
+       ap->ac_uid = p->p_cred->p_ruid;
+       ap->ac_gid = p->p_cred->p_rgid;
        t = st;
        timevaladd(&t, &ut);
        if (i = t.tv_sec * hz + t.tv_usec / tick)
        t = st;
        timevaladd(&t, &ut);
        if (i = t.tv_sec * hz + t.tv_usec / tick)
-               ap->ac_mem = (ru->ru_ixrss+ru->ru_idrss+ru->ru_isrss) / i;
+               ap->ac_mem = (ru->ru_ixrss + ru->ru_idrss + ru->ru_isrss) / i;
        else
                ap->ac_mem = 0;
        ap->ac_io = compress(ru->ru_inblock + ru->ru_oublock, (long)0);
        else
                ap->ac_mem = 0;
        ap->ac_io = compress(ru->ru_inblock + ru->ru_oublock, (long)0);
@@ -152,9 +151,9 @@ acct(p)
                ap->ac_tty = p->p_session->s_ttyp->t_dev;
        else
                ap->ac_tty = NODEV;
                ap->ac_tty = p->p_session->s_ttyp->t_dev;
        else
                ap->ac_tty = NODEV;
-       ap->ac_flag = u.u_acflag;
+       ap->ac_flag = p->p_acflag;
        return (vn_rdwr(UIO_WRITE, vp, (caddr_t)ap, sizeof (acctbuf),
        return (vn_rdwr(UIO_WRITE, vp, (caddr_t)ap, sizeof (acctbuf),
-               (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_APPEND, u.u_cred, (int *)0));
+           (off_t)0, UIO_SYSSPACE, IO_UNIT|IO_APPEND, p->p_ucred, (int *)0));
 }
 
 /*
 }
 
 /*
index 57b4316..fc07bc5 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)kern_sysctl.c       7.12 (Berkeley) %G%
+ *     @(#)kern_sysctl.c       7.13 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -31,11 +31,11 @@ getkerninfo(p, uap, retval)
        int *retval;
 {
 
        int *retval;
 {
 
-       int     bufsize,        /* max size of users buffer */
-               needed, locked, (*server)(), error = 0;
+       int bufsize;            /* max size of users buffer */
+       int needed, locked, (*server)(), error = 0;
 
 
-       if (error = copyin((caddr_t)uap->size,
-                               (caddr_t)&bufsize, sizeof (bufsize)))
+       if (error = copyin((caddr_t)uap->size, (caddr_t)&bufsize,
+           sizeof (bufsize)))
                goto done;
 
        switch (ki_type(uap->op)) {
                goto done;
 
        switch (ki_type(uap->op)) {
@@ -139,12 +139,12 @@ again:
                        break;
 
                case KINFO_PROC_UID:
                        break;
 
                case KINFO_PROC_UID:
-                       if (p->p_uid != (uid_t)arg)
+                       if (p->p_ucred->cr_uid != (uid_t)arg)
                                continue;
                        break;
 
                case KINFO_PROC_RUID:
                                continue;
                        break;
 
                case KINFO_PROC_RUID:
-                       if (p->p_ruid != (uid_t)arg)
+                       if (p->p_cred->p_ruid != (uid_t)arg)
                                continue;
                        break;
                }
                                continue;
                        break;
                }
@@ -156,6 +156,9 @@ again:
                                return (error);
                        eproc.e_paddr = p;
                        eproc.e_sess = p->p_pgrp->pg_session;
                                return (error);
                        eproc.e_paddr = p;
                        eproc.e_sess = p->p_pgrp->pg_session;
+                       eproc.e_pcred = *p->p_cred;
+                       eproc.e_ucred = *p->p_ucred;
+                       eproc.e_vm = *p->p_vmspace;
                        eproc.e_pgid = p->p_pgrp->pg_id;
                        eproc.e_jobc = p->p_pgrp->pg_jobc;
                        if ((p->p_flag&SCTTY) && 
                        eproc.e_pgid = p->p_pgrp->pg_id;
                        eproc.e_jobc = p->p_pgrp->pg_jobc;
                        if ((p->p_flag&SCTTY) && 
index 140d7fe..da18fe3 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)tty.c       7.37 (Berkeley) %G%
+ *     @(#)tty.c       7.38 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -85,7 +85,6 @@ char partab[] = {
 };
 
 extern struct tty *constty;            /* temporary virtual console */
 };
 
 extern struct tty *constty;            /* temporary virtual console */
-extern char partab[], maptab[];
 
 /*
  * Is 'c' a line delimiter ("break" character)?
 
 /*
  * Is 'c' a line delimiter ("break" character)?
@@ -107,6 +106,7 @@ extern char partab[], maptab[];
 ttychars(tp)
        struct tty *tp;
 {
 ttychars(tp)
        struct tty *tp;
 {
+
        bcopy(ttydefchars, tp->t_cc, sizeof(ttydefchars));
 }
 
        bcopy(ttydefchars, tp->t_cc, sizeof(ttydefchars));
 }
 
@@ -207,12 +207,20 @@ ttyblock(tp)
 }
 
 /*
 }
 
 /*
- * Restart typewriter output following a delay
- * timeout.
- * The name of the routine is passed to the timeout
- * subroutine and it is called during a clock interrupt.
+ * Start output on the typewriter. It is used from the top half
+ * after some characters have been put on the output queue,
+ * from the interrupt routine to transmit the next
+ * character.
  */
  */
-ttrstrt(tp)
+ttstart(tp)
+       struct tty *tp;
+{
+
+       if (tp->t_oproc)                /* kludge for pty */
+               (*tp->t_oproc)(tp);
+}
+
+ttrstrt(tp)                            /* XXX */
        struct tty *tp;
 {
 
        struct tty *tp;
 {
 
@@ -224,19 +232,6 @@ ttrstrt(tp)
        ttstart(tp);
 }
 
        ttstart(tp);
 }
 
-/*
- * Start output on the typewriter. It is used from the top half
- * after some characters have been put on the output queue,
- * from the interrupt routine to transmit the next
- * character, and after a timeout has finished.
- */
-ttstart(tp)
-       struct tty *tp;
-{
-
-       if (tp->t_oproc)                /* kludge for pty */
-               (*tp->t_oproc)(tp);
-}
 
 /*
  * Common code for tty ioctls.
 
 /*
  * Common code for tty ioctls.
@@ -246,6 +241,7 @@ ttioctl(tp, com, data, flag)
        register struct tty *tp;
        caddr_t data;
 {
        register struct tty *tp;
        caddr_t data;
 {
+       register struct proc *p = curproc;              /* XXX */
        extern int nldisp;
        int soft;
        int s, error;
        extern int nldisp;
        int soft;
        int s, error;
@@ -273,12 +269,11 @@ ttioctl(tp, com, data, flag)
        case TIOCLSET:
        case OTIOCSETD:
 #endif
        case TIOCLSET:
        case OTIOCSETD:
 #endif
-               while (isbackground(u.u_procp, tp) && 
-                  u.u_procp->p_pgrp->pg_jobc &&
-                  (u.u_procp->p_flag&SVFORK) == 0 &&
-                  (u.u_procp->p_sigignore & sigmask(SIGTTOU)) == 0 &&
-                  (u.u_procp->p_sigmask & sigmask(SIGTTOU)) == 0) {
-                       pgsignal(u.u_procp->p_pgrp, SIGTTOU, 1);
+               while (isbackground(curproc, tp) && 
+                  p->p_pgrp->pg_jobc && (p->p_flag&SPPWAIT) == 0 &&
+                  (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
+                  (p->p_sigmask & sigmask(SIGTTOU)) == 0) {
+                       pgsignal(p->p_pgrp, SIGTTOU, 1);
                        if (error = ttysleep(tp, (caddr_t)&lbolt, 
                            TTOPRI | PCATCH, ttybg, 0)) 
                                return (error);
                        if (error = ttysleep(tp, (caddr_t)&lbolt, 
                            TTOPRI | PCATCH, ttybg, 0)) 
                                return (error);
@@ -387,9 +382,9 @@ ttioctl(tp, com, data, flag)
         * Simulate typing of a character at the terminal.
         */
        case TIOCSTI:
         * Simulate typing of a character at the terminal.
         */
        case TIOCSTI:
-               if (u.u_uid && (flag & FREAD) == 0)
+               if (p->p_ucred->cr_uid && (flag & FREAD) == 0)
                        return (EPERM);
                        return (EPERM);
-               if (u.u_uid && !isctty(u.u_procp, tp))
+               if (p->p_ucred->cr_uid && !isctty(p, tp))
                        return (EACCES);
                (*linesw[tp->t_line].l_rint)(*(char *)data, tp);
                break;
                        return (EACCES);
                (*linesw[tp->t_line].l_rint)(*(char *)data, tp);
                break;
@@ -451,7 +446,6 @@ ttioctl(tp, com, data, flag)
         * Set terminal process group.
         */
        case TIOCSPGRP: {
         * Set terminal process group.
         */
        case TIOCSPGRP: {
-               register struct proc *p = u.u_procp;
                register struct pgrp *pgrp = pgfind(*(int *)data);
 
                if (!isctty(p, tp))
                register struct pgrp *pgrp = pgfind(*(int *)data);
 
                if (!isctty(p, tp))
@@ -463,7 +457,7 @@ ttioctl(tp, com, data, flag)
        }
 
        case TIOCGPGRP:
        }
 
        case TIOCGPGRP:
-               if (!isctty(u.u_procp, tp))
+               if (!isctty(p, tp))
                        return (ENOTTY);
                *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
                break;
                        return (ENOTTY);
                *(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
                break;
@@ -487,7 +481,7 @@ ttioctl(tp, com, data, flag)
                            (TS_CARR_ON|TS_ISOPEN))
                                return (EBUSY);
 #ifndef        UCONSOLE
                            (TS_CARR_ON|TS_ISOPEN))
                                return (EBUSY);
 #ifndef        UCONSOLE
-                       if (error = suser(u.u_cred, &u.u_acflag))
+                       if (error = suser(p->p_ucred, &p->p_acflag))
                                return (error);
 #endif
                        constty = tp;
                                return (error);
 #endif
                        constty = tp;
@@ -495,24 +489,6 @@ ttioctl(tp, com, data, flag)
                        constty = NULL;
                break;
 
                        constty = NULL;
                break;
 
-#ifdef COMPAT_43
-       case TIOCGETP:
-       case TIOCSETP:
-       case TIOCSETN:
-       case TIOCGETC:
-       case TIOCSETC:
-       case TIOCSLTC:
-       case TIOCGLTC:
-       case TIOCLBIS:
-       case TIOCLBIC:
-       case TIOCLSET:
-       case TIOCLGET:
-       case OTIOCGETD:
-       case OTIOCSETD:
-       case OTIOCCONS:
-               return(ttcompat(tp, com, data, flag));
-#endif
-
        /* allow old ioctls for now */
        case TIOCGETP:
        case TIOCSETP:
        /* allow old ioctls for now */
        case TIOCGETP:
        case TIOCSETP:
@@ -528,7 +504,11 @@ ttioctl(tp, com, data, flag)
                return(ottioctl(tp, com, data, flag));
 
        default:
                return(ottioctl(tp, com, data, flag));
 
        default:
+#ifdef COMPAT_43
+               return (ttcompat(tp, com, data, flag));
+#else
                return (-1);
                return (-1);
+#endif
        }
        return (0);
 }
        }
        return (0);
 }
@@ -604,7 +584,7 @@ ttselect(dev, rw)
                if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait)
                        tp->t_state |= TS_RCOLL;
                else
                if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait)
                        tp->t_state |= TS_RCOLL;
                else
-                       tp->t_rsel = u.u_procp;
+                       tp->t_rsel = curproc;
                break;
 
        case FWRITE:
                break;
 
        case FWRITE:
@@ -613,7 +593,7 @@ ttselect(dev, rw)
                if (tp->t_wsel && tp->t_wsel->p_wchan == (caddr_t)&selwait)
                        tp->t_state |= TS_WCOLL;
                else
                if (tp->t_wsel && tp->t_wsel->p_wchan == (caddr_t)&selwait)
                        tp->t_state |= TS_WCOLL;
                else
-                       tp->t_wsel = u.u_procp;
+                       tp->t_wsel = curproc;
                break;
        }
        splx(s);
                break;
        }
        splx(s);
@@ -869,27 +849,6 @@ ttyinput(c, tp)
                }
                if (CCEQ(cc[VSTART], c))
                        goto restartoutput;
                }
                if (CCEQ(cc[VSTART], c))
                        goto restartoutput;
-       }
-       /*
-        * Non canonical mode, don't process line editing
-        * characters; check high water mark for wakeup.
-        * 
-        * 
-        */
-       if (!(lflag&ICANON)) {
-               if (tp->t_rawq.c_cc > TTYHOG) {
-                       if (iflag&IMAXBEL) {
-                               if (tp->t_outq.c_cc < tp->t_hiwat)
-                                       (void) ttyoutput(CTRL('g'), tp);
-                       } else
-                               ttyflush(tp, FREAD | FWRITE);
-               } else {
-                       if (putc(c, &tp->t_rawq) >= 0) {
-                               ttwakeup(tp);
-                               ttyecho(c, tp);
-                       }
-               }
-               goto endcase;
        }
                        c = unputc(&tp->t_rawq);
                } while (c != ' ' && c != '\t');
        }
                        c = unputc(&tp->t_rawq);
                } while (c != ' ' && c != '\t');
@@ -906,7 +865,7 @@ ttyinput(c, tp)
        /*
         * Check for input buffer overflow
         */
        /*
         * Check for input buffer overflow
         */
-       if (tp->t_rawq.c_cc+tp->t_canq.c_cc >= TTYHOG) {
+       if (tp->t_rawq.c_cc + tp->t_canq.c_cc >= TTYHOG) {
                if (iflag&IMAXBEL) {
                        if (tp->t_outq.c_cc < TTHIWAT(tp))
                                (void) ttyoutput(CTRL('g'), tp);
                if (iflag&IMAXBEL) {
                        if (tp->t_outq.c_cc < TTHIWAT(tp))
                                (void) ttyoutput(CTRL('g'), tp);
@@ -919,6 +878,11 @@ ttyinput(c, tp)
         * wakeup on seeing a line delimiter.
         */
        if (putc(c, &tp->t_rawq) >= 0) {
         * wakeup on seeing a line delimiter.
         */
        if (putc(c, &tp->t_rawq) >= 0) {
+               if ((lflag&ICANON) == 0) {
+                       ttwakeup(tp);
+                       ttyecho(c, tp);
+                       goto endcase;
+               }
                if (ttbreakc(c)) {
                        tp->t_rocount = 0;
                        catq(&tp->t_rawq, &tp->t_canq);
                if (ttbreakc(c)) {
                        tp->t_rocount = 0;
                        catq(&tp->t_rawq, &tp->t_canq);
@@ -1013,7 +977,7 @@ ttyoutput(c, tp)
                return (c ? -1 : '\t');
        }
        if (c == CEOT && oflag&ONOEOT)
                return (c ? -1 : '\t');
        }
        if (c == CEOT && oflag&ONOEOT)
-               return(-1);
+               return (-1);
        tk_nout++;
        tp->t_outcc++;
 #ifdef notdef
        tk_nout++;
        tp->t_outcc++;
 #ifdef notdef
@@ -1025,18 +989,9 @@ ttyoutput(c, tp)
                return (c);
        if ((tp->t_lflag&FLUSHO) == 0 && putc(c, &tp->t_outq))
                return (c);
                return (c);
        if ((tp->t_lflag&FLUSHO) == 0 && putc(c, &tp->t_outq))
                return (c);
-       /*
-        * Calculate delays.
-        * The numbers here represent clock ticks
-        * and are not necessarily optimal for all terminals.
-        *
-        * SHOULD JUST ALLOW USER TO SPECIFY DELAYS
-        *
-        * (actually, should THROW AWAY terminals which need delays)
-        */
+
        colp = &tp->t_col;
        ctype = partab[c];
        colp = &tp->t_col;
        ctype = partab[c];
-       c = 0;
        switch (ctype&077) {
 
        case ORDINARY:
        switch (ctype&077) {
 
        case ORDINARY:
@@ -1050,61 +1005,20 @@ ttyoutput(c, tp)
                        (*colp)--;
                break;
 
                        (*colp)--;
                break;
 
-       /*
-        * This macro is close enough to the correct thing;
-        * it should be replaced by real user settable delays
-        * in any event...
-        */
-#define        mstohz(ms)      (((ms) * hz) >> 10)
        case NEWLINE:
        case NEWLINE:
-               ctype = (tp->t_flags >> 8) & 03;
-               if (ctype == 1) { /* tty 37 */
-                       if (*colp > 0) {
-                               c = (((unsigned)*colp) >> 4) + 3;
-                               if ((unsigned)c > 6)
-                                       c = 6;
-                       }
-               } else if (ctype == 2) /* vt05 */
-                       c = mstohz(100);
                *colp = 0;
                break;
 
        case TAB:
                *colp = 0;
                break;
 
        case TAB:
-               ctype = (tp->t_flags >> 10) & 03;
-               if (ctype == 1) { /* tty 37 */
-                       c = 1 - (*colp | ~07);
-                       if (c < 5)
-                               c = 0;
-               }
                *colp |= 07;
                (*colp)++;
                break;
 
                *colp |= 07;
                (*colp)++;
                break;
 
-       case VTAB:
-               if (tp->t_flags&VTDELAY) /* tty 37 */
-                       c = 0177;
-               break;
-
        case RETURN:
        case RETURN:
-               ctype = (tp->t_flags >> 12) & 03;
-               if (ctype == 1) /* tn 300 */
-                       c = mstohz(83);
-               else if (ctype == 2) /* ti 700 */
-                       c = mstohz(166);
-               else if (ctype == 3) { /* concept 100 */
-                       int i;
-
-                       if ((i = *colp) >= 0)
-                               for (; i < 9; i++)
-                                       (void) putc(0177, &tp->t_outq);
-               }
                *colp = 0;
        }
                *colp = 0;
        }
-       if (c && (tp->t_lflag&FLUSHO) == 0)
-               (void) putc(c|TTY_QUOTE, &tp->t_outq);
        return (-1);
 }
        return (-1);
 }
-#undef mstohz
 
 /*
  * Called from device's read routine after it has
 
 /*
  * Called from device's read routine after it has
@@ -1135,12 +1049,12 @@ loop:
        /*
         * Hang process if it's in the background.
         */
        /*
         * Hang process if it's in the background.
         */
-       if (isbackground(u.u_procp, tp)) {
-               if ((u.u_procp->p_sigignore & sigmask(SIGTTIN)) ||
-                  (u.u_procp->p_sigmask & sigmask(SIGTTIN)) ||
-                   u.u_procp->p_flag&SVFORK || u.u_procp->p_pgrp->pg_jobc == 0)
+       if (isbackground(p, tp)) {
+               if ((p->p_sigignore & sigmask(SIGTTIN)) ||
+                  (p->p_sigmask & sigmask(SIGTTIN)) ||
+                   p->p_flag&SPPWAIT || p->p_pgrp->pg_jobc == 0)
                        return (EIO);
                        return (EIO);
-               pgsignal(u.u_procp->p_pgrp, SIGTTIN, 1);
+               pgsignal(p->p_pgrp, SIGTTIN, 1);
                if (error = ttysleep(tp, (caddr_t)&lbolt, TTIPRI | PCATCH, 
                    ttybg, 0)) 
                        return (error);
                if (error = ttysleep(tp, (caddr_t)&lbolt, TTIPRI | PCATCH, 
                    ttybg, 0)) 
                        return (error);
@@ -1251,11 +1165,11 @@ ttycheckoutq(tp, wait)
 
        hiwat = tp->t_hiwat;
        s = spltty();
 
        hiwat = tp->t_hiwat;
        s = spltty();
-       oldsig = u.u_procp->p_sig;
+       oldsig = curproc->p_sig;
        if (tp->t_outq.c_cc > hiwat + 200)
                while (tp->t_outq.c_cc > hiwat) {
                        ttstart(tp);
        if (tp->t_outq.c_cc > hiwat + 200)
                while (tp->t_outq.c_cc > hiwat) {
                        ttstart(tp);
-                       if (wait == 0 || u.u_procp->p_sig != oldsig) {
+                       if (wait == 0 || curproc->p_sig != oldsig) {
                                splx(s);
                                return (0);
                        }
                                splx(s);
                                return (0);
                        }
@@ -1277,6 +1191,7 @@ ttwrite(tp, uio, flag)
 {
        register char *cp;
        register int cc = 0, ce;
 {
        register char *cp;
        register int cc = 0, ce;
+       register struct proc *p = curproc;
        int i, hiwat, cnt, error, s;
        char obuf[OBUFSIZ];
 
        int i, hiwat, cnt, error, s;
        char obuf[OBUFSIZ];
 
@@ -1309,11 +1224,12 @@ loop:
        /*
         * Hang the process if it's in the background.
         */
        /*
         * Hang the process if it's in the background.
         */
-           (tp->t_lflag&TOSTOP) && (u.u_procp->p_flag&SVFORK)==0 &&
-           (u.u_procp->p_sigignore & sigmask(SIGTTOU)) == 0 &&
-           (u.u_procp->p_sigmask & sigmask(SIGTTOU)) == 0 &&
-            u.u_procp->p_pgrp->pg_jobc) {
-               pgsignal(u.u_procp->p_pgrp, SIGTTOU, 1);
+       if (isbackground(p, tp) && 
+           tp->t_lflag&TOSTOP && (p->p_flag&SPPWAIT) == 0 &&
+           (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
+           (p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
+            p->p_pgrp->pg_jobc) {
+               pgsignal(p->p_pgrp, SIGTTOU, 1);
                if (error = ttysleep(tp, (caddr_t)&lbolt, TTIPRI | PCATCH, 
                    ttybg, 0))
                        goto out;
                if (error = ttysleep(tp, (caddr_t)&lbolt, TTIPRI | PCATCH, 
                    ttybg, 0))
                        goto out;
@@ -1484,7 +1400,7 @@ ttyrub(c, tp)
                case BACKSPACE:
                case CONTROL:
                case RETURN:
                case BACKSPACE:
                case CONTROL:
                case RETURN:
-               case NEWLINE:   /* XXX can't happen ? */
+               case NEWLINE:
                        if (tp->t_lflag&ECHOCTL)
                                ttyrubo(tp, 2);
                        break;
                        if (tp->t_lflag&ECHOCTL)
                                ttyrubo(tp, 2);
                        break;
@@ -1616,7 +1532,7 @@ ttyoutstr(cp, tp)
 }
 
 ttwakeup(tp)
 }
 
 ttwakeup(tp)
-       struct tty *tp;
+       register struct tty *tp;
 {
 
        if (tp->t_rsel) {
 {
 
        if (tp->t_rsel) {
@@ -1650,18 +1566,6 @@ ttsetwater(tp)
 #undef clamp
 }
 
 #undef clamp
 }
 
-ttspeedtab(speed, table)
-       struct speedtab table[];
-{
-       register int i;
-
-       for (i = 0; table[i].sp_speed != -1; i++)
-               if (table[i].sp_speed == speed)
-                       return(table[i].sp_code);
-       return(-1);
-}
-
-int ttyhostname = 0;
 /*
  * (^T)
  * Report on state of foreground process group.
 /*
  * (^T)
  * Report on state of foreground process group.
@@ -1700,11 +1604,11 @@ ttyinfo(tp)
                /* 
                 * cpu time 
                 */
                /* 
                 * cpu time 
                 */
-               if (u.u_procp == pick)
+               if (curproc == pick)
                        s = splclock();
                utime = pick->p_utime;
                stime = pick->p_stime;
                        s = splclock();
                utime = pick->p_utime;
                stime = pick->p_stime;
-               if (u.u_procp == pick)
+               if (curproc == pick)
                        splx(s);
                /* user time */
                x = (utime.tv_usec + 5000) / 10000; /* scale to 100's */
                        splx(s);
                /* user time */
                x = (utime.tv_usec + 5000) / 10000; /* scale to 100's */
@@ -1729,7 +1633,7 @@ ttyinfo(tp)
                tputchar('.', tp);
                ttyoutint(x%100, 10, 2, tp);
 #endif
                tputchar('.', tp);
                ttyoutint(x%100, 10, 2, tp);
 #endif
-               ttyprintf(tp, "%% %dk\n", pgtok(pick->p_rssize));
+               ttyprintf(tp, "%% %dk\n", pgtok(pick->p_vmspace->vm_rssize));
        }
        tp->t_rocount = 0;      /* so pending input will be retyped if BS */
 }
        }
        tp->t_rocount = 0;      /* so pending input will be retyped if BS */
 }
@@ -1821,9 +1725,10 @@ proc_compare(p1, p2)
                return (1);
        if (p2->p_flag&SSINTR && (p1->p_flag&SSINTR) == 0)
                return (0);
                return (1);
        if (p2->p_flag&SSINTR && (p1->p_flag&SSINTR) == 0)
                return (0);
-       return(p2->p_pid > p1->p_pid);          /* tie - return highest pid */
+       return (p2->p_pid > p1->p_pid);         /* tie - return highest pid */
 }
 
 }
 
+/* XXX move to subr_prf.c */
 #define TOTTY  0x2     /* XXX should be in header */
 /*VARARGS2*/
 ttyprintf(tp, fmt, x1)
 #define TOTTY  0x2     /* XXX should be in header */
 /*VARARGS2*/
 ttyprintf(tp, fmt, x1)
@@ -1843,8 +1748,7 @@ tputchar(c, tp)
 {
        register s = spltty();
 
 {
        register s = spltty();
 
-       if ((tp->t_state & (TS_CARR_ON | TS_ISOPEN)) 
-           == (TS_CARR_ON | TS_ISOPEN)) {
+       if ((tp->t_state & (TS_CARR_ON|TS_ISOPEN)) == (TS_CARR_ON|TS_ISOPEN)) {
                if (c == '\n')
                        (void) ttyoutput('\r', tp);
                (void) ttyoutput(c, tp);
                if (c == '\n')
                        (void) ttyoutput('\r', tp);
                (void) ttyoutput(c, tp);
index 80c66cb..177c38b 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)tty_subr.c  7.5 (Berkeley) %G%
+ *     @(#)tty_subr.c  7.6 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -23,6 +23,23 @@ char cwaiting;
                (int)(cp)&CROUND)
 #define cbptr(x) ((struct cblock *)(x))
 
                (int)(cp)&CROUND)
 #define cbptr(x) ((struct cblock *)(x))
 
+/*
+ * Initialize clist by freeing all character blocks.
+ */
+cinit()
+{
+       register int ccp;
+       register struct cblock *cp;
+
+       ccp = (int) cfree;
+       ccp = (ccp + CROUND) & ~CROUND;
+       for(cp = (struct cblock *) ccp; cp < &cfree[nclist - 1]; cp++) {
+               cp->c_next = cfreelist;
+               cfreelist = cp;
+               cfreecount += CBSIZE;
+       }
+}
+
 /*
  * Character list get/put
  */
 /*
  * Character list get/put
  */
index 7fb68d7..53b29dc 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)tty_tty.c   7.9 (Berkeley) %G%
+ *     @(#)tty_tty.c   7.10 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #define cttyvp(p) ((p)->p_flag&SCTTY ? (p)->p_session->s_ttyvp : NULL)
 
 /*ARGSUSED*/
 #define cttyvp(p) ((p)->p_flag&SCTTY ? (p)->p_session->s_ttyvp : NULL)
 
 /*ARGSUSED*/
-syopen(dev, flag)
+cttyopen(dev, flag)
        dev_t dev;
        int flag;
 {
        dev_t dev;
        int flag;
 {
-       struct vnode *ttyvp = cttyvp(u.u_procp);
+       struct proc *p = curproc;
+       struct vnode *ttyvp = cttyvp(p);
        int error;
 
        if (ttyvp == NULL)
                return (ENXIO);
        VOP_LOCK(ttyvp);
        error = VOP_ACCESS(ttyvp,
        int error;
 
        if (ttyvp == NULL)
                return (ENXIO);
        VOP_LOCK(ttyvp);
        error = VOP_ACCESS(ttyvp,
-          (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), u.u_cred);
+          (flag&FREAD ? VREAD : 0) | (flag&FWRITE ? VWRITE : 0), p->p_ucred);
        VOP_UNLOCK(ttyvp);
        if (error)
                return (error);
        VOP_UNLOCK(ttyvp);
        if (error)
                return (error);
@@ -42,11 +43,11 @@ syopen(dev, flag)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-syread(dev, uio, flag)
+cttyread(dev, uio, flag)
        dev_t dev;
        struct uio *uio;
 {
        dev_t dev;
        struct uio *uio;
 {
-       register struct vnode *ttyvp = cttyvp(u.u_procp);
+       register struct vnode *ttyvp = cttyvp(curproc);
        int error;
 
        if (ttyvp == NULL)
        int error;
 
        if (ttyvp == NULL)
@@ -58,11 +59,11 @@ syread(dev, uio, flag)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-sywrite(dev, uio, flag)
+cttywrite(dev, uio, flag)
        dev_t dev;
        struct uio *uio;
 {
        dev_t dev;
        struct uio *uio;
 {
-       register struct vnode *ttyvp = cttyvp(u.u_procp);
+       register struct vnode *ttyvp = cttyvp(curproc);
        int error;
 
        if (ttyvp == NULL)
        int error;
 
        if (ttyvp == NULL)
@@ -74,19 +75,19 @@ sywrite(dev, uio, flag)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-syioctl(dev, cmd, addr, flag)
+cttyioctl(dev, cmd, addr, flag)
        dev_t dev;
        int cmd;
        caddr_t addr;
        int flag;
 {
        dev_t dev;
        int cmd;
        caddr_t addr;
        int flag;
 {
-       struct vnode *ttyvp = cttyvp(u.u_procp);
+       struct vnode *ttyvp = cttyvp(curproc);
 
        if (ttyvp == NULL)
                return (ENXIO);
        if (cmd == TIOCNOTTY) {
 
        if (ttyvp == NULL)
                return (ENXIO);
        if (cmd == TIOCNOTTY) {
-               if (!SESS_LEADER(u.u_procp)) {
-                       u.u_procp->p_flag &= ~SCTTY;
+               if (!SESS_LEADER(curproc)) {
+                       curproc->p_flag &= ~SCTTY;
                        return (0);
                } else
                        return (EINVAL);
                        return (0);
                } else
                        return (EINVAL);
@@ -95,11 +96,11 @@ syioctl(dev, cmd, addr, flag)
 }
 
 /*ARGSUSED*/
 }
 
 /*ARGSUSED*/
-syselect(dev, flag)
+cttyselect(dev, flag)
        dev_t dev;
        int flag;
 {
        dev_t dev;
        int flag;
 {
-       struct vnode *ttyvp = cttyvp(u.u_procp);
+       struct vnode *ttyvp = cttyvp(curproc);
 
        if (ttyvp == NULL)
                return (1);     /* try operation to get EOF/failure */
 
        if (ttyvp == NULL)
                return (1);     /* try operation to get EOF/failure */
index 4b8e9dd..b1c9808 100644 (file)
@@ -4,11 +4,12 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_bio.c   7.33 (Berkeley) %G%
+ *     @(#)vfs_bio.c   7.34 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "user.h"
  */
 
 #include "param.h"
 #include "user.h"
+#include "proc.h"
 #include "buf.h"
 #include "vnode.h"
 #include "specdev.h"
 #include "buf.h"
 #include "vnode.h"
 #include "specdev.h"
@@ -31,6 +32,7 @@ bread(vp, blkno, size, cred, bpp)
        long secsize;
 #endif SECSIZE
 {
        long secsize;
 #endif SECSIZE
 {
+       struct proc *p = curproc;               /* XXX */
        register struct buf *bp;
 
        if (size == 0)
        register struct buf *bp;
 
        if (size == 0)
@@ -53,7 +55,7 @@ bread(vp, blkno, size, cred, bpp)
        }
        VOP_STRATEGY(bp);
        trace(TR_BREADMISS, pack(vp, size), blkno);
        }
        VOP_STRATEGY(bp);
        trace(TR_BREADMISS, pack(vp, size), blkno);
-       u.u_ru.ru_inblock++;            /* pay for read */
+       p->p_stats->p_ru.ru_inblock++;          /* pay for read */
        return (biowait(bp));
 }
 
        return (biowait(bp));
 }
 
@@ -71,6 +73,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
        struct ucred *cred;
        struct buf **bpp;
 {
        struct ucred *cred;
        struct buf **bpp;
 {
+       struct proc *p = curproc;               /* XXX */
        register struct buf *bp, *rabp;
 
        bp = NULL;
        register struct buf *bp, *rabp;
 
        bp = NULL;
@@ -91,7 +94,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
                        }
                        VOP_STRATEGY(bp);
                        trace(TR_BREADMISS, pack(vp, size), blkno);
                        }
                        VOP_STRATEGY(bp);
                        trace(TR_BREADMISS, pack(vp, size), blkno);
-                       u.u_ru.ru_inblock++;            /* pay for read */
+                       p->p_stats->p_ru.ru_inblock++;  /* pay for read */
                } else
                        trace(TR_BREADHIT, pack(vp, size), blkno);
        }
                } else
                        trace(TR_BREADHIT, pack(vp, size), blkno);
        }
@@ -115,7 +118,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
                        }
                        VOP_STRATEGY(rabp);
                        trace(TR_BREADMISSRA, pack(vp, rabsize), rablkno);
                        }
                        VOP_STRATEGY(rabp);
                        trace(TR_BREADMISSRA, pack(vp, rabsize), rablkno);
-                       u.u_ru.ru_inblock++;            /* pay in advance */
+                       p->p_stats->p_ru.ru_inblock++;  /* pay in advance */
                }
        }
 
                }
        }
 
@@ -139,13 +142,14 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
 bwrite(bp)
        register struct buf *bp;
 {
 bwrite(bp)
        register struct buf *bp;
 {
+       struct proc *p = curproc;               /* XXX */
        register int flag;
        int s, error;
 
        flag = bp->b_flags;
        bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI);
        if ((flag & B_DELWRI) == 0)
        register int flag;
        int s, error;
 
        flag = bp->b_flags;
        bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI);
        if ((flag & B_DELWRI) == 0)
-               u.u_ru.ru_oublock++;            /* noone paid yet */
+               p->p_stats->p_ru.ru_oublock++;          /* no one paid yet */
        else
                reassignbuf(bp, bp->b_vp);
        trace(TR_BWRITE, pack(bp->b_vp, bp->b_bcount), bp->b_lblkno);
        else
                reassignbuf(bp, bp->b_vp);
        trace(TR_BWRITE, pack(bp->b_vp, bp->b_bcount), bp->b_lblkno);
@@ -185,11 +189,12 @@ bwrite(bp)
 bdwrite(bp)
        register struct buf *bp;
 {
 bdwrite(bp)
        register struct buf *bp;
 {
+       struct proc *p = curproc;               /* XXX */
 
        if ((bp->b_flags & B_DELWRI) == 0) {
                bp->b_flags |= B_DELWRI;
                reassignbuf(bp, bp->b_vp);
 
        if ((bp->b_flags & B_DELWRI) == 0) {
                bp->b_flags |= B_DELWRI;
                reassignbuf(bp, bp->b_vp);
-               u.u_ru.ru_oublock++;            /* noone paid yet */
+               p->p_stats->p_ru.ru_oublock++;          /* no one paid yet */
        }
        /*
         * If this is a tape drive, the write must be initiated.
        }
        /*
         * If this is a tape drive, the write must be initiated.
index 7671e0e..94a8d27 100644 (file)
@@ -4,11 +4,12 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_cluster.c       7.33 (Berkeley) %G%
+ *     @(#)vfs_cluster.c       7.34 (Berkeley) %G%
  */
 
 #include "param.h"
 #include "user.h"
  */
 
 #include "param.h"
 #include "user.h"
+#include "proc.h"
 #include "buf.h"
 #include "vnode.h"
 #include "specdev.h"
 #include "buf.h"
 #include "vnode.h"
 #include "specdev.h"
@@ -31,6 +32,7 @@ bread(vp, blkno, size, cred, bpp)
        long secsize;
 #endif SECSIZE
 {
        long secsize;
 #endif SECSIZE
 {
+       struct proc *p = curproc;               /* XXX */
        register struct buf *bp;
 
        if (size == 0)
        register struct buf *bp;
 
        if (size == 0)
@@ -53,7 +55,7 @@ bread(vp, blkno, size, cred, bpp)
        }
        VOP_STRATEGY(bp);
        trace(TR_BREADMISS, pack(vp, size), blkno);
        }
        VOP_STRATEGY(bp);
        trace(TR_BREADMISS, pack(vp, size), blkno);
-       u.u_ru.ru_inblock++;            /* pay for read */
+       p->p_stats->p_ru.ru_inblock++;          /* pay for read */
        return (biowait(bp));
 }
 
        return (biowait(bp));
 }
 
@@ -71,6 +73,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
        struct ucred *cred;
        struct buf **bpp;
 {
        struct ucred *cred;
        struct buf **bpp;
 {
+       struct proc *p = curproc;               /* XXX */
        register struct buf *bp, *rabp;
 
        bp = NULL;
        register struct buf *bp, *rabp;
 
        bp = NULL;
@@ -91,7 +94,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
                        }
                        VOP_STRATEGY(bp);
                        trace(TR_BREADMISS, pack(vp, size), blkno);
                        }
                        VOP_STRATEGY(bp);
                        trace(TR_BREADMISS, pack(vp, size), blkno);
-                       u.u_ru.ru_inblock++;            /* pay for read */
+                       p->p_stats->p_ru.ru_inblock++;  /* pay for read */
                } else
                        trace(TR_BREADHIT, pack(vp, size), blkno);
        }
                } else
                        trace(TR_BREADHIT, pack(vp, size), blkno);
        }
@@ -115,7 +118,7 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
                        }
                        VOP_STRATEGY(rabp);
                        trace(TR_BREADMISSRA, pack(vp, rabsize), rablkno);
                        }
                        VOP_STRATEGY(rabp);
                        trace(TR_BREADMISSRA, pack(vp, rabsize), rablkno);
-                       u.u_ru.ru_inblock++;            /* pay in advance */
+                       p->p_stats->p_ru.ru_inblock++;  /* pay in advance */
                }
        }
 
                }
        }
 
@@ -139,13 +142,14 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
 bwrite(bp)
        register struct buf *bp;
 {
 bwrite(bp)
        register struct buf *bp;
 {
+       struct proc *p = curproc;               /* XXX */
        register int flag;
        int s, error;
 
        flag = bp->b_flags;
        bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI);
        if ((flag & B_DELWRI) == 0)
        register int flag;
        int s, error;
 
        flag = bp->b_flags;
        bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI);
        if ((flag & B_DELWRI) == 0)
-               u.u_ru.ru_oublock++;            /* noone paid yet */
+               p->p_stats->p_ru.ru_oublock++;          /* no one paid yet */
        else
                reassignbuf(bp, bp->b_vp);
        trace(TR_BWRITE, pack(bp->b_vp, bp->b_bcount), bp->b_lblkno);
        else
                reassignbuf(bp, bp->b_vp);
        trace(TR_BWRITE, pack(bp->b_vp, bp->b_bcount), bp->b_lblkno);
@@ -185,11 +189,12 @@ bwrite(bp)
 bdwrite(bp)
        register struct buf *bp;
 {
 bdwrite(bp)
        register struct buf *bp;
 {
+       struct proc *p = curproc;               /* XXX */
 
        if ((bp->b_flags & B_DELWRI) == 0) {
                bp->b_flags |= B_DELWRI;
                reassignbuf(bp, bp->b_vp);
 
        if ((bp->b_flags & B_DELWRI) == 0) {
                bp->b_flags |= B_DELWRI;
                reassignbuf(bp, bp->b_vp);
-               u.u_ru.ru_oublock++;            /* noone paid yet */
+               p->p_stats->p_ru.ru_oublock++;          /* no one paid yet */
        }
        /*
         * If this is a tape drive, the write must be initiated.
        }
        /*
         * If this is a tape drive, the write must be initiated.