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");
82 print_one_config(ctx, var, "dm-snapshots", "%s",
83 config->disable_snapshots ? "disabled" : "enabled");
86 int main(int argc, char **argv)
88 struct waitset *waitset;
89 struct config *config;
96 int opt = getopt_long(argc, argv, "l", options, NULL);
110 ctx = talloc_new(NULL);
112 waitset = waitset_create(ctx);
114 process_init(ctx, waitset, false);
120 config = config_get();
123 print_config(ctx, config, NULL);
127 for (i = optind; i < argc; i++)
128 print_config(ctx, config, argv[i]);