X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fmachine-id-setup%2Fmachine-id-setup-main.c;h=20cb60b804592f4896eb70cfe35e6708617222ef;hb=3aaaaa482892069058587d07eda68f4edc7b2f35;hp=eb2d514855ade593a4ff325afcfb0e875346a49c;hpb=f274ece0f76b5709408821e317e87aef76123db6;p=elogind.git
diff --git a/src/machine-id-setup/machine-id-setup-main.c b/src/machine-id-setup/machine-id-setup-main.c
index eb2d51485..20cb60b80 100644
--- a/src/machine-id-setup/machine-id-setup-main.c
+++ b/src/machine-id-setup/machine-id-setup-main.c
@@ -19,7 +19,6 @@
along with systemd; If not, see .
***/
-#include
#include
#include
#include
@@ -29,27 +28,29 @@
#include "log.h"
#include "build.h"
-static int help(void) {
+static const char *arg_root = "";
+static void help(void) {
printf("%s [OPTIONS...]\n\n"
"Initialize /etc/machine-id from a random source.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n",
+ " --version Show package version\n"
+ " --root=ROOT Filesystem root\n",
program_invocation_short_name);
-
- return 0;
}
static int parse_argv(int argc, char *argv[]) {
enum {
- ARG_VERSION = 0x100
+ ARG_VERSION = 0x100,
+ ARG_ROOT,
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
- { NULL, 0, NULL, 0 }
+ { "root", required_argument, NULL, ARG_ROOT },
+ {}
};
int c;
@@ -57,7 +58,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "hqcv", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hqcv", options, NULL)) >= 0)
switch (c) {
@@ -70,17 +71,19 @@ static int parse_argv(int argc, char *argv[]) {
puts(SYSTEMD_FEATURES);
return 0;
+ case ARG_ROOT:
+ arg_root = optarg;
+ break;
+
case '?':
return -EINVAL;
default:
- log_error("Unknown option code %c", c);
- return -EINVAL;
+ assert_not_reached("Unhandled option");
}
- }
if (optind < argc) {
- help();
+ log_error("Extraneous arguments");
return -EINVAL;
}
@@ -97,5 +100,5 @@ int main(int argc, char *argv[]) {
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
- return machine_id_setup() < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ return machine_id_setup(arg_root) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}