1*22028508SToomas Soome /* $NetBSD: ioctl.c,v 1.4 1994/10/30 21:48:24 cgd Exp $ */
2*22028508SToomas Soome
3*22028508SToomas Soome /*
4*22028508SToomas Soome * Copyright (c) 1993
5*22028508SToomas Soome * The Regents of the University of California. All rights reserved.
6*22028508SToomas Soome *
7*22028508SToomas Soome * This code is derived from software contributed to Berkeley by
8*22028508SToomas Soome * The Mach Operating System project at Carnegie-Mellon University.
9*22028508SToomas Soome *
10*22028508SToomas Soome * Redistribution and use in source and binary forms, with or without
11*22028508SToomas Soome * modification, are permitted provided that the following conditions
12*22028508SToomas Soome * are met:
13*22028508SToomas Soome * 1. Redistributions of source code must retain the above copyright
14*22028508SToomas Soome * notice, this list of conditions and the following disclaimer.
15*22028508SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
16*22028508SToomas Soome * notice, this list of conditions and the following disclaimer in the
17*22028508SToomas Soome * documentation and/or other materials provided with the distribution.
18*22028508SToomas Soome * 3. Neither the name of the University nor the names of its contributors
19*22028508SToomas Soome * may be used to endorse or promote products derived from this software
20*22028508SToomas Soome * without specific prior written permission.
21*22028508SToomas Soome *
22*22028508SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*22028508SToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*22028508SToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*22028508SToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*22028508SToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*22028508SToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*22028508SToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*22028508SToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*22028508SToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*22028508SToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*22028508SToomas Soome * SUCH DAMAGE.
33*22028508SToomas Soome *
34*22028508SToomas Soome * @(#)ioctl.c 8.1 (Berkeley) 6/11/93
35*22028508SToomas Soome *
36*22028508SToomas Soome *
37*22028508SToomas Soome * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
38*22028508SToomas Soome * All Rights Reserved.
39*22028508SToomas Soome *
40*22028508SToomas Soome * Author: Alessandro Forin
41*22028508SToomas Soome *
42*22028508SToomas Soome * Permission to use, copy, modify and distribute this software and its
43*22028508SToomas Soome * documentation is hereby granted, provided that both the copyright
44*22028508SToomas Soome * notice and this permission notice appear in all copies of the
45*22028508SToomas Soome * software, derivative works or modified versions, and any portions
46*22028508SToomas Soome * thereof, and that both notices appear in supporting documentation.
47*22028508SToomas Soome *
48*22028508SToomas Soome * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
49*22028508SToomas Soome * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
50*22028508SToomas Soome * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
51*22028508SToomas Soome *
52*22028508SToomas Soome * Carnegie Mellon requests users of this software to return to
53*22028508SToomas Soome *
54*22028508SToomas Soome * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
55*22028508SToomas Soome * School of Computer Science
56*22028508SToomas Soome * Carnegie Mellon University
57*22028508SToomas Soome * Pittsburgh PA 15213-3890
58*22028508SToomas Soome *
59*22028508SToomas Soome * any improvements or extensions that they make and grant Carnegie the
60*22028508SToomas Soome * rights to redistribute these changes.
61*22028508SToomas Soome */
62*22028508SToomas Soome
63*22028508SToomas Soome #include <sys/cdefs.h>
64*22028508SToomas Soome
65*22028508SToomas Soome #include "stand.h"
66*22028508SToomas Soome
67*22028508SToomas Soome int
ioctl(int fd,ulong_t cmd,char * arg)68*22028508SToomas Soome ioctl(int fd, ulong_t cmd, char *arg)
69*22028508SToomas Soome {
70*22028508SToomas Soome struct open_file *f;
71*22028508SToomas Soome
72*22028508SToomas Soome f = fd2open_file(fd);
73*22028508SToomas Soome if (f == NULL || f->f_flags == 0) {
74*22028508SToomas Soome errno = EBADF;
75*22028508SToomas Soome return (-1);
76*22028508SToomas Soome }
77*22028508SToomas Soome if (f->f_flags & F_RAW) {
78*22028508SToomas Soome errno = (f->f_dev->dv_ioctl)(f, cmd, arg);
79*22028508SToomas Soome if (errno)
80*22028508SToomas Soome return (-1);
81*22028508SToomas Soome return (0);
82*22028508SToomas Soome }
83*22028508SToomas Soome errno = EIO;
84*22028508SToomas Soome return (-1);
85*22028508SToomas Soome }
86