From d6c2feb9fa039aa0692823f4ecccfd9c66c72db8 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Mon, 28 Jan 2019 10:49:55 -0800 Subject: [PATCH] init: delete code that sets ro.recovery_id It looks like this code is dead currently. From history, this was meant to be used as a way to check that the recovery image is what was expected during runtime, but that effort never completed, and we have full verification of the recovery image when booting into recovery anyway. The code is functionally dead as is too, since /recovery doesn't actually exist in any fstab, since recovery is either mounted as a ramdisk during recovery or not mounted during normal boot. Test: boot Change-Id: I48cd324ef0d5a163db2df2648f6042174b83f10e --- init/property_service.cpp | 36 ------------------------------------ init/util.cpp | 11 ----------- init/util.h | 1 - 3 files changed, 48 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 3199d4501..91b7dddf9 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -49,8 +49,6 @@ #include #include #include -#include -#include #include #include #include @@ -79,8 +77,6 @@ using android::properties::ParsePropertyInfoFile; using android::properties::PropertyInfoAreaFile; using android::properties::PropertyInfoEntry; -#define RECOVERY_MOUNT_POINT "/recovery" - namespace android { namespace init { @@ -732,37 +728,6 @@ void load_persist_props(void) { property_set("ro.persistent_properties.ready", "true"); } -void load_recovery_id_prop() { - std::unique_ptr fstab(fs_mgr_read_fstab_default(), - fs_mgr_free_fstab); - if (!fstab) { - PLOG(ERROR) << "unable to read default fstab"; - return; - } - - fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab.get(), RECOVERY_MOUNT_POINT); - if (rec == NULL) { - LOG(ERROR) << "/recovery not specified in fstab"; - return; - } - - int fd = open(rec->blk_device, O_RDONLY | O_CLOEXEC); - if (fd == -1) { - PLOG(ERROR) << "error opening block device " << rec->blk_device; - return; - } - - boot_img_hdr hdr; - if (android::base::ReadFully(fd, &hdr, sizeof(hdr))) { - std::string hex = bytes_to_hex(reinterpret_cast(hdr.id), sizeof(hdr.id)); - property_set("ro.recovery_id", hex); - } else { - PLOG(ERROR) << "error reading /recovery"; - } - - close(fd); -} - void property_load_boot_defaults() { // TODO(b/117892318): merge prop.default and build.prop files into one // TODO(b/122864654): read the prop files from all partitions and then @@ -783,7 +748,6 @@ void property_load_boot_defaults() { load_properties_from_file("/odm/build.prop", NULL); load_properties_from_file("/vendor/build.prop", NULL); load_properties_from_file("/factory/factory.prop", "ro.*"); - load_recovery_id_prop(); update_sys_usb_config(); } diff --git a/init/util.cpp b/init/util.cpp index 378114120..80fb03d6e 100644 --- a/init/util.cpp +++ b/init/util.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -268,16 +267,6 @@ bool make_dir(const std::string& path, mode_t mode) { return rc == 0; } -/* - * Writes hex_len hex characters (1/2 byte) to hex from bytes. - */ -std::string bytes_to_hex(const uint8_t* bytes, size_t bytes_len) { - std::string hex("0x"); - for (size_t i = 0; i < bytes_len; i++) - android::base::StringAppendF(&hex, "%02x", bytes[i]); - return hex; -} - /* * Returns true is pathname is a directory */ diff --git a/init/util.h b/init/util.h index 53f45473a..2b57910fc 100644 --- a/init/util.h +++ b/init/util.h @@ -51,7 +51,6 @@ int wait_for_file(const char *filename, std::chrono::nanoseconds timeout); void import_kernel_cmdline(bool in_qemu, const std::function&); bool make_dir(const std::string& path, mode_t mode); -std::string bytes_to_hex(const uint8_t *bytes, size_t bytes_len); bool is_dir(const char* pathname); bool expand_props(const std::string& src, std::string* dst);