diff options
-rw-r--r-- | sys/arch/amiga/amiga/dkbad.c | 4 | ||||
-rw-r--r-- | sys/arch/atari/atari/dkbad.c | 2 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/dkbad.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/dkbad.c | 2 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/dkbad.c | 4 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/dkbad.c | 4 | ||||
-rw-r--r-- | sys/dev/ata/wd.c | 46 | ||||
-rw-r--r-- | sys/sys/dkbad.h | 6 |
8 files changed, 41 insertions, 31 deletions
diff --git a/sys/arch/amiga/amiga/dkbad.c b/sys/arch/amiga/amiga/dkbad.c index 00cfee99b06..41df81b57c8 100644 --- a/sys/arch/amiga/amiga/dkbad.c +++ b/sys/arch/amiga/amiga/dkbad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkbad.c,v 1.2 1996/05/02 06:43:16 niklas Exp $ */ +/* $OpenBSD: dkbad.c,v 1.3 1999/07/20 03:23:05 csapuntz Exp $ */ /* $NetBSD: dkbad.c,v 1.7 1996/04/21 21:07:00 veego Exp $ */ /* @@ -58,7 +58,7 @@ isbad(bt, cyl, trk, sec) register long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/arch/atari/atari/dkbad.c b/sys/arch/atari/atari/dkbad.c index d426a362e83..ecf2c92ed7d 100644 --- a/sys/arch/atari/atari/dkbad.c +++ b/sys/arch/atari/atari/dkbad.c @@ -53,7 +53,7 @@ isbad(bt, cyl, trk, sec) register long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/arch/hp300/hp300/dkbad.c b/sys/arch/hp300/hp300/dkbad.c index 50aea2df4a0..78edf5bfddb 100644 --- a/sys/arch/hp300/hp300/dkbad.c +++ b/sys/arch/hp300/hp300/dkbad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkbad.c,v 1.3 1997/04/16 11:56:23 downsj Exp $ */ +/* $OpenBSD: dkbad.c,v 1.4 1999/07/20 03:23:05 csapuntz Exp $ */ /* $NetBSD: dkbad.c,v 1.5 1997/04/01 03:12:15 scottr Exp $ */ /* @@ -58,7 +58,7 @@ isbad(bt, cyl, trk, sec) long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/arch/i386/i386/dkbad.c b/sys/arch/i386/i386/dkbad.c index 25cd19bb7d1..ac3041f8236 100644 --- a/sys/arch/i386/i386/dkbad.c +++ b/sys/arch/i386/i386/dkbad.c @@ -57,7 +57,7 @@ isbad(bt, cyl, trk, sec) register long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/arch/mvme68k/mvme68k/dkbad.c b/sys/arch/mvme68k/mvme68k/dkbad.c index 38f26a4e960..9d0de666038 100644 --- a/sys/arch/mvme68k/mvme68k/dkbad.c +++ b/sys/arch/mvme68k/mvme68k/dkbad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkbad.c,v 1.3 1996/04/28 10:59:00 deraadt Exp $ */ +/* $OpenBSD: dkbad.c,v 1.4 1999/07/20 03:23:05 csapuntz Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -54,7 +54,7 @@ isbad(bt, cyl, trk, sec) register long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/arch/mvme88k/mvme88k/dkbad.c b/sys/arch/mvme88k/mvme88k/dkbad.c index 84357e9decc..cc3a62d7697 100644 --- a/sys/arch/mvme88k/mvme88k/dkbad.c +++ b/sys/arch/mvme88k/mvme88k/dkbad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkbad.c,v 1.2 1999/02/09 06:36:28 smurph Exp $ */ +/* $OpenBSD: dkbad.c,v 1.3 1999/07/20 03:23:06 csapuntz Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -54,7 +54,7 @@ isbad(bt, cyl, trk, sec) register long blk, bblk; blk = ((long)cyl << 16) + (trk << 8) + sec; - for (i = 0; i < 126; i++) { + for (i = 0; i < NBT_BAD; i++) { bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec; if (blk == bblk) return (i); diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 21ece2bca60..4a46ea063c1 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.1 1999/07/18 21:25:17 csapuntz Exp $ */ +/* $OpenBSD: wd.c,v 1.2 1999/07/20 03:23:05 csapuntz Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -212,7 +212,9 @@ struct wd_ioctl *wi_get __P((void)); void wdioctlstrategy __P((struct buf *)); void wdgetdefaultlabel __P((struct wd_softc *, struct disklabel *)); -static void wdgetdisklabel __P((dev_t dev, struct wd_softc *)); +static void wdgetdisklabel __P((dev_t dev, struct wd_softc *, + struct disklabel *, + struct cpu_disklabel *, int)); void wdstrategy __P((struct buf *)); void wdstart __P((void *)); void __wdstart __P((struct wd_softc*, struct buf *)); @@ -227,7 +229,7 @@ struct dkdriver wddkdriver = { wdstrategy }; cdev_decl(wd); bdev_decl(wd); -#ifdef HAS_BAD144_HANDLING +#ifdef DKBAD static void bad144intern __P((struct wd_softc *)); #endif int wdlock __P((struct wd_softc *)); @@ -690,18 +692,14 @@ wdopen(dev, flag, fmt, p) } } else { if ((wd->sc_flags & WDF_LOADED) == 0) { - int ret; - wd->sc_flags |= WDF_LOADED; /* Load the physical device parameters. */ - ret = wd_get_params(wd, AT_WAIT, &wd->sc_params); - if (ret != 0) { - panic ("Parameter loading problem: %d\n"); - } + wd_get_params(wd, AT_WAIT, &wd->sc_params); /* Load the partition info if not already loaded. */ - wdgetdisklabel(dev, wd); + wdgetdisklabel(dev, wd, wd->sc_dk.dk_label, + wd->sc_dk.dk_cpulabel, 0); } } @@ -827,16 +825,18 @@ wdgetdefaultlabel(wd, lp) * Fabricate a default disk label, and try to read the correct one. */ static void -wdgetdisklabel(dev, wd) +wdgetdisklabel(dev, wd, lp, clp, spoofonly) dev_t dev; struct wd_softc *wd; + struct disklabel *lp; + struct cpu_disklabel *clp; + int spoofonly; { - struct disklabel *lp = wd->sc_dk.dk_label; char *errstring; WDCDEBUG_PRINT(("wdgetdisklabel\n"), DEBUG_FUNCS); - memset(wd->sc_dk.dk_cpulabel, 0, sizeof(struct cpu_disklabel)); + memset(clp, 0, sizeof(struct cpu_disklabel)); wdgetdefaultlabel(wd, lp); @@ -845,7 +845,7 @@ wdgetdisklabel(dev, wd) if (wd->drvp->state > RECAL) wd->drvp->drive_flags |= DRIVE_RESET; errstring = readdisklabel(WDLABELDEV(dev), - wdstrategy, lp, wd->sc_dk.dk_cpulabel, 0); + wdstrategy, lp, clp, spoofonly); if (errstring) { /* * This probably happened because the drive's default @@ -856,7 +856,7 @@ wdgetdisklabel(dev, wd) if (wd->drvp->state > RECAL) wd->drvp->drive_flags |= DRIVE_RESET; errstring = readdisklabel(WDLABELDEV(dev), - wdstrategy, lp, wd->sc_dk.dk_cpulabel, 0); + wdstrategy, lp, clp, spoofonly); } if (errstring) { printf("%s: %s\n", wd->sc_dev.dv_xname, errstring); @@ -865,7 +865,7 @@ wdgetdisklabel(dev, wd) if (wd->drvp->state > RECAL) wd->drvp->drive_flags |= DRIVE_RESET; -#ifdef HAS_BAD144_HANDLING +#ifdef DKBAD if ((lp->d_flags & D_BADSECT) != 0) bad144intern(wd); #endif @@ -888,16 +888,24 @@ wdioctl(dev, xfer, addr, flag, p) return EIO; switch (xfer) { -#ifdef HAS_BAD144_HANDLING +#ifdef DKBAD case DIOCSBAD: if ((flag & FWRITE) == 0) return EBADF; - wd->sc_dk.dk_cpulabel->bad = *(struct dkbad *)addr; + DKBAD(wd->sc_dk.dk_cpulabel) = *(struct dkbad *)addr; wd->sc_dk.dk_label->d_flags |= D_BADSECT; bad144intern(wd); return 0; #endif + case DIOCGPDINFO: { + struct cpu_disklabel osdep; + + wdgetdisklabel(dev, wd, (struct disklabel *)addr, + &osdep, 1); + return 0; + } + case DIOCGDINFO: *(struct disklabel *)addr = *(wd->sc_dk.dk_label); return 0; @@ -1224,7 +1232,7 @@ wddump(dev, blkno, va, size) } #endif /* __BDEVSW_DUMP_NEW_TYPE */ -#ifdef HAS_BAD144_HANDLING +#ifdef DKBAD /* * Internalize the bad sector table. */ diff --git a/sys/sys/dkbad.h b/sys/sys/dkbad.h index dd0e28e8b16..9a6c4d9e2a9 100644 --- a/sys/sys/dkbad.h +++ b/sys/sys/dkbad.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dkbad.h,v 1.2 1996/03/03 12:11:35 niklas Exp $ */ +/* $OpenBSD: dkbad.h,v 1.3 1999/07/20 03:23:04 csapuntz Exp $ */ /* $NetBSD: dkbad.h,v 1.10 1994/12/25 13:14:21 pk Exp $ */ /*- @@ -58,6 +58,8 @@ * making sure that it does not overlap the bad sector information or any * replacement sectors. */ +#define NBT_BAD 126 + struct dkbad { int32_t bt_csn; /* cartridge serial number */ u_int16_t bt_mbz; /* unused; should be 0 */ @@ -65,7 +67,7 @@ struct dkbad { struct bt_bad { u_int16_t bt_cyl; /* cylinder number of bad sector */ u_int16_t bt_trksec; /* track and sector number */ - } bt_bad[126]; + } bt_bad[NBT_BAD]; }; #define ECC 0 |