diff --git a/zipl/include/zipl.h b/zipl/include/zipl.h index bd54822a..364cdb66 100644 --- a/zipl/include/zipl.h +++ b/zipl/include/zipl.h @@ -66,4 +66,24 @@ extern int verbose; extern int interactive; extern int dry_run; +/* Verbosity levels/classes */ +#define VERBOSITY_STANDARD 0 +#define VERBOSITY_EXTENDED 1 +#define VERBOSITY_DEBUG 2 + +/* + * Macro for messages with assigned verbosity classes + * + * NOTE: Verbosity levels/classes 3 and higher are "reserved". To implement + * them, make "--debug" zipl option accept arguments. + */ +#define pr_class(class_id, ...) \ +do { \ + if (verbose >= (class_id)) \ + printf(__VA_ARGS__); \ +} while (0) + +#define pr_verbose(...) pr_class(VERBOSITY_EXTENDED, __VA_ARGS__) +#define pr_debug(...) pr_class(VERBOSITY_DEBUG, __VA_ARGS__) + #endif /* not ZIPL_H */ diff --git a/zipl/man/zipl.8.in b/zipl/man/zipl.8.in index e7256ea5..e9072636 100644 --- a/zipl/man/zipl.8.in +++ b/zipl/man/zipl.8.in @@ -351,6 +351,10 @@ interaction is possible. .BR "\-V" " or " "\-\-verbose" Provide more verbose output. +.TP +.B "\-\-debug" +Provide output debugging information. + .TP .BR "\-a" " or " "\-\-add-files" Copy all specified files to the bootmap file instead of just referencing them. diff --git a/zipl/src/job.c b/zipl/src/job.c index d384e011..c5b51869 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -60,6 +60,7 @@ static struct option options[] = { { "noninteractive", no_argument, NULL, 'n'}, { "version", no_argument, NULL, 'v'}, { "verbose", no_argument, NULL, 'V'}, + { "debug", no_argument, NULL, 0xb2}, { "add-files", no_argument, NULL, 'a'}, { "tape", required_argument, NULL, 'T'}, { "dry-run", no_argument, NULL, '0'}, @@ -131,6 +132,16 @@ set_secure_ipl(char *keyword, int *is_secure) return 0; } +static void set_verbosity_level(struct command_line *cmdline, int level) +{ + /* + * In case of multiple verbosity levels specified by user + * the highest one will take place + */ + if (cmdline->verbose < level) + cmdline->verbose = level; +} + static int get_command_line(int argc, char* argv[], struct command_line* line) { @@ -278,7 +289,7 @@ get_command_line(int argc, char* argv[], struct command_line* line) cmdline.version = 1; break; case 'V': - cmdline.verbose = 1; + set_verbosity_level(&cmdline, VERBOSITY_EXTENDED); break; case 'a': cmdline.add_files = 1; @@ -295,6 +306,9 @@ get_command_line(int argc, char* argv[], struct command_line* line) case 0xb1: cmdline.no_compress = 1; break; + case 0xb2: + set_verbosity_level(&cmdline, VERBOSITY_DEBUG); + break; case 1: /* Non-option is interpreted as section name */ if (cmdline.section != NULL) { diff --git a/zipl/src/zipl.c b/zipl/src/zipl.c index 4992d937..21f6eb0a 100644 --- a/zipl/src/zipl.c +++ b/zipl/src/zipl.c @@ -30,7 +30,7 @@ /* Flag deciding the level of verbosity */ -int verbose = 0; +int verbose = VERBOSITY_STANDARD; /* Flag deciding whether confirmation questions are asked */ int interactive = 1; @@ -81,6 +81,7 @@ static const char* usage_text[] = { "-m, --menu MENU Install multi-boot configuration MENU", "-n, --noninteractive Answer all confirmation questions with 'yes'", "-V, --verbose Provide more verbose output", +" --debug Provide output debugging information", "-a, --add-files Add all referenced files to bootmap file", " --dry-run Simulate run but don't modify IPL records", "-S, --secure SWITCH Control the zIPL secure boot support.",