Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/ioctl.c
Show All 26 Lines | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* @(#)ioctl.c 8.1 (Berkeley) 6/11/93 | * @(#)ioctl.c 8.1 (Berkeley) 6/11/93 | ||||
* | * | ||||
* | * | ||||
* Copyright (c) 1989, 1990, 1991 Carnegie Mellon University | * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University | ||||
* All Rights Reserved. | * All Rights Reserved. | ||||
* | * | ||||
* Author: Alessandro Forin | * Author: Alessandro Forin | ||||
* | * | ||||
* Permission to use, copy, modify and distribute this software and its | * Permission to use, copy, modify and distribute this software and its | ||||
* documentation is hereby granted, provided that both the copyright | * documentation is hereby granted, provided that both the copyright | ||||
* notice and this permission notice appear in all copies of the | * notice and this permission notice appear in all copies of the | ||||
* software, derivative works or modified versions, and any portions | * software, derivative works or modified versions, and any portions | ||||
* thereof, and that both notices appear in supporting documentation. | * thereof, and that both notices appear in supporting documentation. | ||||
* | * | ||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | ||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | ||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | ||||
* | * | ||||
* Carnegie Mellon requests users of this software to return to | * Carnegie Mellon requests users of this software to return to | ||||
* | * | ||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | ||||
* School of Computer Science | * School of Computer Science | ||||
* Carnegie Mellon University | * Carnegie Mellon University | ||||
* Pittsburgh PA 15213-3890 | * Pittsburgh PA 15213-3890 | ||||
* | * | ||||
* any improvements or extensions that they make and grant Carnegie the | * any improvements or extensions that they make and grant Carnegie the | ||||
* rights to redistribute these changes. | * rights to redistribute these changes. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "stand.h" | #include "stand.h" | ||||
int | int | ||||
ioctl(fd, cmd, arg) | ioctl(int fd, u_long cmd, char *arg) | ||||
int fd; | |||||
u_long cmd; | |||||
char *arg; | |||||
{ | { | ||||
struct open_file *f = &files[fd]; | struct open_file *f; | ||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) { | f = fd2open_file(fd); | ||||
if (f == NULL || f->f_flags == 0) { | |||||
errno = EBADF; | errno = EBADF; | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (f->f_flags & F_RAW) { | if (f->f_flags & F_RAW) { | ||||
errno = (f->f_dev->dv_ioctl)(f, cmd, arg); | errno = (f->f_dev->dv_ioctl)(f, cmd, arg); | ||||
if (errno) | if (errno) | ||||
return (-1); | return (-1); | ||||
return (0); | return (0); | ||||
} | } | ||||
errno = EIO; | errno = EIO; | ||||
return (-1); | return (-1); | ||||
} | } |