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/compat/freebsd/freebsd_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: freebsd_ioctl.c,v 1.15 2007/12/20 23:02:47 dsl Exp $   */
    2 
    3 /*
    4  * Copyright (c) 1995 Frank van der Linden
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed for the NetBSD Project
   18  *      by Frank van der Linden
   19  * 4. The name of the author may not be used to endorse or promote products
   20  *    derived from this software without specific prior written permission
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __KERNEL_RCSID(0, "$NetBSD: freebsd_ioctl.c,v 1.15 2007/12/20 23:02:47 dsl Exp $");
   36 
   37 #include <sys/param.h>
   38 #include <sys/systm.h>
   39 #include <sys/proc.h>
   40 #include <sys/mount.h>
   41 #include <sys/sockio.h>
   42 
   43 #include <sys/syscallargs.h>
   44 
   45 #include <net/if.h>
   46 
   47 #include <compat/sys/sockio.h>
   48 
   49 #include <compat/freebsd/freebsd_syscallargs.h>
   50 #include <compat/common/compat_util.h>
   51 #include <compat/freebsd/freebsd_ioctl.h>
   52 
   53 #include <compat/ossaudio/ossaudio.h>
   54 #include <compat/ossaudio/ossaudiovar.h>
   55 
   56 /* The FreeBSD and OSS(Linux) encodings of ioctl R/W differ. */
   57 static void freebsd_to_oss(const struct freebsd_sys_ioctl_args *,
   58                            struct oss_sys_ioctl_args *);
   59 
   60 static void
   61 freebsd_to_oss(const struct freebsd_sys_ioctl_args *uap, struct oss_sys_ioctl_args *rap)
   62 {
   63         u_long ocmd, ncmd;
   64 
   65         ocmd = SCARG(uap, com);
   66         ncmd = ocmd &~ FREEBSD_IOC_DIRMASK;
   67         switch(ocmd & FREEBSD_IOC_DIRMASK) {
   68         case FREEBSD_IOC_VOID:  ncmd |= OSS_IOC_VOID;  break;
   69         case FREEBSD_IOC_OUT:   ncmd |= OSS_IOC_OUT;   break;
   70         case FREEBSD_IOC_IN:    ncmd |= OSS_IOC_IN;    break;
   71         case FREEBSD_IOC_INOUT: ncmd |= OSS_IOC_INOUT; break;
   72         }
   73         SCARG(rap, fd) = SCARG(uap, fd);
   74         SCARG(rap, com) = ncmd;
   75         SCARG(rap, data) = SCARG(uap, data);
   76 }
   77 
   78 
   79 static void freebsd_to_netbsd_ifioctl(const struct freebsd_sys_ioctl_args *uap,
   80                                       struct sys_ioctl_args *nap);
   81 
   82 static void
   83 freebsd_to_netbsd_ifioctl(const struct freebsd_sys_ioctl_args *uap, struct sys_ioctl_args *nap)
   84 {
   85         u_long ocmd, ncmd;
   86         ocmd = SCARG(uap, com);
   87         switch (ocmd) {
   88         case FREEBSD_SIOCALIFADDR:
   89                 ncmd =SIOCALIFADDR;
   90                 break;
   91         case FREEBSD_SIOCGLIFADDR:
   92                 ncmd =SIOCGLIFADDR;
   93                 break;
   94         case FREEBSD_SIOCDLIFADDR:
   95                 ncmd =SIOCDLIFADDR;
   96                 break;
   97         case FREEBSD_SIOCGIFMTU:
   98                 ncmd = SIOCGIFMTU;
   99                 break;
  100         case FREEBSD_SIOCSIFMTU:
  101                 ncmd = SIOCSIFMTU;
  102                 break;
  103         default:
  104                 ncmd = ocmd;
  105                 break;
  106         }
  107         SCARG(nap, fd) = SCARG(uap, fd);
  108         SCARG(nap, com) = ncmd;
  109         SCARG(nap, data) = SCARG(uap, data);
  110 }
  111 
  112 int
  113 freebsd_sys_ioctl(struct lwp *l, const struct freebsd_sys_ioctl_args *uap, register_t *retval)
  114 {
  115         /* {
  116                 syscallarg(int) fd;
  117                 syscallarg(u_long) com;
  118                 syscallarg(void *) data;
  119         } */
  120         struct oss_sys_ioctl_args ap;
  121         struct sys_ioctl_args nap;
  122 
  123         /*
  124          * XXX - <sys/cdio.h>'s incompatibility
  125          *      _IO('c', 25..27, *):    incompatible
  126          *      _IO('c', 28... , *):    not exist
  127          */
  128         /* XXX - <sys/mtio.h> */
  129         /* XXX - <sys/scsiio.h> */
  130         /* XXX - should convert machine dependent ioctl()s */
  131 
  132         switch (FREEBSD_IOCGROUP(SCARG(uap, com))) {
  133         case 'M':
  134                 freebsd_to_oss(uap, &ap);
  135                 return oss_ioctl_mixer(l, &ap, retval);
  136         case 'Q':
  137                 freebsd_to_oss(uap, &ap);
  138                 return oss_ioctl_sequencer(l, &ap, retval);
  139         case 'P':
  140                 freebsd_to_oss(uap, &ap);
  141                 return oss_ioctl_audio(l, &ap, retval);
  142         case 'i':
  143                 freebsd_to_netbsd_ifioctl(uap, &nap);
  144                 return sys_ioctl(l, &nap, retval);
  145         default:
  146                 return sys_ioctl(l, (const void *)uap, retval);
  147         }
  148 }

Cache object: b32477faf9afc2718ca8ec68b1ac47f2


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