Annotation of sys/compat/linux/linux_fdio.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: linux_fdio.c,v 1.6 2002/03/14 01:26:50 millert Exp $ */
! 2: /* $NetBSD: linux_fdio.c,v 1.1 2000/12/10 14:12:16 fvdl Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 2000 Wasabi Systems, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * Written by Frank van der Linden for Wasabi Systems, Inc.
! 9: *
! 10: * Redistribution and use in source and binary forms, with or without
! 11: * modification, are permitted provided that the following conditions
! 12: * are met:
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: * 2. Redistributions in binary form must reproduce the above copyright
! 16: * notice, this list of conditions and the following disclaimer in the
! 17: * documentation and/or other materials provided with the distribution.
! 18: * 3. All advertising materials mentioning features or use of this software
! 19: * must display the following acknowledgement:
! 20: * This product includes software developed for the NetBSD Project by
! 21: * Wasabi Systems, Inc.
! 22: * 4. The name of Wasabi Systems, Inc. may not be used to endorse
! 23: * or promote products derived from this software without specific prior
! 24: * written permission.
! 25: *
! 26: * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
! 27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
! 30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 36: * POSSIBILITY OF SUCH DAMAGE.
! 37: */
! 38:
! 39: #include <sys/param.h>
! 40: #include <sys/systm.h>
! 41: #include <sys/ioctl.h>
! 42: #include <sys/file.h>
! 43: #include <sys/filedesc.h>
! 44: #include <sys/mount.h>
! 45: #include <sys/proc.h>
! 46: #include <sys/disklabel.h>
! 47:
! 48: #include <sys/syscallargs.h>
! 49:
! 50: #include <dev/isa/fdreg.h>
! 51:
! 52: #include <compat/linux/linux_types.h>
! 53: #include <compat/linux/linux_ioctl.h>
! 54: #include <compat/linux/linux_signal.h>
! 55: #include <compat/linux/linux_util.h>
! 56: #include <compat/linux/linux_fdio.h>
! 57:
! 58: #include <machine/ioctl_fd.h>
! 59:
! 60: #include <compat/linux/linux_syscallargs.h>
! 61:
! 62: int
! 63: linux_ioctl_fdio(struct proc *p, struct linux_sys_ioctl_args *uap,
! 64: register_t *retval)
! 65: {
! 66: struct filedesc *fdp;
! 67: struct file *fp;
! 68: int error;
! 69: int (*ioctlf)(struct file *, u_long, caddr_t, struct proc *);
! 70: u_long com;
! 71: struct fd_type fparams;
! 72: struct linux_floppy_struct lflop;
! 73: struct linux_floppy_drive_struct ldrive;
! 74:
! 75: com = (u_long)SCARG(uap, data);
! 76:
! 77: fdp = p->p_fd;
! 78: if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
! 79: return (EBADF);
! 80:
! 81: FREF(fp);
! 82: com = SCARG(uap, com);
! 83: ioctlf = fp->f_ops->fo_ioctl;
! 84:
! 85: retval[0] = error = 0;
! 86:
! 87: switch (com) {
! 88: case LINUX_FDMSGON:
! 89: case LINUX_FDMSGOFF:
! 90: case LINUX_FDTWADDLE:
! 91: case LINUX_FDCLRPRM:
! 92: /* whatever you say */
! 93: break;
! 94: case LINUX_FDPOLLDRVSTAT:
! 95: /*
! 96: * Just fill in some innocent defaults.
! 97: */
! 98: memset(&ldrive, 0, sizeof ldrive);
! 99: ldrive.fd_ref = 1;
! 100: ldrive.maxblock = 2;
! 101: ldrive.maxtrack = ldrive.track = 1;
! 102: ldrive.flags = LINUX_FD_DISK_WRITABLE;
! 103: error = copyout(&ldrive, SCARG(uap, data), sizeof ldrive);
! 104: break;
! 105: case LINUX_FDGETPRM:
! 106: error = ioctlf(fp, FD_GTYPE, (caddr_t)&fparams, p);
! 107: if (error != 0)
! 108: break;
! 109: lflop.size = fparams.heads * fparams.sectrac * fparams.tracks;
! 110: lflop.sect = fparams.sectrac;
! 111: lflop.head = fparams.heads;
! 112: lflop.track = fparams.tracks;
! 113: lflop.stretch = fparams.step == 2 ? 1 : 0;
! 114: lflop.spec1 = fparams.steprate;
! 115: lflop.gap = fparams.gap1;
! 116: lflop.fmt_gap = fparams.gap2;
! 117: lflop.rate = fparams.rate;
! 118:
! 119: error = copyout(&lflop, SCARG(uap, data), sizeof lflop);
! 120: break;
! 121: case LINUX_FDSETPRM:
! 122: /*
! 123: * Should use FDIOCSETFORMAT here, iff its interface
! 124: * is extended.
! 125: */
! 126: case LINUX_FDDEFPRM:
! 127: case LINUX_FDFMTBEG:
! 128: case LINUX_FDFMTTRK:
! 129: case LINUX_FDFMTEND:
! 130: case LINUX_FDSETEMSGTRESH:
! 131: case LINUX_FDFLUSH:
! 132: case LINUX_FDSETMAXERRS:
! 133: case LINUX_FDGETMAXERRS:
! 134: case LINUX_FDGETDRVTYP:
! 135: case LINUX_FDSETDRVPRM:
! 136: case LINUX_FDGETDRVPRM:
! 137: case LINUX_FDGETDRVSTAT:
! 138: case LINUX_FDRESET:
! 139: case LINUX_FDGETFDCSTAT:
! 140: case LINUX_FDWERRORCLR:
! 141: case LINUX_FDWERRORGET:
! 142: case LINUX_FDRAWCMD:
! 143: case LINUX_FDEJECT:
! 144: default:
! 145: error = EINVAL;
! 146: }
! 147:
! 148: FRELE(fp);
! 149: return 0;
! 150: }
CVSweb