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
This commit is contained in:
Yifan Hong 2020-11-19 12:12:11 -08:00
parent a1ee8cea9d
commit 7e7f881508
1 changed files with 2 additions and 2 deletions

View File

@ -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)) {