summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Ramaraj <nramaraj@codeaurora.org>2016-05-09 21:17:32 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-05-09 21:17:32 +0000
commit230353fe3bcadd1b7cf748005f1220c6c445963c (patch)
treede524f4a03ec0921abe185582816002f4a305feb
parenta4185b5c1c6cfdb9a6bb287ece1a2afd8e561f0f (diff)
parentc861423217206eb40e0d05cae59f0d293e7861d6 (diff)
downloadandroid_hardware_qcom_bootctrl-230353fe3bcadd1b7cf748005f1220c6c445963c.tar.gz
android_hardware_qcom_bootctrl-230353fe3bcadd1b7cf748005f1220c6c445963c.tar.bz2
android_hardware_qcom_bootctrl-230353fe3bcadd1b7cf748005f1220c6c445963c.zip
bootctrl: Fix implementation of get_current_slot am: 2af2922e5d
am: c861423217 * commit 'c861423217206eb40e0d05cae59f0d293e7861d6': bootctrl: Fix implementation of get_current_slot Change-Id: Ic9f8054fd3bf67f8b78564ab4571eea2575b3f51
-rw-r--r--Android.mk2
-rw-r--r--boot_control.c21
2 files changed, 14 insertions, 9 deletions
diff --git a/Android.mk b/Android.mk
index 7e07955..14873fb 100644
--- a/Android.mk
+++ b/Android.mk
@@ -4,7 +4,7 @@ include $(CLEAR_VARS)
LOCAL_C_INCLUDES += hardware/libhardware/include
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/gpt-utils/inc
LOCAL_CFLAGS += -Wall -Werror
-LOCAL_SHARED_LIBRARIES += liblog librecovery_updater_msm
+LOCAL_SHARED_LIBRARIES += liblog librecovery_updater_msm libcutils
LOCAL_SRC_FILES := boot_control.c
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE := bootctrl.$(TARGET_BOARD_PLATFORM)
diff --git a/boot_control.c b/boot_control.c
index 58edf5e..6fa066d 100644
--- a/boot_control.c
+++ b/boot_control.c
@@ -38,11 +38,13 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
+#include <cutils/properties.h>
#include "gpt-utils.h"
#define BOOTDEV_DIR "/dev/block/bootdevice/by-name"
#define BOOT_IMG_PTN_NAME "boot"
#define LUN_NAME_END_LOC 14
+#define BOOT_SLOT_PROP "ro.boot.slot_suffix"
const char *slot_suffix_arr[] = {
AB_SLOT_A_SUFFIX,
@@ -260,7 +262,7 @@ error:
unsigned get_current_slot(struct boot_control_module *module)
{
uint32_t num_slots = 0;
- char bootPartition[MAX_GPT_NAME_SIZE + 1];
+ char bootSlotProp[PROPERTY_VALUE_MAX] = {'\0'};
unsigned i = 0;
if (!module) {
ALOGE("%s: Invalid argument", __func__);
@@ -271,16 +273,19 @@ unsigned get_current_slot(struct boot_control_module *module)
//Slot 0 is the only slot around.
return 0;
}
+ property_get(BOOT_SLOT_PROP, bootSlotProp, "N/A");
+ if (!strncmp(bootSlotProp, "N/A", strlen("N/A"))) {
+ ALOGE("%s: Unable to read boot slot property",
+ __func__);
+ goto error;
+ }
//Iterate through a list of partitons named as boot+suffix
//and see which one is currently active.
for (i = 0; slot_suffix_arr[i] != NULL ; i++) {
- memset(bootPartition, '\0', sizeof(bootPartition));
- snprintf(bootPartition, sizeof(bootPartition) - 1,
- "boot%s",
- slot_suffix_arr[i]);
- if (get_partition_attribute(bootPartition,
- ATTR_SLOT_ACTIVE) == 1)
- return i;
+ if (!strncmp(bootSlotProp,
+ slot_suffix_arr[i],
+ strlen(slot_suffix_arr[i])))
+ return i;
}
error:
//The HAL spec requires that we return a number between