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

Commit 7e7f8815 authored by Yifan Hong's avatar Yifan Hong
Browse files

init: don't abort if directory already exists

create_directories return false with ec == 0 if directory
already exists. Do not abort in this case.

Bug: 173425293
Test: boots with pre-existing /first_stage_ramdisk/system/bin
Change-Id: I351837f0a5a56361ebc385b9a9da9658882a131d
parent a1ee8cea
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ void PrepareSwitchRoot() {

    auto dst_dir = android::base::Dirname(dst);
    std::error_code ec;
    if (!fs::create_directories(dst_dir, ec)) {
    if (!fs::create_directories(dst_dir, ec) && !!ec) {
        LOG(FATAL) << "Cannot create " << dst_dir << ": " << ec.message();
    }
    if (rename(src, dst) != 0) {
@@ -314,7 +314,7 @@ int FirstStageMain(int argc, char** argv) {
        std::string dest = GetRamdiskPropForSecondStage();
        std::string dir = android::base::Dirname(dest);
        std::error_code ec;
        if (!fs::create_directories(dir, ec)) {
        if (!fs::create_directories(dir, ec) && !!ec) {
            LOG(FATAL) << "Can't mkdir " << dir << ": " << ec.message();
        }
        if (!fs::copy_file(kBootImageRamdiskProp, dest, ec)) {