diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-12-20 16:48:10 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-12-20 16:48:10 +0000 |
commit | 276a39682e7b08b533a35d39633f2fa36c3cca6f (patch) | |
tree | 9f0f34e7ce79c0b578bd1c142ccaf88e24625056 /sys | |
parent | ae5d53a181560f61721ef6e4e01cc3a36a0c92c3 (diff) |
Add readdisklabel support for BSD disklabels. I got tired of the amiga RDB
only requirement, now you can partition with disklabel(8) -r instead.
However I have not done in-kernel writedisklabel support yet.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amiga/amiga/disksubr.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/sys/arch/amiga/amiga/disksubr.c b/sys/arch/amiga/amiga/disksubr.c index 5225f21d9ff..ca73414bf37 100644 --- a/sys/arch/amiga/amiga/disksubr.c +++ b/sys/arch/amiga/amiga/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.6 1996/06/10 19:37:05 niklas Exp $ */ +/* $OpenBSD: disksubr.c,v 1.7 1996/12/20 16:48:09 niklas Exp $ */ /* $NetBSD: disksubr.c,v 1.25 1996/04/30 05:00:51 mhitch Exp $ */ /* @@ -100,6 +100,7 @@ readdisklabel(dev, strat, lp, clp) struct disklabel *lp; struct cpu_disklabel *clp; { + struct disklabel *dlp; struct adostype adt; struct partition *pp = NULL; struct partblock *pbp; @@ -165,12 +166,36 @@ readdisklabel(dev, strat, lp, clp) if (rdbchksum(rbp) == 0) break; else - msg = "rdb bad checksum"; + msg = "bad rdb checksum"; } } if (nextb == RDB_MAXBLOCKS) { - if (msg == NULL) - msg = "no rdb found"; + /* + * No RDB found, let's look for an OpenBSD label instead. + */ + bp->b_dev = dev; + bp->b_blkno = LABELSECTOR; + bp->b_resid = 0; /* was b_cylin */ + bp->b_bcount = lp->d_secsize; + bp->b_flags = B_BUSY | B_READ; + (*strat)(bp); + + /* if successful, find disk label within block and validate */ + if (biowait(bp)) { + msg = "disklabel read error"; + goto done; + } + + dlp = (struct disklabel *)(bp->b_un.b_addr + LABELOFFSET); + if (dlp->d_magic == DISKMAGIC) { + if (dkcksum(dlp)) { + msg = "OpenBSD disk label corrupted"; + goto done; + } + *lp = *dlp; + goto done; + } + msg = "no rdb nor BSD disklabel found"; goto done; } else if (msg) { /* |