From 7e7f881508cbda09f7092919052f28b84a63a30d Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 19 Nov 2020 12:12:11 -0800 Subject: [PATCH 1/3] 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 --- init/first_stage_init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp index 843ac5c08..6e9d6378d 100644 --- a/init/first_stage_init.cpp +++ b/init/first_stage_init.cpp @@ -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)) { From e85233c5601a3140f1941226d26be2499151e7a8 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Wed, 18 Nov 2020 20:22:47 -0800 Subject: [PATCH 2/3] libsparse: make vendor_ramdisk_available. Test: pass Bug: 173425293 Change-Id: Id360f205b9135b83edb59d13f978eb28cad041de --- libsparse/Android.bp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsparse/Android.bp b/libsparse/Android.bp index bf06bbc63..860b9ae4a 100644 --- a/libsparse/Android.bp +++ b/libsparse/Android.bp @@ -4,6 +4,7 @@ cc_library { name: "libsparse", host_supported: true, ramdisk_available: true, + vendor_ramdisk_available: true, recovery_available: true, unique_host_soname: true, vendor_available: true, From c7ed02f445618c16324dd1fe2bde1dd82141718d Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 19 Nov 2020 15:20:44 -0800 Subject: [PATCH 3/3] fs_config Add first_stage_ramdisk/system/bin/linker[64] Now that tune2fs and resize2fs may be dynamic, add linker[64] to first_stage_ramdisk/system/bin. Test: boot and examine serial output, ensure tune2fs and resize2fs can be executed. Bug: 173425293 Change-Id: I35699b38ddf5004c04ec0adc1b0c54d5d9c92ae6 --- libcutils/fs_config.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp index 31e1679db..79c3abca2 100644 --- a/libcutils/fs_config.cpp +++ b/libcutils/fs_config.cpp @@ -203,9 +203,14 @@ static const struct fs_path_config android_files[] = { CAP_MASK_LONG(CAP_SETGID), "system/bin/simpleperf_app_runner" }, { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/e2fsck" }, - { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/tune2fs" }, +#ifdef __LP64__ + { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/linker64" }, +#else + { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/linker" }, +#endif { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/resize2fs" }, { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/snapuserd" }, + { 00755, AID_ROOT, AID_ROOT, 0, "first_stage_ramdisk/system/bin/tune2fs" }, // generic defaults { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" }, { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },