diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-01-22 11:00:40 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-01-22 11:00:40 +0000 |
commit | dc525b2b303cabb8371d35abcc681c9b9a2f42f5 (patch) | |
tree | 347d9452a141a9880bd55a758ea9282200768683 /sbin/bioctl | |
parent | e8ecb71d2f8ede42f41552d3df445d2ad527133b (diff) |
If no controller name is provided, use the program name as a prefix. Also,
exit with an "unknown error" if a bio(4) error is reported but no status
message has been provided.
Diffstat (limited to 'sbin/bioctl')
-rw-r--r-- | sbin/bioctl/bioctl.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index 538938ad852..363f9d6c9cf 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.108 2012/01/20 14:09:25 jsing Exp $ */ +/* $OpenBSD: bioctl.c,v 1.109 2012/01/22 11:00:39 jsing Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -310,16 +310,24 @@ str2locator(const char *string, struct locator *location) void bio_status(struct bio_status *bs) { + extern char *__progname; + char *prefix; int i; - for (i = 0; i < bs->bs_msg_count; i++) { - if (strlen(bs->bs_controller)) - printf("%s: ", bs->bs_controller); - printf("%s\n", bs->bs_msgs[i].bm_msg); - } + if (strlen(bs->bs_controller)) + prefix = bs->bs_controller; + else + prefix = __progname; + + for (i = 0; i < bs->bs_msg_count; i++) + printf("%s: %s\n", prefix, bs->bs_msgs[i].bm_msg); - if (bs->bs_status == BIO_STATUS_ERROR) - exit(1); + if (bs->bs_status == BIO_STATUS_ERROR) { + if (bs->bs_msg_count == 0) + errx(1, "unknown error"); + else + exit(1); + } } void |