Merge "Only set quota project ID inheritance on app-private dirs." into rvc-dev
diff --git a/FsCrypt.cpp b/FsCrypt.cpp
index d8af6f4..4d5cd33 100644
--- a/FsCrypt.cpp
+++ b/FsCrypt.cpp
@@ -825,14 +825,6 @@
             if (!prepare_dir(vendor_ce_path, 0771, AID_ROOT, AID_ROOT)) return false;
         }
         if (!prepare_dir(media_ce_path, 0770, AID_MEDIA_RW, AID_MEDIA_RW)) return false;
-        // Setup quota project ID and inheritance policy
-        if (!IsFilesystemSupported("sdcardfs")) {
-            if (SetQuotaInherit(media_ce_path) != 0) return false;
-            if (SetQuotaProjectId(media_ce_path,
-                                  multiuser_get_uid(user_id, PROJECT_ID_EXT_DEFAULT)) != 0) {
-                return false;
-            }
-        }
 
         if (!prepare_dir(user_ce_path, 0771, AID_SYSTEM, AID_SYSTEM)) return false;
 
diff --git a/Utils.cpp b/Utils.cpp
index 82ad1f1..1e20d75 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -366,6 +366,15 @@
             if (ret != 0) {
                 return ret;
             }
+
+            if (!IsFilesystemSupported("sdcardfs")) {
+                // Set project ID inheritance, so that future subdirectories inherit the
+                // same project ID
+                ret = SetQuotaInherit(pathToCreate);
+                if (ret != 0) {
+                    return ret;
+                }
+            }
         }
 
         depth++;