mirror of
https://github.com/systemd/systemd
synced 2024-07-23 19:25:39 +00:00
Merge pull request #32863 from YHNdnzj/switch-root-followup
Two minor followups
This commit is contained in:
commit
aa4644882e
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue