From 57cd391d21ff8ad805c6d7bd1fbc9d5b37943fe9 Mon Sep 17 00:00:00 2001 From: jhb Date: Sat, 10 Jun 2017 01:20:08 +0000 Subject: [PATCH] Improve decoding of RB_AUTOBOOT in the 'howto' argument to reboot(). The reboot() system call accepts a mode (RB_AUTOBOOT, RB_HALT, RB_POWEROFF, or RB_REROOT) as well as zero or more optional flags in 'howto'. However, RB_AUTOBOOT was only displayed if 'howto' was exactly 0. Combinations like 'RB_AUTOBOOT | RB_DUMP' were decoded as 'RB_DUMP'. Instead, imply that RB_AUTOBOOT was specified if none of the other "mode" flags were specified. --- lib/libsysdecode/flags.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c index bf0319f5dcaf..eb28820a0365 100644 --- a/lib/libsysdecode/flags.c +++ b/lib/libsysdecode/flags.c @@ -634,8 +634,19 @@ sysdecode_quotactl_cmd(FILE *fp, int cmd) bool sysdecode_reboot_howto(FILE *fp, int howto, int *rem) { + bool printed; - return (print_mask_int(fp, rebootopt, howto, rem)); + /* + * RB_AUTOBOOT is special in that its value is zero, but it is + * also an implied argument if a different operation is not + * requested via RB_HALT, RB_POWEROFF, or RB_REROOT. + */ + if (howto != 0 && (howto & (RB_HALT | RB_POWEROFF | RB_REROOT)) == 0) { + fputs("RB_AUTOBOOT|", fp); + printed = true; + } else + printed = false; + return (print_mask_int(fp, rebootopt, howto, rem) || printed); } bool