summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/networkd-bridge.c2
-rw-r--r--src/network/networkd-manager.c27
-rw-r--r--src/network/networkd-network.c2
-rw-r--r--src/network/networkd.h3
-rw-r--r--src/shared/path-util.c4
-rw-r--r--src/shared/path-util.h2
-rw-r--r--src/udev/net/link-config.c34
-rw-r--r--src/udev/udev-rules.c26
8 files changed, 38 insertions, 62 deletions
diff --git a/src/network/networkd-bridge.c b/src/network/networkd-bridge.c
index ac71cf39d8..1b05bf1caa 100644
--- a/src/network/networkd-bridge.c
+++ b/src/network/networkd-bridge.c
@@ -305,7 +305,7 @@ int bridge_load(Manager *manager) {
while ((bridge = hashmap_first(manager->bridges)))
bridge_free(bridge);
- r = conf_files_list_strv(&files, ".netdev", NULL, (const char **)manager->network_dirs);
+ r = conf_files_list_strv(&files, ".netdev", NULL, network_dirs);
if (r < 0) {
log_error("Failed to enumerate netdev files: %s", strerror(-r));
return r;
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 4e2cf45791..c9ce1d6a13 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -24,6 +24,15 @@
#include "libudev-private.h"
#include "udev-util.h"
+const char* const network_dirs[] = {
+ "/etc/systemd/network",
+ "/run/systemd/network",
+ "/usr/lib/systemd/network",
+#ifdef HAVE_SPLIT_USER
+ "/lib/systemd/network",
+#endif
+ NULL};
+
int manager_new(Manager **ret) {
_cleanup_manager_free_ Manager *m = NULL;
int r;
@@ -60,19 +69,6 @@ int manager_new(Manager **ret) {
LIST_HEAD_INIT(m->networks);
- m->network_dirs = strv_new("/etc/systemd/network/",
- "/run/systemd/network/",
- "/usr/lib/systemd/network",
-#ifdef HAVE_SPLIT_USER
- "/lib/systemd/network",
-#endif
- NULL);
- if (!m->network_dirs)
- return -ENOMEM;
-
- if (!path_strv_canonicalize_uniq(m->network_dirs))
- return -ENOMEM;
-
*ret = m;
m = NULL;
@@ -100,7 +96,6 @@ void manager_free(Manager *m) {
bridge_free(bridge);
hashmap_free(m->bridges);
- strv_free(m->network_dirs);
sd_rtnl_unref(m->rtnl);
free(m);
@@ -110,7 +105,7 @@ int manager_load_config(Manager *m) {
int r;
/* update timestamp */
- paths_check_timestamp(m->network_dirs, &m->network_dirs_ts_usec, true);
+ paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, true);
r = bridge_load(m);
if (r < 0)
@@ -124,7 +119,7 @@ int manager_load_config(Manager *m) {
}
bool manager_should_reload(Manager *m) {
- return paths_check_timestamp(m->network_dirs, &m->network_dirs_ts_usec, false);
+ return paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, false);
}
static int manager_process_link(Manager *m, struct udev_device *device) {
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 0326fe675b..1606042264 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -112,7 +112,7 @@ int network_load(Manager *manager) {
while ((network = manager->networks))
network_free(network);
- r = conf_files_list_strv(&files, ".network", NULL, (const char **)manager->network_dirs);
+ r = conf_files_list_strv(&files, ".network", NULL, network_dirs);
if (r < 0) {
log_error("Failed to enumerate network files: %s", strerror(-r));
return r;
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 75309a9b85..bfa01a94f0 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -178,10 +178,11 @@ struct Manager {
Hashmap *bridges;
LIST_HEAD(Network, networks);
- char **network_dirs;
usec_t network_dirs_ts_usec;
};
+extern const char* const network_dirs[];
+
/* Manager */
int manager_new(Manager **ret);
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 2cc2b2d4b7..fc42a704b7 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -464,9 +464,9 @@ int find_binary(const char *name, char **filename) {
}
}
-bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update) {
+bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
bool changed = false;
- char **i;
+ const char* const* i;
assert(timestamp);
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
index 4b74fe077e..178bed5f17 100644
--- a/src/shared/path-util.h
+++ b/src/shared/path-util.h
@@ -55,7 +55,7 @@ int path_is_os_tree(const char *path);
int find_binary(const char *name, char **filename);
-bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update);
+bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
/* Iterates through the path prefixes of the specified path, going up
* the tree, to root. Also returns "" (and not "/"!) for the root
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index a31c121076..bd97cd8cf8 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -50,10 +50,18 @@ struct link_config_ctx {
sd_rtnl *rtnl;
- char **link_dirs;
usec_t link_dirs_ts_usec;
};
+static const char* const link_dirs[] = {
+ "/etc/systemd/network",
+ "/run/systemd/network",
+ "/usr/lib/systemd/network",
+#ifdef HAVE_SPLIT_USR
+ "/lib/systemd/network",
+#endif
+ NULL};
+
DEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free);
#define _cleanup_link_config_ctx_free_ _cleanup_(link_config_ctx_freep)
@@ -73,23 +81,6 @@ int link_config_ctx_new(link_config_ctx **ret) {
ctx->enable_name_policy = true;
- ctx->link_dirs = strv_new("/etc/systemd/network",
- "/run/systemd/network",
- "/usr/lib/systemd/network",
-#ifdef HAVE_SPLIT_USR
- "/lib/systemd/network",
-#endif
- NULL);
- if (!ctx->link_dirs) {
- log_error("failed to build link config directory array");
- return -ENOMEM;
- }
-
- if (!path_strv_canonicalize_uniq(ctx->link_dirs)) {
- log_error("failed to canonicalize link config directories");
- return -ENOMEM;
- }
-
*ret = ctx;
ctx = NULL;
@@ -140,7 +131,6 @@ void link_config_ctx_free(link_config_ctx *ctx) {
sd_rtnl_unref(ctx->rtnl);
- strv_free(ctx->link_dirs);
link_configs_free(ctx);
free(ctx);
@@ -224,9 +214,9 @@ int link_config_load(link_config_ctx *ctx) {
}
/* update timestamp */
- paths_check_timestamp(ctx->link_dirs, &ctx->link_dirs_ts_usec, true);
+ paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true);
- r = conf_files_list_strv(&files, ".link", NULL, (const char **)ctx->link_dirs);
+ r = conf_files_list_strv(&files, ".link", NULL, link_dirs);
if (r < 0) {
log_error("failed to enumerate link files: %s", strerror(-r));
return r;
@@ -242,7 +232,7 @@ int link_config_load(link_config_ctx *ctx) {
}
bool link_config_should_reload(link_config_ctx *ctx) {
- return paths_check_timestamp(ctx->link_dirs, &ctx->link_dirs_ts_usec, false);
+ return paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, false);
}
int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_config **ret) {
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 52634f137d..8d2b057e2f 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -46,9 +46,14 @@ struct uid_gid {
};
};
+static const char* const rules_dirs[] = {
+ "/etc/udev/rules.d",
+ "/run/udev/rules.d",
+ UDEVLIBEXECDIR "/rules.d",
+ NULL};
+
struct udev_rules {
struct udev *udev;
- char **dirs;
usec_t dirs_ts_usec;
int resolve_names;
@@ -1629,23 +1634,9 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
if (!rules->strbuf)
return udev_rules_unref(rules);
- rules->dirs = strv_new("/etc/udev/rules.d",
- "/run/udev/rules.d",
- UDEVLIBEXECDIR "/rules.d",
- NULL);
- if (!rules->dirs) {
- log_error("failed to build config directory array");
- return udev_rules_unref(rules);
- }
- if (!path_strv_canonicalize(rules->dirs)) {
- log_error("failed to canonicalize config directories");
- return udev_rules_unref(rules);
- }
- strv_uniq(rules->dirs);
-
udev_rules_check_timestamp(rules);
- r = conf_files_list_strv(&files, ".rules", NULL, (const char **)rules->dirs);
+ r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
if (r < 0) {
log_error("failed to enumerate rules files: %s", strerror(-r));
return udev_rules_unref(rules);
@@ -1697,7 +1688,6 @@ struct udev_rules *udev_rules_unref(struct udev_rules *rules)
strbuf_cleanup(rules->strbuf);
free(rules->uids);
free(rules->gids);
- strv_free(rules->dirs);
free(rules);
return NULL;
}
@@ -1707,7 +1697,7 @@ bool udev_rules_check_timestamp(struct udev_rules *rules)
if (!rules)
return false;
- return paths_check_timestamp(rules->dirs, &rules->dirs_ts_usec, true);
+ return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val)