[BACK]Return to freebsd_ioctl.c CVS log [TXT][DIR] Up to [local] / sys / compat / freebsd

Annotation of sys/compat/freebsd/freebsd_ioctl.c, Revision 1.1.1.1

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

CVSweb