For ioctl commands which may change the device's state, ensure that

the caller has the device open for writing.
This commit is contained in:
thorpej 1996-09-13 00:35:59 +00:00
parent 9118c05a03
commit fcde57a426
2 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsipi_ioctl.c,v 1.20 1996/02/14 21:47:22 christos Exp $ */
/* $NetBSD: scsipi_ioctl.c,v 1.21 1996/09/13 00:35:59 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -44,6 +44,7 @@
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/fcntl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
@ -287,6 +288,16 @@ scsi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
SC_DEBUG(sc_link, SDEV_DB2, ("scsi_do_ioctl(0x%lx)\n", cmd));
/* Check for the safe-ness of this request. */
switch (cmd) {
case SCIOCIDENTIFY:
break;
default:
if ((flag & FWRITE) == 0)
return EBADF;
}
switch(cmd) {
case SCIOCCOMMAND: {
scsireq_t *screq = (scsireq_t *)addr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi_ioctl.c,v 1.20 1996/02/14 21:47:22 christos Exp $ */
/* $NetBSD: scsi_ioctl.c,v 1.21 1996/09/13 00:35:59 thorpej Exp $ */
/*
* Copyright (c) 1994 Charles Hannum. All rights reserved.
@ -44,6 +44,7 @@
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/device.h>
#include <sys/fcntl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
@ -287,6 +288,16 @@ scsi_do_ioctl(sc_link, dev, cmd, addr, flag, p)
SC_DEBUG(sc_link, SDEV_DB2, ("scsi_do_ioctl(0x%lx)\n", cmd));
/* Check for the safe-ness of this request. */
switch (cmd) {
case SCIOCIDENTIFY:
break;
default:
if ((flag & FWRITE) == 0)
return EBADF;
}
switch(cmd) {
case SCIOCCOMMAND: {
scsireq_t *screq = (scsireq_t *)addr;