Merge "Remove dead dlmalloc stubs."
diff --git a/adb/set_verity_enable_state_service.cpp b/adb/set_verity_enable_state_service.cpp
index 49e0363..253d14a 100644
--- a/adb/set_verity_enable_state_service.cpp
+++ b/adb/set_verity_enable_state_service.cpp
@@ -93,9 +93,21 @@
/* Helper function to get A/B suffix, if any. If the device isn't
* using A/B the empty string is returned. Otherwise either "_a",
* "_b", ... is returned.
+ *
+ * Note that since sometime in O androidboot.slot_suffix is deprecated
+ * and androidboot.slot should be used instead. Since bootloaders may
+ * be out of sync with the OS, we check both and for extra safety
+ * prepend a leading underscore if there isn't one already.
*/
static std::string get_ab_suffix() {
- return android::base::GetProperty("ro.boot.slot_suffix", "");
+ std::string ab_suffix = android::base::GetProperty("ro.boot.slot_suffix", "");
+ if (ab_suffix == "") {
+ ab_suffix = android::base::GetProperty("ro.boot.slot", "");
+ }
+ if (ab_suffix.size() > 0 && ab_suffix[0] != '_') {
+ ab_suffix = std::string("_") + ab_suffix;
+ }
+ return ab_suffix;
}
/* Use AVB to turn verity on/off */
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 40c18e0..6175f59 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -485,7 +485,7 @@
return bdata;
}
-static void* unzip_file(ZipArchiveHandle zip, const char* entry_name, int64_t* sz) {
+static void* unzip_to_memory(ZipArchiveHandle zip, const char* entry_name, int64_t* sz) {
ZipString zip_entry_name(entry_name);
ZipEntry zip_entry;
if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
@@ -495,7 +495,7 @@
*sz = zip_entry.uncompressed_length;
- fprintf(stderr, "extracting %s (%" PRId64 " MB)...\n", entry_name, *sz / 1024 / 1024);
+ fprintf(stderr, "extracting %s (%" PRId64 " MB) to RAM...\n", entry_name, *sz / 1024 / 1024);
uint8_t* data = reinterpret_cast<uint8_t*>(malloc(zip_entry.uncompressed_length));
if (data == nullptr) die("failed to allocate %" PRId64 " bytes for '%s'", *sz, entry_name);
@@ -613,17 +613,20 @@
return -1;
}
- fprintf(stderr, "extracting %s (%" PRIu32 " MB)...\n", entry_name,
+ fprintf(stderr, "extracting %s (%" PRIu32 " MB) to disk...", entry_name,
zip_entry.uncompressed_length / 1024 / 1024);
+ double start = now();
int error = ExtractEntryToFile(zip, &zip_entry, fd);
if (error != 0) {
- die("failed to extract '%s': %s", entry_name, ErrorCodeString(error));
+ die("\nfailed to extract '%s': %s", entry_name, ErrorCodeString(error));
}
if (lseek(fd, 0, SEEK_SET) != 0) {
- die("lseek on extracted file '%s' failed: %s", entry_name, strerror(errno));
+ die("\nlseek on extracted file '%s' failed: %s", entry_name, strerror(errno));
}
+ fprintf(stderr, " took %.3fs\n", now() - start);
+
return fd.release();
}
@@ -1091,7 +1094,7 @@
static void do_update_signature(ZipArchiveHandle zip, const char* filename) {
int64_t sz;
- void* data = unzip_file(zip, filename, &sz);
+ void* data = unzip_to_memory(zip, filename, &sz);
if (data == nullptr) return;
fb_queue_download("signature", data, sz);
fb_queue_command("signature", "installing signature");
@@ -1130,7 +1133,7 @@
}
int64_t sz;
- void* data = unzip_file(zip, "android-info.txt", &sz);
+ void* data = unzip_to_memory(zip, "android-info.txt", &sz);
if (data == nullptr) {
die("update package '%s' has no android-info.txt", filename);
}
diff --git a/fs_mgr/fs_mgr_slotselect.cpp b/fs_mgr/fs_mgr_slotselect.cpp
index 33fd562..f604bcf 100644
--- a/fs_mgr/fs_mgr_slotselect.cpp
+++ b/fs_mgr/fs_mgr_slotselect.cpp
@@ -21,12 +21,19 @@
#include "fs_mgr.h"
#include "fs_mgr_priv.h"
-// Returns "_a" or "_b" based on androidboot.slot_suffix in kernel cmdline, or an empty string
-// if that parameter does not exist.
+// Returns "_a" or "_b" based on two possible values in kernel cmdline:
+// - androidboot.slot = a or b OR
+// - androidboot.slot_suffix = _a or _b
+// TODO: remove slot_suffix once it's deprecated.
std::string fs_mgr_get_slot_suffix() {
+ std::string slot;
std::string ab_suffix;
- fs_mgr_get_boot_config("slot_suffix", &ab_suffix);
+ if (fs_mgr_get_boot_config("slot", &slot)) {
+ ab_suffix = "_" + slot;
+ } else if (!fs_mgr_get_boot_config("slot_suffix", &ab_suffix)) {
+ ab_suffix = "";
+ }
return ab_suffix;
}
@@ -40,7 +47,7 @@
char *tmp;
if (ab_suffix.empty()) {
ab_suffix = fs_mgr_get_slot_suffix();
- // Returns false as non A/B devices should not have MF_SLOTSELECT.
+ // Return false if failed to get ab_suffix when MF_SLOTSELECT is specified.
if (ab_suffix.empty()) return false;
}
if (asprintf(&tmp, "%s%s", fstab->recs[n].blk_device, ab_suffix.c_str()) > 0) {
diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp
index 0f7e38f..6fa07e7 100644
--- a/init/init_first_stage.cpp
+++ b/init/init_first_stage.cpp
@@ -118,7 +118,10 @@
FirstStageMount::FirstStageMount()
: need_dm_verity_(false), device_tree_fstab_(fs_mgr_read_fstab_dt(), fs_mgr_free_fstab) {
if (!device_tree_fstab_) {
- LOG(ERROR) << "Failed to read fstab from device tree";
+ // The client of FirstStageMount should check the existence of fstab in device-tree
+ // in advance, without parsing it. Reaching here means there is a FATAL error when
+ // parsing the fstab. So stop here to expose the failure.
+ LOG(FATAL) << "Failed to read fstab from device tree";
return;
}
// Stores device_tree_fstab_->recs[] into mount_fstab_recs_ (vector<fstab_rec*>)