app: aboot: update commandline for system as root behaviour.

System-As-Root behaviour, system.img should contain both system
content and ramdisk content, and should be mounted at root(a/b).

This change ensure we are updating commandline with skip initram fs
to skip mounting of ramfs from boot image, and append init path and
system partition block.

Change-Id: I866cafedf3efb481b5eca2d331dc94a2e6314381
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 31b5315..93e23fd 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -199,7 +199,7 @@
 static const char *verity_system_part = " dm=\"system";
 static const char *verity_params = " none ro,0 1 android-verity /dev/mmcblk0p";
 #else
-static const char *sys_path = "  root=/dev/mmcblk0p";
+static const char *sys_path = " root=/dev/mmcblk0p";
 #endif
 
 #if VERIFIED_BOOT
@@ -550,7 +550,8 @@
 		cmdline_len += strlen(warmboot_cmdline);
 	}
 
-	if (partition_multislot_is_supported())
+	if (target_uses_system_as_root() ||
+		partition_multislot_is_supported())
 	{
 		current_active_slot = partition_find_active_slot();
 		cmdline_len += (strlen(androidboot_slot_suffix)+
@@ -589,10 +590,15 @@
 					partition_get_index_in_lun("system", lun));
 		}
 
-		cmdline_len += strlen(sys_path_cmdline);
 #ifndef VERIFIED_BOOT_2
 		cmdline_len += strlen(syspath_buf);
 #endif
+	}
+
+	if (target_uses_system_as_root() ||
+		partition_multislot_is_supported())
+	{
+		cmdline_len += strlen(sys_path_cmdline);
 		if (!boot_into_recovery)
 			cmdline_len += strlen(skip_ramfs);
 	}
@@ -813,22 +819,34 @@
 				--dst;
 				src = SUFFIX_SLOT(current_active_slot);
 				while ((*dst++ = *src++));
+		}
 
-				if (!boot_into_recovery)
-				{
-					src = skip_ramfs;
-					--dst;
-					while ((*dst++ = *src++));
-				}
 
-				src = sys_path_cmdline;
+		/*
+		 * System-As-Root behaviour, system.img should contain both
+		 * system content and ramdisk content, and should be mounted at
+		 * root(a/b).
+		 * Apending skip_ramfs for non a/b builds which use, system as root.
+		 */
+		if ((target_uses_system_as_root() ||
+			partition_multislot_is_supported()) &&
+			have_cmdline)
+		{
+			if (!boot_into_recovery)
+			{
+				src = skip_ramfs;
 				--dst;
 				while ((*dst++ = *src++));
+			}
+
+			src = sys_path_cmdline;
+			--dst;
+			while ((*dst++ = *src++));
 
 #ifndef VERIFIED_BOOT_2
-				src = syspath_buf;
-				--dst;
-				while ((*dst++ = *src++));
+			src = syspath_buf;
+			--dst;
+			while ((*dst++ = *src++));
 #endif
 		}