summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/sparc/dev/presto.c18
-rw-r--r--sys/arch/sparc/dev/xd.c31
-rw-r--r--sys/arch/sparc/dev/xy.c31
-rw-r--r--sys/arch/vax/mba/hp.c19
-rw-r--r--sys/arch/vax/vsa/hdc9224.c11
5 files changed, 47 insertions, 63 deletions
diff --git a/sys/arch/sparc/dev/presto.c b/sys/arch/sparc/dev/presto.c
index 891205dbe40..82e7c0c3ef2 100644
--- a/sys/arch/sparc/dev/presto.c
+++ b/sys/arch/sparc/dev/presto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: presto.c,v 1.14 2008/06/15 00:36:40 krw Exp $ */
+/* $OpenBSD: presto.c,v 1.15 2009/09/05 00:48:39 krw Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -333,26 +333,20 @@ prestoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *proc)
bcopy(sc->sc_dk.dk_label, data, sizeof(struct disklabel));
return (0);
- case DIOCSDINFO:
- if ((flag & FWRITE) == 0)
- return (EBADF);
-
- error = setdisklabel(sc->sc_dk.dk_label,
- (struct disklabel *)data, /*sd->sc_dk.dk_openmask : */0);
- return (error);
-
case DIOCWDINFO:
+ case DIOCSDINFO:
if ((flag & FWRITE) == 0)
return (EBADF);
error = setdisklabel(sc->sc_dk.dk_label,
(struct disklabel *)data, /*sd->sc_dk.dk_openmask : */0);
if (error == 0) {
- error = writedisklabel(DISKLABELDEV(dev),
- prestostrategy, sc->sc_dk.dk_label);
+ if (cmd == DIOCWDINFO)
+ error = writedisklabel(DISKLABELDEV(dev),
+ prestostrategy, sc->sc_dk.dk_label);
}
-
return (error);
+
default:
return (EINVAL);
}
diff --git a/sys/arch/sparc/dev/xd.c b/sys/arch/sparc/dev/xd.c
index dbdb87adbaf..7e9d908001f 100644
--- a/sys/arch/sparc/dev/xd.c
+++ b/sys/arch/sparc/dev/xd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xd.c,v 1.45 2009/08/13 15:23:12 deraadt Exp $ */
+/* $OpenBSD: xd.c,v 1.46 2009/09/05 00:48:39 krw Exp $ */
/* $NetBSD: xd.c,v 1.37 1997/07/29 09:58:16 fair Exp $ */
/*
@@ -854,17 +854,6 @@ xdioctl(dev, command, addr, flag, p)
&xd->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
- case DIOCSDINFO: /* set disk label */
- if ((flag & FWRITE) == 0)
- return EBADF;
- error = setdisklabel(xd->sc_dk.dk_label,
- (struct disklabel *) addr, /* xd->sc_dk.dk_openmask : */ 0);
- if (error == 0) {
- if (xd->state == XD_DRIVE_NOLABEL)
- xd->state = XD_DRIVE_ONLINE;
- }
- return error;
-
case DIOCWLABEL: /* change write status of disk label */
if ((flag & FWRITE) == 0)
return EBADF;
@@ -875,6 +864,7 @@ xdioctl(dev, command, addr, flag, p)
return 0;
case DIOCWDINFO: /* write disk label */
+ case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
error = setdisklabel(xd->sc_dk.dk_label,
@@ -883,12 +873,17 @@ xdioctl(dev, command, addr, flag, p)
if (xd->state == XD_DRIVE_NOLABEL)
xd->state = XD_DRIVE_ONLINE;
- /* Simulate opening partition 0 so write succeeds. */
- xd->sc_dk.dk_openmask |= (1 << 0);
- error = writedisklabel(DISKLABELDEV(dev), xdstrategy,
- xd->sc_dk.dk_label);
- xd->sc_dk.dk_openmask =
- xd->sc_dk.dk_copenmask | xd->sc_dk.dk_bopenmask;
+ if (cmd == DIOCWDINFO) {
+ /*
+ * Simulate opening partition 0 so write
+ * succeeds.
+ */
+ xd->sc_dk.dk_openmask |= (1 << 0);
+ error = writedisklabel(DISKLABELDEV(dev),
+ xdstrategy, xd->sc_dk.dk_label);
+ xd->sc_dk.dk_openmask = xd->sc_dk.dk_copenmask |
+ xd->sc_dk.dk_bopenmask;
+ }
}
return error;
diff --git a/sys/arch/sparc/dev/xy.c b/sys/arch/sparc/dev/xy.c
index a4684a70c42..41afe3b6b84 100644
--- a/sys/arch/sparc/dev/xy.c
+++ b/sys/arch/sparc/dev/xy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xy.c,v 1.42 2009/08/13 15:23:12 deraadt Exp $ */
+/* $OpenBSD: xy.c,v 1.43 2009/09/05 00:48:39 krw Exp $ */
/* $NetBSD: xy.c,v 1.26 1997/07/19 21:43:56 pk Exp $ */
/*
@@ -815,17 +815,6 @@ xyioctl(dev, command, addr, flag, p)
&xy->sc_dk.dk_label->d_partitions[DISKPART(dev)];
return 0;
- case DIOCSDINFO: /* set disk label */
- if ((flag & FWRITE) == 0)
- return EBADF;
- error = setdisklabel(xy->sc_dk.dk_label,
- (struct disklabel *) addr, /* xy->sc_dk.dk_openmask : */ 0);
- if (error == 0) {
- if (xy->state == XY_DRIVE_NOLABEL)
- xy->state = XY_DRIVE_ONLINE;
- }
- return error;
-
case DIOCWLABEL: /* change write status of disk label */
if ((flag & FWRITE) == 0)
return EBADF;
@@ -836,6 +825,7 @@ xyioctl(dev, command, addr, flag, p)
return 0;
case DIOCWDINFO: /* write disk label */
+ case DIOCSDINFO: /* set disk label */
if ((flag & FWRITE) == 0)
return EBADF;
error = setdisklabel(xy->sc_dk.dk_label,
@@ -844,12 +834,17 @@ xyioctl(dev, command, addr, flag, p)
if (xy->state == XY_DRIVE_NOLABEL)
xy->state = XY_DRIVE_ONLINE;
- /* Simulate opening partition 0 so write succeeds. */
- xy->sc_dk.dk_openmask |= (1 << 0);
- error = writedisklabel(DISKLABELDEV(dev), xystrategy,
- xy->sc_dk.dk_label);
- xy->sc_dk.dk_openmask =
- xy->sc_dk.dk_copenmask | xy->sc_dk.dk_bopenmask;
+ if (cmd == DIOCWDINFO) {
+ /*
+ * Simulate opening partition 0 so write
+ * succeeds.
+ */
+ xy->sc_dk.dk_openmask |= (1 << 0);
+ error = writedisklabel(DISKLABELDEV(dev),
+ xystrategy, xy->sc_dk.dk_label);
+ xy->sc_dk.dk_openmask = xy->sc_dk.dk_copenmask |
+ xy->sc_dk.dk_bopenmask;
+ }
}
return error;
diff --git a/sys/arch/vax/mba/hp.c b/sys/arch/vax/mba/hp.c
index 391f6fd96fe..088213e60cc 100644
--- a/sys/arch/vax/mba/hp.c
+++ b/sys/arch/vax/mba/hp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hp.c,v 1.19 2007/09/01 12:45:42 miod Exp $ */
+/* $OpenBSD: hp.c,v 1.20 2009/09/05 00:48:39 krw Exp $ */
/* $NetBSD: hp.c,v 1.22 2000/02/12 16:09:33 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -338,19 +338,18 @@ hpioctl(dev, cmd, addr, flag, p)
&lp->d_partitions[DISKPART(dev)];
break;
+ case DIOCWDINFO:
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
return EBADF;
- return setdisklabel(lp, (struct disklabel *)addr, 0, 0);
-
- case DIOCWDINFO:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- else {
- sc->sc_wlabel = 1;
- error = writedisklabel(dev, hpstrategy, lp, 0);
- sc->sc_wlabel = 0;
+ error = setdisklabel(lp, (struct disklabel *)addr, 0);
+ if (error == 0) {
+ if (cmd == DIOCWDINFO) {
+ sc->sc_wlabel = 1;
+ error = writedisklabel(dev, hpstrategy, lp, 0);
+ sc->sc_wlabel = 0;
+ }
}
return error;
case DIOCWLABEL:
diff --git a/sys/arch/vax/vsa/hdc9224.c b/sys/arch/vax/vsa/hdc9224.c
index 10151a5eae3..126cf8700a6 100644
--- a/sys/arch/vax/vsa/hdc9224.c
+++ b/sys/arch/vax/vsa/hdc9224.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hdc9224.c,v 1.24 2009/08/13 15:23:13 deraadt Exp $ */
+/* $OpenBSD: hdc9224.c,v 1.25 2009/09/05 00:48:39 krw Exp $ */
/* $NetBSD: hdc9224.c,v 1.16 2001/07/26 15:05:09 wiz Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -715,10 +715,11 @@ hdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
case DIOCSDINFO:
if ((flag & FWRITE) == 0)
return EBADF;
- else
- err = (cmd == DIOCSDINFO ?
- setdisklabel(lp, (struct disklabel *)addr, 0) :
- writedisklabel(dev, hdstrategy, lp));
+ error = setdisklabel(lp, (struct disklabel *)addr, 0) :
+ if (error == 0) {
+ if (cmd == DIOCWDINFO)
+ error = writedisklabel(dev, hdstrategy, lp));
+ }
break;
case DIOCWLABEL: