Merge pull request #10408 from keszybz/analyze-cat-presets
systemd-analyze cat-presets
This commit is contained in:
+22
-18
@@ -270,14 +270,13 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get timestamp properties: %s", bus_error_message(&error, r));
|
||||
|
||||
if (times.finish_time <= 0) {
|
||||
log_error("Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n"
|
||||
"Please try again later.\n"
|
||||
"Hint: Use 'systemctl%s list-jobs' to see active jobs",
|
||||
times.finish_time,
|
||||
arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
if (times.finish_time <= 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINPROGRESS),
|
||||
"Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n"
|
||||
"Please try again later.\n"
|
||||
"Hint: Use 'systemctl%s list-jobs' to see active jobs",
|
||||
times.finish_time,
|
||||
arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
|
||||
|
||||
if (arg_scope == UNIT_FILE_SYSTEM && times.security_start_time > 0) {
|
||||
/* security_start_time is set when systemd is not running under container environment. */
|
||||
@@ -312,7 +311,6 @@ finish:
|
||||
}
|
||||
|
||||
static void free_host_info(struct host_info *hi) {
|
||||
|
||||
if (!hi)
|
||||
return;
|
||||
|
||||
@@ -385,7 +383,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
|
||||
NULL,
|
||||
t);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s", u.id, bus_error_message(&error, r));
|
||||
return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s",
|
||||
u.id, bus_error_message(&error, r));
|
||||
|
||||
subtract_timestamp(&t->activating, boot_times->reverse_offset);
|
||||
subtract_timestamp(&t->activated, boot_times->reverse_offset);
|
||||
@@ -458,7 +457,8 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
|
||||
NULL,
|
||||
host);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s", bus_error_message(&error, r));
|
||||
log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s",
|
||||
bus_error_message(&error, r));
|
||||
sd_bus_error_free(&error);
|
||||
}
|
||||
|
||||
@@ -472,10 +472,10 @@ manager:
|
||||
NULL,
|
||||
host);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get host information from systemd: %s", bus_error_message(&error, r));
|
||||
return log_error_errno(r, "Failed to get host information from systemd: %s",
|
||||
bus_error_message(&error, r));
|
||||
|
||||
*hi = TAKE_PTR(host);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1328,7 +1328,8 @@ static int dump(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0) {
|
||||
/* fall back to Dump if DumpByFileDescriptor is not supported */
|
||||
if (!IN_SET(r, -EACCES, -EBADR))
|
||||
return log_error_errno(r, "Failed to issue method call DumpByFileDescriptor: %s", bus_error_message(&error, r));
|
||||
return log_error_errno(r, "Failed to issue method call DumpByFileDescriptor: %s",
|
||||
bus_error_message(&error, r));
|
||||
|
||||
return dump_fallback(bus);
|
||||
}
|
||||
@@ -1365,8 +1366,7 @@ static int cat_config(int argc, char *argv[], void *userdata) {
|
||||
|
||||
if (!t)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Path %s does not start with any known prefix.",
|
||||
*arg);
|
||||
"Path %s does not start with any known prefix.", *arg);
|
||||
} else
|
||||
t = *arg;
|
||||
|
||||
@@ -1628,8 +1628,8 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
|
||||
/* make sure the error appears below normal output */
|
||||
fflush(stdout);
|
||||
|
||||
log_error("Filter set \"%s\" not found.", *name);
|
||||
return -ENOENT;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||
"Filter set \"%s\" not found.", *name);
|
||||
}
|
||||
|
||||
dump_syscall_filter(set);
|
||||
@@ -2000,6 +2000,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Option --global only makes sense with verbs dot, unit-paths, verify.");
|
||||
|
||||
if (streq_ptr(argv[optind], "cat-config") && arg_scope == UNIT_FILE_USER)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Option --user is not supported for cat-config right now.");
|
||||
|
||||
if (arg_root && !streq_ptr(argv[optind], "cat-config"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Option --root is only supported for cat-config right now.");
|
||||
|
||||
+14
-6
@@ -66,12 +66,20 @@
|
||||
"/usr/lib/" n "\0" \
|
||||
_CONF_PATHS_SPLIT_USR_NULSTR(n)
|
||||
|
||||
#define CONF_PATHS_USR(n) \
|
||||
"/etc/" n, \
|
||||
"/run/" n, \
|
||||
"/usr/local/lib/" n, \
|
||||
"/usr/lib/" n
|
||||
|
||||
#define CONF_PATHS(n) \
|
||||
CONF_PATHS_USR(n) \
|
||||
_CONF_PATHS_SPLIT_USR(n)
|
||||
|
||||
#define CONF_PATHS_USR_STRV(n) \
|
||||
STRV_MAKE(CONF_PATHS_USR(n))
|
||||
|
||||
#define CONF_PATHS_STRV(n) \
|
||||
STRV_MAKE( \
|
||||
"/etc/" n, \
|
||||
"/run/" n, \
|
||||
"/usr/local/lib/" n, \
|
||||
"/usr/lib/" n \
|
||||
_CONF_PATHS_SPLIT_USR(n))
|
||||
STRV_MAKE(CONF_PATHS(n))
|
||||
|
||||
#define HIGH_RLIMIT_MEMLOCK (1024ULL*1024ULL*64ULL)
|
||||
|
||||
+1
-1
@@ -1382,7 +1382,7 @@ static int bump_rlimit_memlock(struct rlimit *saved_rlimit) {
|
||||
|
||||
static void test_usr(void) {
|
||||
|
||||
/* Check that /usr is not a separate fs */
|
||||
/* Check that /usr is either on the same file system as / or mounted already. */
|
||||
|
||||
if (dir_is_empty("/usr") <= 0)
|
||||
return;
|
||||
|
||||
@@ -14,7 +14,7 @@ static int environment_dirs(char ***ret) {
|
||||
_cleanup_free_ char *c = NULL;
|
||||
int r;
|
||||
|
||||
dirs = strv_split_nulstr(CONF_PATHS_NULSTR("environment.d"));
|
||||
dirs = strv_new(CONF_PATHS_USR("environment.d"), NULL);
|
||||
if (!dirs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
#include "condition.h"
|
||||
#include "conf-parser.h"
|
||||
#include "def.h"
|
||||
#include "set.h"
|
||||
#include "strv.h"
|
||||
|
||||
#define LINK_BRIDGE_PORT_PRIORITY_INVALID 128
|
||||
#define LINK_BRIDGE_PORT_PRIORITY_MAX 63
|
||||
@@ -57,3 +59,5 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t
|
||||
|
||||
/* It is not necessary to add deserialize_dhcp_option(). Use unhexmem() instead. */
|
||||
int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
|
||||
|
||||
#define NETWORK_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/network"))
|
||||
|
||||
@@ -661,7 +661,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
};
|
||||
|
||||
dropin_dirname = strjoina(basename(filename), ".d");
|
||||
r = config_parse_many(filename, network_dirs, dropin_dirname,
|
||||
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
||||
"Match\0NetDev\0",
|
||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||
CONFIG_PARSE_WARN|CONFIG_PARSE_RELAXED, netdev_raw);
|
||||
@@ -702,7 +702,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
|
||||
if (NETDEV_VTABLE(netdev)->init)
|
||||
NETDEV_VTABLE(netdev)->init(netdev);
|
||||
|
||||
r = config_parse_many(filename, network_dirs, dropin_dirname,
|
||||
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
||||
NETDEV_VTABLE(netdev)->sections,
|
||||
config_item_perf_lookup, network_netdev_gperf_lookup,
|
||||
CONFIG_PARSE_WARN, netdev);
|
||||
@@ -802,7 +802,7 @@ int netdev_load(Manager *manager) {
|
||||
|
||||
hashmap_clear_with_destructor(manager->netdevs, netdev_unref);
|
||||
|
||||
r = conf_files_list_strv(&files, ".netdev", NULL, 0, network_dirs);
|
||||
r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate netdev files: %m");
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "fileio.h"
|
||||
#include "local-addresses.h"
|
||||
#include "netlink-util.h"
|
||||
#include "network-internal.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "ordered-set.h"
|
||||
#include "path-util.h"
|
||||
@@ -29,15 +30,6 @@
|
||||
/* use 8 MB for receive socket kernel queue. */
|
||||
#define RCVBUF_SIZE (8*1024*1024)
|
||||
|
||||
const char* const network_dirs[] = {
|
||||
"/etc/systemd/network",
|
||||
"/run/systemd/network",
|
||||
"/usr/lib/systemd/network",
|
||||
#if HAVE_SPLIT_USR
|
||||
"/lib/systemd/network",
|
||||
#endif
|
||||
NULL};
|
||||
|
||||
static int setup_default_address_pool(Manager *m) {
|
||||
AddressPool *p;
|
||||
int r;
|
||||
@@ -1512,7 +1504,7 @@ int manager_load_config(Manager *m) {
|
||||
int r;
|
||||
|
||||
/* update timestamp */
|
||||
paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, true);
|
||||
paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, true);
|
||||
|
||||
r = netdev_load(m);
|
||||
if (r < 0)
|
||||
@@ -1526,7 +1518,7 @@ int manager_load_config(Manager *m) {
|
||||
}
|
||||
|
||||
bool manager_should_reload(Manager *m) {
|
||||
return paths_check_timestamp(network_dirs, &m->network_dirs_ts_usec, false);
|
||||
return paths_check_timestamp(NETWORK_DIRS, &m->network_dirs_ts_usec, false);
|
||||
}
|
||||
|
||||
int manager_rtnl_enumerate_links(Manager *m) {
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include "networkd-link.h"
|
||||
#include "networkd-network.h"
|
||||
|
||||
extern const char* const network_dirs[];
|
||||
|
||||
struct Manager {
|
||||
sd_netlink *rtnl;
|
||||
/* lazy initialized */
|
||||
|
||||
@@ -212,7 +212,7 @@ int network_load_one(Manager *manager, const char *filename) {
|
||||
.ipv6_accept_ra_route_table_set = false,
|
||||
};
|
||||
|
||||
r = config_parse_many(filename, network_dirs, dropin_dirname,
|
||||
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
||||
"Match\0"
|
||||
"Link\0"
|
||||
"Network\0"
|
||||
@@ -292,7 +292,7 @@ int network_load(Manager *manager) {
|
||||
while ((network = manager->networks))
|
||||
network_free(network);
|
||||
|
||||
r = conf_files_list_strv(&files, ".network", NULL, 0, network_dirs);
|
||||
r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate network files: %m");
|
||||
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "conf-files.h"
|
||||
#include "conf-parser.h"
|
||||
#include "def.h"
|
||||
#include "resolved-dnssd.h"
|
||||
#include "resolved-dns-rr.h"
|
||||
#include "resolved-manager.h"
|
||||
#include "specifier.h"
|
||||
#include "strv.h"
|
||||
|
||||
const char* const dnssd_service_dirs[] = {
|
||||
"/etc/systemd/dnssd",
|
||||
"/run/systemd/dnssd",
|
||||
"/usr/lib/systemd/dnssd",
|
||||
#if HAVE_SPLIT_USR
|
||||
"/lib/systemd/dnssd",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
#define DNSSD_SERVICE_DIRS ((const char* const*) CONF_PATHS_STRV("systemd/dnssd"))
|
||||
|
||||
DnssdTxtData *dnssd_txtdata_free(DnssdTxtData *txt_data) {
|
||||
if (!txt_data)
|
||||
@@ -92,7 +86,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
|
||||
|
||||
dropin_dirname = strjoina(service->name, ".dnssd.d");
|
||||
|
||||
r = config_parse_many(filename, dnssd_service_dirs, dropin_dirname,
|
||||
r = config_parse_many(filename, DNSSD_SERVICE_DIRS, dropin_dirname,
|
||||
"Service\0",
|
||||
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
|
||||
false, service);
|
||||
@@ -195,7 +189,7 @@ int dnssd_load(Manager *manager) {
|
||||
if (manager->mdns_support != RESOLVE_SUPPORT_YES)
|
||||
return 0;
|
||||
|
||||
r = conf_files_list_strv(&files, ".dnssd", NULL, 0, dnssd_service_dirs);
|
||||
r = conf_files_list_strv(&files, ".dnssd", NULL, 0, DNSSD_SERVICE_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate .dnssd files: %m");
|
||||
|
||||
|
||||
+25
-27
@@ -15,6 +15,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
#include "conf-parser.h"
|
||||
#include "def.h"
|
||||
#include "dirent-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
@@ -2820,6 +2821,29 @@ static int split_pattern_into_name_and_instances(const char *pattern, char **out
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int presets_find_config(UnitFileScope scope, const char *root_dir, char ***files) {
|
||||
const char* const* dirs;
|
||||
|
||||
assert(scope >= 0);
|
||||
assert(scope < _UNIT_FILE_SCOPE_MAX);
|
||||
|
||||
switch (scope) {
|
||||
case UNIT_FILE_SYSTEM:
|
||||
dirs = (const char* const*) CONF_PATHS_STRV("systemd/system-preset");
|
||||
break;
|
||||
|
||||
case UNIT_FILE_GLOBAL:
|
||||
case UNIT_FILE_USER:
|
||||
dirs = (const char* const*) CONF_PATHS_USR_STRV("systemd/user-preset");
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid unit file scope");
|
||||
}
|
||||
|
||||
return conf_files_list_strv(files, ".preset", root_dir, 0, dirs);
|
||||
}
|
||||
|
||||
static int read_presets(UnitFileScope scope, const char *root_dir, Presets *presets) {
|
||||
_cleanup_(presets_freep) Presets ps = {};
|
||||
size_t n_allocated = 0;
|
||||
@@ -2831,33 +2855,7 @@ static int read_presets(UnitFileScope scope, const char *root_dir, Presets *pres
|
||||
assert(scope < _UNIT_FILE_SCOPE_MAX);
|
||||
assert(presets);
|
||||
|
||||
switch (scope) {
|
||||
case UNIT_FILE_SYSTEM:
|
||||
r = conf_files_list(&files, ".preset", root_dir, 0,
|
||||
"/etc/systemd/system-preset",
|
||||
"/run/systemd/system-preset",
|
||||
"/usr/local/lib/systemd/system-preset",
|
||||
"/usr/lib/systemd/system-preset",
|
||||
#if HAVE_SPLIT_USR
|
||||
"/lib/systemd/system-preset",
|
||||
#endif
|
||||
NULL);
|
||||
break;
|
||||
|
||||
case UNIT_FILE_GLOBAL:
|
||||
case UNIT_FILE_USER:
|
||||
r = conf_files_list(&files, ".preset", root_dir, 0,
|
||||
"/etc/systemd/user-preset",
|
||||
"/run/systemd/user-preset",
|
||||
"/usr/local/lib/systemd/user-preset",
|
||||
"/usr/lib/systemd/user-preset",
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid unit file scope");
|
||||
}
|
||||
|
||||
r = presets_find_config(scope, root_dir, &files);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
+65
-10
@@ -213,33 +213,88 @@ void print_separator(void) {
|
||||
fputs("\n\n", stdout);
|
||||
}
|
||||
|
||||
static int guess_type(const char **name, bool *is_usr, bool *is_collection, const char **extension) {
|
||||
/* Try to figure out if name is like tmpfiles.d/ or systemd/system-presets/,
|
||||
* i.e. a collection of directories without a main config file. */
|
||||
|
||||
_cleanup_free_ char *n = NULL;
|
||||
bool usr = false, coll = false;
|
||||
const char *ext = ".conf";
|
||||
|
||||
if (path_equal(*name, "environment.d"))
|
||||
/* Special case: we need to include /etc/environment in the search path, even
|
||||
* though the whole concept is called environment.d. */
|
||||
*name = "environment";
|
||||
|
||||
n = strdup(*name);
|
||||
if (!n)
|
||||
return log_oom();
|
||||
|
||||
delete_trailing_chars(n, "/");
|
||||
|
||||
if (endswith(n, ".d"))
|
||||
coll = true;
|
||||
|
||||
if (path_equal(n, "environment"))
|
||||
usr = true;
|
||||
|
||||
if (path_equal(n, "udev/hwdb.d"))
|
||||
ext = ".hwdb";
|
||||
|
||||
if (path_equal(n, "udev/rules.d"))
|
||||
ext = ".rules";
|
||||
|
||||
if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) {
|
||||
coll = true;
|
||||
ext = ".preset";
|
||||
}
|
||||
|
||||
if (path_equal(n, "systemd/user-preset"))
|
||||
usr = true;
|
||||
|
||||
*is_usr = usr;
|
||||
*is_collection = coll;
|
||||
*extension = ext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int conf_files_cat(const char *root, const char *name) {
|
||||
_cleanup_strv_free_ char **dirs = NULL, **files = NULL;
|
||||
_cleanup_free_ char *path = NULL;
|
||||
const char *dir;
|
||||
char **dir;
|
||||
bool is_usr, is_collection;
|
||||
const char *extension;
|
||||
char **t;
|
||||
int r;
|
||||
|
||||
NULSTR_FOREACH(dir, CONF_PATHS_NULSTR("")) {
|
||||
assert(endswith(dir, "/"));
|
||||
r = strv_extendf(&dirs, "%s%s.d", dir, name);
|
||||
r = guess_type(&name, &is_usr, &is_collection, &extension);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
STRV_FOREACH(dir, is_usr ? CONF_PATHS_USR_STRV("") : CONF_PATHS_STRV("")) {
|
||||
assert(endswith(*dir, "/"));
|
||||
r = strv_extendf(&dirs, "%s%s%s", *dir, name,
|
||||
is_collection ? "" : ".d");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to build directory list: %m");
|
||||
}
|
||||
|
||||
r = conf_files_list_strv(&files, ".conf", root, 0, (const char* const*) dirs);
|
||||
r = conf_files_list_strv(&files, extension, root, 0, (const char* const*) dirs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to query file list: %m");
|
||||
|
||||
path = path_join(root, "/etc", name);
|
||||
if (!path)
|
||||
return log_oom();
|
||||
if (!is_collection) {
|
||||
path = path_join(root, "/etc", name);
|
||||
if (!path)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
log_debug("Looking for configuration in:");
|
||||
log_debug(" %s", path);
|
||||
if (path)
|
||||
log_debug(" %s", path);
|
||||
STRV_FOREACH(t, dirs)
|
||||
log_debug(" %s/*.conf", *t);
|
||||
log_debug(" %s/*%s", *t, extension);
|
||||
}
|
||||
|
||||
/* show */
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
#include "conf-parser.h"
|
||||
#include "def.h"
|
||||
#include "device-util.h"
|
||||
#include "ethtool-util.h"
|
||||
#include "fd-util.h"
|
||||
@@ -36,18 +37,9 @@ struct link_config_ctx {
|
||||
|
||||
sd_netlink *rtnl;
|
||||
|
||||
usec_t link_dirs_ts_usec;
|
||||
usec_t network_dirs_ts_usec;
|
||||
};
|
||||
|
||||
static const char* const link_dirs[] = {
|
||||
"/etc/systemd/network",
|
||||
"/run/systemd/network",
|
||||
"/usr/lib/systemd/network",
|
||||
#if HAVE_SPLIT_USR
|
||||
"/lib/systemd/network",
|
||||
#endif
|
||||
NULL};
|
||||
|
||||
static void link_config_free(link_config *link) {
|
||||
if (!link)
|
||||
return;
|
||||
@@ -216,9 +208,9 @@ int link_config_load(link_config_ctx *ctx) {
|
||||
}
|
||||
|
||||
/* update timestamp */
|
||||
paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true);
|
||||
paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, true);
|
||||
|
||||
r = conf_files_list_strv(&files, ".link", NULL, 0, link_dirs);
|
||||
r = conf_files_list_strv(&files, ".link", NULL, 0, NETWORK_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "failed to enumerate link files: %m");
|
||||
|
||||
@@ -232,7 +224,7 @@ int link_config_load(link_config_ctx *ctx) {
|
||||
}
|
||||
|
||||
bool link_config_should_reload(link_config_ctx *ctx) {
|
||||
return paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, false);
|
||||
return paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, false);
|
||||
}
|
||||
|
||||
int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-files.h"
|
||||
#include "def.h"
|
||||
#include "device-private.h"
|
||||
#include "device-util.h"
|
||||
#include "dirent-util.h"
|
||||
@@ -41,6 +42,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#define PREALLOC_TOKEN 2048
|
||||
#define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d")
|
||||
|
||||
struct uid_gid {
|
||||
unsigned name_off;
|
||||
@@ -50,13 +52,6 @@ struct uid_gid {
|
||||
};
|
||||
};
|
||||
|
||||
static const char* const rules_dirs[] = {
|
||||
"/etc/udev/rules.d",
|
||||
"/run/udev/rules.d",
|
||||
UDEVLIBEXECDIR "/rules.d",
|
||||
NULL
|
||||
};
|
||||
|
||||
struct UdevRules {
|
||||
usec_t dirs_ts_usec;
|
||||
ResolveNameTiming resolve_name_timing;
|
||||
@@ -1591,7 +1586,7 @@ int udev_rules_new(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing)
|
||||
|
||||
udev_rules_check_timestamp(rules);
|
||||
|
||||
r = conf_files_list_strv(&files, ".rules", NULL, 0, rules_dirs);
|
||||
r = conf_files_list_strv(&files, ".rules", NULL, 0, RULES_DIRS);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate rules files: %m");
|
||||
|
||||
@@ -1643,7 +1638,7 @@ bool udev_rules_check_timestamp(UdevRules *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 bool match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||
|
||||
Reference in New Issue
Block a user