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

Cache object: abee542af5dab8ef7c639512deeabfa1


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