summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc/sparc/disksubr.c46
-rw-r--r--sys/arch/sparc64/sparc64/disksubr.c46
-rw-r--r--sys/dev/sun/disklabel.h74
3 files changed, 52 insertions, 114 deletions
diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c
index 995aeeadd79..10c56e999c1 100644
--- a/sys/arch/sparc/sparc/disksubr.c
+++ b/sys/arch/sparc/sparc/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.71 2007/09/19 23:47:50 tsi Exp $ */
+/* $OpenBSD: disksubr.c,v 1.72 2007/10/02 03:26:59 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */
/*
@@ -236,11 +236,12 @@ sun_extended_sum(struct sun_disklabel *sl, void *end)
char *
disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
{
- struct partition *npp;
- struct sun_dkpart *spp;
+ struct sun_preamble *preamble = (struct sun_preamble *)sl;
struct sun_partinfo *ppp;
- int i, secpercyl;
+ struct sun_dkpart *spp;
+ struct partition *npp;
u_short cksum = 0, *sp1, *sp2;
+ int i, secpercyl;
/* Verify the XOR check. */
sp1 = (u_short *)sl;
@@ -343,42 +344,24 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp->p_cpg = sl->sl_cpg[i];
}
}
- } else if (sl->sl_nparts <= 8) {
+ } else if (preamble->sl_nparts <= 8) {
/*
* A more traditional Sun label. Recognise certain filesystem
* types from it, if they are available.
*/
- if ((i = sl->sl_nparts) == 0) {
- for (i = 8; i-- > 0; ) {
- npp = &lp->d_partitions[i];
- if (npp->p_size == 0)
- continue;
-
- ppp = &sl->sl_ipart[i];
- if ((ppp->spi_tag == 0) && (ppp->spi_flag == 0))
- continue;
+ i = preamble->sl_nparts;
+ if (i == 0)
+ i = 8;
- i = 8;
- break;
- }
- }
-
- while (i-- > 0) {
- npp = &lp->d_partitions[i];
+ npp = &lp->d_partitions[i-1];
+ ppp = &preamble->sl_part[i-1];
+ for (; i > 0; i--, npp--, ppp--) {
if (npp->p_size == 0)
continue;
+ if ((ppp->spi_tag == 0) && (ppp->spi_flag == 0))
+ continue;
- ppp = &sl->sl_ipart[i];
switch (ppp->spi_tag) {
- case SPTAG_EMPTY:
- case SPTAG_BOOT:
- case SPTAG_WHOLE_DISK:
- npp->p_fstype = FS_UNUSED;
- break;
- case SPTAG_SUNOS_SWAP:
- case SPTAG_LINUX_SWAP:
- npp->p_fstype = FS_UNUSED; /* FS_SWAP? */
- break;
case SPTAG_SUNOS_ROOT:
case SPTAG_SUNOS_USR:
case SPTAG_SUNOS_VAR:
@@ -392,6 +375,7 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp->p_fstype = FS_EXT2FS;
break;
default:
+ /* FS_SWAP for _SUNOS_SWAP and _LINUX_SWAP? */
npp->p_fstype = FS_UNUSED;
break;
}
diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c
index 7addd06835e..99c28286c3c 100644
--- a/sys/arch/sparc64/sparc64/disksubr.c
+++ b/sys/arch/sparc64/sparc64/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.47 2007/09/19 23:47:50 tsi Exp $ */
+/* $OpenBSD: disksubr.c,v 1.48 2007/10/02 03:26:59 krw Exp $ */
/* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */
/*
@@ -229,11 +229,12 @@ sun_extended_sum(struct sun_disklabel *sl, void *end)
static char *
disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
{
- struct partition *npp;
- struct sun_dkpart *spp;
+ struct sun_preamble *preamble = (struct sun_preamble *)sl;
struct sun_partinfo *ppp;
- int i, secpercyl;
+ struct sun_dkpart *spp;
+ struct partition *npp;
u_short cksum = 0, *sp1, *sp2;
+ int i, secpercyl;
/* Verify the XOR check. */
sp1 = (u_short *)sl;
@@ -336,42 +337,24 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp->p_cpg = sl->sl_cpg[i];
}
}
- } else if (sl->sl_nparts <= 8) {
+ } else if (preamble->sl_nparts <= 8) {
/*
* A more traditional Sun label. Recognise certain filesystem
* types from it, if they are available.
*/
- if ((i = sl->sl_nparts) == 0) {
- for (i = 8; i-- > 0; ) {
- npp = &lp->d_partitions[i];
- if (npp->p_size == 0)
- continue;
-
- ppp = &sl->sl_ipart[i];
- if ((ppp->spi_tag == 0) && (ppp->spi_flag == 0))
- continue;
+ i = preamble->sl_nparts;
+ if (i == 0)
+ i = 8;
- i = 8;
- break;
- }
- }
-
- while (i-- > 0) {
- npp = &lp->d_partitions[i];
+ npp = &lp->d_partitions[i-1];
+ ppp = &preamble->sl_part[i-1];
+ for (; i > 0; i--, npp--, ppp--) {
if (npp->p_size == 0)
continue;
+ if ((ppp->spi_tag == 0) && (ppp->spi_flag == 0))
+ continue;
- ppp = &sl->sl_ipart[i];
switch (ppp->spi_tag) {
- case SPTAG_EMPTY:
- case SPTAG_BOOT:
- case SPTAG_WHOLE_DISK:
- npp->p_fstype = FS_UNUSED;
- break;
- case SPTAG_SUNOS_SWAP:
- case SPTAG_LINUX_SWAP:
- npp->p_fstype = FS_UNUSED; /* FS_SWAP? */
- break;
case SPTAG_SUNOS_ROOT:
case SPTAG_SUNOS_USR:
case SPTAG_SUNOS_VAR:
@@ -385,6 +368,7 @@ disklabel_sun_to_bsd(struct sun_disklabel *sl, struct disklabel *lp)
npp->p_fstype = FS_EXT2FS;
break;
default:
+ /* FS_SWAP for _SUNOS_SWAP and _LINUX_SWAP? */
npp->p_fstype = FS_UNUSED;
break;
}
diff --git a/sys/dev/sun/disklabel.h b/sys/dev/sun/disklabel.h
index 947719cd15a..2a83b008ed6 100644
--- a/sys/dev/sun/disklabel.h
+++ b/sys/dev/sun/disklabel.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.h,v 1.5 2007/09/19 23:47:50 tsi Exp $ */
+/* $OpenBSD: disklabel.h,v 1.6 2007/10/02 03:26:59 krw Exp $ */
/* $NetBSD: disklabel.h,v 1.2 1998/08/22 14:55:28 mrg Exp $ */
/*
@@ -80,57 +80,17 @@ struct sun_partinfo {
struct sun_disklabel { /* total size = 512 bytes */
char sl_text[128];
- union {
- /* Sun standard fields, also used on Linux */
- struct {
- /* label version */
- u_int sli_version;
- /* short volume name */
- char sli_volume[8];
- /* partition count */
- u_short sli_nparts;
- struct sun_partinfo sli_part[8];
- char sli_xxx1[292 - sizeof(u_int) -
- (sizeof(char) * 8) - sizeof(u_short) -
- (sizeof(struct sun_partinfo) * 8)];
- } i;
- /* BSD-specific extensions */
- struct {
- /* additive cksum, [xl_xpmag,sl_xx1) */
- u_int slx_xpsum;
- /* "extended" magic number */
- u_int slx_xpmag;
- /* "extended" partitions, i through p */
- struct sun_dkpart slx_xpart[SUNXPART];
- u_char slx_types[MAXPARTITIONS];
- u_int8_t slx_fragblock[MAXPARTITIONS];
- u_int16_t slx_cpg[MAXPARTITIONS];
- char slx_xxx1[292 - sizeof(u_int) -
- sizeof(u_int) -
- (sizeof(struct sun_dkpart) *
- SUNXPART) -
- (sizeof(u_char) *
- MAXPARTITIONS) -
- (sizeof(u_int8_t) *
- MAXPARTITIONS) -
- (sizeof(u_int16_t) *
- MAXPARTITIONS)];
- } x;
- } u;
-/* Compatibility */
-#define sl_xpsum u.x.slx_xpsum
-#define sl_xpmag u.x.slx_xpmag
-#define sl_xpart u.x.slx_xpart
-#define sl_types u.x.slx_types
-#define sl_fragblock u.x.slx_fragblock
-#define sl_cpg u.x.slx_cpg
-#define sl_xxx1 u.x.slx_xxx1
-/* Convenience */
-#define sl_version u.i.sli_version
-#define sl_volume u.i.sli_volume
-#define sl_nparts u.i.sli_nparts
-#define sl_ipart u.i.sli_part
-#define sl_xxx1i u.i.sli_xxx1
+ u_int sl_xpsum; /* additive cksum, [xl_xpmag,sl_xx1) */
+ u_int sl_xpmag; /* "extended" magic number */
+ struct sun_dkpart sl_xpart[SUNXPART]; /* "extended" partitions i..p */
+ u_char sl_types[MAXPARTITIONS];
+ u_int8_t sl_fragblock[MAXPARTITIONS];
+ u_int16_t sl_cpg[MAXPARTITIONS];
+ char sl_xxx1[292 - sizeof(u_int) - sizeof(u_int) -
+ (sizeof(struct sun_dkpart) * SUNXPART) -
+ sizeof(u_char) * MAXPARTITIONS -
+ sizeof(u_int8_t) * MAXPARTITIONS -
+ sizeof(u_int16_t) * MAXPARTITIONS];
u_short sl_rpm; /* rotational speed */
u_short sl_pcylinders; /* number of physical cyls */
#define sl_pcyl sl_pcylinders /* XXX: old sun3 */
@@ -146,3 +106,13 @@ struct sun_disklabel { /* total size = 512 bytes */
u_short sl_magic; /* == SUN_DKMAGIC */
u_short sl_cksum; /* xor checksum of all shorts */
};
+
+/* Sun standard fields, also used on Linux. */
+struct sun_preamble {
+ char sl_text[128];
+ u_int sl_version; /* label version */
+ char sl_volume[8]; /* short volume name */
+ u_short sl_nparts; /* partition count */
+
+ struct sun_partinfo sl_part[8];
+};