summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-23 19:50:59 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-27 20:12:44 +0100
commit51327bcc7457abb05cc80a5744fc233778a08ff8 (patch)
tree9484b2a5e460e4887a15509e62b19634dca07666
parentd32014a5bba837a288286e0f06e1927786d06d82 (diff)
downloadsystemd-51327bcc7457abb05cc80a5744fc233778a08ff8.tar.gz
sd-path: rename the two functions
I think the two names were both pretty bad. They did not give a proper hint what the difference between the two functions is, and sd_path_home sounds like it is somehow related to /home or home directories or whatever, when in fact both functions return the same set of paths as either a colon-delimited string or a strv. "_strv" suffix is used by various functions in sd-bus, so let's reuse that. Those functions are not public yet, so let's rename.
-rw-r--r--src/core/manager.c2
-rw-r--r--src/environment-d-generator/environment-d-generator.c2
-rw-r--r--src/libsystemd/sd-path/sd-path.c8
-rw-r--r--src/path/path.c4
-rw-r--r--src/systemd/sd-path.h4
-rw-r--r--src/test/test-sd-path.c20
-rw-r--r--src/tmpfiles/tmpfiles.c2
7 files changed, 21 insertions, 21 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 38f7ba1eb8..4c59addfc8 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -689,7 +689,7 @@ static int manager_setup_prefix(Manager *m) {
p = paths_user;
for (i = 0; i < _EXEC_DIRECTORY_TYPE_MAX; i++) {
- r = sd_path_home(p[i].type, p[i].suffix, &m->prefix[i]);
+ r = sd_path_lookup(p[i].type, p[i].suffix, &m->prefix[i]);
if (r < 0)
return r;
}
diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c
index 5fe51359f6..4a14c23f11 100644
--- a/src/environment-d-generator/environment-d-generator.c
+++ b/src/environment-d-generator/environment-d-generator.c
@@ -20,7 +20,7 @@ static int environment_dirs(char ***ret) {
return -ENOMEM;
/* ~/.config/systemd/environment.d */
- r = sd_path_home(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
+ r = sd_path_lookup(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c
index 95d6551e5c..5797f55c75 100644
--- a/src/libsystemd/sd-path/sd-path.c
+++ b/src/libsystemd/sd-path/sd-path.c
@@ -323,7 +323,7 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
return -EOPNOTSUPP;
}
-_public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
+_public_ int sd_path_lookup(uint64_t type, const char *suffix, char **path) {
_cleanup_free_ char *buffer = NULL;
const char *ret;
char *cc;
@@ -343,7 +343,7 @@ _public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
_cleanup_strv_free_ char **l = NULL;
- r = sd_path_search(type, suffix, &l);
+ r = sd_path_lookup_strv(type, suffix, &l);
if (r < 0)
return r;
@@ -550,7 +550,7 @@ static int get_search(uint64_t type, char ***list) {
return -EOPNOTSUPP;
}
-_public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
+_public_ int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths) {
char **i, **j;
_cleanup_strv_free_ char **l = NULL, **n = NULL;
int r;
@@ -569,7 +569,7 @@ _public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
char *p;
- r = sd_path_home(type, suffix, &p);
+ r = sd_path_lookup(type, suffix, &p);
if (r < 0)
return r;
diff --git a/src/path/path.c b/src/path/path.c
index fa81632bb2..26252948c5 100644
--- a/src/path/path.c
+++ b/src/path/path.c
@@ -68,7 +68,7 @@ static int list_homes(void) {
_cleanup_free_ char *p = NULL;
int q;
- q = sd_path_home(i, arg_suffix, &p);
+ q = sd_path_lookup(i, arg_suffix, &p);
if (q == -ENXIO)
continue;
if (q < 0) {
@@ -91,7 +91,7 @@ static int print_home(const char *n) {
if (streq(path_table[i], n)) {
_cleanup_free_ char *p = NULL;
- r = sd_path_home(i, arg_suffix, &p);
+ r = sd_path_lookup(i, arg_suffix, &p);
if (r < 0)
return log_error_errno(r, "Failed to query %s: %m", n);
diff --git a/src/systemd/sd-path.h b/src/systemd/sd-path.h
index 16379876eb..2bb0b85244 100644
--- a/src/systemd/sd-path.h
+++ b/src/systemd/sd-path.h
@@ -81,8 +81,8 @@ enum {
_SD_PATH_MAX,
};
-int sd_path_home(uint64_t type, const char *suffix, char **path);
-int sd_path_search(uint64_t type, const char *suffix, char ***paths);
+int sd_path_lookup(uint64_t type, const char *suffix, char **path);
+int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths);
_SD_END_DECLARATIONS;
diff --git a/src/test/test-sd-path.c b/src/test/test-sd-path.c
index 780a62a2cf..5888d3b9f9 100644
--- a/src/test/test-sd-path.c
+++ b/src/test/test-sd-path.c
@@ -7,40 +7,40 @@
#include "strv.h"
#include "tests.h"
-static void test_sd_path_home(void) {
+static void test_sd_path_lookup(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_free_ char *t, *s;
- assert_se(sd_path_home(i, NULL, &t) == 0);
+ assert_se(sd_path_lookup(i, NULL, &t) == 0);
assert_se(t);
log_info("%02"PRIu64": \"%s\"", i, t);
- assert_se(sd_path_home(i, "suffix", &s) == 0);
+ assert_se(sd_path_lookup(i, "suffix", &s) == 0);
assert_se(s);
log_info("%02"PRIu64": \"%s\"", i, s);
assert_se(endswith(s, "/suffix"));
}
char *tt;
- assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+ assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
}
-static void test_sd_path_search(void) {
+static void test_sd_path_lookup_strv(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_strv_free_ char **t, **s;
char **item;
- assert_se(sd_path_search(i, NULL, &t) == 0);
+ assert_se(sd_path_lookup_strv(i, NULL, &t) == 0);
assert_se(t);
log_info("%02"PRIu64":", i);
STRV_FOREACH(item, t)
log_debug(" %s", *item);
- assert_se(sd_path_search(i, "suffix", &s) == 0);
+ assert_se(sd_path_lookup_strv(i, "suffix", &s) == 0);
assert_se(s);
log_info("%02"PRIu64":", i);
STRV_FOREACH(item, s) {
@@ -50,12 +50,12 @@ static void test_sd_path_search(void) {
}
char *tt;
- assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+ assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
}
int main(void) {
test_setup_logging(LOG_DEBUG);
- test_sd_path_home();
- test_sd_path_search();
+ test_sd_path_lookup();
+ test_sd_path_lookup_strv();
}
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index d1ba5841fd..6ab30cdecf 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -244,7 +244,7 @@ static int specifier_directory(char specifier, const void *data, const void *use
i = PTR_TO_UINT(data);
assert(i < ELEMENTSOF(paths_system));
- return sd_path_home(paths[i].type, paths[i].suffix, ret);
+ return sd_path_lookup(paths[i].type, paths[i].suffix, ret);
}
static int log_unresolvable_specifier(const char *filename, unsigned line) {