User 0 directories are created by vold now.

This ensures that all users on device follow a consistent path for
setup and validation of encryption policy.

Also add remaining user-specific directories and fix linking order.

Bug: 25796509
Change-Id: I8c2e42a78569817f7f5ea03f54b743a6661fdb9c
diff --git a/init/Android.mk b/init/Android.mk
index 66ce8a8..d8b574f 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -89,8 +89,8 @@
     libsquashfs_utils \
     liblogwrap \
     libcutils \
-    libbase \
     libext4_utils_static \
+    libbase \
     libutils \
     libc \
     libselinux \
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 210ce4a..229487f 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -878,9 +878,6 @@
 }
 
 static int do_init_user0(const std::vector<std::string>& args) {
-    if (!is_file_crypto()) {
-        return 0;
-    }
     return e4crypt_do_init_user0();
 }
 
diff --git a/rootdir/init.rc b/rootdir/init.rc
index b354cbb..3a7aa1f 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -412,19 +412,20 @@
 
     mkdir /data/system 0775 system system
     mkdir /data/system/heapdump 0700 system system
+
+    mkdir /data/system_de 0770 system system
     mkdir /data/system_ce 0770 system system
-    mkdir /data/system_ce/0 0770 system system
+
+    mkdir /data/misc_de 01771 system misc
+    mkdir /data/misc_ce 01771 system misc
 
     mkdir /data/user 0711 system system
     mkdir /data/user_de 0711 system system
-    mkdir /data/user_de/0 0771 system system
+    symlink /data/data /data/user/0
 
     mkdir /data/media 0770 media_rw media_rw
-    mkdir /data/media/0 0770 media_rw media_rw
     mkdir /data/media/obb 0770 media_rw media_rw
 
-    symlink /data/data /data/user/0
-
     init_user0
 
     # Reload policy from /data/security if present.