diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 1996-09-27 19:14:09 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 1996-09-27 19:14:09 +0000 |
commit | fa6a09b54e98c39000009800f494eba1b766707d (patch) | |
tree | 5f01538487c35a0488f7e73caa9f0a235e7aa83b /sys/arch/arc | |
parent | b44a616ea5c66f88ef4bccbb7583afc03acb4c33 (diff) |
OpenBSD changes
Diffstat (limited to 'sys/arch/arc')
-rw-r--r-- | sys/arch/arc/arc/disksubr.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/sys/arch/arc/arc/disksubr.c b/sys/arch/arc/arc/disksubr.c index 6665f0e2d62..88cd87466bd 100644 --- a/sys/arch/arc/arc/disksubr.c +++ b/sys/arch/arc/arc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.4 1996/09/22 11:26:09 pefo Exp $ */ +/* $OpenBSD: disksubr.c,v 1.5 1996/09/27 19:14:08 pefo Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -51,11 +51,10 @@ dk_establish(dk, dev) } /* - * Attempt to read a disk label from a device - * using the indicated stategy routine. + * Attempt to read a disk label from a device * using the indicated stategy routine. * The label must be partly set up before this: - * secpercyl and anything required in the strategy routine - * (e.g., sector size) must be filled in before calling us. + * secpercyl and anything required in the strategy routine + * (e.g., sector size) must be filled in before calling us. * Returns null on success and an error string on failure. */ char * @@ -69,8 +68,7 @@ readdisklabel(dev, strat, lp, clp) struct disklabel *dlp; struct dos_partition *dp = clp->dosparts; char *msg = NULL; - int dospartoff = 0; - int i; + int dospart, dospartoff, i; /* minimal requirements for archtypal disk label */ if (lp->d_secperunit == 0) @@ -87,6 +85,8 @@ readdisklabel(dev, strat, lp, clp) /* obtain buffer to probe drive with */ bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; + dospartoff = 0; + dospart = -1; /* do dos partitions in the process of getting disklabel? */ if (dp) { @@ -101,22 +101,35 @@ readdisklabel(dev, strat, lp, clp) if (biowait(bp)) { msg = "dos partition I/O error"; goto done; - } else if (*(unsigned int *)(bp->b_data) == 0x8efac033) { + } + if (*(unsigned int *)(bp->b_data) == 0x8efac033) { /* XXX how do we check veracity/bounds of this? */ bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp)); - for (i = 0; i < NDOSPART; i++, dp++) { - /* is this ours? */ + + for (i = 0, dp = clp->dosparts; i < NDOSPART; i++, dp++) { + if (dp->dp_size && dp->dp_typ == DOSPTYP_OPENBSD + && dospart < 0) + dospart = i; + } + for (i = 0, dp = clp->dosparts; i < NDOSPART; i++, dp++) { if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD - && dospartoff == 0) { - dospartoff = dp->dp_start; + && dospart < 0) + dospart = i; + } + if(dospart >= 0) { + /* + * set part a to show OpenBSD part + */ + dp = clp->dosparts+dospart; + dospartoff = dp->dp_start; - /* set part a to show OpenBSD part */ - lp->d_partitions[0].p_size = dp->dp_size; - lp->d_partitions[0].p_offset = dp->dp_start; - lp->d_ntracks = dp->dp_ehd + 1; - lp->d_nsectors = DPSECT(dp->dp_esect); - lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; - } + lp->d_partitions[0].p_size = dp->dp_size; + lp->d_partitions[0].p_offset = dp->dp_start; + lp->d_partitions[RAW_PART].p_size = dp->dp_size; + lp->d_partitions[RAW_PART].p_offset = dp->dp_start; + lp->d_ntracks = dp->dp_ehd + 1; + lp->d_nsectors = DPSECT(dp->dp_esect); + lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; } } @@ -213,10 +226,12 @@ writedisklabel(dev, strat, lp, clp) struct disklabel *dlp; struct dos_partition *dp = clp->dosparts; int error = 0, i; - int dospartoff = 0; + int dospart, dospartoff; bp = geteblk((int)lp->d_secsize); bp->b_dev = dev; + dospart = -1; + dospartoff = 0; /* do dos partitions in the process of getting disklabel? */ if (dp) { @@ -231,10 +246,18 @@ writedisklabel(dev, strat, lp, clp) && *(unsigned int *)(bp->b_data) == 0x8efac033) { /* XXX how do we check veracity/bounds of this? */ bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp)); - for (i = 0; i < NDOSPART; i++, dp++) { - /* is this ours? */ + + for (i = 0, dp = clp->dosparts; i < NDOSPART; i++, dp++) { + if (dp->dp_size && dp->dp_typ == DOSPTYP_OPENBSD + && dospart < 0) { + dospart = i; + dospartoff = dp->dp_start; + } + } + for (i = 0, dp = clp->dosparts; i < NDOSPART; i++, dp++) { if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD - && dospartoff == 0) { + && dospart < 0) { + dospart = i; dospartoff = dp->dp_start; } } |