summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2005-08-18 12:19:09 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2005-08-18 12:19:09 +0000
commit3aceaebc75df9090b2684887634a1046d7b62b7a (patch)
treef13ae4e94b933d9b2d913146d5d867562dbe1524 /sbin
parentcc04a12b665ff97b29ebd56b6e6de37b493111e7 (diff)
very basic blink support.
some manpage tweaks from jmc@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/bioctl/bioctl.89
-rw-r--r--sbin/bioctl/bioctl.c38
2 files changed, 41 insertions, 6 deletions
diff --git a/sbin/bioctl/bioctl.8 b/sbin/bioctl/bioctl.8
index 18d2379f86b..f4a731a433b 100644
--- a/sbin/bioctl/bioctl.8
+++ b/sbin/bioctl/bioctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bioctl.8,v 1.27 2005/08/18 09:16:16 jmc Exp $
+.\" $OpenBSD: bioctl.8,v 1.28 2005/08/18 12:19:08 dlg Exp $
.\"
.\" Copyright (c) 2004, 2005 Marco Peereboom
.\"
@@ -34,6 +34,7 @@
.Bk -words
.Op Fl Dhiv
.Op Fl a Ar alarm-function
+.Op Fl b Ar target
.Op Fl H Ar channel:target[.lun]
.Ar device
.Ek
@@ -63,6 +64,12 @@ The
may be specified as given above,
or by the first letter only
(e.g. -a e).
+.It Fl b Ar target
+Instructs the slot in the enclosure containing the device specified by
+.Ar target
+to blink.
+.Ar device
+is the enclosure.
.It Fl D
Enable debug output.
.It Fl H Ar channel:target[.lun]
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c
index 3032555664b..e73bccf8492 100644
--- a/sbin/bioctl/bioctl.c
+++ b/sbin/bioctl/bioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioctl.c,v 1.31 2005/08/18 04:49:52 marco Exp $ */
+/* $OpenBSD: bioctl.c,v 1.32 2005/08/18 12:19:08 dlg Exp $ */
/*
* Copyright (c) 2004, 2005 Marco Peereboom
@@ -61,6 +61,7 @@ void cleanup(void);
void bio_inq(char *);
void bio_alarm(char *);
void bio_setstate(char *);
+void bio_blink(char *);
/* globals */
const char *bio_device = "/dev/bio";
@@ -80,17 +81,22 @@ main(int argc, char *argv[])
/* u_int64_t subfunc = 0; */
char *bioc_dev = NULL, *sd_dev = NULL;
char *realname = NULL, *al_arg = NULL;
+ char *bl_arg = NULL;
int ch, rv;
if (argc < 2)
usage();
- while ((ch = getopt(argc, argv, "H:ha:Div")) != -1) {
+ while ((ch = getopt(argc, argv, "b:H:ha:Div")) != -1) {
switch (ch) {
case 'a': /* alarm */
func |= BIOC_ALARM;
al_arg = optarg;
break;
+ case 'b': /* blink */
+ func |= BIOC_BLINK;
+ bl_arg = optarg;
+ break;
case 'D': /* debug */
debug = 1;
break;
@@ -152,6 +158,8 @@ main(int argc, char *argv[])
bio_inq(sd_dev);
} else if (func == BIOC_ALARM) {
bio_alarm(al_arg);
+ } else if (func == BIOC_BLINK) {
+ bio_blink(bl_arg);
} else if (func == BIOC_SETSTATE) {
bio_setstate(al_arg);
}
@@ -164,9 +172,8 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr,
- "usage: %s [-Dhiv] [-a alarm-function] [-H channel:target[.lun]] "
- "device\n", __progname);
+ fprintf(stderr, "usage: %s [-Dhiv] [-a alarm-function] [-b targ]"
+ " [-H chan:targ[.lun]] device\n", __progname);
exit(1);
}
@@ -420,3 +427,24 @@ void bio_setstate(char *arg)
return;
}
}
+
+void
+bio_blink(char *arg)
+{
+ struct bioc_blink blink;
+ int target, rv;
+ const char *errstr;
+
+ target = strtonum(arg, 0, 255, &errstr);
+ if (errstr != NULL)
+ errx(1, "target is %s", errstr);
+
+ memset(&blink, 0, sizeof(blink));
+ blink.bb_cookie = bl.bl_cookie;
+ blink.bb_status = BIOC_SBBLINK;
+ blink.bb_target = target;
+
+ rv = ioctl(devh, BIOCBLINK, &blink);
+ if (rv == -1)
+ err(1, "blink unable to be set");
+}