Subject: CVS commit: src/sys
To: None <source-changes@NetBSD.org>
From: David Young <dyoung@netbsd.org>
List: source-changes
Date: 06/24/2007 01:43:36
Module Name:	src
Committed By:	dyoung
Date:		Sun Jun 24 01:43:36 UTC 2007

Modified Files:
	src/sys/arch/evbmips/evbmips: disksubr.c
	src/sys/arch/sparc64/sparc64: autoconf.c
	src/sys/arch/x86/x86: x86_autoconf.c
	src/sys/arch/xen/i386: autoconf.c
	src/sys/dev/dkwedge: dk.c
	src/sys/kern: kern_subr.c subr_autoconf.c subr_disk.c subr_disk_mbr.c
	src/sys/sys: device.h disk.h disklabel.h

Log Message:
Extract common code from i386, xen, and sparc64, creating
config_handle_wedges() and read_disk_sectors().  On x86, handle_wedges()
is a thin wrapper for config_handle_wedges().  Share opendisk()
across architectures.

Add kernel code in support of specifying a root partition by wedge
name.  E.g., root specifications "wedge:wd0a", "wedge:David's Root
Volume" are possible.  (Patches for config(1) coming soon.)

In support of moving disks between architectures (esp. i386 <->
evbmips), I've written a routine convertdisklabel() that ensures
that the raw partition is at RAW_DISK by following these steps:

        0 If we have read a disklabel that has a RAW_PART with
          p_offset == 0 and p_size != 0, then use that raw partition.

        1 If we have read a disklabel that has both partitions 'c'
          and 'd', and RAW_PART has p_offset != 0 or p_size == 0,
          but the other partition is suitable for a raw partition
          (p_offset == 0, p_size != 0), then swap the two partitions
          and use the new raw partition.

        2 If the architecture's raw partition is 'd', and if there
          is no partition 'd', but there is a partition 'c' that
          is suitable for a raw partition, then copy partition 'c'
          to partition 'd'.

        3 Determine the drive's last sector, using either the
          d_secperunit the drive reported, or by guessing (0x1fffffff).
          If we cannot read the drive's last sector, then fail.

        4 If we have read a disklabel that has no partition slot
          RAW_PART, then create a partition RAW_PART.  Make it span
          the whole drive.

        5 If there are fewer than MAXPARTITIONS partitions,
          then "slide" the unsuitable raw partition RAW_PART, and
          subsequent partitions, into partition slots RAW_PART+1
          and subsequent slots.  Create a raw partition at RAW_PART.
          Make it span the whole drive.

The convertdisklabel() procedure can probably stand to be simplified,
but it ought to deal with all but an extraordinarily broken disklabel,
now.

i386: compiled and tested, sparc64: compiled, evbmips: compiled.


To generate a diff of this commit:
cvs rdiff -r1.12 -r1.13 src/sys/arch/evbmips/evbmips/disksubr.c
cvs rdiff -r1.137 -r1.138 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -r1.25 -r1.26 src/sys/arch/x86/x86/x86_autoconf.c
cvs rdiff -r1.23 -r1.24 src/sys/arch/xen/i386/autoconf.c
cvs rdiff -r1.24 -r1.25 src/sys/dev/dkwedge/dk.c
cvs rdiff -r1.158 -r1.159 src/sys/kern/kern_subr.c
cvs rdiff -r1.117 -r1.118 src/sys/kern/subr_autoconf.c
cvs rdiff -r1.85 -r1.86 src/sys/kern/subr_disk.c
cvs rdiff -r1.27 -r1.28 src/sys/kern/subr_disk_mbr.c
cvs rdiff -r1.94 -r1.95 src/sys/sys/device.h
cvs rdiff -r1.43 -r1.44 src/sys/sys/disk.h
cvs rdiff -r1.99 -r1.100 src/sys/sys/disklabel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.