chiark / gitweb /
shutdown: don't pivot to /run/initramfs if already there
[elogind.git] / src / core / shutdown.c
index cc8c57bd2d89e86f0ad0fa4a563d2221d3be06e7..4bb4b4d13e435e157a950907762d5902fce246c6 100644 (file)
@@ -263,7 +263,7 @@ int main(int argc, char *argv[]) {
         arguments[2] = NULL;
         execute_directory(SYSTEM_SHUTDOWN_PATH, NULL, arguments);
 
-        if (!in_container &&
+        if (!in_container && !in_initrd() &&
             access("/run/initramfs/shutdown", X_OK) == 0) {
 
                 if (prepare_new_root() >= 0 &&
@@ -273,6 +273,13 @@ int main(int argc, char *argv[]) {
                 }
         }
 
+        /* The kernel will automaticall flush ATA disks and suchlike
+         * on reboot(), but the file systems need to be synce'd
+         * explicitly in advance. So let's do this here, but not
+         * needlessly slow down containers. */
+        if (!in_container)
+                sync();
+
         if (cmd == LINUX_REBOOT_CMD_KEXEC) {
 
                 if (!in_container) {