am ca3593df: am 311edc8c: Merge "Add SELinux restorecon calls on ASEC containers."

* commit 'ca3593df3d48cb4b51acf89e6df4872b922fd51d':
  Add SELinux restorecon calls on ASEC containers.
diff --git a/Android.mk b/Android.mk
index 249681c..7f93229 100644
--- a/Android.mk
+++ b/Android.mk
@@ -34,7 +34,8 @@
 	libhardware_legacy \
 	liblogwrap \
 	libext4_utils \
-	libcrypto
+	libcrypto \
+	libselinux
 
 common_static_libraries := \
 	libfs_mgr \
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 9440832..95263a8 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -35,6 +35,8 @@
 #include <cutils/fs.h>
 #include <cutils/log.h>
 
+#include <selinux/android.h>
+
 #include <sysutils/NetlinkEvent.h>
 
 #include <private/android_filesystem_config.h>
@@ -643,6 +645,12 @@
             } else if (ftsent->fts_info & FTS_F) {
                 result |= fchmod(fd, privateFile ? 0640 : 0644);
             }
+
+            if (selinux_android_restorecon(ftsent->fts_path) < 0) {
+                SLOGE("restorecon failed for %s: %s\n", ftsent->fts_path, strerror(errno));
+                result |= -1;
+            }
+
             close(fd);
         }
         fts_close(fts);