[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] vttest
Peter Persson wrote:
> > I'll have to do some cleanup and hopefully can commit the changes to =
> the kernel in the helmut-branch next weekend. But there's still the =
> question with the \r vs. \n - I suspect it may be a bug in vttest *and* =
> linux :) Or in conholio/toswin.
>
>
> Now that I think of it, VT100 has two modes for this; one which =
> generates \n, and one that generates \r\n.
>
> I've only implemented one of them, and forgot about the other. This =
> could very well be the problem.
This could be the reason for the failure.
I've just committed the patch to the kernel in my branch (also attached).
-Helmut
--- k_fds.c 9 Apr 2010 23:36:22 -0000 1.22.2.1
+++ k_fds.c 28 Jul 2010 19:27:34 -0000
@@ -244,7 +244,7 @@
char temp1[PATH_MAX];
short cur_gid, cur_egid;
- TRACE (("do_open(%s)", name));
+ TRACE (("do_open(%s) mode=%x", name, rwmode));
/*
* first step: get a cookie for the directory
@@ -471,11 +471,17 @@
FP_FREE (*f);
*f = fp;
+ if( rwmode & O_NDELAY )
+ (*f)->flags |= O_NDELAY;
+ else
+ (*f)->flags &= ~O_NDELAY;
+
fp->links++;
release_cookie (&dir);
release_cookie (&fc);
+ DEBUG(("do_open: fakedev -> 0"));
return 0;
}
@@ -648,6 +654,16 @@
// XXX return 0;
}
+
+ if (is_terminal (f))
+ {
+ struct tty *tty = (struct tty *) f->devinfo;
+ DEBUG(("do_close(terminal): flags=%x links=%d pgrp=%d/%d", f->flags, f->links, tty->pgrp, get_curproc()->pgrp));
+
+ /* reset O_NDELAY if tty is not bound to a pgrp */
+ if( tty->pgrp != get_curproc()->pgrp )
+ f->flags &= ~O_NDELAY;
+ }
/* TTY manipulation must be done *before* calling the device close routine,
* since afterwards the TTY structure may no longer exist
*/
@@ -674,6 +690,7 @@
tty->hup_ospeed = -1;
/* stop output, flush buffers, drop DTR... */
tty_ioctl(f, TIOCSTOP, 0);
+ //FORCE("TIOCFLUSH for %lx", f);
tty_ioctl(f, TIOCFLUSH, 0);
if (ospeed > 0) {
tty->hup_ospeed = ospeed;
--- tty.c 9 Apr 2010 23:48:42 -0000 1.22.2.1
+++ tty.c 28 Jul 2010 19:27:37 -0000
@@ -108,7 +108,7 @@
long r;
long bytes_read = 0;
unsigned char ch, *ptr;
- int rdmode, mode;
+ int rdmode, mode, delayflg = 0;
struct tty *tty;
tty = (struct tty *) f->devinfo;
@@ -139,6 +139,8 @@
mode = T_TOS | T_ECHO | T_ECHOCTL;
}
+ DEBUG(("tty_read: pgrp=%d state=%x %ld bytes", tty->pgrp, tty->state, nbytes ));
+
if (nbytes == 0)
return bytes_read;
@@ -182,8 +184,11 @@
}
if (!bytes)
+ {
+ DEBUG(("tty_read: return %ld *buf=%x", bytes_read, *(char*)buf));
return bytes_read;
}
+ }
# if 1
/* see if we can do fast RAW byte IO thru the device driver...
*/
@@ -202,23 +207,38 @@
&& !(tty->state & TS_BLIND)
&& (r = (*f->dev->readb)(f, buf, nbytes)) != ENODEV)
{
+ DEBUG(("tty_read(2): return %ld *buf=%x", r, *(char*)buf));
return r;
}
# endif
ptr = buf;
+ //*ptr = 0;
while (bytes_read < nbytes)
{
+ /* if the caller expects more than 2 bytes use blocking read */
+ if( (f->flags & O_NDELAY) && nbytes > 2 )
+ {
+ delayflg = 1;
+ f->flags &= ~ O_NDELAY;
+ }
r = tty_getchar (f, rdmode);
+
+ if( delayflg )
+ f->flags |= O_NDELAY;
+
if (r < E_OK)
{
tty_error:
- DEBUG (("tty_read: tty_getchar returned %ld", r));
+ DEBUG (("tty_read-error: tty_getchar returned %ld", r));
return (bytes_read) ? bytes_read : r;
}
else if (r == MiNTEOF)
+ {
+ DEBUG(("tty_read(EOF,NDELAY): return %ld *buf=%x nbytes=%ld", bytes_read, *(char*)buf, nbytes));
return bytes_read;
+ }
ch = r & 0xff;
@@ -230,6 +250,7 @@
{
put (f, ch);
*ptr = ch;
+ DEBUG(("tty_read(3): return 1 *buf=%x", *(char*)buf));
return 1;
}
@@ -312,14 +333,20 @@
if (r < E_OK)
goto tty_error;
else if (r == MiNTEOF)
+ {
+ DEBUG(("tty_read(MINTEOF2): return %ld *buf=%x", bytes_read, *(char*)buf));
return bytes_read;
+ }
ch = r & 0xff;
goto stuff_it;
}
else if ((char)ch == tty->tc.t_eofc && !(mode & T_TOS))
+ {
+ DEBUG(("tty_read(4): return %ld *buf=%x", bytes_read, *(char*)buf));
return bytes_read;
}
+ }
/* both T_CBREAK and T_COOKED modes have to do signals, though
*/
@@ -361,6 +388,7 @@
else
tty->state &= ~TS_COOKED;
+ DEBUG(("tty_read(5): return %ld *buf=%x ch=%x", bytes_read, *(char*)buf, ch));
return bytes_read;
}
@@ -396,6 +424,7 @@
else
tty->state &= ~TS_COOKED;
+ DEBUG(("tty_read(6): return %ld *buf=%x", bytes_read, *(char*)buf));
return bytes_read;
}
@@ -467,6 +496,10 @@
if (nbytes == 0)
return bytes_written;
+
+ DEBUG(("tty_write: pgrp=%d state=%x %ld bytes ext=%lx", tty->pgrp, tty->state, nbytes, get_curproc()->p_ext));
+
+
# if 1
/* see if we can do fast RAW byte IO thru the device driver... */
if (!use_putchar && HAS_WRITEB(f))
@@ -1227,9 +1260,11 @@
if (!suser (get_curproc()->p_cred->ucr) ||
(long)arg != 1)
{
+ DEBUG (("TIOCSCTTY: do_close %lx", f));
do_close (get_curproc(), f);
return EPERM;
}
+ DEBUG (("TIOCSCTTY: do_close(control) %lx", p->p_fd->control));
do_close (get_curproc(), p->p_fd->control);
p->p_fd->control = NULL;
}
@@ -1464,11 +1499,10 @@
TRACE (("tty_getchar: offline"));
return MiNTEOF;
}
-
ret = (*f->dev->read)(f, (char *) &r, 4L);
if (ret != 4L)
{
- DEBUG (("EOF on tty device (%li)", ret));
+ DEBUG (("tty_getchar: EOF on tty device (%li) flags:%x,NDELAY:%x", ret, f->flags, f->flags & O_NDELAY));
return MiNTEOF;
}