Subject: kern/36244: various ioctls fail for ld noticably on install
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Todd Kover <kovert@omniscient.com>
List: netbsd-bugs
Date: 04/29/2007 15:35:00
>Number:         36244
>Category:       kern
>Synopsis:       ioctls fail to the ld driver preventing sysinst install
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 29 15:35:00 +0000 2007
>Originator:     Todd Kover
>Release:        NetBSD 4.0_BETA2 (patch for -current)
>Organization:
Omniscient Technologies
>Environment:
NetBSD slivovice.cz.omniscient.com 4.0_BETA2 NetBSD 4.0_BETA2 (SLIVOVICE) #0: Sun Apr 29 16:28:38 CEST 2007  kovert@slivovice.cz.omniscient.com:/usr/obj/4.0-stable/i386/usr/src/os/NetBSD-4.0-branch/src/sys/arch/i386/compile/SLIVOVICE i386
Architecture: i386
Machine: i386
>Description:

        ldioctl() fails to set a return value for success so any ioctls
        processed by the function return ENOTTY.  This prevents sysinst
        from noticing the disk, preventing installations or upgrades.
        It's also noticable with invocations of disklabel and fdisk.

        oddly, I notice this on a Adaptec 2610SA-based ld0 but not a
        2410SA-based ld0; I didn't dig into why (the latter is also an
        older rev of BETA2, so it may have been caused by a pullup).

>How-To-Repeat:
        1. attempt to use sysinst or disklabel -I -e or fdisk on an
        	ld-based disk
	2. read " Inappropriate ioctl for device"
	3. curse

>Fix:

        The below patch fixes it. (it's against -current, but I tested
        it under 4.0_BETA2).

        It would be great if this could be applied and pulled up to 4.0.
        This would allow 4.0 to install on all ld-based disks.


Index: ld.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ld.c,v
retrieving revision 1.46
diff -u -r1.46 ld.c
--- ld.c	4 Mar 2007 06:01:42 -0000	1.46
+++ ld.c	29 Apr 2007 14:56:02 -0000
@@ -402,6 +402,7 @@
 	if (error != EPASSTHROUGH)
 		return (error);
 
+	error = 0;	/* reset to avoid erroneous passthru */
 	switch (cmd) {
 	case DIOCGDINFO:
 		memcpy(addr, sc->sc_dk.dk_label, sizeof(struct disklabel));