Subject: port-i386/269: buglet in [i386] /sys/scsi/sd.c
To: None <gnats-admin>
From: John Brezak <brezak@ch.hp.com>
List: netbsd-bugs
Date: 05/29/1994 22:05:05
>Number:         269
>Category:       port-i386
>Synopsis:       Default label for unlabelled disks sets fs_type to '9'. Check in open looks logic reversed.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 29 22:05:03 1994
>Originator:     John Brezak
>Organization:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 John Brezak                    UUCP:     uunet!apollo.hp!brezak
 Hewlett Packard/Apollo         Internet: brezak@ch.hp.com
 300 Apollo Drive               Phone:    (508) 436-4915
 Chelmsford, Massachusetts      Fax:      (508) 436-5103
>Release:        0.9B
>Environment:
	
System: NetBSD sussex 0.9B NetBSD 0.9B (ESSEX) #26: Sat May 28 17:11:42 EDT 1994 brezak@sussex:/u0/src/netbsd/sys/arch/i386/compile/ESSEX i386


>Description:
When attempting to disklabel a fresh SCSI disk, the default label for the
'd' partition is created with a fs_type of 9. This probably should be a
FS_UNUSED. Also in the sdopen() routine there is a check if the partition
is 'd' and it is FS_UNUSED, then ENXIO. It seems that the login is reversed
in the check for FS_UNUSED. Otherwise how can you label an 'unused' partition ?

>How-To-Repeat:
Get a new disk. Try to label it with the default label, and use "disklabel -r -e"
to turn it into something more reasonable.
>Fix:

Here is a suggested fix, if this is suppose to be how it should work.

===================================================================
RCS file: /u1/CVS/netbsd/sys/scsi/sd.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 sd.c
*** 1.1.1.1	1994/05/30 03:47:41
--- sd.c	1994/05/30 04:34:02
***************
*** 276,282 ****
  	/*
  	 *  Check that the partition exists
  	 */
! 	if (sd->sc_dk.dk_label.d_partitions[part].p_fstype == FS_UNUSED &&
  	    part != RAW_PART) {
  		error = ENXIO;
  		goto bad;
--- 276,282 ----
  	/*
  	 *  Check that the partition exists
  	 */
! 	if (sd->sc_dk.dk_label.d_partitions[part].p_fstype != FS_UNUSED &&
  	    part != RAW_PART) {
  		error = ENXIO;
  		goto bad;
***************
*** 646,652 ****
  	sd->sc_dk.dk_label.d_partitions[0].p_offset = 0;
  	sd->sc_dk.dk_label.d_partitions[0].p_size =
  	    sd->params.disksize * (sd->params.blksize / DEV_BSIZE);
! 	sd->sc_dk.dk_label.d_partitions[0].p_fstype = 9;	/* XXXX */
  	sd->sc_dk.dk_label.d_partitions[RAW_PART].p_offset = 0;
  	sd->sc_dk.dk_label.d_partitions[RAW_PART].p_size =
  	    sd->params.disksize * (sd->params.blksize / DEV_BSIZE);
--- 646,652 ----
  	sd->sc_dk.dk_label.d_partitions[0].p_offset = 0;
  	sd->sc_dk.dk_label.d_partitions[0].p_size =
  	    sd->params.disksize * (sd->params.blksize / DEV_BSIZE);
! 	sd->sc_dk.dk_label.d_partitions[0].p_fstype = FS_UNUSED;
  	sd->sc_dk.dk_label.d_partitions[RAW_PART].p_offset = 0;
  	sd->sc_dk.dk_label.d_partitions[RAW_PART].p_size =
  	    sd->params.disksize * (sd->params.blksize / DEV_BSIZE);

>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------