Messages from the driver always land on standard output, but they may
contain errors, which ought to land on standard error.
Seen when scripted creation silently failed:
# bioctl -Cforce -cC -lvnd0a softraid0 1>/dev/null ; echo $?
1
# ./obj/bioctl -Cforce -cC -lvnd0a softraid0 1>/dev/null ; echo $?
softraid0: chunk vnd0a already in use
1
Besides BIO_STATUS_SUCCESS and _ERROR there is _UNKNOWN, which
/sys/dev/bio.c uses to initialise, so I presume we should never hit this.
If we do, I'd count that as an error rather than success, hence the
success <> stdout, else <> stderr mapping.
Feedback? OK?
Index: bioctl.c
===================================================================
RCS file: /cvs/src/sbin/bioctl/bioctl.c,v
retrieving revision 1.152
diff -u -p -r1.152 bioctl.c
--- bioctl.c 18 Aug 2023 14:09:19 -0000 1.152
+++ bioctl.c 18 Aug 2023 16:14:32 -0000
@@ -376,7 +376,8 @@ bio_status(struct bio_status *bs)
prefix = __progname;
for (i = 0; i < bs->bs_msg_count; i++)
- printf("%s: %s\n", prefix, bs->bs_msgs[i].bm_msg);
+ fprintf(bs->bs_status == BIO_STATUS_SUCCESS ? stdout : stderr,
+ "%s: %s\n", prefix, bs->bs_msgs[i].bm_msg);
if (bs->bs_status == BIO_STATUS_ERROR) {
if (bs->bs_msg_count == 0)