chiark / gitweb /
networkd-wait-online: allow specific devices to be ignored
[elogind.git] / src / network / networkd-wait-online.c
index 32a8d85301628d2285b058137d75263c5a1054ca..826ab929cc5bb5af17d9ab4e9d505461e436f58d 100644 (file)
@@ -29,6 +29,7 @@
 
 static bool arg_quiet = false;
 static char **arg_interfaces = NULL;
+static char **arg_ignore = NULL;
 
 static void help(void) {
         printf("%s [OPTIONS...]\n\n"
@@ -37,6 +38,7 @@ static void help(void) {
                "     --version              Print version string\n"
                "  -q --quiet                Do not show status information\n"
                "  -i --interface=INTERFACE  Block until at least these interfaces have appeared\n"
+               "     --ignore=INTERFACE     Don't take these interfaces into account\n"
                , program_invocation_short_name);
 }
 
@@ -44,6 +46,7 @@ static int parse_argv(int argc, char *argv[]) {
 
         enum {
                 ARG_VERSION = 0x100,
+                ARG_IGNORE,
         };
 
         static const struct option options[] = {
@@ -51,6 +54,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "version",         no_argument,       NULL, ARG_VERSION },
                 { "quiet",           no_argument,       NULL, 'q'         },
                 { "interface",       required_argument, NULL, 'i'         },
+                { "ignore",          required_argument, NULL, ARG_IGNORE  },
                 {}
         };
 
@@ -82,6 +86,12 @@ static int parse_argv(int argc, char *argv[]) {
 
                         break;
 
+                case ARG_IGNORE:
+                        if (strv_extend(&arg_ignore, optarg) < 0)
+                                return log_oom();
+
+                        break;
+
                 case '?':
                         return -EINVAL;
 
@@ -111,7 +121,7 @@ int main(int argc, char *argv[]) {
 
         assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
 
-        r = manager_new(&m, arg_interfaces);
+        r = manager_new(&m, arg_interfaces, arg_ignore);
         if (r < 0) {
                 log_error_errno(r, "Could not create manager: %m");
                 goto finish;
@@ -135,5 +145,8 @@ int main(int argc, char *argv[]) {
 finish:
         sd_notify(false, "STATUS=All interfaces configured...");
 
+        strv_free(arg_interfaces);
+        strv_free(arg_ignore);
+
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }