diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
commit | 78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch) | |
tree | f515d16b6efd858a9aeb5b0ef5d6f90bf288283d /src/boot/bless-boot.c | |
parent | Adding debian version 255.5-1. (diff) | |
download | systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boot/bless-boot.c')
-rw-r--r-- | src/boot/bless-boot.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c index 0c0b4f2..f86d102 100644 --- a/src/boot/bless-boot.c +++ b/src/boot/bless-boot.c @@ -316,13 +316,6 @@ static int make_bad(const char *prefix, uint64_t done, const char *suffix, char return 0; } -static const char *skip_slash(const char *path) { - assert(path); - assert(path[0] == '/'); - - return path + 1; -} - static int verb_status(int argc, char *argv[], void *userdata) { _cleanup_free_ char *path = NULL, *prefix = NULL, *suffix = NULL, *good = NULL, *bad = NULL; uint64_t left, done; @@ -370,14 +363,14 @@ static int verb_status(int argc, char *argv[], void *userdata) { return log_error_errno(errno, "Failed to open $BOOT partition '%s': %m", *p); } - if (faccessat(fd, skip_slash(path), F_OK, 0) >= 0) { + if (faccessat(fd, skip_leading_slash(path), F_OK, 0) >= 0) { puts("indeterminate"); return 0; } if (errno != ENOENT) return log_error_errno(errno, "Failed to check if '%s' exists: %m", path); - if (faccessat(fd, skip_slash(good), F_OK, 0) >= 0) { + if (faccessat(fd, skip_leading_slash(good), F_OK, 0) >= 0) { puts("good"); return 0; } @@ -385,7 +378,7 @@ static int verb_status(int argc, char *argv[], void *userdata) { if (errno != ENOENT) return log_error_errno(errno, "Failed to check if '%s' exists: %m", good); - if (faccessat(fd, skip_slash(bad), F_OK, 0) >= 0) { + if (faccessat(fd, skip_leading_slash(bad), F_OK, 0) >= 0) { puts("bad"); return 0; } @@ -395,7 +388,7 @@ static int verb_status(int argc, char *argv[], void *userdata) { /* We didn't find any of the three? If so, let's try the next directory, before we give up. */ } - return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Couldn't determine boot state: %m"); + return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Couldn't determine boot state."); } static int verb_set(int argc, char *argv[], void *userdata) { @@ -445,17 +438,17 @@ static int verb_set(int argc, char *argv[], void *userdata) { if (fd < 0) return log_error_errno(errno, "Failed to open $BOOT partition '%s': %m", *p); - r = rename_noreplace(fd, skip_slash(source1), fd, skip_slash(target)); + r = rename_noreplace(fd, skip_leading_slash(source1), fd, skip_leading_slash(target)); if (r == -EEXIST) goto exists; if (r == -ENOENT) { - r = rename_noreplace(fd, skip_slash(source2), fd, skip_slash(target)); + r = rename_noreplace(fd, skip_leading_slash(source2), fd, skip_leading_slash(target)); if (r == -EEXIST) goto exists; if (r == -ENOENT) { - if (faccessat(fd, skip_slash(target), F_OK, 0) >= 0) /* Hmm, if we can't find either source file, maybe the destination already exists? */ + if (faccessat(fd, skip_leading_slash(target), F_OK, 0) >= 0) /* Hmm, if we can't find either source file, maybe the destination already exists? */ goto exists; if (errno != ENOENT) @@ -474,9 +467,9 @@ static int verb_set(int argc, char *argv[], void *userdata) { log_debug("Successfully renamed '%s' to '%s'.", source1, target); /* First, fsync() the directory these files are located in */ - r = fsync_parent_at(fd, skip_slash(target)); + r = fsync_parent_at(fd, skip_leading_slash(target)); if (r < 0) - log_debug_errno(errno, "Failed to synchronize image directory, ignoring: %m"); + log_debug_errno(r, "Failed to synchronize image directory, ignoring: %m"); /* Secondly, syncfs() the whole file system these files are located in */ if (syncfs(fd) < 0) @@ -486,8 +479,7 @@ static int verb_set(int argc, char *argv[], void *userdata) { return 0; } - log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Can't find boot counter source file for '%s': %m", target); - return 1; + return log_error_errno(SYNTHETIC_ERRNO(EBUSY), "Can't find boot counter source file for '%s'.", target); exists: log_debug("Operation already executed before, not doing anything."); @@ -506,8 +498,7 @@ static int run(int argc, char *argv[]) { int r; - log_parse_environment(); - log_open(); + log_setup(); r = parse_argv(argc, argv); if (r <= 0) |