Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi Allow open of RAWPART even when no medium is ...
details: https://anonhg.NetBSD.org/src/rev/24493cdcd9e3
branches: trunk
changeset: 970546:24493cdcd9e3
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Fri Mar 27 11:15:33 2020 +0000
description:
Allow open of RAWPART even when no medium is loaded.
Keep errors silent if no medium is loaded.
Fixes PR kern/55104
diffstat:
sys/dev/scsipi/cd.c | 40 +++++++++++++++++++++++++++++-----------
1 files changed, 29 insertions(+), 11 deletions(-)
diffs (101 lines):
diff -r ad8133035337 -r 24493cdcd9e3 sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c Fri Mar 27 11:13:57 2020 +0000
+++ b/sys/dev/scsipi/cd.c Fri Mar 27 11:15:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.342 2018/09/03 16:29:33 riastradh Exp $ */
+/* $NetBSD: cd.c,v 1.343 2020/03/27 11:15:33 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.342 2018/09/03 16:29:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.343 2020/03/27 11:15:33 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -401,8 +401,8 @@
else
silent = 0;
- /* make cdclose() loud again */
- cd->flags &= ~CDF_EJECTED;
+ /* make cdclose() silent */
+ cd->flags |= CDF_EJECTED;
/* Check that it is still responding and ok. */
error = scsipi_test_unit_ready(periph,
@@ -419,8 +419,11 @@
if (error == EINVAL)
error = EIO;
}
- if (error)
+ if (error) {
+ if (part == RAW_PART)
+ goto out;
goto bad;
+ }
/* Lock the pack in. */
error = scsipi_prevent(periph, SPAMR_PREVENT_DT,
@@ -448,6 +451,9 @@
SC_DEBUG(periph, SCSIPI_DB3, ("Params loaded "));
cd_set_geometry(cd);
+
+ /* make cdclose() loud again */
+ cd->flags &= ~CDF_EJECTED;
}
periph->periph_flags |= PERIPH_OPEN;
@@ -519,7 +525,8 @@
struct scsipi_adapter *adapt = periph->periph_channel->chan_adapter;
int silent;
- if (cd->flags & CDF_EJECTED)
+ if ((cd->flags & CDF_EJECTED) != 0 ||
+ (periph->periph_flags & PERIPH_MEDIA_LOADED) == 0)
silent = XS_CTL_SILENT;
else
silent = 0;
@@ -1213,6 +1220,14 @@
return (EIO);
switch (cmd) {
+ case DIOCTUR: {
+ /* test unit ready */
+ error = scsipi_test_unit_ready(cd->sc_periph, XS_CTL_SILENT);
+ *((int*)addr) = (error == 0);
+ if (error == ENODEV || error == EIO || error == 0)
+ return 0;
+ return error;
+ }
case CDIOCPLAYTRACKS: {
/* PLAY_MSF command */
struct ioc_play_track *args = addr;
@@ -1447,15 +1462,18 @@
cd_label(device_t self, struct disklabel *lp)
{
struct cd_softc *cd = device_private(self);
+ struct scsipi_periph *periph = cd->sc_periph;
struct cd_formatted_toc toc;
- int lastsession;
+ int lastsession = 0;
strncpy(lp->d_typename, "optical media", 16);
lp->d_rpm = 300;
- lp->d_flags |= D_REMOVABLE | D_SCSI_MMC;
-
- if (cdreadmsaddr(cd, &toc, &lastsession) != 0)
- lastsession = 0;
+ lp->d_flags |= D_REMOVABLE;
+
+ if ((periph->periph_flags & PERIPH_MEDIA_LOADED) != 0) {
+ lp->d_flags |= D_SCSI_MMC;
+ (void) cdreadmsaddr(cd, &toc, &lastsession);
+ }
lp->d_partitions[0].p_offset = 0;
lp->d_partitions[0].p_size = lp->d_secperunit;
Home |
Main Index |
Thread Index |
Old Index