diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 17 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/arm/arm/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/disksubr.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/landisk/landisk/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/disksubr.c | 16 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 16 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/disksubr.c | 5 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 5 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/disksubr.c | 24 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/disksubr.c | 24 | ||||
-rw-r--r-- | sys/arch/vax/vax/disksubr.c | 15 |
17 files changed, 123 insertions, 94 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 199b5acf00a..b7447c24f93 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.83 2007/06/10 05:42:48 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.84 2007/06/12 20:57:41 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -389,7 +389,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { char *msg = "no disk label"; - struct buf *bp; + struct buf *bp = NULL; struct disklabel dl; struct cpu_disklabel cdl; int labeloffset, error, i, partoff = 0, cyl = 0, needcsum = 0; @@ -416,8 +416,10 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), labeloffset = I386_LABELOFFSET; } if (msg) { - if (partoff == -1) - return EIO; + if (partoff == -1) { + error = EIO; + goto done; + } /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; @@ -439,7 +441,10 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), (*strat)(bp); error = biowait(bp); - bp->b_flags |= B_INVAL; - brelse(bp); +done: + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index ba152aec806..d9f3f22fa51 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.45 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.46 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -333,7 +333,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -403,7 +403,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index d4ee2767673..885d68a5818 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.40 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.41 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -306,7 +306,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -376,7 +376,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 1214ff4d0fc..371ab87a180 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.31 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.32 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -306,7 +306,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -375,7 +375,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index 2bdf804bc14..f80945f2746 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.36 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.37 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.9 1997/04/01 03:12:13 scottr Exp $ */ /* @@ -119,7 +119,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), done: if (bp) { - bp->b_flags = B_INVAL | B_AGE; + bp->b_flags |= B_INVAL; brelse(bp); } disklabeltokernlabel(lp); @@ -133,7 +133,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; int labelpart; int error = 0; @@ -148,7 +148,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), labelpart); bp->b_blkno = LABELSECTOR; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_READ; + bp->b_flags = B_BUSY | B_READ; (*strat)(bp); if ((error = biowait(bp))) goto done; @@ -159,7 +159,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { *dlp = *lp; - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); goto done; @@ -172,6 +172,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index 9071281959d..75aec04ea0b 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.86 2007/06/10 18:03:59 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.87 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -333,7 +333,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -403,7 +403,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/landisk/landisk/disksubr.c b/sys/arch/landisk/landisk/disksubr.c index 09ba4d46fea..d8730a8118b 100644 --- a/sys/arch/landisk/landisk/disksubr.c +++ b/sys/arch/landisk/landisk/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.28 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.29 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -306,7 +306,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -376,7 +376,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c index 431af300d22..41c35069ea1 100644 --- a/sys/arch/luna88k/luna88k/disksubr.c +++ b/sys/arch/luna88k/luna88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.24 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.25 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */ /* @@ -202,7 +202,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), done: if (bp) { - bp->b_flags = B_INVAL | B_AGE | B_READ; + bp->b_flags |= B_INVAL; brelse(bp); } disklabeltokernlabel(lp); @@ -220,7 +220,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp) { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; int error; @@ -230,7 +230,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = disklabel_bsd_to_om(lp, clp->cd_block); if (error) - return (error); + goto done; /* Get a buffer and copy the new label into it. */ bp = geteblk((int)lp->d_secsize); @@ -241,11 +241,15 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_blkno = LABELSECTOR; bp->b_cylinder = 0; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); - brelse(bp); +done: + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/mac68k/mac68k/disksubr.c b/sys/arch/mac68k/mac68k/disksubr.c index 23b1bcf65db..0f779bc7bf4 100644 --- a/sys/arch/mac68k/mac68k/disksubr.c +++ b/sys/arch/mac68k/mac68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.44 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.45 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.22 1997/11/26 04:18:20 briggs Exp $ */ /* @@ -438,7 +438,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; int labelpart; int error = 0; @@ -480,7 +480,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 293e1e609ed..6e5f35a1313 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.50 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.51 2007/06/12 20:57:42 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -397,7 +397,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -488,7 +488,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index c1c0241a923..5c26d3ef23f 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.52 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.53 2007/06/12 20:57:42 deraadt Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -509,7 +509,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { char *msg = "no disk label"; - struct buf *bp; + struct buf *bp = NULL; struct disklabel dl; struct cpu_disklabel cdl; int labeloffset, error, partoff = 0, cyl = 0; @@ -527,8 +527,10 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), labeloffset = LABELOFFSET; } if (msg) { - if (partoff == -1) - return EIO; + if (partoff == -1) { + error = EIO; + goto error; + } /* Write it in the regular place with native byte order. */ labeloffset = LABELOFFSET; @@ -543,7 +545,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), (*strat)(bp); error = biowait(bp); - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/mvme68k/mvme68k/disksubr.c b/sys/arch/mvme68k/mvme68k/disksubr.c index 5c56e139d92..829b68a61aa 100644 --- a/sys/arch/mvme68k/mvme68k/disksubr.c +++ b/sys/arch/mvme68k/mvme68k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.53 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.54 2007/06/12 20:57:42 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -157,7 +157,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), } if (error) - return (error); + goto done; bsdtocpulabel(lp, osdep); @@ -176,6 +176,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); } +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c index 2e5633dd0d6..957220d411e 100644 --- a/sys/arch/mvme88k/mvme88k/disksubr.c +++ b/sys/arch/mvme88k/mvme88k/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.49 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.50 2007/06/12 20:57:43 deraadt Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1995 Dale Rahn. @@ -157,7 +157,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), } if (error) - return (error); + goto done; bsdtocpulabel(lp, osdep); @@ -176,6 +176,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); } +done: if (bp) { bp->b_flags |= B_INVAL; brelse(bp); diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index 3b03f6a7142..747101e9976 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.46 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.47 2007/06/12 20:57:43 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -309,7 +309,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), { struct dos_partition dp[NDOSPART], *dp2; struct disklabel *dlp; - struct buf *bp; + struct buf *bp = NULL; int error, dospartoff, cyl, i; int ourpart = -1; @@ -378,7 +378,9 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), error = biowait(bp); done: - bp->b_flags |= B_INVAL; - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/sparc/sparc/disksubr.c b/sys/arch/sparc/sparc/disksubr.c index 4c35a05adfd..c2684037e3f 100644 --- a/sys/arch/sparc/sparc/disksubr.c +++ b/sys/arch/sparc/sparc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.58 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.59 2007/06/12 20:57:43 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.16 1996/04/28 20:25:59 thorpej Exp $ */ /* @@ -175,7 +175,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), done: if (bp) { - bp->b_flags = B_INVAL | B_AGE | B_READ; + bp->b_flags |= B_INVAL; brelse(bp); } disklabeltokernlabel(lp); @@ -191,20 +191,12 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp) { - struct buf *bp; + struct buf *bp = NULL; int error; error = disklabel_bsd_to_sun(lp, clp->cd_block); if (error) - return (error); - -#if 0 /* XXX - Allow writing native disk labels? */ - { - struct disklabel *dlp; - dlp = (struct disklabel *)(clp->cd_block + LABELOFFSET); - *dlp = *lp; /* struct assignment */ - } -#endif + goto done; /* Get a buffer and copy the new label into it. */ bp = geteblk((int)lp->d_secsize); @@ -215,11 +207,15 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_blkno = LABELSECTOR; bp->b_cylinder = 0; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); - brelse(bp); +done: + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/sparc64/sparc64/disksubr.c b/sys/arch/sparc64/sparc64/disksubr.c index 9597405a53b..7ab32acc3e0 100644 --- a/sys/arch/sparc64/sparc64/disksubr.c +++ b/sys/arch/sparc64/sparc64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.37 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.38 2007/06/12 20:57:43 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk Exp $ */ /* @@ -174,7 +174,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), done: if (bp) { - bp->b_flags = B_INVAL | B_AGE | B_READ; + bp->b_flags |= B_INVAL; brelse(bp); } disklabeltokernlabel(lp); @@ -190,20 +190,12 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *clp) { - struct buf *bp; + struct buf *bp = NULL; int error; error = disklabel_bsd_to_sun(lp, clp->cd_block); if (error) - return (error); - -#if 0 /* XXX - Allow writing native disk labels? */ - { - struct disklabel *dlp; - dlp = (struct disklabel *)(clp->cd_block + LABELOFFSET); - *dlp = *lp; /* struct assignment */ - } -#endif + goto done; /* Get a buffer and copy the new label into it. */ bp = geteblk((int)lp->d_secsize); @@ -214,11 +206,15 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_blkno = LABELSECTOR; bp->b_cylinder = 0; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); - brelse(bp); +done: + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } diff --git a/sys/arch/vax/vax/disksubr.c b/sys/arch/vax/vax/disksubr.c index 8963697fe87..f13939627a1 100644 --- a/sys/arch/vax/vax/disksubr.c +++ b/sys/arch/vax/vax/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.47 2007/06/09 23:06:46 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.48 2007/06/12 20:57:43 deraadt Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1999/06/30 18:48:06 ragge Exp $ */ /* @@ -124,7 +124,7 @@ readdisklabel(dev_t dev, void (*strat)(struct buf *), done: if (bp) { - bp->b_flags = B_INVAL | B_AGE | B_READ; + bp->b_flags |= B_INVAL; brelse(bp); } disklabeltokernlabel(lp); @@ -140,7 +140,7 @@ int writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, struct cpu_disklabel *osdep) { - struct buf *bp; + struct buf *bp = NULL; struct disklabel *dlp; int error = 0; @@ -149,19 +149,22 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), bp->b_blkno = LABELSECTOR; bp->b_cylinder = LABELSECTOR / lp->d_secpercyl; bp->b_bcount = lp->d_secsize; - bp->b_flags = B_READ; + bp->b_flags = B_BUSY | B_READ; (*strat)(bp); if ((error = biowait(bp)) != 0) goto done; dlp = (struct disklabel *)(bp->b_data + LABELOFFSET); bcopy(lp, dlp, sizeof(struct disklabel)); - bp->b_flags = B_WRITE; + bp->b_flags = B_BUSY | B_WRITE; (*strat)(bp); error = biowait(bp); done: - brelse(bp); + if (bp) { + bp->b_flags |= B_INVAL; + brelse(bp); + } return (error); } |