On Fri, Aug 18, 2023 at 04:20:13PM +0000, Klemens Nanni wrote:
> 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
Better diff using actual per-message type rather than the controller
status which I mixed up.
BIO_MSG_INFO goes to stdin, _WARN and _ERROR to stderr.
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 19 Aug 2023 04:58:36 -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_msgs[i].bm_type == BIO_MSG_INFO ?
+ 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)