Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux/common Emulate LINUX_TCFLSH with our TIOCFL...



details:   https://anonhg.NetBSD.org/src/rev/805f8508ee46
branches:  trunk
changeset: 503245:805f8508ee46
user:      ross <ross%NetBSD.org@localhost>
date:      Sat Feb 03 19:01:29 2001 +0000

description:
Emulate LINUX_TCFLSH with our TIOCFLUSH. Do some CSE.

diffstat:

 sys/compat/linux/common/linux_termios.c |  35 ++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 9 deletions(-)

diffs (104 lines):

diff -r 9abe142a49fe -r 805f8508ee46 sys/compat/linux/common/linux_termios.c
--- a/sys/compat/linux/common/linux_termios.c   Sat Feb 03 18:50:31 2001 +0000
+++ b/sys/compat/linux/common/linux_termios.c   Sat Feb 03 19:01:29 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_termios.c,v 1.8 2000/12/10 14:12:17 fvdl Exp $   */
+/*     $NetBSD: linux_termios.c,v 1.9 2001/02/03 19:01:29 ross Exp $   */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -463,6 +463,7 @@
        struct sys_ioctl_args ia;
        int error;
        char tioclinux;
+       int (*bsdioctl) __P((struct file *, u_long, caddr_t, struct proc *));
 
        fdp = p->p_fd;
        if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
@@ -472,12 +473,13 @@
        if ((fp->f_flag & (FREAD | FWRITE)) == 0)
                return (EBADF);
 
+       bsdioctl = fp->f_ops->fo_ioctl;
        com = SCARG(uap, com);
        retval[0] = 0;
                 
        switch (com) {
        case LINUX_TCGETS:
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                bsd_termios_to_linux_termios(&tmpbts, &tmplts);
@@ -492,7 +494,7 @@
                 * First fill in all fields, so that we keep the current
                 * values for fields that Linux doesn't know about.
                 */
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                error = copyin(SCARG(uap, data), &tmplts, sizeof tmplts);
@@ -510,12 +512,12 @@
                        com = TIOCSETAF;
                        break;
                }
-               error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, com, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                return 0;
        case LINUX_TCGETA:
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                bsd_termios_to_linux_termio(&tmpbts, &tmplt);
@@ -530,7 +532,7 @@
                 * First fill in all fields, so that we keep the current
                 * values for fields that Linux doesn't know about.
                 */
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, TIOCGETA, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                error = copyin(SCARG(uap, data), &tmplt, sizeof tmplt);
@@ -548,12 +550,27 @@
                        com = TIOCSETAF;
                        break;
                }
-               error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&tmpbts, p);
+               error = (*bsdioctl)(fp, com, (caddr_t)&tmpbts, p);
                if (error)
                        return error;
                return 0;
+       case LINUX_TCFLSH:
+               switch((int)SCARG(uap, data)) {
+               case 0:
+                       idat = FREAD;
+                       break;
+               case 1:
+                       idat = FWRITE;
+                       break;
+               case 2:
+                       idat = 0;
+                       break;
+               default:
+                       return EINVAL;
+               }
+               return (*bsdioctl)(fp, TIOCFLUSH, (caddr_t)&idat, p);
        case LINUX_TIOCGETD:
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETD, (caddr_t)&idat, p);
+               error = (*bsdioctl)(fp, TIOCGETD, (caddr_t)&idat, p);
                if (error)
                        return error;
                switch (idat) {
@@ -608,7 +625,7 @@
                default:
                        return EINVAL;
                }
-               error = (*fp->f_ops->fo_ioctl)(fp, TIOCSETD, (caddr_t)&idat, p);
+               error = (*bsdioctl)(fp, TIOCSETD, (caddr_t)&idat, p);
                if (error)
                        return error;
                return 0;



Home | Main Index | Thread Index | Old Index