From owner-freebsd-hackers Thu May 2 21:48:19 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id VAA24199 for hackers-outgoing; Thu, 2 May 1996 21:48:19 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id VAA24166 for ; Thu, 2 May 1996 21:48:02 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.12/8.6.9) id OAA15889; Fri, 3 May 1996 14:42:16 +1000 Date: Fri, 3 May 1996 14:42:16 +1000 From: Bruce Evans Message-Id: <199605030442.OAA15889@godzilla.zeta.org.au> To: grog@lemis.de, hackers@FreeBSD.org Subject: Re: New disks on 2.1-RELEASE: help Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >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 > is a tag in /etc/disktab. If you don't have one for your disk, Use `disklabel -R -r sd1 ' to avoid mucking with /etc/disktab. 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