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

Cache object: a3c37b1feaa833aa529ba8b44607452f


[ 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.