diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 12 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_ch.c | 9 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_pass.c | 29 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_pt.c | 9 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_sa.c | 6 |
5 files changed, 46 insertions, 19 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index dfe86fc..9c6ddb6 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_cd.c,v 1.7 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_cd.c,v 1.8 1998/10/22 22:16:56 ken Exp $ */ /* * Portions of this driver taken from the original FreeBSD cd driver. @@ -890,15 +890,21 @@ cdopen(dev_t dev, int flags, int fmt, struct proc *p) softc = (struct cd_softc *)periph->softc; + /* + * Grab splsoftcam and hold it until we lock the peripheral. + */ s = splsoftcam(); if (softc->flags & CD_FLAG_INVALID) { splx(s); return(ENXIO); } - splx(s); - if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) + if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) { + splx(s); return (error); + } + + splx(s); if ((softc->flags & CD_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index 32bb92d..aa0883f 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_ch.c,v 1.4 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_ch.c,v 1.5 1998/10/22 22:16:56 ken Exp $ */ /* * Derived from the NetBSD SCSI changer driver. @@ -458,11 +458,14 @@ chopen(dev_t dev, int flags, int fmt, struct proc *p) splx(s); return(ENXIO); } - splx(s); - if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) + if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) { + splx(s); return (error); + } + splx(s); + if ((softc->flags & CH_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) return(ENXIO); diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index 7e9055a7..40e6376 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_pass.c,v 1.3 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_pass.c,v 1.4 1998/10/22 22:16:56 ken Exp $ */ #include <sys/param.h> @@ -399,26 +399,39 @@ passopen(dev_t dev, int flags, int fmt, struct proc *p) splx(s); return(ENXIO); } - splx(s); + + /* + * Don't allow access when we're running at a high securelvel. + */ + if (securelevel > 1) { + splx(s); + return(EPERM); + } /* * Only allow read-write access. */ - if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0)) + if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0)) { + splx(s); return(EPERM); + } /* * We don't allow nonblocking access. */ if ((flags & O_NONBLOCK) != 0) { - printf("%s%d: can't do nonblocking accesss\n", - periph->periph_name, - periph->unit_number); - return(ENODEV); + xpt_print_path(periph->path); + printf("can't do nonblocking accesss\n"); + splx(s); + return(EINVAL); } - if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) + if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) { + splx(s); return (error); + } + + splx(s); if ((softc->flags & PASS_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index deace7d..b937ad4 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_pt.c,v 1.2 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_pt.c,v 1.3 1998/10/22 22:16:56 ken Exp $ */ #include <sys/param.h> @@ -160,13 +160,16 @@ ptopen(dev_t dev, int flags, int fmt, struct proc *p) splx(s); return(ENXIO); } - splx(s); CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("ptopen: dev=0x%x (unit %d)\n", dev, unit)); - if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) + if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) { + splx(s); return (error); /* error code from tsleep */ + } + + splx(s); if ((softc->flags & PT_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 07f992d..304d88e 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: scsi_sa.c,v 1.3 1998/10/15 17:46:26 ken Exp $ + * $Id: scsi_sa.c,v 1.4 1998/10/22 22:16:56 ken Exp $ */ #include <sys/param.h> @@ -285,12 +285,14 @@ saopen(dev_t dev, int flags, int fmt, struct proc *p) splx(s); return(ENXIO); } - splx(s); if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0) { + splx(s); return (error); /* error code from tsleep */ } + splx(s); + if ((softc->flags & SA_FLAG_OPEN) == 0) { if (cam_periph_acquire(periph) != CAM_REQ_CMP) return(ENXIO); |