11 #include <pb-config/pb-config.h>
12 #include <types/types.h>
13 #include <waiter/waiter.h>
14 #include <process/process.h>
15 #include <talloc/talloc.h>
17 extern struct config *config_get(void);
18 extern int platform_init(void);
20 static const struct option options[] = {
28 static void usage(const char *progname)
30 fprintf(stderr, "Usage:\t%1$s <var>\n"
31 "\t%1$s --list\n", progname);
34 static void print_one_config(void *ctx, const char *req, const char *name,
37 bool use_prefix = !req;
41 if (req && strcmp(req, name))
45 val = talloc_vasprintf(ctx, fmt, ap);
48 if (!strcmp(val, "(null)")) {
52 val = talloc_strdup(ctx, "");
55 sep = use_prefix ? ": " : "";
57 printf("%s%s%s\n", use_prefix ? name : "", sep, val);
62 static void print_config(void *ctx, struct config *config, const char *var)
66 for (i = 0; i < config->n_autoboot_opts; i++) {
67 if (config->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE)
68 print_one_config(ctx, var, "bootdev", "%s",
69 device_type_name(config->autoboot_opts[i].type));
71 print_one_config(ctx, var, "bootdev", "%s",
72 config->autoboot_opts[i].uuid);
74 print_one_config(ctx, var, "autoboot", "%s",
75 config->autoboot_enabled ? "enabled" : "disabled");
76 print_one_config(ctx, var, "timeout", "%d",
77 config->autoboot_timeout_sec);
78 print_one_config(ctx, var, "safe-mode", "%s",
79 config->safe_mode ? "enabled" : "disabled");
80 print_one_config(ctx, var, "debug", "%s",
81 config->debug ? "enabled" : "disabled");
84 int main(int argc, char **argv)
86 struct waitset *waitset;
87 struct config *config;
94 int opt = getopt_long(argc, argv, "l", options, NULL);
108 ctx = talloc_new(NULL);
110 waitset = waitset_create(ctx);
112 process_init(ctx, waitset, false);
118 config = config_get();
121 print_config(ctx, config, NULL);
125 for (i = optind; i < argc; i++)
126 print_config(ctx, config, argv[i]);