The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386/ibcs2/ibcs2_ioctl.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ibcs2_ioctl.c,v 1.6 1995/03/14 15:12:28 scottb Exp $   */
    2 
    3 /*-
    4  * Copyright (c) 1994, 1995 Scott Bartram
    5  * All rights reserved.
    6  *
    7  * based on compat/sunos/sun_ioctl.c
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  */
   28 
   29 #include <sys/cdefs.h>
   30 __FBSDID("$FreeBSD: stable/8/sys/i386/ibcs2/ibcs2_ioctl.c 199583 2009-11-20 15:27:52Z jhb $");
   31 
   32 #include <sys/param.h>
   33 #include <sys/systm.h>
   34 #include <sys/consio.h>
   35 #include <sys/fcntl.h>
   36 #include <sys/file.h>
   37 #include <sys/filedesc.h>
   38 #include <sys/filio.h>
   39 #include <sys/kbio.h>
   40 #include <sys/lock.h>
   41 #include <sys/mutex.h>
   42 #include <sys/sysproto.h>
   43 #include <sys/tty.h>
   44 
   45 #include <i386/ibcs2/ibcs2_signal.h>
   46 #include <i386/ibcs2/ibcs2_socksys.h>
   47 #include <i386/ibcs2/ibcs2_stropts.h>
   48 #include <i386/ibcs2/ibcs2_proto.h>
   49 #include <i386/ibcs2/ibcs2_termios.h>
   50 #include <i386/ibcs2/ibcs2_util.h>
   51 #include <i386/ibcs2/ibcs2_ioctl.h>
   52 
   53 static void stios2btios(struct ibcs2_termios *, struct termios *);
   54 static void btios2stios(struct termios *, struct ibcs2_termios *);
   55 static void stios2stio(struct ibcs2_termios *, struct ibcs2_termio *);
   56 static void stio2stios(struct ibcs2_termio *, struct ibcs2_termios *);
   57 
   58 /*
   59  * iBCS2 ioctl calls.
   60  */
   61 
   62 struct speedtab {
   63         int sp_speed;                   /* Speed. */
   64         int sp_code;                    /* Code. */
   65 };
   66 
   67 static struct speedtab sptab[] = {
   68         { 0, 0 },
   69         { 50, 1 },
   70         { 75, 2 },
   71         { 110, 3 },
   72         { 134, 4 },
   73         { 135, 4 },
   74         { 150, 5 },
   75         { 200, 6 },
   76         { 300, 7 },
   77         { 600, 8 },
   78         { 1200, 9 },
   79         { 1800, 10 },
   80         { 2400, 11 },
   81         { 4800, 12 },
   82         { 9600, 13 },
   83         { 19200, 14 },
   84         { 38400, 15 },
   85         { -1, -1 }
   86 };
   87 
   88 static u_long s2btab[] = { 
   89         0,
   90         50,
   91         75,
   92         110,
   93         134,
   94         150,
   95         200,
   96         300,
   97         600,
   98         1200,
   99         1800,
  100         2400,
  101         4800,
  102         9600,
  103         19200,
  104         38400,
  105 };
  106 
  107 static int
  108 ttspeedtab(int speed, struct speedtab *table)
  109 {
  110 
  111         for ( ; table->sp_speed != -1; table++)
  112                 if (table->sp_speed == speed)
  113                         return (table->sp_code);
  114         return (-1);
  115 }
  116 
  117 static void
  118 stios2btios(st, bt)
  119         struct ibcs2_termios *st;
  120         struct termios *bt;
  121 {
  122         register u_long l, r;
  123 
  124         l = st->c_iflag;        r = 0;
  125         if (l & IBCS2_IGNBRK)   r |= IGNBRK;
  126         if (l & IBCS2_BRKINT)   r |= BRKINT;
  127         if (l & IBCS2_IGNPAR)   r |= IGNPAR;
  128         if (l & IBCS2_PARMRK)   r |= PARMRK;
  129         if (l & IBCS2_INPCK)    r |= INPCK;
  130         if (l & IBCS2_ISTRIP)   r |= ISTRIP;
  131         if (l & IBCS2_INLCR)    r |= INLCR;
  132         if (l & IBCS2_IGNCR)    r |= IGNCR;
  133         if (l & IBCS2_ICRNL)    r |= ICRNL;
  134         if (l & IBCS2_IXON)     r |= IXON;
  135         if (l & IBCS2_IXANY)    r |= IXANY;
  136         if (l & IBCS2_IXOFF)    r |= IXOFF;
  137         if (l & IBCS2_IMAXBEL)  r |= IMAXBEL;
  138         bt->c_iflag = r;
  139 
  140         l = st->c_oflag;        r = 0;
  141         if (l & IBCS2_OPOST)    r |= OPOST;
  142         if (l & IBCS2_ONLCR)    r |= ONLCR;
  143         if (l & IBCS2_TAB3)     r |= TAB3;
  144         bt->c_oflag = r;
  145 
  146         l = st->c_cflag;        r = 0;
  147         switch (l & IBCS2_CSIZE) {
  148         case IBCS2_CS5:         r |= CS5; break;
  149         case IBCS2_CS6:         r |= CS6; break;
  150         case IBCS2_CS7:         r |= CS7; break;
  151         case IBCS2_CS8:         r |= CS8; break;
  152         }
  153         if (l & IBCS2_CSTOPB)   r |= CSTOPB;
  154         if (l & IBCS2_CREAD)    r |= CREAD;
  155         if (l & IBCS2_PARENB)   r |= PARENB;
  156         if (l & IBCS2_PARODD)   r |= PARODD;
  157         if (l & IBCS2_HUPCL)    r |= HUPCL;
  158         if (l & IBCS2_CLOCAL)   r |= CLOCAL;
  159         bt->c_cflag = r;
  160 
  161         bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f];
  162 
  163         l = st->c_lflag;        r = 0;
  164         if (l & IBCS2_ISIG)     r |= ISIG;
  165         if (l & IBCS2_ICANON)   r |= ICANON;
  166         if (l & IBCS2_ECHO)     r |= ECHO;
  167         if (l & IBCS2_ECHOE)    r |= ECHOE;
  168         if (l & IBCS2_ECHOK)    r |= ECHOK;
  169         if (l & IBCS2_ECHONL)   r |= ECHONL;
  170         if (l & IBCS2_NOFLSH)   r |= NOFLSH;
  171         if (l & IBCS2_TOSTOP)   r |= TOSTOP;
  172         bt->c_lflag = r;
  173 
  174         bt->c_cc[VINTR] =
  175             st->c_cc[IBCS2_VINTR]  ? st->c_cc[IBCS2_VINTR]  : _POSIX_VDISABLE;
  176         bt->c_cc[VQUIT] =
  177             st->c_cc[IBCS2_VQUIT]  ? st->c_cc[IBCS2_VQUIT]  : _POSIX_VDISABLE;
  178         bt->c_cc[VERASE] =
  179             st->c_cc[IBCS2_VERASE] ? st->c_cc[IBCS2_VERASE] : _POSIX_VDISABLE;
  180         bt->c_cc[VKILL] =
  181             st->c_cc[IBCS2_VKILL]  ? st->c_cc[IBCS2_VKILL]  : _POSIX_VDISABLE;
  182         if (bt->c_lflag & ICANON) {
  183                 bt->c_cc[VEOF] =
  184                     st->c_cc[IBCS2_VEOF] ? st->c_cc[IBCS2_VEOF] : _POSIX_VDISABLE;
  185                 bt->c_cc[VEOL] =
  186                     st->c_cc[IBCS2_VEOL] ? st->c_cc[IBCS2_VEOL] : _POSIX_VDISABLE;
  187         } else {
  188                 bt->c_cc[VMIN]  = st->c_cc[IBCS2_VMIN];
  189                 bt->c_cc[VTIME] = st->c_cc[IBCS2_VTIME];
  190         }
  191         bt->c_cc[VEOL2] =
  192             st->c_cc[IBCS2_VEOL2]  ? st->c_cc[IBCS2_VEOL2]  : _POSIX_VDISABLE;
  193 #if 0
  194         bt->c_cc[VSWTCH] =
  195             st->c_cc[IBCS2_VSWTCH] ? st->c_cc[IBCS2_VSWTCH] : _POSIX_VDISABLE;
  196 #endif
  197         bt->c_cc[VSTART] =
  198             st->c_cc[IBCS2_VSTART] ? st->c_cc[IBCS2_VSTART] : _POSIX_VDISABLE;
  199         bt->c_cc[VSTOP] =
  200             st->c_cc[IBCS2_VSTOP]  ? st->c_cc[IBCS2_VSTOP]  : _POSIX_VDISABLE;
  201         bt->c_cc[VSUSP] =
  202             st->c_cc[IBCS2_VSUSP]  ? st->c_cc[IBCS2_VSUSP]  : _POSIX_VDISABLE;
  203         bt->c_cc[VDSUSP]   = _POSIX_VDISABLE;
  204         bt->c_cc[VREPRINT] = _POSIX_VDISABLE;
  205         bt->c_cc[VDISCARD] = _POSIX_VDISABLE;
  206         bt->c_cc[VWERASE]  = _POSIX_VDISABLE;
  207         bt->c_cc[VLNEXT]   = _POSIX_VDISABLE;
  208         bt->c_cc[VSTATUS]  = _POSIX_VDISABLE;
  209 }
  210 
  211 static void
  212 btios2stios(bt, st)
  213         struct termios *bt;
  214         struct ibcs2_termios *st;
  215 {
  216         register u_long l, r;
  217 
  218         l = bt->c_iflag;        r = 0;
  219         if (l & IGNBRK)         r |= IBCS2_IGNBRK;
  220         if (l & BRKINT)         r |= IBCS2_BRKINT;
  221         if (l & IGNPAR)         r |= IBCS2_IGNPAR;
  222         if (l & PARMRK)         r |= IBCS2_PARMRK;
  223         if (l & INPCK)          r |= IBCS2_INPCK;
  224         if (l & ISTRIP)         r |= IBCS2_ISTRIP;
  225         if (l & INLCR)          r |= IBCS2_INLCR;
  226         if (l & IGNCR)          r |= IBCS2_IGNCR;
  227         if (l & ICRNL)          r |= IBCS2_ICRNL;
  228         if (l & IXON)           r |= IBCS2_IXON;
  229         if (l & IXANY)          r |= IBCS2_IXANY;
  230         if (l & IXOFF)          r |= IBCS2_IXOFF;
  231         if (l & IMAXBEL)        r |= IBCS2_IMAXBEL;
  232         st->c_iflag = r;
  233 
  234         l = bt->c_oflag;        r = 0;
  235         if (l & OPOST)          r |= IBCS2_OPOST;
  236         if (l & ONLCR)          r |= IBCS2_ONLCR;
  237         if (l & TAB3)           r |= IBCS2_TAB3;
  238         st->c_oflag = r;
  239 
  240         l = bt->c_cflag;        r = 0;
  241         switch (l & CSIZE) {
  242         case CS5:               r |= IBCS2_CS5; break;
  243         case CS6:               r |= IBCS2_CS6; break;
  244         case CS7:               r |= IBCS2_CS7; break;
  245         case CS8:               r |= IBCS2_CS8; break;
  246         }
  247         if (l & CSTOPB)         r |= IBCS2_CSTOPB;
  248         if (l & CREAD)          r |= IBCS2_CREAD;
  249         if (l & PARENB)         r |= IBCS2_PARENB;
  250         if (l & PARODD)         r |= IBCS2_PARODD;
  251         if (l & HUPCL)          r |= IBCS2_HUPCL;
  252         if (l & CLOCAL)         r |= IBCS2_CLOCAL;
  253         st->c_cflag = r;
  254 
  255         l = bt->c_lflag;        r = 0;
  256         if (l & ISIG)           r |= IBCS2_ISIG;
  257         if (l & ICANON)         r |= IBCS2_ICANON;
  258         if (l & ECHO)           r |= IBCS2_ECHO;
  259         if (l & ECHOE)          r |= IBCS2_ECHOE;
  260         if (l & ECHOK)          r |= IBCS2_ECHOK;
  261         if (l & ECHONL)         r |= IBCS2_ECHONL;
  262         if (l & NOFLSH)         r |= IBCS2_NOFLSH;
  263         if (l & TOSTOP)         r |= IBCS2_TOSTOP;
  264         st->c_lflag = r;
  265 
  266         l = ttspeedtab(bt->c_ospeed, sptab);
  267         if ((int)l >= 0)
  268                 st->c_cflag |= l;
  269 
  270         st->c_cc[IBCS2_VINTR] =
  271             bt->c_cc[VINTR]  != _POSIX_VDISABLE ? bt->c_cc[VINTR]  : 0;
  272         st->c_cc[IBCS2_VQUIT] =
  273             bt->c_cc[VQUIT]  != _POSIX_VDISABLE ? bt->c_cc[VQUIT]  : 0;
  274         st->c_cc[IBCS2_VERASE] =
  275             bt->c_cc[VERASE] != _POSIX_VDISABLE ? bt->c_cc[VERASE] : 0;
  276         st->c_cc[IBCS2_VKILL] =
  277             bt->c_cc[VKILL]  != _POSIX_VDISABLE ? bt->c_cc[VKILL]  : 0;
  278         if (bt->c_lflag & ICANON) {
  279                 st->c_cc[IBCS2_VEOF] =
  280                     bt->c_cc[VEOF] != _POSIX_VDISABLE ? bt->c_cc[VEOF] : 0;
  281                 st->c_cc[IBCS2_VEOL] =
  282                     bt->c_cc[VEOL] != _POSIX_VDISABLE ? bt->c_cc[VEOL] : 0;
  283         } else {
  284                 st->c_cc[IBCS2_VMIN]  = bt->c_cc[VMIN];
  285                 st->c_cc[IBCS2_VTIME] = bt->c_cc[VTIME];
  286         }
  287         st->c_cc[IBCS2_VEOL2] =
  288             bt->c_cc[VEOL2]  != _POSIX_VDISABLE ? bt->c_cc[VEOL2]  : 0;
  289         st->c_cc[IBCS2_VSWTCH] =
  290             0;
  291         st->c_cc[IBCS2_VSUSP] =
  292             bt->c_cc[VSUSP]  != _POSIX_VDISABLE ? bt->c_cc[VSUSP]  : 0;
  293         st->c_cc[IBCS2_VSTART] =
  294             bt->c_cc[VSTART] != _POSIX_VDISABLE ? bt->c_cc[VSTART] : 0;
  295         st->c_cc[IBCS2_VSTOP] =
  296             bt->c_cc[VSTOP]  != _POSIX_VDISABLE ? bt->c_cc[VSTOP]  : 0;
  297 
  298         st->c_line = 0;
  299 }
  300 
  301 static void
  302 stios2stio(ts, t)
  303         struct ibcs2_termios *ts;
  304         struct ibcs2_termio *t;
  305 {
  306         t->c_iflag = ts->c_iflag;
  307         t->c_oflag = ts->c_oflag;
  308         t->c_cflag = ts->c_cflag;
  309         t->c_lflag = ts->c_lflag;
  310         t->c_line  = ts->c_line;
  311         bcopy(ts->c_cc, t->c_cc, IBCS2_NCC);
  312 }
  313 
  314 static void
  315 stio2stios(t, ts)
  316         struct ibcs2_termio *t;
  317         struct ibcs2_termios *ts;
  318 {
  319         ts->c_iflag = t->c_iflag;
  320         ts->c_oflag = t->c_oflag;
  321         ts->c_cflag = t->c_cflag;
  322         ts->c_lflag = t->c_lflag;
  323         ts->c_line  = t->c_line;
  324         bcopy(t->c_cc, ts->c_cc, IBCS2_NCC);
  325 }
  326 
  327 int
  328 ibcs2_ioctl(td, uap)
  329         struct thread *td;
  330         struct ibcs2_ioctl_args *uap;
  331 {
  332         struct proc *p = td->td_proc;
  333         struct file *fp;
  334         int error;
  335 
  336         if ((error = fget(td, uap->fd, &fp)) != 0) {
  337                 DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid,
  338                          uap->fd));
  339                 return EBADF;
  340         }
  341 
  342         if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
  343                 fdrop(fp, td);
  344                 DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
  345                 return EBADF;
  346         }
  347 
  348         switch (uap->cmd) {
  349         case IBCS2_TCGETA:
  350         case IBCS2_XCGETA:
  351         case IBCS2_OXCGETA:
  352             {
  353                 struct termios bts;
  354                 struct ibcs2_termios sts;
  355                 struct ibcs2_termio st;
  356         
  357                 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts,
  358                     td->td_ucred, td)) != 0)
  359                         break;
  360         
  361                 btios2stios (&bts, &sts);
  362                 if (uap->cmd == IBCS2_TCGETA) {
  363                         stios2stio (&sts, &st);
  364                         error = copyout((caddr_t)&st, uap->data,
  365                                         sizeof (st));
  366 #ifdef DEBUG_IBCS2
  367                         if (error)
  368                                 DPRINTF(("ibcs2_ioctl(%d): copyout failed ",
  369                                          p->p_pid));
  370 #endif
  371                         break;
  372                 } else {
  373                         error = copyout((caddr_t)&sts, uap->data,
  374                                         sizeof (sts));
  375                         break;
  376                 }
  377                 /*NOTREACHED*/
  378             }
  379 
  380         case IBCS2_TCSETA:
  381         case IBCS2_TCSETAW:
  382         case IBCS2_TCSETAF:
  383             {
  384                 struct termios bts;
  385                 struct ibcs2_termios sts;
  386                 struct ibcs2_termio st;
  387 
  388                 if ((error = copyin(uap->data, (caddr_t)&st,
  389                                     sizeof(st))) != 0) {
  390                         DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ",
  391                                  p->p_pid));
  392                         break;
  393                 }
  394 
  395                 /* get full BSD termios so we don't lose information */
  396                 if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bts,
  397                     td->td_ucred, td)) != 0) {
  398                         DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ",
  399                                  p->p_pid, uap->fd));
  400                         break;
  401                 }
  402 
  403                 /*
  404                  * convert to iBCS2 termios, copy in information from
  405                  * termio, and convert back, then set new values.
  406                  */
  407                 btios2stios(&bts, &sts);
  408                 stio2stios(&st, &sts);
  409                 stios2btios(&sts, &bts);
  410 
  411                 error = fo_ioctl(fp, uap->cmd - IBCS2_TCSETA + TIOCSETA,
  412                               (caddr_t)&bts, td->td_ucred, td);
  413                 break;
  414             }
  415 
  416         case IBCS2_XCSETA:
  417         case IBCS2_XCSETAW:
  418         case IBCS2_XCSETAF:
  419             {
  420                 struct termios bts;
  421                 struct ibcs2_termios sts;
  422 
  423                 if ((error = copyin(uap->data, (caddr_t)&sts,
  424                                     sizeof (sts))) != 0)
  425                         break;
  426                 stios2btios (&sts, &bts);
  427                 error = fo_ioctl(fp, uap->cmd - IBCS2_XCSETA + TIOCSETA,
  428                               (caddr_t)&bts, td->td_ucred, td);
  429                 break;
  430             }
  431 
  432         case IBCS2_OXCSETA:
  433         case IBCS2_OXCSETAW:
  434         case IBCS2_OXCSETAF:
  435             {
  436                 struct termios bts;
  437                 struct ibcs2_termios sts;
  438 
  439                 if ((error = copyin(uap->data, (caddr_t)&sts,
  440                                     sizeof (sts))) != 0)
  441                         break;
  442                 stios2btios (&sts, &bts);
  443                 error = fo_ioctl(fp, uap->cmd - IBCS2_OXCSETA + TIOCSETA,
  444                               (caddr_t)&bts, td->td_ucred, td);
  445                 break;
  446             }
  447 
  448         case IBCS2_TCSBRK:
  449                 DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid));
  450                 error = ENOSYS;
  451                 break;
  452 
  453         case IBCS2_TCXONC:
  454             {
  455                 switch ((int)uap->data) {
  456                 case 0:
  457                 case 1:
  458                         DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid));
  459                         error = ENOSYS;
  460                         break;
  461                 case 2:
  462                         error = fo_ioctl(fp, TIOCSTOP, (caddr_t)0,
  463                             td->td_ucred, td);
  464                         break;
  465                 case 3:
  466                         error = fo_ioctl(fp, TIOCSTART, (caddr_t)1,
  467                             td->td_ucred, td);
  468                         break;
  469                 default:
  470                         error = EINVAL;
  471                         break;
  472                 }
  473                 break;
  474             }
  475 
  476         case IBCS2_TCFLSH:
  477             {
  478                 int arg;
  479 
  480                 switch ((int)uap->data) {
  481                 case 0:
  482                         arg = FREAD;
  483                         break;
  484                 case 1:
  485                         arg = FWRITE;
  486                         break;
  487                 case 2:
  488                         arg = FREAD | FWRITE;
  489                         break;
  490                 default:
  491                         fdrop(fp, td);
  492                         return EINVAL;
  493                 }
  494                 error = fo_ioctl(fp, TIOCFLUSH, (caddr_t)&arg, td->td_ucred,
  495                     td);
  496                 break;
  497             }
  498 
  499         case IBCS2_TIOCGWINSZ:
  500                 uap->cmd = TIOCGWINSZ;
  501                 error = ioctl(td, (struct ioctl_args *)uap);
  502                 break;
  503 
  504         case IBCS2_TIOCSWINSZ:
  505                 uap->cmd = TIOCSWINSZ;
  506                 error = ioctl(td, (struct ioctl_args *)uap);
  507                 break;
  508 
  509         case IBCS2_TIOCGPGRP:
  510             {
  511                 pid_t   pg_id;
  512 
  513                 PROC_LOCK(p);
  514                 pg_id = p->p_pgrp->pg_id;
  515                 PROC_UNLOCK(p);
  516                 error = copyout((caddr_t)&pg_id, uap->data,
  517                                 sizeof(pg_id));
  518                 break;
  519             }
  520 
  521         case IBCS2_TIOCSPGRP:   /* XXX - is uap->data a pointer to pgid? */
  522             {
  523                 struct setpgid_args sa;
  524 
  525                 sa.pid = 0;
  526                 sa.pgid = (int)uap->data;
  527                 error = setpgid(td, &sa);
  528                 break;
  529             }
  530 
  531         case IBCS2_TCGETSC:     /* SCO console - get scancode flags */
  532                 error = EINTR;  /* ENOSYS; */
  533                 break;
  534 
  535         case IBCS2_TCSETSC:     /* SCO console - set scancode flags */
  536                 error = 0;   /* ENOSYS; */
  537                 break;
  538 
  539         case IBCS2_JWINSIZE:    /* Unix to Jerq I/O control */
  540             {
  541                 struct ibcs2_jwinsize {
  542                   char bytex, bytey; 
  543                   short bitx, bity;
  544                 } ibcs2_jwinsize;
  545 
  546                 PROC_LOCK(p);
  547                 SESS_LOCK(p->p_session);
  548                 ibcs2_jwinsize.bytex = 80;
  549                   /* p->p_session->s_ttyp->t_winsize.ws_col; XXX */
  550                 ibcs2_jwinsize.bytey = 25;
  551                   /* p->p_session->s_ttyp->t_winsize.ws_row; XXX */
  552                 ibcs2_jwinsize.bitx = 
  553                   p->p_session->s_ttyp->t_winsize.ws_xpixel;
  554                 ibcs2_jwinsize.bity =
  555                   p->p_session->s_ttyp->t_winsize.ws_ypixel;
  556                 SESS_UNLOCK(p->p_session);
  557                 PROC_UNLOCK(p);
  558                 error = copyout((caddr_t)&ibcs2_jwinsize, uap->data,
  559                                sizeof(ibcs2_jwinsize));
  560                 break;
  561              }
  562 
  563         /* keyboard and display ioctl's -- type 'K' */
  564         case IBCS2_KDGKBMODE:        /* get keyboard translation mode */
  565                 uap->cmd = KDGKBMODE;
  566 /* printf("ioctl KDGKBMODE = %x\n", uap->cmd);*/
  567                 error = ioctl(td, (struct ioctl_args *)uap);
  568                 break;
  569 
  570         case IBCS2_KDSKBMODE:        /* set keyboard translation mode */
  571                 uap->cmd = KDSKBMODE;
  572                 error = ioctl(td, (struct ioctl_args *)uap);
  573                 break;
  574 
  575         case IBCS2_KDMKTONE:        /* sound tone */
  576                 uap->cmd = KDMKTONE;
  577                 error = ioctl(td, (struct ioctl_args *)uap);
  578                 break;
  579 
  580         case IBCS2_KDGETMODE:        /* get text/graphics mode */  
  581                 uap->cmd = KDGETMODE;
  582                 error = ioctl(td, (struct ioctl_args *)uap);
  583                 break;
  584 
  585         case IBCS2_KDSETMODE:       /* set text/graphics mode */
  586                 uap->cmd = KDSETMODE;
  587                 error = ioctl(td, (struct ioctl_args *)uap);
  588                 break;
  589 
  590         case IBCS2_KDSBORDER:       /* set ega color border */
  591                 uap->cmd = KDSBORDER;
  592                 error = ioctl(td, (struct ioctl_args *)uap);
  593                 break;
  594 
  595         case IBCS2_KDGKBSTATE:
  596                 uap->cmd = KDGKBSTATE;
  597                 error = ioctl(td, (struct ioctl_args *)uap);
  598                 break;
  599 
  600         case IBCS2_KDSETRAD:
  601                 uap->cmd = KDSETRAD;
  602                 error = ioctl(td, (struct ioctl_args *)uap);
  603                 break;
  604 
  605         case IBCS2_KDENABIO:       /* enable direct I/O to ports */
  606                 uap->cmd = KDENABIO;
  607                 error = ioctl(td, (struct ioctl_args *)uap);
  608                 break;
  609 
  610         case IBCS2_KDDISABIO:       /* disable direct I/O to ports */
  611                 uap->cmd = KDDISABIO;
  612                 error = ioctl(td, (struct ioctl_args *)uap);
  613                 break;
  614 
  615         case IBCS2_KIOCSOUND:       /* start sound generation */
  616                 uap->cmd = KIOCSOUND;
  617                 error = ioctl(td, (struct ioctl_args *)uap);
  618                 break;
  619 
  620         case IBCS2_KDGKBTYPE:       /* get keyboard type */
  621                 uap->cmd = KDGKBTYPE;
  622                 error = ioctl(td, (struct ioctl_args *)uap);
  623                 break;
  624 
  625         case IBCS2_KDGETLED:       /* get keyboard LED status */
  626                 uap->cmd = KDGETLED;
  627                 error = ioctl(td, (struct ioctl_args *)uap);
  628                 break;
  629 
  630         case IBCS2_KDSETLED:       /* set keyboard LED status */
  631                 uap->cmd = KDSETLED;
  632                 error = ioctl(td, (struct ioctl_args *)uap);
  633                 break;
  634 
  635             /* Xenix keyboard and display ioctl's from sys/kd.h -- type 'k' */
  636         case IBCS2_GETFKEY:      /* Get function key */
  637                 uap->cmd = GETFKEY;
  638                 error = ioctl(td, (struct ioctl_args *)uap);
  639                 break;
  640 
  641         case IBCS2_SETFKEY:      /* Set function key */
  642                 uap->cmd = SETFKEY;
  643                 error = ioctl(td, (struct ioctl_args *)uap);
  644                 break;
  645 
  646         case IBCS2_GIO_SCRNMAP:      /* Get screen output map table */
  647                 uap->cmd = GIO_SCRNMAP;
  648                 error = ioctl(td, (struct ioctl_args *)uap);
  649                 break;
  650 
  651         case IBCS2_PIO_SCRNMAP:      /* Set screen output map table */
  652                 uap->cmd = PIO_SCRNMAP;
  653                 error = ioctl(td, (struct ioctl_args *)uap);
  654                 break;
  655 
  656         case IBCS2_GIO_KEYMAP:      /* Get keyboard map table */
  657                 uap->cmd = GIO_KEYMAP;
  658                 error = ioctl(td, (struct ioctl_args *)uap);
  659                 break;
  660 
  661         case IBCS2_PIO_KEYMAP:      /* Set keyboard map table */
  662                 uap->cmd = PIO_KEYMAP;
  663                 error = ioctl(td, (struct ioctl_args *)uap);
  664                 break;
  665 
  666             /* socksys */
  667         case IBCS2_SIOCSOCKSYS:
  668                 error = ibcs2_socksys(td, (struct ibcs2_socksys_args *)uap);
  669                 break;
  670 
  671         case IBCS2_FIONREAD:
  672         case IBCS2_I_NREAD:     /* STREAMS */
  673                 uap->cmd = FIONREAD;
  674                 error = ioctl(td, (struct ioctl_args *)uap);
  675                 break;
  676 
  677         default:
  678                 DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ",
  679                          td->proc->p_pid, uap->cmd));
  680                 error = ENOSYS;
  681                 break;
  682         }
  683 
  684         fdrop(fp, td);
  685         return error;
  686 }

Cache object: 293ba51b864b71fc2fb2a23386132381


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.