summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1995-10-26 08:38:08 +0000
committerDavid Greenman <dg@FreeBSD.org>1995-10-26 08:38:08 +0000
commitdc8ebd9f1be77ea95aac5ae149e2a89c50460f36 (patch)
treea7ac6aaf9646bcf944448e1cd13020de1a8fd078 /sys
parentc846e4a63557c648e4f3708c17751e47fbefd854 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/tty_pty.c30
-rw-r--r--sys/kern/tty_subr.c10
2 files changed, 31 insertions, 9 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 1f83006f5441..3890a029c918 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
- * $Id: tty_pty.c,v 1.11.4.1 1995/09/14 07:10:05 davidg Exp $
+ * $Id: tty_pty.c,v 1.11.4.2 1995/09/26 15:38:27 davidg Exp $
*/
/*
@@ -52,6 +52,9 @@
#include <sys/vnode.h>
#include <sys/signalvar.h>
+void ptyattach __P((int n));
+void ptsstart __P((struct tty *tp));
+
#if NPTY == 1
#undef NPTY
#define NPTY 32 /* crude XXX */
@@ -486,7 +489,8 @@ again:
if (pti->pt_flags & PF_REMOTE) {
if (tp->t_canq.c_cc)
goto block;
- while (uio->uio_resid > 0 && tp->t_canq.c_cc < TTYHOG - 1) {
+ while ((uio->uio_resid > 0 || cc > 0) &&
+ tp->t_canq.c_cc < TTYHOG - 1) {
if (cc == 0) {
cc = min(uio->uio_resid, BUFSIZ);
cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
@@ -495,19 +499,23 @@ again:
if (error)
return (error);
/* check again for safety */
- if ((tp->t_state&TS_ISOPEN) == 0)
+ if ((tp->t_state & TS_ISOPEN) == 0) {
+ /* adjust as usual */
+ uio->uio_resid += cc;
return (EIO);
+ }
}
if (cc)
- (void) b_to_q((char *)cp, cc, &tp->t_canq);
- cc = 0;
+ cc -= b_to_q((char *)cp, cc, &tp->t_canq);
}
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
(void) putc(0, &tp->t_canq);
ttwakeup(tp);
wakeup(TSA_PTS_READ(tp));
return (0);
}
- while (uio->uio_resid > 0) {
+ while (uio->uio_resid > 0 || cc > 0) {
if (cc == 0) {
cc = min(uio->uio_resid, BUFSIZ);
cp = locbuf;
@@ -515,8 +523,11 @@ again:
if (error)
return (error);
/* check again for safety */
- if ((tp->t_state&TS_ISOPEN) == 0)
+ if ((tp->t_state & TS_ISOPEN) == 0) {
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
return (EIO);
+ }
}
while (cc > 0) {
if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
@@ -536,8 +547,11 @@ block:
* Come here to wait for slave to open, for space
* in outq, or space in rawq.
*/
- if ((tp->t_state & TS_CONNECTED) == 0)
+ if ((tp->t_state & TS_CONNECTED) == 0) {
+ /* adjust for data copied in but not written */
+ uio->uio_resid += cc;
return (EIO);
+ }
if (flag & IO_NDELAY) {
/* adjust for data copied in but not written */
uio->uio_resid += cc;
diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c
index eb4a62ad8a76..6b69bbc65180 100644
--- a/sys/kern/tty_subr.c
+++ b/sys/kern/tty_subr.c
@@ -6,7 +6,7 @@
* of this software, nor does the author assume any responsibility
* for damages incurred with its use.
*
- * $Id: tty_subr.c,v 1.11 1995/07/11 19:39:54 bde Exp $
+ * $Id: tty_subr.c,v 1.10.4.1 1995/09/14 07:10:07 davidg Exp $
*/
/*
@@ -127,6 +127,14 @@ clist_alloc_cblocks(clistp, ccmax, ccreserved)
{
int dcbr;
+ /*
+ * Allow for wasted space at the head.
+ */
+ if (ccmax != 0)
+ ccmax += CBSIZE - 1;
+ if (ccreserved != 0)
+ ccreserved += CBSIZE - 1;
+
clistp->c_cbmax = roundup(ccmax, CBSIZE) / CBSIZE;
dcbr = roundup(ccreserved, CBSIZE) / CBSIZE - clistp->c_cbreserved;
if (dcbr >= 0)