diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-08-03 02:39:56 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-08-03 02:39:56 +0000 |
commit | ce9ca2691a4cd28815a28cc4151dd061d7fd85b8 (patch) | |
tree | 22409b0f45ef10c20d34c1f379f51176e7aab2ca /sbin/bioctl | |
parent | cb89963e0d4de20f7d8fa5c88368348d66b7ed8b (diff) |
various cleanups, the way i like it, ok marco
Diffstat (limited to 'sbin/bioctl')
-rw-r--r-- | sbin/bioctl/bioctl.8 | 21 | ||||
-rw-r--r-- | sbin/bioctl/bioctl.c | 60 |
2 files changed, 25 insertions, 56 deletions
diff --git a/sbin/bioctl/bioctl.8 b/sbin/bioctl/bioctl.8 index d9575718490..591e4215f87 100644 --- a/sbin/bioctl/bioctl.8 +++ b/sbin/bioctl/bioctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bioctl.8,v 1.17 2005/08/02 20:27:13 jmc Exp $ +.\" $OpenBSD: bioctl.8,v 1.18 2005/08/03 02:39:55 deraadt Exp $ .\" .\" Copyright (c) 2004, 2005 Marco Peereboom .\" @@ -32,10 +32,9 @@ .Sh SYNOPSIS .Nm bioctl .Bk -words -.Op Fl Dhi +.Op Fl Di .Op Fl a Ar function -.Fl d Ar device | -.Fl f Ar device +.Op Ar device | drive .Ek .Sh DESCRIPTION .Nm @@ -65,21 +64,15 @@ or by the first letter only (e.g. -a e). .It Fl D Enable debug output. -.It Fl d Ar device +.It Fl i +Enumerate the selected RAID devices. +.It Ar device Select RAID controller e.g. ami0. Use the .Fl d option for controller operations that impact all disk devices. -.It Fl f Ar device +.It Ar drive Select RAID disk e.g. sd0. -.It Fl h -Online help. -.It Fl i -Depending on whether -.Fl d -or -.Fl f -was specified, enumerate all or only selected RAID device(s), respectively. .El .Sh SEE ALSO .Xr ami 4 , diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index d961d881050..eab5079cae7 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,5 @@ -/* $OpenBSD: bioctl.c,v 1.18 2005/08/02 20:27:13 jmc Exp $ */ +/* $OpenBSD: bioctl.c,v 1.19 2005/08/03 02:39:55 deraadt Exp $ */ + /* * Copyright (c) 2004, 2005 Marco Peereboom * All rights reserved. @@ -56,56 +57,42 @@ int main(int argc, char *argv[]) { extern char *optarg; - u_int64_t func = 0; /* u_int64_t subfunc = 0; */ - - int ch; - int rv; - - char *bioc_dev = NULL; - char *sd_dev = NULL; - char *realname = NULL; - char *al_arg = NULL; /* argument to alarm */ + char *bioc_dev = NULL, *sd_dev = NULL; + char *realname = NULL, *al_arg = NULL; + int ch, rv; if (argc < 2) usage(); - atexit(cleanup); - - while ((ch = getopt(argc, argv, "a:Dd:f:hi")) != -1) { + while ((ch = getopt(argc, argv, "a:Di")) != -1) { switch (ch) { case 'a': /* alarm */ func |= BIOC_ALARM; al_arg = optarg; break; - case 'D': /* debug */ debug = 1; break; - - case 'd': /* bio device */ - bioc_dev = optarg; - break; - - case 'f': /* scsi device */ - sd_dev = optarg; - break; - case 'i': /* inquiry */ func |= BIOC_INQ; break; - - case 'h': /* help/usage */ - /* FALLTHROUGH */ default: usage(); /* NOTREACHED */ } } + argc -= optind; + argv += optind; + + if (argc < 0 || argc > 1) + usage(); - if (sd_dev && bioc_dev) - err(1, "-d and -f are mutually exclusive"); + if (strncmp(argv[0], "sd", 2) == 0) + sd_dev = argv[0]; + else + bioc_dev = argv[0]; if (bioc_dev) { devh = open(bio_device, O_RDWR); @@ -118,7 +105,7 @@ main(int argc, char *argv[]) errx(1, "Can't locate %s device via %s", bl.name, bio_device); } else if (sd_dev) { - devh = opendev(sd_dev, O_RDWR, OPENDEV_PART, &realname); + devh = opendev(sd_dev, O_RDWR, OPENDEV_PART, &realname); if (devh == -1) err(1, "Can't open %s", sd_dev); } else @@ -141,28 +128,17 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-Dhi] [-a function] -d device | -f device\n", __progname); - + fprintf(stderr, + "usage: %s [-Di] [-a function] [device | drive]\n", __progname); exit(1); } void -cleanup(void) -{ - if (debug) - printf("atexit\n"); - - if (devh != -1) - close(devh); -} - -void bio_inq(void) { bioc_inq bi; bioc_vol bv; bioc_disk bd; - int rv, i, d; memset(&bi, 0, sizeof(bi)); |