add definition for ability to produce a backtrace
[unix-history] / usr / src / sys / kern / tty_bk.c
index 0a19cc1..307d6cd 100644 (file)
@@ -1,18 +1,20 @@
-/*     tty_bk.c        4.2     82/08/01        */
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)tty_bk.c    7.3 (Berkeley) %G%
+ */
 
 #include "bk.h"
 
 #if NBK > 0
 
 #include "bk.h"
 
 #if NBK > 0
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/proc.h"
-#include "../h/inode.h"
-#include "../h/file.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
+#include "param.h"
+#include "user.h"
+#include "ioctl.h"
+#include "tty.h"
+#include "file.h"
+#include "buf.h"
 
 /*
  * Line discipline for Berkeley network.
 
 /*
  * Line discipline for Berkeley network.
@@ -39,18 +41,15 @@ bkopen(dev, tp)
 {
        register struct buf *bp;
 
 {
        register struct buf *bp;
 
-       if (u.u_error)
-               return;         /* paranoia */
-       if (tp->t_line == NETLDISC) {
-               u.u_error = EBUSY;              /* sometimes the network */
-               return;                         /* ... opens /dev/tty */
-       }
+       if (tp->t_line == NETLDISC)
+               return (EBUSY); /* sometimes the network opens /dev/tty */
        bp = geteblk(1024);
        bp = geteblk(1024);
-       flushtty(tp, FREAD|FWRITE);
+       ttyflush(tp, FREAD|FWRITE);
        tp->t_bufp = bp;
        tp->t_cp = (char *)bp->b_un.b_addr;
        tp->t_inbuf = 0;
        tp->t_rec = 0;
        tp->t_bufp = bp;
        tp->t_cp = (char *)bp->b_un.b_addr;
        tp->t_inbuf = 0;
        tp->t_rec = 0;
+       return (0);
 }
 
 /*
 }
 
 /*
@@ -58,9 +57,9 @@ bkopen(dev, tp)
  * close routine.
  */
 bkclose(tp)
  * close routine.
  */
 bkclose(tp)
-register struct tty *tp;
+       register struct tty *tp;
 {
 {
-       register s;
+       register int s;
 
        s = spl5();
        wakeup((caddr_t)&tp->t_rawq);
 
        s = spl5();
        wakeup((caddr_t)&tp->t_rawq);
@@ -84,11 +83,12 @@ register struct tty *tp;
  * is waiting.  Our clearing tp->t_rec here allows further input
  * to accumulate.
  */
  * is waiting.  Our clearing tp->t_rec here allows further input
  * to accumulate.
  */
-bkread(tp)
-register struct tty *tp;
+bkread(tp, uio)
+       register struct tty *tp;
+       struct uio *uio;
 {
 {
-       register int i;
-       register s;
+       register int s;
+       int error;
 
        if ((tp->t_state&TS_CARR_ON)==0)
                return (-1);
 
        if ((tp->t_state&TS_CARR_ON)==0)
                return (-1);
@@ -98,18 +98,11 @@ register struct tty *tp;
        splx(s);
        if (tp->t_line != NETLDISC)
                return (-1);
        splx(s);
        if (tp->t_line != NETLDISC)
                return (-1);
-       i = MIN(tp->t_inbuf, (int)u.u_count);
-       if (copyout(tp->t_bufp->b_un.b_addr, u.u_base, (unsigned)i)) {
-               u.u_error = EFAULT;
-               return (-1);
-       }
-       u.u_count -= i;
-       u.u_base += i;
-       u.u_offset += i;
+       error = uiomove(tp->t_bufp->b_un.b_addr, tp->t_inbuf, uio);
        tp->t_cp = (char *)tp->t_bufp->b_un.b_addr;
        tp->t_inbuf = 0;
        tp->t_rec = 0;
        tp->t_cp = (char *)tp->t_bufp->b_un.b_addr;
        tp->t_inbuf = 0;
        tp->t_rec = 0;
-       return (0);
+       return (error);
 }
 
 /*
 }
 
 /*
@@ -151,16 +144,15 @@ bkioctl(tp, cmd, data, flag)
 {
 
        if ((cmd>>8) != 't')
 {
 
        if ((cmd>>8) != 't')
-               return (cmd);
+               return (-1);
        switch (cmd) {
 
        case TIOCSETD:
        case TIOCGETD:
        case TIOCGETP:
        case TIOCGETC:
        switch (cmd) {
 
        case TIOCSETD:
        case TIOCGETD:
        case TIOCGETP:
        case TIOCGETC:
-               return (cmd);
+               return (-1);
        }
        }
-       u.u_error = ENOTTY;
-       return (0);
+       return (ENOTTY);
 }
 #endif
 }
 #endif