Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit beb7b87a authored by Yuan Yao's avatar Yuan Yao Committed by Automerger Merge Worker
Browse files

Merge "init: flush ext4 file system on shutdown" into main am: a3b721a3

parents 5233c322 a3b721a3
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <dirent.h>
#include <fcntl.h>
#include <linux/ext4.h>
#include <linux/f2fs.h>
#include <linux/fs.h>
#include <linux/loop.h>
@@ -835,6 +836,15 @@ static void DoReboot(unsigned int cmd, const std::string& reason, const std::str
        } else {
            LOG(INFO) << "Shutdown /data";
        }
    } else if (IsDataMounted("ext4")) {
        uint32_t flag = EXT4_GOING_FLAGS_DEFAULT;
        unique_fd fd(TEMP_FAILURE_RETRY(open("/data", O_RDONLY)));
        int ret = ioctl(fd.get(), EXT4_IOC_SHUTDOWN, &flag);
        if (ret) {
            PLOG(ERROR) << "Shutdown /data: ";
        } else {
            LOG(INFO) << "Shutdown /data";
        }
    }
    RebootSystem(cmd, reboot_target, reason);
    abort();