diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-01 19:29:18 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-01 19:29:18 +0000 |
commit | a97029e989ef5c35cea27b28af96ed95951c71ea (patch) | |
tree | 6195a18d1aaf4755e6a8fbec22e820ab52af8581 /sys/scsi/sd.c | |
parent | 49b98b86bd49f7af2d222da6891e9cba361dae86 (diff) |
Allow RAW_PART+S_IFCHR device opens to succeed even if media not
present. A successful open is required for ioctl's to work. Mostly
from NetBSD, partly correcting previous code cleanup error.
From deraadt@, treat MTIOCTOP+MTRETEN as CDIOCCLOSE for cd devices
(i.e. close the cd drawer).
ok deraadt@.
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r-- | sys/scsi/sd.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 1e13885f423..33e41e1c884 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.75 2005/04/06 02:51:13 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.76 2005/05/01 19:29:17 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -383,9 +383,11 @@ sdopen(dev, flag, fmt, p) if (sd->sc_dk.dk_openmask != 0) { /* * If any partition is open, but the disk has been invalidated, - * disallow further opens. + * disallow further opens of non-raw partition. */ if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) { + if (part == RAW_PART && fmt == S_IFCHR) + goto out; error = EIO; goto bad; } @@ -405,8 +407,13 @@ sdopen(dev, flag, fmt, p) SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_MEDIA_CHANGE); - if (error) - goto bad; + if (error) { + if (part == RAW_PART && fmt == S_IFCHR) { + error = 0; + goto out; + } else + goto bad; + } /* Lock the pack in. */ if ((sc_link->flags & SDEV_REMOVABLE) != 0) { @@ -440,7 +447,7 @@ sdopen(dev, flag, fmt, p) goto bad; } - /* Insure only one open at a time. */ +out: /* Insure only one open at a time. */ switch (fmt) { case S_IFCHR: sd->sc_dk.dk_copenmask |= (1 << part); |