xref: /csrg-svn/sys/stand/ioctl.c (revision 63370)
163275Smckusick /*-
2*63370Sbostic  * Copyright (c) 1993
3*63370Sbostic  *	The Regents of the University of California.  All rights reserved.
463275Smckusick  *
563275Smckusick  * This code is derived from software contributed to Berkeley by
663275Smckusick  * The Mach Operating System project at Carnegie-Mellon University.
763275Smckusick  *
863275Smckusick  * %sccs.include.redist.c%
963275Smckusick  *
10*63370Sbostic  *	@(#)ioctl.c	8.1 (Berkeley) 06/11/93
1163275Smckusick  *
1263275Smckusick  *
1363275Smckusick  * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
1463275Smckusick  * All Rights Reserved.
1563275Smckusick  *
1663275Smckusick  * Author: Alessandro Forin
1763275Smckusick  *
1863275Smckusick  * Permission to use, copy, modify and distribute this software and its
1963275Smckusick  * documentation is hereby granted, provided that both the copyright
2063275Smckusick  * notice and this permission notice appear in all copies of the
2163275Smckusick  * software, derivative works or modified versions, and any portions
2263275Smckusick  * thereof, and that both notices appear in supporting documentation.
2363275Smckusick  *
2463275Smckusick  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
2563275Smckusick  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
2663275Smckusick  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
2763275Smckusick  *
2863275Smckusick  * Carnegie Mellon requests users of this software to return to
2963275Smckusick  *
3063275Smckusick  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
3163275Smckusick  *  School of Computer Science
3263275Smckusick  *  Carnegie Mellon University
3363275Smckusick  *  Pittsburgh PA 15213-3890
3463275Smckusick  *
3563275Smckusick  * any improvements or extensions that they make and grant Carnegie the
3663275Smckusick  * rights to redistribute these changes.
3763275Smckusick  */
3863275Smckusick 
3963275Smckusick #include <stand/stand.h>
4063275Smckusick 
ioctl(fd,cmd,arg)4163275Smckusick ioctl(fd, cmd, arg)
4263275Smckusick 	int fd;
4363275Smckusick 	int cmd;
4463275Smckusick 	char *arg;
4563275Smckusick {
4663275Smckusick 	register struct open_file *f = &files[fd];
4763275Smckusick 
4863275Smckusick 	if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
4963275Smckusick 		errno = EBADF;
5063275Smckusick 		return (-1);
5163275Smckusick 	}
5263275Smckusick 	if (f->f_flags & F_RAW) {
5363275Smckusick 		errno = (f->f_dev->dv_ioctl)(f, cmd, arg);
5463275Smckusick 		if (errno)
5563275Smckusick 			return (-1);
5663275Smckusick 		return (0);
5763275Smckusick 	}
5863275Smckusick 	return (-1);
5963275Smckusick }
60