Merge "rootdir: Fix system emulation startup." into honeycomb
diff --git a/init/builtins.c b/init/builtins.c
index 8b2e4aa..915c5aa 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -388,6 +388,7 @@
                 /* Set the property that triggers the framework to do a minimal
                  * startup and ask the user for a password
                  */
+                property_set("ro.crypto.state", "encrypted");
                 property_set("vold.decrypt", "1");
             } else {
                 return -1;
@@ -395,6 +396,7 @@
         } else {
             if (!strcmp(target, DATA_MNT_POINT)) {
                 /* We succeeded in mounting /data, so it's not encrypted */
+                property_set("ro.crypto.state", "unencrypted");
                 action_for_each_trigger("nonencrypted", action_add_queue_tail);
             }
         }
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 1136057..f76ee37 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -297,6 +297,9 @@
 on property:vold.decrypt=trigger_post_fs_data
     trigger post-fs-data
 
+on property:vold.decrypt=trigger_restart_min_framework
+    class_start main
+
 on property:vold.decrypt=trigger_restart_framework
     class_start main
     class_start late_start
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 21a44ce..cc2cce7 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -116,6 +116,15 @@
 
 #define PATH_BUFFER_SIZE 1024
 
+static void normalize_name(char *name)
+{
+    if (force_lower_case) {
+        char ch;
+        while ((ch = *name) != 0)
+            *name++ = tolower(ch);
+    }
+}
+
 /*
  * Get the real-life absolute path to a node.
  *   node: start at this node
@@ -146,6 +155,7 @@
         out[0] = '/';
     }
 
+    normalize_name(out);
     return out;
 }
 
@@ -457,15 +467,6 @@
     return 0;
 }
 
-static void normalize_name(char *name)
-{
-    if (force_lower_case) {
-        char ch;
-        while ((ch = *name) != 0)
-            *name++ = tolower(ch);
-    }
-}
-
 static void recursive_fix_files(const char* path) {
     DIR* dir;
     struct dirent* entry;
@@ -549,7 +550,6 @@
 
     switch (hdr->opcode) {
     case FUSE_LOOKUP: { /* bytez[] -> entry_out */
-        normalize_name((char*) data);
         TRACE("LOOKUP %llx %s\n", hdr->nodeid, (char*) data);
         lookup_entry(fuse, node, (char*) data, hdr->unique);
         return;
@@ -609,8 +609,6 @@
         char *name = ((char*) data) + sizeof(*req);
         int res;
 
-        normalize_name(name);
-
         TRACE("MKNOD %s @ %llx\n", name, hdr->nodeid);
         path = node_get_path(node, buffer, name);
 
@@ -630,8 +628,6 @@
         char *name = ((char*) data) + sizeof(*req);
         int res;
 
-        normalize_name(name);
-
         TRACE("MKDIR %s @ %llx 0%o\n", name, hdr->nodeid, req->mode);
         path = node_get_path(node, buffer, name);
 
@@ -647,7 +643,6 @@
     case FUSE_UNLINK: { /* bytez[] -> */
         char *path, buffer[PATH_BUFFER_SIZE];
         int res;
-        normalize_name((char*) data);
         TRACE("UNLINK %s @ %llx\n", (char*) data, hdr->nodeid);
         path = node_get_path(node, buffer, (char*) data);
         res = unlink(path);
@@ -657,7 +652,6 @@
     case FUSE_RMDIR: { /* bytez[] -> */
         char *path, buffer[PATH_BUFFER_SIZE];
         int res;
-        normalize_name((char*) data);
         TRACE("RMDIR %s @ %llx\n", (char*) data, hdr->nodeid);
         path = node_get_path(node, buffer, (char*) data);
         res = rmdir(path);
@@ -674,9 +668,6 @@
         struct node *newparent;
         int res;
 
-        normalize_name(oldname);
-        normalize_name(newname);
-
         TRACE("RENAME %s->%s @ %llx\n", oldname, newname, hdr->nodeid);
 
         target = lookup_child_by_name(node, oldname);
@@ -723,7 +714,6 @@
             return;
         }
 
-        normalize_name(buffer);
         path = node_get_path(node, buffer, 0);
         TRACE("OPEN %llx '%s' 0%o fh=%p\n", hdr->nodeid, path, req->flags, h);
         h->fd = open(path, req->flags);
@@ -825,7 +815,6 @@
             return;
         }
 
-        normalize_name(buffer);
         path = node_get_path(node, buffer, 0);
         TRACE("OPENDIR %llx '%s'\n", hdr->nodeid, path);
         h->d = opendir(path);