Subject: Re: port-next68k/11938: NeXT disklabel support
To: None <netbsd-bugs@netbsd.org>
From: Timm Wetzel <me@kaa.wew>
List: netbsd-bugs
Date: 01/14/2001 17:52:55
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--16868152-1916715721-979489928=:304
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.NXT.4.21.0101141740491.304@kaa.wew>

On Fri, 26 Jun 1998 perseant@hhhh.org wrote:
[...]
> >Description:
> 	The NeXT disklabel code does not currently support reading from a
> 	NextStep-generated disklabel.  I've stolen the Ultrix compatibility
> 	code and modified it to the point that (with a trivial tweak to ffs)
> 	I can mount a NeXT "4.3BSD" ffs from disk.

I was just tinkering with this myself, and I have some
comments. 

> diff -u -r1.5 disksubr.c
> --- next68k/disksubr.c	2000/11/20 08:24:19	1.5
> +++ next68k/disksubr.c	2001/01/11 22:05:01
[...]
> +		lp->d_bbsize = LABELSIZE;
> +		lp->d_sbsize = SBSIZE; /* XXX KS */
> +		for (part = 0; part < MAXPARTITIONS; part++) {
> +			cpp = cdlp->cd_partitions + part;
> +			if (cpp->cp_size >= 0 && cpp->cp_offset >= 0) {
> +				/* XXX is this the correct use of cd_front? */
> +				if (part != RAW_PART && cpp->cp_offset == 0) {
> +					cpp->cp_offset = cdlp->cd_front;
> +					cpp->cp_size -= cdlp->cd_front;
> +				}

Isn't this supposed to be something like this?
  lp->d_partitions[part].p_size = cpp->cp_size * msec;
  lp->d_partitions[part].p_offset = (cpp->cp_offset + cdlp->cd_front) * msec;

There's prior art from Rolf Grossmann in arch/next68k/stand/boot/sd.c
which seems to suggest this.

[...]
> +			} else if (part == RAW_PART) {
> +				/* If RAW_PART was empty, make one up */
I assumed this is already filled in by sdgetdefaultlabel()?

I'd suppose a boot disk would need a NeXT disklabel for the PROM to
recognize it. So being able to write a NeXT disklabel seems useful to me.

It's easy enough to store the necessary info in osdep, and one would
probably translate the info from the disklabel into cpu_disklabel in
writelabel(). But how is selected whether a native or NetBSD label is
wanted?

I've appended a version of your patch which tries to cater for the fact
that NetBSD and NS use different whole-platter partitions (sd#c vs.
rsd#h). Does this make sense?


Regards,
Timm
-- 
Timm Wetzel       <twetzel@gwdg.de>
Max-Planck-Institut fuer biophysikalische Chemie, Abt. 081
Am Fassberg 11, D-37077 Goettingen

--16868152-1916715721-979489928=:304
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="disksubr.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NXT.4.21.0101141732080.304@kaa.wew>
Content-Description: 
Content-Disposition: ATTACHMENT; FILENAME="disksubr.diff"

SW5kZXg6IC4uLy4uL25leHQ2OGsvZGlza3N1YnIuYw0KPT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PQ0KUkNTIGZpbGU6IC9jbGllbnRzL2N2c3Jvb3QvbmV0YnNk
L3NyYy9zeXMvYXJjaC9uZXh0NjhrL25leHQ2OGsvZGlza3N1YnIuYyx2DQpy
ZXRyaWV2aW5nIHJldmlzaW9uIDEuMS4xLjINCmRpZmYgLXUgLXIxLjEuMS4y
IGRpc2tzdWJyLmMNCi0tLSBkaXNrc3Vici5jCTIwMDAvMDYvMDggMjI6MTk6
NTYJMS4xLjEuMg0KKysrIGRpc2tzdWJyLmMJMjAwMS8wMS8xNCAxNTo1MTox
NQ0KQEAgLTQwLDEzICs0MCwyMyBAQA0KICAqCUAoIyl1ZnNfZGlza3N1YnIu
Ywk4LjUgKEJlcmtlbGV5KSAxLzIxLzk0DQogICovDQogDQorLyogI2luY2x1
ZGUgIm9wdF9jb21wYXRfbmV4dHN0ZXAuaCIgKi8NCisNCiAjaW5jbHVkZSA8
c3lzL3BhcmFtLmg+DQogI2luY2x1ZGUgPHN5cy9zeXN0bS5oPg0KICNpbmNs
dWRlIDxzeXMvYnVmLmg+DQorI2luY2x1ZGUgPHN5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