udev: builtin - rename net_link to net_setup_link
authorTom Gundersen <teg@jklm.no>
Mon, 28 Oct 2013 19:20:59 +0000 (20:20 +0100)
committerTom Gundersen <teg@jklm.no>
Tue, 29 Oct 2013 13:17:57 +0000 (14:17 +0100)
Also add shell completions.

Makefile.am
rules/85-net-configure-link.rules
shell-completion/bash/udevadm
shell-completion/zsh/_udevadm
src/udev/udev-builtin-net_link.c [deleted file]
src/udev/udev-builtin-net_setup_link.c [new file with mode: 0644]
src/udev/udev-builtin.c
src/udev/udev.h

index bf5459a7b8fe9e16c7dd555ccf7c732a46e5cc7e..2f6ba211d7a5ac4217a8d54a6a71683f8758bf41 100644 (file)
@@ -2312,7 +2312,7 @@ libudev_core_la_SOURCES = \
        src/udev/udev-builtin-input_id.c \
        src/udev/udev-builtin-keyboard.c \
        src/udev/udev-builtin-net_id.c \
-       src/udev/udev-builtin-net_link.c \
+       src/udev/udev-builtin-net_setup_link.c \
        src/udev/udev-builtin-path_id.c \
        src/udev/udev-builtin-usb_id.c \
        src/udev/net/link-config.h \
index 29d689325d52be6dbd597d2c1cc81f1dfb80aaee..d0ecb93058d88715cf46bb4f79a94b9793cfa32c 100644 (file)
@@ -1,11 +1,11 @@
 # do not edit this file, it will be overwritten on update
 
-SUBSYSTEM!="net", GOTO="net_link_end"
+SUBSYSTEM!="net", GOTO="net_setup_link_end"
 
 IMPORT{builtin}="path_id"
 
-ACTION!="add", GOTO="net_link_end"
+ACTION!="add", GOTO="net_setup_link_end"
 
-RUN{builtin}="net_link"
+RUN{builtin}="net_setup_link"
 
-LABEL="net_link_end"
+LABEL="net_setup_link_end"
index 8ad855060c652ad130d5850be4042495a79a99f9..d58cdf532dc57a2c848fae36f950b2e1f188a027 100644 (file)
@@ -83,7 +83,7 @@ _udevadm() {
                         fi
                         ;;
                 'test-builtin')
-                        comps='blkid btrfs hwdb input_id keyboard kmod net_id path_id usb_id uaccess'
+                        comps='blkid btrfs hwdb input_id keyboard kmod net_id net_setup_link path_id usb_id uaccess'
                         ;;
                 *)
                         comps=${VERBS[*]}
index 04e9f8dd8ec57de01e23c02bbff2a81d66f6ba8f..e5d252c818bed6ae223fd6f9b0dbcbf545270dbb 100644 (file)
@@ -75,7 +75,7 @@ _udevadm_test-builtin(){
     if (( CURRENT == 2 )); then
     _arguments \
         '--help[Print help text]' \
-        '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)'
+        '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)'
     elif  (( CURRENT == 3 )); then
         _arguments \
             '--help[Print help text]' \
diff --git a/src/udev/udev-builtin-net_link.c b/src/udev/udev-builtin-net_link.c
deleted file mode 100644 (file)
index f4fb63e..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2013 Tom Gundersen
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include "link-config.h"
-#include "udev.h"
-#include "log.h"
-
-link_config_ctx *ctx;
-
-static int builtin_net_link(struct udev_device *dev, int argc, char **argv, bool test) {
-        link_config *link;
-        int r;
-
-        if (argc > 1) {
-                log_error("This program takes no arguments.");
-                return EXIT_FAILURE;
-        }
-
-        r = link_config_get(ctx, dev, &link);
-        if (r < 0) {
-                if (r == -ENOENT) {
-                        log_debug("No matching link configuration found");
-                        return EXIT_SUCCESS;
-                } else {
-                        log_error("Could not get link config");
-                        return EXIT_FAILURE;
-                }
-        }
-
-        r = link_config_apply(ctx, link, dev);
-        if (r < 0) {
-                log_error("Could not apply link config to %s", udev_device_get_sysname(dev));
-                return EXIT_FAILURE;
-        }
-
-        return EXIT_SUCCESS;
-}
-
-static int builtin_net_link_init(struct udev *udev) {
-        int r;
-
-        if (ctx)
-                return 0;
-
-        r = link_config_ctx_new(&ctx);
-        if (r < 0)
-                return r;
-
-        r = link_config_load(ctx);
-        if (r < 0)
-                return r;
-
-        log_debug("Created link configuration context");
-        return 0;
-}
-
-static void builtin_net_link_exit(struct udev *udev) {
-        link_config_ctx_free(ctx);
-        log_debug("Unloaded link configuration context");
-}
-
-static bool builtin_net_link_validate(struct udev *udev) {
-        log_debug("Check if link configuration needs reloading");
-        if (!ctx)
-                return false;
-
-        return link_config_should_reload(ctx);
-}
-
-const struct udev_builtin udev_builtin_net_link = {
-        .name = "net_link",
-        .cmd = builtin_net_link,
-        .init = builtin_net_link_init,
-        .exit = builtin_net_link_exit,
-        .validate = builtin_net_link_validate,
-        .help = "configure network link",
-        .run_once = false,
-};
diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
new file mode 100644 (file)
index 0000000..739221b
--- /dev/null
@@ -0,0 +1,96 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Tom Gundersen
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "link-config.h"
+#include "udev.h"
+#include "log.h"
+
+link_config_ctx *ctx;
+
+static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv, bool test) {
+        link_config *link;
+        int r;
+
+        if (argc > 1) {
+                log_error("This program takes no arguments.");
+                return EXIT_FAILURE;
+        }
+
+        r = link_config_get(ctx, dev, &link);
+        if (r < 0) {
+                if (r == -ENOENT) {
+                        log_debug("No matching link configuration found");
+                        return EXIT_SUCCESS;
+                } else {
+                        log_error("Could not get link config");
+                        return EXIT_FAILURE;
+                }
+        }
+
+        r = link_config_apply(ctx, link, dev);
+        if (r < 0) {
+                log_error("Could not apply link config to %s", udev_device_get_sysname(dev));
+                return EXIT_FAILURE;
+        }
+
+        return EXIT_SUCCESS;
+}
+
+static int builtin_net_setup_link_init(struct udev *udev) {
+        int r;
+
+        if (ctx)
+                return 0;
+
+        r = link_config_ctx_new(&ctx);
+        if (r < 0)
+                return r;
+
+        r = link_config_load(ctx);
+        if (r < 0)
+                return r;
+
+        log_debug("Created link configuration context");
+        return 0;
+}
+
+static void builtin_net_setup_link_exit(struct udev *udev) {
+        link_config_ctx_free(ctx);
+        log_debug("Unloaded link configuration context");
+}
+
+static bool builtin_net_setup_link_validate(struct udev *udev) {
+        log_debug("Check if link configuration needs reloading");
+        if (!ctx)
+                return false;
+
+        return link_config_should_reload(ctx);
+}
+
+const struct udev_builtin udev_builtin_net_setup_link = {
+        .name = "net_setup_link",
+        .cmd = builtin_net_setup_link,
+        .init = builtin_net_setup_link_init,
+        .exit = builtin_net_setup_link_exit,
+        .validate = builtin_net_setup_link_validate,
+        .help = "configure network link",
+        .run_once = false,
+};
index 85901e8ee3c9c522261eda7d701205acbf78ff84..fd373d04dc0289212224d9c087c6711a50419f5b 100644 (file)
@@ -44,7 +44,7 @@ static const struct udev_builtin *builtins[] = {
         [UDEV_BUILTIN_KMOD] = &udev_builtin_kmod,
 #endif
         [UDEV_BUILTIN_NET_ID] = &udev_builtin_net_id,
-        [UDEV_BUILTIN_NET_LINK] = &udev_builtin_net_link,
+        [UDEV_BUILTIN_NET_LINK] = &udev_builtin_net_setup_link,
         [UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id,
         [UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id,
 #ifdef HAVE_ACL
index 7cca8b8c83e1b4ca901bdc48882e5cdee7b55a4e..46235b13a7bf1034c9f4914a05160206a8c75d21 100644 (file)
@@ -184,7 +184,7 @@ extern const struct udev_builtin udev_builtin_keyboard;
 extern const struct udev_builtin udev_builtin_kmod;
 #endif
 extern const struct udev_builtin udev_builtin_net_id;
-extern const struct udev_builtin udev_builtin_net_link;
+extern const struct udev_builtin udev_builtin_net_setup_link;
 extern const struct udev_builtin udev_builtin_path_id;
 extern const struct udev_builtin udev_builtin_usb_id;
 extern const struct udev_builtin udev_builtin_uaccess;