Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 1996 14:42:16 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        grog@lemis.de, hackers@FreeBSD.org
Subject:   Re: New disks on 2.1-RELEASE: help
Message-ID:  <199605030442.OAA15889@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>So: my question.  Would some kind soul please try this with a SCSI
>disk they don't mind overwriting.  Please stick very closely to the
>sequence (or tell me why it's broken :-), since that's what I'm going
>to write.  Obviously the disk doesn't have to be sd1.

>1.  Format:

>    scsiformat sd1

`cp somejunk /dev/sd1' would be faster.  sd1 should probably be /dev/rsd1.

>2.  fdisk -u sd1

sd1 should certainly be /dev/rsd1.

>    Put at least 2 partitions in.
                    ^^^^^^^^^^ slices :-)

Including at least one FreeBSD one.  Otherwise the device used in step 3
won't exist.  Step 3 would still work if you give the slice name (sd1s1,
sd1s2, ...) in step 3.

>3.  disklabel -w -r sd1 <tag>

><tag> is a tag in /etc/disktab.  If you don't have one for your disk,

Use `disklabel -R -r sd1 <file>' to avoid mucking with /etc/disktab.
<file> can be created by editing the output of `disklabel /dev/rsd1'.

>Back to the problem:  disklabel issues an ioctl (DIOCSDINFO) against
>the raw disk, and then checks the return value.  disklabel.c:408:

>		if (ioctl(f, DIOCSDINFO, lp) < 0 &&
>		    errno != ENODEV && errno != ENOTTY) {
>			l_perror("ioctl DIOCSDINFO");
>			return (1);
>		}

>In the -current kernel, this ioctl returns an EINVAL when issued
>against a disk with an invalid label.  I changed this to:

>		if (ioctl(f, DIOCSDINFO, lp) < 0 &&
>		    errno != ENODEV && errno != ENOTTY && errno != EINVAL) {
>			l_perror("ioctl DIOCSDINFO");
>			return (1);
>		}

This is wrong.  EINVAL usually means that the supplied label is invalid.
It sometimes means that the wrong device is being labelled, but this case
should be rare because `disklabel sd1' always uses the correct partition
(sd1c).

I'd better change some ENODEV's to EINVAL's to stop disklabel from ignoring
fatal errors :-(.  DIOCSDINFO /dev/rsd1 doesn't make sense, so it seemed like
a good idea to return ENODEV for it.  (You have to label the logically
different device /dev/rsd1c even if you want to use the whole disk for BSD.)

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605030442.OAA15889>