1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95 |
34 * $Id: tty_pty.c,v 1.37 1996/03/11 02:24:39 hsu Exp $ |
35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42 --- 486 unchanged lines hidden (view full) --- 529 return (error); 530 /* check again for safety */ 531 if ((tp->t_state & TS_ISOPEN) == 0) { 532 /* adjust as usual */ 533 uio->uio_resid += cc; 534 return (EIO); 535 } 536 } |
537 if (cc > 0) { 538 cc = b_to_q((char *)cp, cc, &tp->t_canq); 539 /* 540 * XXX we don't guarantee that the canq size 541 * is >= TTYHOG, so the above b_to_q() may 542 * leave some bytes uncopied. However, space 543 * is guaranteed for the null terminator if 544 * we don't fail here since (TTYHOG - 1) is 545 * not a multiple of CBSIZE. 546 */ 547 if (cc > 0) 548 break; 549 } |
550 } 551 /* adjust for data copied in but not written */ 552 uio->uio_resid += cc; 553 (void) putc(0, &tp->t_canq); 554 ttwakeup(tp); 555 wakeup(TSA_PTS_READ(tp)); 556 return (0); 557 } --- 22 unchanged lines hidden (view full) --- 580 cc--; 581 } 582 cc = 0; 583 } 584 return (0); 585block: 586 /* 587 * Come here to wait for slave to open, for space |
588 * in outq, or space in rawq, or an empty canq. |
589 */ 590 if ((tp->t_state & TS_CONNECTED) == 0) { 591 /* adjust for data copied in but not written */ 592 uio->uio_resid += cc; 593 return (EIO); 594 } 595 if (flag & IO_NDELAY) { 596 /* adjust for data copied in but not written */ --- 232 unchanged lines hidden --- |