Merge "Passing additional parameter to powerctl" am: e0ab2557d4 am: 0c146e6572
am: cff6544e2e

Change-Id: I6e21babe911996ac0f91e9a61aeb46499c4949c0
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 7298dff..e1d9b94 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -607,7 +607,7 @@
     bool runFsck = false;
     bool commandInvalid = false;
 
-    if (cmd_params.size() > 2) {
+    if (cmd_params.size() > 3) {
         commandInvalid = true;
     } else if (cmd_params[0] == "shutdown") {
         cmd = ANDROID_RB_POWEROFF;
@@ -619,7 +619,7 @@
         }
     } else if (cmd_params[0] == "reboot") {
         cmd = ANDROID_RB_RESTART2;
-        if (cmd_params.size() == 2) {
+        if (cmd_params.size() >= 2) {
             reboot_target = cmd_params[1];
             // When rebooting to the bootloader notify the bootloader writing
             // also the BCB.
@@ -631,6 +631,10 @@
                                << err;
                 }
             }
+            // If there is an additional bootloader parameter, pass it along
+            if (cmd_params.size() == 3) {
+                reboot_target += "," + cmd_params[2];
+            }
         }
     } else if (command == "thermal-shutdown") {  // no additional parameter allowed
         cmd = ANDROID_RB_THERMOFF;