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

Cache object: a0a1e0d98a20b0d60e8d4fbf6168420e


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