diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-10-04 21:05:21 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-10-04 21:26:04 +0200 |
commit | 7c1dd9e288047a69d4a6a6dd6585725410cfdadd (patch) | |
tree | c9c77241ffcfdb258c1318a90c15e91f1624ce10 /src/system-update-generator | |
parent | Merge pull request #34608 from DaanDeMeyer/ukify (diff) | |
download | systemd-7c1dd9e288047a69d4a6a6dd6585725410cfdadd.tar.xz systemd-7c1dd9e288047a69d4a6a6dd6585725410cfdadd.zip |
various: correct laccess() error check
laccess is our own macro that uses RET_NERRNO.
Diffstat (limited to 'src/system-update-generator')
-rw-r--r-- | src/system-update-generator/system-update-generator.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c index a1782d5c05..d884530674 100644 --- a/src/system-update-generator/system-update-generator.c +++ b/src/system-update-generator/system-update-generator.c @@ -20,22 +20,26 @@ static const char *arg_dest = NULL; static int generate_symlink(void) { + int r; + FOREACH_STRING(p, "/system-update", "/etc/system-update") { - if (laccess(p, F_OK) >= 0) { - _cleanup_free_ char *j = NULL; + r = laccess(p, F_OK); + if (r < 0) { + if (r != -ENOENT) + log_warning_errno(r, "Failed to check if %s symlink exists, ignoring: %m", p); + continue; + } - j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET); - if (!j) - return log_oom(); + _cleanup_free_ char *j = NULL; - if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0) - return log_error_errno(errno, "Failed to create symlink %s: %m", j); + j = path_join(arg_dest, SPECIAL_DEFAULT_TARGET); + if (!j) + return log_oom(); - return 1; - } + if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", j) < 0) + return log_error_errno(errno, "Failed to create symlink %s: %m", j); - if (errno != ENOENT) - log_warning_errno(errno, "Failed to check if %s symlink exists, ignoring: %m", p); + return 1; } return 0; |