summaryrefslogtreecommitdiff
path: root/sys/scsi/sd.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-04-13 18:56:27 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-04-13 18:56:27 +0000
commit977eb8538189c8e232f80c85b5a0416ec6cd3670 (patch)
tree9432a2366123171fd3b73dba39927d778ad8f047 /sys/scsi/sd.c
parent8359a21404ea2d54efab7d672ceb2d364b054ebf (diff)
If a removable device refuses to process PREVENT_ALLOW to lock the
media in while the device is open, allow the open anyway. Fixes some USB devices which do odd things when presented by PREVENT_ALLOW. Suggestion from mickey@. ok millert@ marco@
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r--sys/scsi/sd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 0d7a6a2317d..733d56b426a 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.123 2007/04/11 10:54:57 bluhm Exp $ */
+/* $OpenBSD: sd.c,v 1.124 2007/04/13 18:56:26 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -378,14 +378,16 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
goto bad;
}
- /* Lock the pack in. */
- if ((sc_link->flags & SDEV_REMOVABLE) != 0) {
- error = scsi_prevent(sc_link, PR_PREVENT,
+ /*
+ * Try to prevent the unloading of a removable device while
+ * it's open. But allow the open to proceed if the device can't
+ * be locked in.
+ */
+ if ((sc_link->flags & SDEV_REMOVABLE) != 0)
+ scsi_prevent(sc_link, PR_PREVENT,
SCSI_IGNORE_ILLEGAL_REQUEST |
SCSI_IGNORE_MEDIA_CHANGE);
- if (error)
- goto bad;
- }
+
/* Load the physical device parameters. */
sc_link->flags |= SDEV_MEDIA_LOADED;
if (sd_get_parms(sd, &sd->params, (rawopen ? SCSI_SILENT : 0))