NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/55046: cd(4) fails to always open the raw partition



>Number:         55046
>Category:       kern
>Synopsis:       cd(4) fails to always open the raw partition
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 04 21:40:00 +0000 2020
>Originator:     Onno van der Linden
>Release:        NetBSD 9.99.48
>Organization:
>Environment:
System: NetBSD sheep 9.99.48 NetBSD 9.99.48 (SHEEPKMS) #15: Wed Mar 4 20:50:17 CET 2020 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
Architecture: i386
Machine: i386
>Description:
Comment around line 414 of dev/scsipi/cd.c says "Always allow the raw partition to be opened, for raw IOCTLs." 
Open a cd device without a disc in the drive and it fails with ENODEV ("Operation not supported by device").
>How-To-Repeat:
Without a disc present in the drive:
scsictl cd0 identify
or any other command that opens the raw cd device.
>Fix:
Diff below works for me.
Without cd_set_geometry I get a crash in disk_read_sectors()
because lp->d_secpercyl is still zero.

--- /usr/src/sys/dev/scsipi/cd.c.orig	2020-03-02 19:40:06.884302886 +0100
+++ /usr/src/sys/dev/scsipi/cd.c	2020-03-04 21:00:52.882957385 +0100
@@ -419,8 +419,13 @@
 		if (error == EINVAL)
 			error = EIO;
 	}
-	if (error)
+	if (error) {
+		if (part == RAW_PART) {
+			cd_set_geometry(cd);
+			goto out;
+		}
 		goto bad;
+	}
 
 	/* Lock the pack in. */
 	error = scsipi_prevent(periph, SPAMR_PREVENT_DT,
@@ -429,8 +434,10 @@
 	SC_DEBUG(periph, SCSIPI_DB1,
 	    ("cdopen: scsipi_prevent, error=%d\n", error));
 	if (error) {
-		if (part == RAW_PART)
+		if (part == RAW_PART) {
+			cd_set_geometry(cd);
 			goto out;
+		}
 		goto bad;
 	}
 



Home | Main Index | Thread Index | Old Index