summaryrefslogtreecommitdiff
path: root/sbin/bioctl/bioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/bioctl/bioctl.c')
-rw-r--r--sbin/bioctl/bioctl.c84
1 files changed, 15 insertions, 69 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c
index 8a86aec1b88..6096c5c2d10 100644
--- a/sbin/bioctl/bioctl.c
+++ b/sbin/bioctl/bioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioctl.c,v 1.73 2008/08/11 17:22:54 marco Exp $ */
+/* $OpenBSD: bioctl.c,v 1.74 2008/08/11 17:28:24 marco Exp $ */
/*
* Copyright (c) 2004, 2005 Marco Peereboom
@@ -70,8 +70,7 @@ void derive_key_pkcs(int, u_int8_t *, size_t, u_int8_t *,
void bio_inq(char *);
void bio_alarm(char *);
-int bio_getvolbyname(char *);
-void bio_setstate(char *, int, char *);
+void bio_setstate(char *);
void bio_setblink(char *, char *, int);
void bio_blink(char *, int, int);
void bio_createraid(u_int16_t, char *);
@@ -98,13 +97,13 @@ main(int argc, char *argv[])
char *realname = NULL, *al_arg = NULL;
char *bl_arg = NULL, *dev_list = NULL;
const char *errstr;
- int ch, rv, blink = 0, diskinq = 0, ss_func = 0;
+ int ch, rv, blink = 0, diskinq = 0;
u_int16_t cr_level = 0;
if (argc < 2)
usage();
- while ((ch = getopt(argc, argv, "a:b:C:c:dH:hil:qr:R:vu:")) != -1) {
+ while ((ch = getopt(argc, argv, "a:b:C:c:dH:hil:qr:vu:")) != -1) {
switch (ch) {
case 'a': /* alarm */
func |= BIOC_ALARM;
@@ -136,7 +135,6 @@ main(int argc, char *argv[])
break;
case 'H': /* set hotspare */
func |= BIOC_SETSTATE;
- ss_func = BIOC_SSHOTSPARE;
al_arg = optarg;
break;
case 'h':
@@ -155,12 +153,6 @@ main(int argc, char *argv[])
errx(1, "Number of rounds is %s: %s",
errstr, optarg);
break;
- case 'R':
- /* rebuild to provided chunk/CTL */
- func |= BIOC_SETSTATE;
- ss_func = BIOC_SSREBUILD;
- al_arg = optarg;
- break;
case 'v':
verbose = 1;
break;
@@ -214,7 +206,7 @@ main(int argc, char *argv[])
} else if (func == BIOC_BLINK) {
bio_setblink(sd_dev, bl_arg, blink);
} else if (func == BIOC_SETSTATE) {
- bio_setstate(al_arg, ss_func, argv[0]);
+ bio_setstate(al_arg);
} else if (func == BIOC_DELETERAID && sd_dev != NULL) {
bio_deleteraid(sd_dev);
} else if (func & BIOC_CREATERAID || func & BIOC_DEVLIST) {
@@ -241,9 +233,8 @@ usage(void)
"\t[-C flag[,flag,...]] [-c raidlevel] "
"[-H channel:target[.lun]]\n"
"\t[-l special[,special,...]] [-r rounds] "
- "[-R device|channel:target[.lun]\n"
- "\t[-u channel:target[.lun]] "
- "device\n", __progname);
+ "[-u channel:target[.lun]]\n"
+ "\tdevice\n", __progname);
exit(1);
}
@@ -501,67 +492,23 @@ bio_alarm(char *arg)
}
}
-int
-bio_getvolbyname(char *name)
-{
- int id = -1, i, rv;
- struct bioc_inq bi;
- struct bioc_vol bv;
-
- memset(&bi, 0, sizeof(bi));
- bi.bi_cookie = bl.bl_cookie;
- rv = ioctl(devh, BIOCINQ, &bi);
- if (rv == -1)
- err(1, "BIOCINQ");
-
- for (i = 0; i < bi.bi_novol; i++) {
- memset(&bv, 0, sizeof(bv));
- bv.bv_cookie = bl.bl_cookie;
- bv.bv_volid = i;
- rv = ioctl(devh, BIOCVOL, &bv);
- if (rv == -1)
- err(1, "BIOCVOL");
-
- if (name && strcmp(name, bv.bv_dev) != 0)
- continue;
- id = i;
- break;
- }
-
- return (id);
-}
-
void
-bio_setstate(char *arg, int status, char *devname)
+bio_setstate(char *arg)
{
struct bioc_setstate bs;
struct locator location;
- struct stat sb;
const char *errstr;
int rv;
- memset(&bs, 0, sizeof(bs));
- if (stat(arg, &sb) == -1) {
- /* use CTL */
- errstr = str2locator(arg, &location);
- if (errstr)
- errx(1, "Target %s: %s", arg, errstr);
- bs.bs_channel = location.channel;
- bs.bs_target = location.target;
- bs.bs_lun = location.lun;
- } else {
- /* use other id */
- bs.bs_other_id = sb.st_rdev;
- bs.bs_other_id_type = BIOC_SSOTHER_DEVT;
- }
+ errstr = str2locator(arg, &location);
+ if (errstr)
+ errx(1, "Target %s: %s", arg, errstr);
bs.bs_cookie = bl.bl_cookie;
- bs.bs_status = status;
-
- /* make sure user supplied a sd device */
- bs.bs_volid = bio_getvolbyname(devname);
- if (bs.bs_volid == -1)
- errx(1, "invalid device %s", devname);
+ bs.bs_status = BIOC_SSHOTSPARE;
+ bs.bs_channel = location.channel;
+ bs.bs_target = location.target;
+ bs.bs_lun = location.lun;
rv = ioctl(devh, BIOCSETSTATE, &bs);
if (rv == -1)
@@ -884,7 +831,6 @@ bio_deleteraid(char *dev)
memset(&bd, 0, sizeof(bd));
bd.bd_cookie = bd.bd_cookie;
- /* XXX make this a dev_t instead of a string */
strlcpy(bd.bd_dev, dev, sizeof bd.bd_dev);
if (ioctl(devh, BIOCDELETERAID, &bd))
errx(1, "delete volume %s failed", dev);