Snap for 5217728 from 0c92531f58 to qt-release
Change-Id: I48c7c27f799417b48dea76f470750a2e5615ab9c
This commit is contained in:
+2
-2
@@ -58,8 +58,8 @@ LOCAL_MODULE := recovery_deps
|
||||
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
|
||||
ifeq ($(HOST_OS),linux)
|
||||
LOCAL_REQUIRED_MODULES += \
|
||||
sload.f2fs \
|
||||
mkfs.f2fs
|
||||
make_f2fs.recovery \
|
||||
sload_f2fs.recovery
|
||||
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/STATIC_LIBRARIES/libminui_intermediates/import_includes)
|
||||
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sbin)
|
||||
|
||||
@@ -223,35 +223,29 @@ int format_volume(const std::string& volume, const std::string& directory) {
|
||||
|
||||
// Has to be f2fs because we checked earlier.
|
||||
static constexpr int kSectorSize = 4096;
|
||||
std::string cmd("/sbin/mkfs.f2fs");
|
||||
// clang-format off
|
||||
std::vector<std::string> make_f2fs_cmd = {
|
||||
cmd,
|
||||
"-g", "android",
|
||||
"/system/bin/make_f2fs",
|
||||
"-g",
|
||||
"android",
|
||||
v->blk_device,
|
||||
};
|
||||
// clang-format on
|
||||
if (length >= kSectorSize) {
|
||||
make_f2fs_cmd.push_back(std::to_string(length / kSectorSize));
|
||||
}
|
||||
|
||||
int result = exec_cmd(make_f2fs_cmd);
|
||||
if (result == 0 && !directory.empty()) {
|
||||
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;
|
||||
if (exec_cmd(make_f2fs_cmd) != 0) {
|
||||
PLOG(ERROR) << "format_volume: Failed to make_f2fs on " << v->blk_device;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -178,14 +178,18 @@ static bool SetPartitionUpdatedMarker(const std::string& marker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool discard_blocks(int fd, off64_t offset, uint64_t size) {
|
||||
// Don't discard blocks unless the update is a retry run.
|
||||
if (!is_retry) {
|
||||
static bool discard_blocks(int fd, off64_t offset, uint64_t size, bool force = false) {
|
||||
// Don't discard blocks unless the update is a retry run or force == true
|
||||
if (!is_retry && !force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t args[2] = { static_cast<uint64_t>(offset), size };
|
||||
if (ioctl(fd, BLKDISCARD, &args) == -1) {
|
||||
// On devices that does not support BLKDISCARD, ignore the error.
|
||||
if (errno == EOPNOTSUPP) {
|
||||
return true;
|
||||
}
|
||||
PLOG(ERROR) << "BLKDISCARD ioctl failed";
|
||||
return false;
|
||||
}
|
||||
@@ -1448,14 +1452,9 @@ static int PerformCommandErase(CommandParameters& params) {
|
||||
LOG(INFO) << " erasing " << tgt.blocks() << " blocks";
|
||||
|
||||
for (const auto& [begin, end] : tgt) {
|
||||
uint64_t blocks[2];
|
||||
// offset in bytes
|
||||
blocks[0] = begin * static_cast<uint64_t>(BLOCKSIZE);
|
||||
// length in bytes
|
||||
blocks[1] = (end - begin) * static_cast<uint64_t>(BLOCKSIZE);
|
||||
|
||||
if (ioctl(params.fd, BLKDISCARD, &blocks) == -1) {
|
||||
PLOG(ERROR) << "BLKDISCARD ioctl failed";
|
||||
off64_t offset = static_cast<off64_t>(begin) * BLOCKSIZE;
|
||||
size_t size = (end - begin) * BLOCKSIZE;
|
||||
if (!discard_blocks(params.fd, offset, size, true /* force */)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -482,18 +482,19 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt
|
||||
return StringValue("");
|
||||
}
|
||||
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) {
|
||||
f2fs_args.push_back(std::to_string(size / 512));
|
||||
}
|
||||
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("");
|
||||
}
|
||||
|
||||
if (auto status = exec_cmd({ "/sbin/sload.f2fs", "-t", mount_point, location }); status != 0) {
|
||||
LOG(ERROR) << name << ": sload.f2fs failed (" << status << ") on " << location;
|
||||
if (auto status = exec_cmd({ "/system/bin/sload_f2fs", "-t", mount_point, location });
|
||||
status != 0) {
|
||||
LOG(ERROR) << name << ": sload_f2fs failed (" << status << ") on " << location;
|
||||
return StringValue("");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user