mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
Merge pull request #27700 from poettering/switch-root-sync
switch-root: add sync() before getting rid of auxiliary mounts of old root
This commit is contained in:
commit
75edb7ca96
@ -72,7 +72,7 @@ int asynchronous_sync(pid_t *ret_pid) {
|
|||||||
return r;
|
return r;
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
/* Child process */
|
/* Child process */
|
||||||
(void) sync();
|
sync();
|
||||||
_exit(EXIT_SUCCESS);
|
_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,13 @@ int switch_root(const char *new_root,
|
|||||||
(void) mkdir_p_label(resolved_old_root_after, 0755);
|
(void) mkdir_p_label(resolved_old_root_after, 0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We are about to unmount various file systems with MNT_DETACH (either explicitly via umount() or
|
||||||
|
* indirectly via pivot_root()), and thus do not synchronously wait for them to be fully sync'ed —
|
||||||
|
* all while making them invisible/inaccessible in the file system tree for later code. That makes
|
||||||
|
* sync'ing them then difficult. Let's hence issue a manual sync() here, so that we at least can
|
||||||
|
* guarantee all file systems are an a good state before entering this state. */
|
||||||
|
sync();
|
||||||
|
|
||||||
/* Work-around for kernel design: the kernel refuses MS_MOVE if any file systems are mounted
|
/* Work-around for kernel design: the kernel refuses MS_MOVE if any file systems are mounted
|
||||||
* MS_SHARED. Hence remount them MS_PRIVATE here as a work-around.
|
* MS_SHARED. Hence remount them MS_PRIVATE here as a work-around.
|
||||||
*
|
*
|
||||||
|
@ -921,7 +921,7 @@ int halt_now(enum action a) {
|
|||||||
/* The kernel will automatically flush ATA disks and suchlike on reboot(), but the file systems need
|
/* The kernel will automatically flush ATA disks and suchlike on reboot(), but the file systems need
|
||||||
* to be synced explicitly in advance. */
|
* to be synced explicitly in advance. */
|
||||||
if (!arg_no_sync && !arg_dry_run)
|
if (!arg_no_sync && !arg_dry_run)
|
||||||
(void) sync();
|
sync();
|
||||||
|
|
||||||
/* Make sure C-A-D is handled by the kernel from this point on... */
|
/* Make sure C-A-D is handled by the kernel from this point on... */
|
||||||
if (!arg_dry_run)
|
if (!arg_dry_run)
|
||||||
|
Loading…
Reference in New Issue
Block a user