summaryrefslogtreecommitdiff
path: root/src/sysctl/sysctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-05-03 18:18:09 +0200
committerLennart Poettering <lennart@poettering.net>2021-05-07 16:43:26 +0200
commit2708160ccda8727de80442cbf634489a360ca001 (patch)
tree2c9e2d90210a41fdcf77c3ca4b01173af306768c /src/sysctl/sysctl.c
parentac2c088939de5aba5a06bee00dbc6c89a2809534 (diff)
downloadsystemd-2708160ccda8727de80442cbf634489a360ca001.tar.gz
fileio: optionally, return discovered path of file in search_and_fopen()
Diffstat (limited to 'src/sysctl/sysctl.c')
-rw-r--r--src/sysctl/sysctl.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 15b68b7d2e..458a91be29 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -182,12 +182,13 @@ static int apply_all(OrderedHashmap *sysctl_options) {
static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ignore_enoent) {
_cleanup_fclose_ FILE *f = NULL;
+ _cleanup_free_ char *pp = NULL;
unsigned c = 0;
int r;
assert(path);
- r = search_and_fopen(path, "re", NULL, (const char**) CONF_PATHS_STRV("sysctl.d"), &f);
+ r = search_and_fopen(path, "re", NULL, (const char**) CONF_PATHS_STRV("sysctl.d"), &f, &pp);
if (r < 0) {
if (ignore_enoent && r == -ENOENT)
return 0;
@@ -195,7 +196,7 @@ static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ig
return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path);
}
- log_debug("Parsing %s", path);
+ log_debug("Parsing %s", pp);
for (;;) {
_cleanup_(option_freep) Option *new_option = NULL;
_cleanup_free_ char *l = NULL;
@@ -208,7 +209,7 @@ static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ig
if (k == 0)
break;
if (k < 0)
- return log_error_errno(k, "Failed to read file '%s', ignoring: %m", path);
+ return log_error_errno(k, "Failed to read file '%s', ignoring: %m", pp);
c++;
@@ -235,7 +236,7 @@ static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ig
/* We have a "negative match" option. Let's continue with value==NULL. */
p++;
else {
- log_syntax(NULL, LOG_WARNING, path, c, 0,
+ log_syntax(NULL, LOG_WARNING, pp, c, 0,
"Line is not an assignment, ignoring: %s", p);
if (r == 0)
r = -EINVAL;
@@ -261,7 +262,7 @@ static int parse_file(OrderedHashmap **sysctl_options, const char *path, bool ig
continue;
}
- log_debug("Overwriting earlier assignment of %s at '%s:%u'.", p, path, c);
+ log_debug("Overwriting earlier assignment of %s at '%s:%u'.", p, pp, c);
option_free(ordered_hashmap_remove(*sysctl_options, p));
}