Add secdiscard command for secure deletion of files
am: f8d604caf3

Change-Id: Ib9d71507b880ee8dc66880536c800212f523332d
diff --git a/Android.mk b/Android.mk
index 06d98eb..45b3f62 100644
--- a/Android.mk
+++ b/Android.mk
@@ -42,6 +42,7 @@
 	libsysutils \
 	libbinder \
 	libcutils \
+	libkeyutils \
 	liblog \
 	libdiskconfig \
 	libhardware_legacy \
diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
index b41e09c..2d4ae89 100644
--- a/Ext4Crypt.cpp
+++ b/Ext4Crypt.cpp
@@ -46,7 +46,7 @@
 
 #include <cutils/fs.h>
 #include <ext4_utils/ext4_crypt.h>
-#include <ext4_utils/key_control.h>
+#include <keyutils.h>
 
 #include <android-base/file.h>
 #include <android-base/logging.h>
diff --git a/Keymaster.h b/Keymaster.h
index e47b403..4bc0df7 100644
--- a/Keymaster.h
+++ b/Keymaster.h
@@ -24,6 +24,7 @@
 #include <utility>
 
 #include <android/hardware/keymaster/3.0/IKeymasterDevice.h>
+#include <android-base/macros.h>
 #include <keystore/authorization_set.h>
 
 namespace android {
diff --git a/Utils.cpp b/Utils.cpp
index 443df1d..95469be 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -608,15 +608,15 @@
 std::string BuildDataUserCePath(const char* volumeUuid, userid_t userId) {
     // TODO: unify with installd path generation logic
     std::string data(BuildDataPath(volumeUuid));
-    if (volumeUuid == nullptr) {
-        if (userId == 0) {
-            return StringPrintf("%s/data", data.c_str());
-        } else {
-            return StringPrintf("%s/user/%u", data.c_str(), userId);
+    if (volumeUuid == nullptr && userId == 0) {
+        std::string legacy = StringPrintf("%s/data", data.c_str());
+        struct stat sb;
+        if (lstat(legacy.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) {
+            /* /data/data is dir, return /data/data for legacy system */
+            return legacy;
         }
-    } else {
-        return StringPrintf("%s/user/%u", data.c_str(), userId);
     }
+    return StringPrintf("%s/user/%u", data.c_str(), userId);
 }
 
 std::string BuildDataUserDePath(const char* volumeUuid, userid_t userId) {