1*63275Smckusick /*- 2*63275Smckusick * Copyright (c) 1993 The Regents of the University of California. 3*63275Smckusick * All rights reserved. 4*63275Smckusick * 5*63275Smckusick * This code is derived from software contributed to Berkeley by 6*63275Smckusick * The Mach Operating System project at Carnegie-Mellon University. 7*63275Smckusick * 8*63275Smckusick * %sccs.include.redist.c% 9*63275Smckusick * 10*63275Smckusick * @(#)ioctl.c 7.1 (Berkeley) 06/11/93 11*63275Smckusick * 12*63275Smckusick * 13*63275Smckusick * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University 14*63275Smckusick * All Rights Reserved. 15*63275Smckusick * 16*63275Smckusick * Author: Alessandro Forin 17*63275Smckusick * 18*63275Smckusick * Permission to use, copy, modify and distribute this software and its 19*63275Smckusick * documentation is hereby granted, provided that both the copyright 20*63275Smckusick * notice and this permission notice appear in all copies of the 21*63275Smckusick * software, derivative works or modified versions, and any portions 22*63275Smckusick * thereof, and that both notices appear in supporting documentation. 23*63275Smckusick * 24*63275Smckusick * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 25*63275Smckusick * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 26*63275Smckusick * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 27*63275Smckusick * 28*63275Smckusick * Carnegie Mellon requests users of this software to return to 29*63275Smckusick * 30*63275Smckusick * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 31*63275Smckusick * School of Computer Science 32*63275Smckusick * Carnegie Mellon University 33*63275Smckusick * Pittsburgh PA 15213-3890 34*63275Smckusick * 35*63275Smckusick * any improvements or extensions that they make and grant Carnegie the 36*63275Smckusick * rights to redistribute these changes. 37*63275Smckusick */ 38*63275Smckusick 39*63275Smckusick #include <stand/stand.h> 40*63275Smckusick 41*63275Smckusick ioctl(fd, cmd, arg) 42*63275Smckusick int fd; 43*63275Smckusick int cmd; 44*63275Smckusick char *arg; 45*63275Smckusick { 46*63275Smckusick register struct open_file *f = &files[fd]; 47*63275Smckusick 48*63275Smckusick if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { 49*63275Smckusick errno = EBADF; 50*63275Smckusick return (-1); 51*63275Smckusick } 52*63275Smckusick if (f->f_flags & F_RAW) { 53*63275Smckusick errno = (f->f_dev->dv_ioctl)(f, cmd, arg); 54*63275Smckusick if (errno) 55*63275Smckusick return (-1); 56*63275Smckusick return (0); 57*63275Smckusick } 58*63275Smckusick return (-1); 59*63275Smckusick } 60