fs_mrg: clean up multi-type mount_all

Move the code that attempts to mount alternative fstab entries
into its own function.
Clarify return codes.
Suggest wipe via recovery in error messages.

Bug: 15747366
Change-Id: I3634477cd4d1d73f974f3e906c53285f0d9e0eac
Signed-off-by: JP Abgrall <jpa@google.com>
diff --git a/init/builtins.c b/init/builtins.c
index 452119e..dd147f6 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -511,27 +511,26 @@
         if (child_ret == -1) {
             ERROR("fs_mgr_mount_all returned an error\n");
         }
-        exit(child_ret);
+        _exit(child_ret);
     } else {
         /* fork failed, return an error */
         return -1;
     }
 
-    /* ret is 2 if device needs encrypted, 1 if the device appears encrypted,
-     * 0 if not, and -1 on error */
-    if (ret == 2) {
+    if (ret == FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION) {
         property_set("ro.crypto.state", "unencrypted");
         property_set("vold.decrypt", "trigger_encryption");
-    } else if (ret == 1) {
+    } else if (ret == FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED) {
         property_set("ro.crypto.state", "encrypted");
         property_set("vold.decrypt", "trigger_default_encryption");
-    } else if (ret == 0) {
+    } else if (ret == FS_MGR_MNTALL_DEV_NOT_ENCRYPTED) {
         property_set("ro.crypto.state", "unencrypted");
         /* If fs_mgr determined this is an unencrypted device, then trigger
          * that action.
          */
         action_for_each_trigger("nonencrypted", action_add_queue_tail);
     }
+    /* else ... < 0: error */
 
     return ret;
 }