diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-29 06:28:17 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-29 06:28:17 +0000 |
commit | 444b0299644e2e692c1f8d00d8b1caa0acea33a3 (patch) | |
tree | 1b53b5865bcc8b3675238c2ebdd9daf6797ccd39 /sys | |
parent | 3f6176ec485942a0e5cfcc7e61ca01950df6452c (diff) |
Updated disklabel format to support larger disks and partitions. We
free room in struct partition by packing fragment size and
fragments/block more tighlty and use the resulting space to make
offset and size 48 bits. For the disk part we use spare fields in
struct disklabel. Kernel converts in-mem copy of the on-disk
label if needed, disklabel(8) writes new version.
We are careful to only change fields not used by bootloaders.
Conception of basic scheme by deraadt.
ok deraadt@ krw@
Diffstat (limited to 'sys')
25 files changed, 161 insertions, 92 deletions
diff --git a/sys/adosfs/advfsops.c b/sys/adosfs/advfsops.c index f26aadfbaf9..3653ccafc8d 100644 --- a/sys/adosfs/advfsops.c +++ b/sys/adosfs/advfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: advfsops.c,v 1.25 2003/08/14 07:46:39 mickey Exp $ */ +/* $OpenBSD: advfsops.c,v 1.26 2007/05/29 06:28:16 otto Exp $ */ /* $NetBSD: advfsops.c,v 1.24 1996/12/22 10:10:12 cgd Exp $ */ /* @@ -200,8 +200,8 @@ adosfs_mountfs(devvp, mp, p) amp->secsperblk = 1; } else { - amp->bsize = parp->p_fsize * parp->p_frag; - amp->secsperblk = parp->p_frag; + amp->bsize = DISKLABELV1_FFS_BSIZE(parp->fragblock); + amp->secsperblk = DISKLABELV1_FFS_FRAG(parp->p_fragblock); } amp->rootb = (parp->p_size / amp->secsperblk - 1 + parp->p_cpg) >> 1; amp->numblks = parp->p_size / amp->secsperblk - parp->p_cpg; diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 141dd05afea..8fe69125170 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.68 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.69 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -194,6 +194,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -450,8 +451,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index d0395f77af6..a084c728ef7 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.32 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.33 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -316,6 +316,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -362,8 +363,7 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index 818d8e695c5..bf75cf30c28 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.27 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.28 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -292,6 +292,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -340,8 +341,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 000ff6aa2c1..13cd52806e0 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.18 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.19 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -292,6 +292,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -340,8 +341,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 025a2e5b57e..84e8442e8eb 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.24 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.25 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -125,6 +125,7 @@ done: bp->b_flags = B_INVAL | B_AGE; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -158,8 +159,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index 313649991d2..7b7991dbe33 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.48 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.49 2007/05/29 06:28:15 otto Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -197,6 +197,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -615,8 +616,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index 60bba818722..678dfee3469 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2007/05/29 05:08:19 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2007/05/29 06:28:15 otto Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -193,6 +193,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -611,8 +612,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index ec7e97d05a7..7cb6237ba9a 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.72 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.73 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -316,6 +316,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -362,8 +363,7 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index c176cae4e4a..2ccb0a91e9d 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.15 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.16 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -292,6 +292,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -340,8 +341,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c index 9168329f120..1112ef4a592 100644 --- a/sys/arch/luna88k/luna88k/disksubr.c +++ b/sys/arch/luna88k/luna88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.11 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.12 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */ /* @@ -208,6 +208,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -453,8 +454,8 @@ disklabel_om_to_bsd(cp, lp) * XXX: (Should remove that code from newfs...) */ if (npp->p_fstype == FS_BSDFFS) { - npp->p_fsize = 1024; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(1024, 8); npp->p_cpg = 16; } } diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index 84ec4f989c3..ad775c8b45c 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.32 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.33 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -436,6 +436,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -481,8 +482,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 8b274d31fe2..34ee90539af 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.37 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.38 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -381,6 +381,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -427,8 +428,7 @@ setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask, */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index f48e84212a2..f191f688e19 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.37 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.38 2007/05/29 06:28:15 otto Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -201,6 +201,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -501,8 +502,8 @@ static struct {int m; int b;} maptab[] = { lp->d_partitions[bsd].p_size = dlp->partitions[i].blocks; lp->d_partitions[bsd].p_fstype = maptab[i].b; if (lp->d_partitions[bsd].p_fstype == FS_BSDFFS) { - lp->d_partitions[bsd].p_fsize = 1024; - lp->d_partitions[bsd].p_frag = 8; + lp->d_partitions[bsd].p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(1024, 8); lp->d_partitions[bsd].p_cpg = 16; } } @@ -561,8 +562,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index 1dd4d51b7b2..13ceb97c242 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.38 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.39 2007/05/29 06:28:15 otto Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -147,6 +147,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -202,8 +203,7 @@ setdisklabel(olp, nlp, openmask, clp) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 04dbd071675..bd9535d72d7 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.34 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.35 2007/05/29 06:28:15 otto Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -144,6 +144,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -199,8 +200,7 @@ setdisklabel(olp, nlp, openmask, clp) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index 0b538400c3a..00d369c3c77 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.33 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.34 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -295,6 +295,7 @@ done: bp->b_flags |= B_INVAL; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -343,8 +344,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index 8d9ceeaf2ac..c8394812869 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.43 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.44 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -186,6 +186,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -448,8 +449,8 @@ disklabel_sun_to_bsd(cp, lp) * The sun label does not store the FFS fields, * so just set them with default values here. */ - npp->p_fsize = 2048; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(2048, 8); npp->p_cpg = 16; } } @@ -481,8 +482,8 @@ disklabel_sun_to_bsd(cp, lp) } npp->p_fstype = sun_fstypes[i+8]; if (npp->p_fstype == FS_BSDFFS) { - npp->p_fsize = 2048; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(2048, 8); npp->p_cpg = 16; } } diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c index b0b4987106b..162bcb88134 100644 --- a/sys/arch/sparc64/sparc64/disksubr.c +++ b/sys/arch/sparc64/sparc64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.21 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.22 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */ /* @@ -185,6 +185,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -445,8 +446,8 @@ disklabel_sun_to_bsd(cp, lp) * The sun label does not store the FFS fields, * so just set them with default values here. */ - npp->p_fsize = 2048; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(2048, 8); npp->p_cpg = 16; } } @@ -478,8 +479,8 @@ disklabel_sun_to_bsd(cp, lp) } npp->p_fstype = sun_fstypes[i+8]; if (npp->p_fstype == FS_BSDFFS) { - npp->p_fsize = 2048; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(2048, 8) npp->p_cpg = 16; } } diff --git a/sys/arch/sparc64/stand/ofwboot/ofdev.c b/sys/arch/sparc64/stand/ofwboot/ofdev.c index 870e7c347b4..e03f7d7bebc 100644 --- a/sys/arch/sparc64/stand/ofwboot/ofdev.c +++ b/sys/arch/sparc64/stand/ofwboot/ofdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofdev.c,v 1.8 2006/07/27 20:41:29 deraadt Exp $ */ +/* $OpenBSD: ofdev.c,v 1.9 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: ofdev.c,v 1.1 2000/08/20 14:58:41 mrg Exp $ */ /* @@ -307,8 +307,8 @@ disklabel_sun_to_bsd(cp, lp) * The sun label does not store the FFS fields, * so just set them with default values here. */ - npp->p_fsize = 1024; - npp->p_frag = 8; + npp->p_fragblock = + DISKLABELV1_FFS_FRAGBLOCK(1024, 8); npp->p_cpg = 16; } } diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index 59aa57f35af..c94fd2c0ff2 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.34 2007/05/29 05:08:20 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.35 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */ /* @@ -185,6 +185,7 @@ done: bp->b_flags = B_INVAL | B_AGE | B_READ; brelse(bp); } + cvtdisklabelv1(lp); return (msg); } @@ -231,8 +232,7 @@ setdisklabel(olp, nlp, openmask, osdep) */ if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) { npp->p_fstype = opp->p_fstype; - npp->p_fsize = opp->p_fsize; - npp->p_frag = opp->p_frag; + npp->p_fragblock = opp->p_fragblock; npp->p_cpg = opp->p_cpg; } } diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c index 183b66b7fde..f06ee19defe 100644 --- a/sys/kern/spec_vnops.c +++ b/sys/kern/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.39 2007/04/10 19:02:26 thib Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.40 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -267,10 +267,13 @@ spec_read(v) if ((majordev = major(vp->v_rdev)) < nblkdev && (ioctl = bdevsw[majordev].d_ioctl) != NULL && (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { - if (dpart.part->p_fstype == FS_BSDFFS && - dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) - bsize = dpart.part->p_frag * - dpart.part->p_fsize; + u_int32_t frag = + DISKLABELV1_FFS_FRAG(dpart.part->p_fragblock); + u_int32_t fsize = + DISKLABELV1_FFS_FSIZE(dpart.part->p_fragblock); + if (dpart.part->p_fstype == FS_BSDFFS && frag != 0 && + fsize != 0) + bsize = frag * fsize; } bscale = btodb(bsize); do { @@ -363,10 +366,13 @@ spec_write(v) if ((majordev = major(vp->v_rdev)) < nblkdev && (ioctl = bdevsw[majordev].d_ioctl) != NULL && (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { - if (dpart.part->p_fstype == FS_BSDFFS && - dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) - bsize = dpart.part->p_frag * - dpart.part->p_fsize; + u_int32_t frag = + DISKLABELV1_FFS_FRAG(dpart.part->p_fragblock); + u_int32_t fsize = + DISKLABELV1_FFS_FSIZE(dpart.part->p_fragblock); + if (dpart.part->p_fstype == FS_BSDFFS && frag != 0 && + fsize != 0) + bsize = frag * fsize; } bscale = btodb(bsize); do { diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index b085a719e56..90ca865c6f8 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.42 2007/05/18 16:26:38 drahn Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.43 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -182,6 +182,31 @@ dkcksum(struct disklabel *lp) } /* + * Convert an old disklabel to a v1 disklabel + */ +void +cvtdisklabelv1(struct disklabel *lp) +{ + int i; + + if (lp->d_version == 1) + return; + + lp->d_version = 1; + lp->d_secperunith = 0; + for (i = 0; i < MAXPARTITIONS; i++) { + struct partition *pp = &lp->d_partitions[i]; + struct __partitionv0 *v0pp = (struct __partitionv0 *) + &lp->d_partitions[i]; + + pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(v0pp->p_fsize, + v0pp->p_frag); + pp->p_offseth = 0; + pp->p_sizeh = 0; + } +} + +/* * Disk error is the preface to plaintive error messages * about failing disk transfers. It prints messages of the form diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 183b66b7fde..f06ee19defe 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.39 2007/04/10 19:02:26 thib Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.40 2007/05/29 06:28:15 otto Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -267,10 +267,13 @@ spec_read(v) if ((majordev = major(vp->v_rdev)) < nblkdev && (ioctl = bdevsw[majordev].d_ioctl) != NULL && (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { - if (dpart.part->p_fstype == FS_BSDFFS && - dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) - bsize = dpart.part->p_frag * - dpart.part->p_fsize; + u_int32_t frag = + DISKLABELV1_FFS_FRAG(dpart.part->p_fragblock); + u_int32_t fsize = + DISKLABELV1_FFS_FSIZE(dpart.part->p_fragblock); + if (dpart.part->p_fstype == FS_BSDFFS && frag != 0 && + fsize != 0) + bsize = frag * fsize; } bscale = btodb(bsize); do { @@ -363,10 +366,13 @@ spec_write(v) if ((majordev = major(vp->v_rdev)) < nblkdev && (ioctl = bdevsw[majordev].d_ioctl) != NULL && (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) { - if (dpart.part->p_fstype == FS_BSDFFS && - dpart.part->p_frag != 0 && dpart.part->p_fsize != 0) - bsize = dpart.part->p_frag * - dpart.part->p_fsize; + u_int32_t frag = + DISKLABELV1_FFS_FRAG(dpart.part->p_fragblock); + u_int32_t fsize = + DISKLABELV1_FFS_FSIZE(dpart.part->p_fragblock); + if (dpart.part->p_fstype == FS_BSDFFS && frag != 0 && + fsize != 0) + bsize = frag * fsize; } bscale = btodb(bsize); do { diff --git a/sys/sys/disklabel.h b/sys/sys/disklabel.h index a80c265aa10..f7a3e7fbf83 100644 --- a/sys/sys/disklabel.h +++ b/sys/sys/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.28 2006/09/26 23:33:04 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.29 2007/05/29 06:28:14 otto Exp $ */ /* $NetBSD: disklabel.h,v 1.41 1996/05/10 23:07:37 mark Exp $ */ /* @@ -145,7 +145,9 @@ struct disklabel { u_int32_t d_flags; /* generic flags */ #define NDDATA 5 u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */ -#define NSPARE 5 + u_int16_t d_secperunith; /* # of data sectors (high part) */ + u_int16_t d_version; /* version # (1=48 bit addressing) */ +#define NSPARE 4 u_int32_t d_spare[NSPARE]; /* reserved for future use */ u_int32_t d_magic2; /* the magic number (again) */ u_int16_t d_checksum; /* xor of data incl. partitions */ @@ -157,9 +159,10 @@ struct disklabel { struct partition { /* the partition table */ u_int32_t p_size; /* number of sectors in partition */ u_int32_t p_offset; /* starting sector */ - u_int32_t p_fsize; /* filesystem basic fragment size */ + u_int16_t p_offseth; /* starting sector (high part) */ + u_int16_t p_sizeh; /* number of sectors (high part) */ u_int8_t p_fstype; /* filesystem type, see below */ - u_int8_t p_frag; /* filesystem fragments per block */ + u_int8_t p_fragblock; /* encoded filesystem frag/block */ union { u_int16_t cpg; /* UFS: FS cylinders per group */ u_int16_t sgs; /* LFS: FS segment shift */ @@ -168,6 +171,20 @@ struct disklabel { #define p_sgs __partition_u1.sgs } d_partitions[MAXPARTITIONS]; /* actually may be more */ }; + + +struct __partitionv0 { /* the partition table */ + u_int32_t p_size; /* number of sectors in partition */ + u_int32_t p_offset; /* starting sector */ + u_int32_t p_fsize; /* filesystem basic fragment size */ + u_int8_t p_fstype; /* filesystem type, see below */ + u_int8_t p_frag; /* filesystem fragments per block */ + union { + u_int16_t cpg; /* UFS: FS cylinders per group */ + u_int16_t sgs; /* LFS: FS segment shift */ + } __partitionv0_u1; +}; + #else /* _LOCORE */ /* * offsets for asm boot files. @@ -181,6 +198,17 @@ struct disklabel { .set d_end_,404 /* size of disk label */ #endif /* _LOCORE */ + +#define DISKLABELV1_FFS_FRAGBLOCK(fsize, frag) \ + ((fsize) * (frag) == 0 ? 0 : \ + (((ffs((fsize) * (frag)) - 13) << 3) | (ffs(frag)))) + +#define DISKLABELV1_FFS_BSIZE(i) ((i) == 0 ? 0 : (1 << (((i) >> 3) + 12))) +#define DISKLABELV1_FFS_FRAG(i) ((i) == 0 ? 0 : (1 << (((i) & 0x07) - 1))) +#define DISKLABELV1_FFS_FSIZE(i) ((i) == 0 ? 0 : \ + (DISKLABELV1_FFS_BSIZE(i) / DISKLABELV1_FFS_FRAG(i))) + + /* d_type values: */ #define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */ #define DTYPE_MSCP 2 /* MSCP */ @@ -354,6 +382,7 @@ struct partinfo { void diskerr(struct buf *, char *, char *, int, int, struct disklabel *); void disksort(struct buf *, struct buf *); u_int dkcksum(struct disklabel *); +void cvtdisklabelv1(struct disklabel *); int setdisklabel(struct disklabel *, struct disklabel *, u_long, struct cpu_disklabel *); char *readdisklabel(dev_t, void (*)(struct buf *), struct disklabel *, |