Merge in upstream changes

From :https://github.com/phhusson/treble_patches

Change-Id: I785ed4d854f28f661b1b48530dc10a5adf076e74
diff --git a/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch b/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
index 815f513..1e4ec14 100644
--- a/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
+++ b/patches/platform_system_vold/0001-Allow-deletion-of-symlink.patch
@@ -1,7 +1,7 @@
 From 06a421423c529991ca38ba2d71b76daa9188849e Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sat, 17 Feb 2018 19:39:38 +0100
-Subject: [PATCH] Allow deletion of symlink
+Subject: [PATCH 1/5] Allow deletion of symlink
 
 Change-Id: I9731895f88729072297f753088583aabbe6990f4
 ---
@@ -21,5 +21,5 @@
          return false;
      }
 -- 
-2.17.1
+2.7.4
 
diff --git a/patches/platform_system_vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch b/patches/platform_system_vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
new file mode 100644
index 0000000..aee9f86
--- /dev/null
+++ b/patches/platform_system_vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
@@ -0,0 +1,21 @@
+From bed499eedc05289da45e9fc4de9f53f98c500332 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Tue, 14 Aug 2018 20:53:12 +0200
+Subject: [PATCH 2/5] Don't set reserved_disk group, it panics old inits
+
+---
+ vold.rc | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/vold.rc b/vold.rc
+index 7d14453..c27aeda 100644
+--- a/vold.rc
++++ b/vold.rc
+@@ -5,4 +5,3 @@ service vold /system/bin/vold \
+     ioprio be 2
+     writepid /dev/cpuset/foreground/tasks
+     shutdown critical
+-    group reserved_disk
+-- 
+2.7.4
+
diff --git a/patches/platform_system_vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch b/patches/platform_system_vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
new file mode 100644
index 0000000..d1423cf
--- /dev/null
+++ b/patches/platform_system_vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
@@ -0,0 +1,26 @@
+From 3a5d884d899664223b8b78c331180c6e3a1b6d05 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Tue, 14 Aug 2018 20:54:08 +0200
+Subject: [PATCH 3/5] Create vendor_de. This is done by /init.rc on
+ system-as-root device
+
+---
+ Ext4Crypt.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
+index 99a63b4..090532f 100644
+--- a/Ext4Crypt.cpp
++++ b/Ext4Crypt.cpp
+@@ -667,6 +667,8 @@ bool e4crypt_prepare_user_storage(const std::string& volume_uuid, userid_t user_
+         auto vendor_de_path = android::vold::BuildDataVendorDePath(user_id);
+         auto user_de_path = android::vold::BuildDataUserDePath(volume_uuid, user_id);
+ 
++	prepare_dir(android::vold::BuildDataPath("") + "/vendor_de", 0771, 0, 0);
++
+         if (volume_uuid.empty()) {
+             if (!prepare_dir(system_legacy_path, 0700, AID_SYSTEM, AID_SYSTEM)) return false;
+ #if MANAGE_MISC_DIRS
+-- 
+2.7.4
+
diff --git a/patches/platform_system_vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch b/patches/platform_system_vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
new file mode 100644
index 0000000..7b02826
--- /dev/null
+++ b/patches/platform_system_vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
@@ -0,0 +1,44 @@
+From dabad429ba29bd565c21bd1dde65c7e763a56238 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Mon, 20 Aug 2018 22:37:54 +0200
+Subject: [PATCH 4/5] Support Samsung's implementation of exfat, called sdfat
+
+---
+ fs/Exfat.cpp | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/fs/Exfat.cpp b/fs/Exfat.cpp
+index 5c15075..5e23a79 100644
+--- a/fs/Exfat.cpp
++++ b/fs/Exfat.cpp
+@@ -35,7 +35,7 @@ static const char* kFsckPath = "/system/bin/fsck.exfat";
+ 
+ bool IsSupported() {
+     return access(kMkfsPath, X_OK) == 0 && access(kFsckPath, X_OK) == 0 &&
+-           IsFilesystemSupported("exfat");
++           (IsFilesystemSupported("exfat") || IsFilesystemSupported("sdfat"));
+ }
+ 
+ status_t Check(const std::string& source) {
+@@ -60,13 +60,16 @@ status_t Mount(const std::string& source, const std::string& target, int ownerUi
+     auto mountData = android::base::StringPrintf("uid=%d,gid=%d,fmask=%o,dmask=%o", ownerUid,
+                                                  ownerGid, permMask, permMask);
+ 
+-    if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
++    const char *fs = "exfat";
++    if(IsFilesystemSupported("sdfat"))
++        fs = "sdfat";
++    if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
+         return 0;
+     }
+ 
+     PLOG(ERROR) << "Mount failed; attempting read-only";
+     mountFlags |= MS_RDONLY;
+-    if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
++    if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
+         return 0;
+     }
+ 
+-- 
+2.7.4
+
diff --git a/patches/platform_system_vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch b/patches/platform_system_vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch
new file mode 100644
index 0000000..5aec913
--- /dev/null
+++ b/patches/platform_system_vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch
@@ -0,0 +1,25 @@
+From 8004f0102629d11e3fa17a13593bf84742761add Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Mon, 20 Aug 2018 22:38:08 +0200
+Subject: [PATCH 5/5] Also create vendor_ce (same reason as vendor_de)
+
+---
+ Ext4Crypt.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
+index 090532f..6b60796 100644
+--- a/Ext4Crypt.cpp
++++ b/Ext4Crypt.cpp
+@@ -706,6 +706,8 @@ bool e4crypt_prepare_user_storage(const std::string& volume_uuid, userid_t user_
+         auto media_ce_path = android::vold::BuildDataMediaCePath(volume_uuid, user_id);
+         auto user_ce_path = android::vold::BuildDataUserCePath(volume_uuid, user_id);
+ 
++	prepare_dir(android::vold::BuildDataPath("") + "/vendor_ce", 0771, 0, 0);
++
+         if (volume_uuid.empty()) {
+             if (!prepare_dir(system_ce_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false;
+             if (!prepare_dir(misc_ce_path, 01771, AID_SYSTEM, AID_MISC)) return false;
+-- 
+2.7.4
+