Use dynamically linked f2fs executables.
It also reduces the space cost for devices using f2fs (e.g. crosshatch). /sbin/mkfs.f2fs 722560 => /system/bin/make_f2fs 49568 /sbin/sload.f2fs 1182456 => /system/bin/sload_f2fs 150032 Test: Build and boot recovery on crosshatch. Factory reset. Test: Install a non-A/B OTA package that formats a f2fs partition. Change-Id: Ibe70c8d91a1d07e1c78ff9eac19b1f7955800161
This commit is contained in:
parent
f0c03e62a2
commit
c674dfb584
4 changed files with 22 additions and 26 deletions
|
@ -58,8 +58,8 @@ LOCAL_MODULE := recovery_deps
|
||||||
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
|
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
|
||||||
ifeq ($(HOST_OS),linux)
|
ifeq ($(HOST_OS),linux)
|
||||||
LOCAL_REQUIRED_MODULES += \
|
LOCAL_REQUIRED_MODULES += \
|
||||||
sload.f2fs \
|
make_f2fs.recovery \
|
||||||
mkfs.f2fs
|
sload_f2fs.recovery
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -49,3 +49,4 @@
|
||||||
# ************************************************
|
# ************************************************
|
||||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/recovery_intermediates)
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/recovery_intermediates)
|
||||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminui_intermediates/import_includes)
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libminui_intermediates/import_includes)
|
||||||
|
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sbin)
|
||||||
|
|
34
roots.cpp
34
roots.cpp
|
@ -223,35 +223,29 @@ int format_volume(const std::string& volume, const std::string& directory) {
|
||||||
|
|
||||||
// Has to be f2fs because we checked earlier.
|
// Has to be f2fs because we checked earlier.
|
||||||
static constexpr int kSectorSize = 4096;
|
static constexpr int kSectorSize = 4096;
|
||||||
std::string cmd("/sbin/mkfs.f2fs");
|
|
||||||
// clang-format off
|
|
||||||
std::vector<std::string> make_f2fs_cmd = {
|
std::vector<std::string> make_f2fs_cmd = {
|
||||||
cmd,
|
"/system/bin/make_f2fs",
|
||||||
"-g", "android",
|
"-g",
|
||||||
|
"android",
|
||||||
v->blk_device,
|
v->blk_device,
|
||||||
};
|
};
|
||||||
// clang-format on
|
|
||||||
if (length >= kSectorSize) {
|
if (length >= kSectorSize) {
|
||||||
make_f2fs_cmd.push_back(std::to_string(length / kSectorSize));
|
make_f2fs_cmd.push_back(std::to_string(length / kSectorSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = exec_cmd(make_f2fs_cmd);
|
if (exec_cmd(make_f2fs_cmd) != 0) {
|
||||||
if (result == 0 && !directory.empty()) {
|
PLOG(ERROR) << "format_volume: Failed to make_f2fs on " << v->blk_device;
|
||||||
cmd = "/sbin/sload.f2fs";
|
|
||||||
// clang-format off
|
|
||||||
std::vector<std::string> sload_f2fs_cmd = {
|
|
||||||
cmd,
|
|
||||||
"-f", directory,
|
|
||||||
"-t", volume,
|
|
||||||
v->blk_device,
|
|
||||||
};
|
|
||||||
// clang-format on
|
|
||||||
result = exec_cmd(sload_f2fs_cmd);
|
|
||||||
}
|
|
||||||
if (result != 0) {
|
|
||||||
PLOG(ERROR) << "format_volume: Failed " << cmd << " on " << v->blk_device;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!directory.empty()) {
|
||||||
|
std::vector<std::string> sload_f2fs_cmd = {
|
||||||
|
"/system/bin/sload_f2fs", "-f", directory, "-t", volume, v->blk_device,
|
||||||
|
};
|
||||||
|
if (exec_cmd(sload_f2fs_cmd) != 0) {
|
||||||
|
PLOG(ERROR) << "format_volume: Failed to sload_f2fs on " << v->blk_device;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -482,18 +482,19 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt
|
||||||
return StringValue("");
|
return StringValue("");
|
||||||
}
|
}
|
||||||
std::vector<std::string> f2fs_args = {
|
std::vector<std::string> f2fs_args = {
|
||||||
"/sbin/mkfs.f2fs", "-g", "android", "-w", "512", location
|
"/system/bin/make_f2fs", "-g", "android", "-w", "512", location
|
||||||
};
|
};
|
||||||
if (size >= 512) {
|
if (size >= 512) {
|
||||||
f2fs_args.push_back(std::to_string(size / 512));
|
f2fs_args.push_back(std::to_string(size / 512));
|
||||||
}
|
}
|
||||||
if (auto status = exec_cmd(f2fs_args); status != 0) {
|
if (auto status = exec_cmd(f2fs_args); status != 0) {
|
||||||
LOG(ERROR) << name << ": mkfs.f2fs failed (" << status << ") on " << location;
|
LOG(ERROR) << name << ": make_f2fs failed (" << status << ") on " << location;
|
||||||
return StringValue("");
|
return StringValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto status = exec_cmd({ "/sbin/sload.f2fs", "-t", mount_point, location }); status != 0) {
|
if (auto status = exec_cmd({ "/system/bin/sload_f2fs", "-t", mount_point, location });
|
||||||
LOG(ERROR) << name << ": sload.f2fs failed (" << status << ") on " << location;
|
status != 0) {
|
||||||
|
LOG(ERROR) << name << ": sload_f2fs failed (" << status << ") on " << location;
|
||||||
return StringValue("");
|
return StringValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue