move copyin() call so if uap->size pointer is null, still return size
[unix-history] / usr / src / sys / kern / tty_bk.c
index f6b71d8..307d6cd 100644 (file)
@@ -1,19 +1,20 @@
-/*     tty_bk.c        4.5     82/10/13        */
+/*
+ * 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 "../h/uio.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.
@@ -40,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);
 }
 
 /*
 }
 
 /*
@@ -59,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);
@@ -89,7 +87,7 @@ bkread(tp, uio)
        register struct tty *tp;
        struct uio *uio;
 {
        register struct tty *tp;
        struct uio *uio;
 {
-       register int i, s;
+       register int s;
        int error;
 
        if ((tp->t_state&TS_CARR_ON)==0)
        int error;
 
        if ((tp->t_state&TS_CARR_ON)==0)
@@ -100,7 +98,7 @@ bkread(tp, uio)
        splx(s);
        if (tp->t_line != NETLDISC)
                return (-1);
        splx(s);
        if (tp->t_line != NETLDISC)
                return (-1);
-       error = uiomove(tp->t_bufp->b_un.b_addr, tp->t_inbuf, UIO_READ, uio);
+       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;
@@ -146,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