/* tty_bk.c 6.1 83/07/29 */
* Line discipline for Berkeley network.
* This supplies single lines to a user level program
* with a minimum of fuss. Lines are newline terminated.
* This discipline requires that tty device drivers call
* the line specific l_ioctl routine from their ioctl routines,
* assigning the result to cmd so that we can refuse most tty specific
* ioctls which are unsafe because we have ambushed the
* teletype input queues, overlaying them with other information.
* Open as networked discipline. Called when discipline changed
* with ioctl, this assigns a buffer to the line for input, and
* changing the interpretation of the information in the tty structure.
if (tp
->t_line
== NETLDISC
)
return (EBUSY
); /* sometimes the network opens /dev/tty */
ttyflush(tp
, FREAD
|FWRITE
);
tp
->t_cp
= (char *)bp
->b_un
.b_addr
;
* Break down... called when discipline changed or from device
wakeup((caddr_t
)&tp
->t_rawq
);
printf("bkclose: no buf\n");
tp
->t_line
= 0; /* paranoid: avoid races */
* Read from a network line.
* Characters have been buffered in a system buffer and are
* now dumped back to the user in one fell swoop, and with a
* minimum of fuss. Note that no input is accepted when a record
* is waiting. Our clearing tp->t_rec here allows further input
if ((tp
->t_state
&TS_CARR_ON
)==0)
while (tp
->t_rec
== 0 && tp
->t_line
== NETLDISC
)
sleep((caddr_t
)&tp
->t_rawq
, TTIPRI
);
if (tp
->t_line
!= NETLDISC
)
error
= uiomove(tp
->t_bufp
->b_un
.b_addr
, tp
->t_inbuf
, UIO_READ
, uio
);
tp
->t_cp
= (char *)tp
->t_bufp
->b_un
.b_addr
;
* Low level character input routine.
* Stuff the character in the buffer, and wake up the top
* half after setting t_rec if this completes the record
* or if the buffer is (ick!) full.
* Thisis where the formatting should get done to allow
* 8 character data paths through escapes.
* This rutine should be expanded in-line in the receiver
* interrupt routine of the dh-11 to make it run as fast as possible.
if (++tp
->t_inbuf
== 1024 || c
== '\n') {
wakeup((caddr_t
)&tp
->t_rawq
);
* This routine is called whenever a ioctl is about to be performed
* and gets a chance to reject the ioctl. We reject all teletype
* oriented ioctl's except those which set the discipline, and
* those which get parameters (gtty and get special characters).
bkioctl(tp
, cmd
, data
, flag
)