From 2599b32e727cbd7058f3d2bba9d9a49aae83d9dc Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 16 May 2024 19:12:38 +0800 Subject: [PATCH 1/2] fd-util: check and log error properly for fd_reopen_propagate_append_and_position Follow-up for b8e25bff386548f679902c6b797a5a8ff1542c8b --- src/basic/fd-util.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 121e6cd219..da4ee63add 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -896,21 +896,18 @@ int fd_reopen_propagate_append_and_position(int fd, int flags) { if (new_fd < 0) return new_fd; - /* Try to adjust the offset, but ignore errors for now. */ + /* Try to adjust the offset, but ignore errors. */ off_t p = lseek(fd, 0, SEEK_CUR); - if (p <= 0) - return new_fd; - - off_t new_p = lseek(new_fd, p, SEEK_SET); - if (new_p == (off_t) -1) - log_debug_errno(errno, - "Failed to propagate file position for re-opened fd %d, ignoring: %m", - fd); - else if (new_p != p) - log_debug("Failed to propagate file position for re-opened fd %d (%lld != %lld), ignoring: %m", - fd, - (long long) new_p, - (long long) p); + if (p > 0) { + off_t new_p = lseek(new_fd, p, SEEK_SET); + if (new_p < 0) + log_debug_errno(errno, + "Failed to propagate file position for re-opened fd %d, ignoring: %m", + fd); + else if (new_p != p) + log_debug("Failed to propagate file position for re-opened fd %d (%lld != %lld), ignoring.", + fd, (long long) new_p, (long long) p); + } return new_fd; } From 4eec099db83ce522f30d02de07970d4f2cbcb41f Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 16 May 2024 19:15:11 +0800 Subject: [PATCH 2/2] switch-root: update comment regarding dropped mounts Follow-up for 07c5c2ab8b80f75a1c89fc405db1ce1dfd08534b --- src/shared/switch-root.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index 2a5307feb7..e64b6f6c8f 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -30,8 +30,8 @@ int switch_root(const char *new_root, const char *old_root_after, /* path below the new root, where to place the old root after the transition; may be NULL to unmount it */ SwitchRootFlags flags) { - /* Stuff mounted below /run/ we don't save on soft reboot, as it might have lost its relevance, i.e. - * credentials, removable media and such, we rather want that the new boot mounts this fresh. But on + /* Stuff mounted below /run/ we don't save on soft reboot, as it might have lost its relevance, + * e.g. removable media and such. We rather want that the new boot mounts this fresh. But on * the switch from initrd we do use MS_REC, as it is expected that mounts set up in /run/ are * maintained. */ static const struct {