app: aboot: Update commandline for UFS devices
Update commandline with system path for UFS devices.
Change-Id: Ieed6eb950c8a520597b225818ff1d12731fe9a96
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index c873882..24ae94b 100755
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -185,7 +185,8 @@
static const char *baseband_apq_nowgr = " androidboot.baseband=baseband_apq_nowgr";
static const char *androidboot_slot_suffix = " androidboot.slot_suffix=";
static const char *skip_ramfs = " skip_initramfs";
-static char *sys_path_cmdline = " rootwait ro init=/init root=/dev/mmcblk0p%d"; /*This will be updated*/
+static const char *sys_path_cmdline = " rootwait ro init=/init";
+static const char *sys_path = " root=/dev/mmcblk0p";
#if VERIFIED_BOOT
#if !VBOOT_MOTA
@@ -347,6 +348,11 @@
char *boot_dev_buf = NULL;
bool is_mdtp_activated = 0;
int current_active_slot = INVALID;
+ int system_ptn_index = -1;
+ unsigned int lun = 0;
+ char lun_char_base = 'a';
+ int syspath_buflen = strlen(sys_path) + sizeof(int) + 1; /*allocate buflen for largest possible string*/
+ char syspath_buf[syspath_buflen];
#if USE_LE_SYSTEMD
is_systemd_present=true;
@@ -495,10 +501,22 @@
cmdline_len += (strlen(androidboot_slot_suffix)+
strlen(SUFFIX_SLOT(current_active_slot)));
- snprintf(sys_path_cmdline, sizeof(*sys_path_cmdline),
- sys_path_cmdline, (partition_get_index("system")+1));
- cmdline_len += strlen(sys_path_cmdline);
+ system_ptn_index = partition_get_index("system");
+ if (platform_boot_dev_isemmc())
+ {
+ snprintf(syspath_buf, syspath_buflen, " root=/dev/mmcblk0p%d",
+ system_ptn_index + 1);
+ }
+ else
+ {
+ lun = partition_get_lun(system_ptn_index);
+ snprintf(syspath_buf, syspath_buflen, " root=/dev/sd%c%d",
+ lun_char_base + lun,
+ partition_get_index_in_lun("system", lun));
+ }
+ cmdline_len += strlen(sys_path_cmdline);
+ cmdline_len += strlen(syspath_buf);
if (!boot_into_recovery)
cmdline_len += strlen(skip_ramfs);
}
@@ -722,6 +740,10 @@
src = sys_path_cmdline;
--dst;
while ((*dst++ = *src++));
+
+ src = syspath_buf;
+ --dst;
+ while ((*dst++ = *src++));
}
#if TARGET_CMDLINE_SUPPORT