From 95a92f9203ca68ab446a7cffd23450f04930fe38 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 17 Jul 2017 13:57:18 -0600 Subject: [PATCH] Only enable quotas when supported by device. Otherwise we might end up creating ext4 partitions that the device can't mount. Bug: 63763609 Test: builds, boots Exempt-From-Owner-Approval: Bug 63673347 Change-Id: I5f6cf73f23a55bc0dea9480523f19049313c3dd1 --- fs/Ext4.cpp | 6 +++++- main.cpp | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fs/Ext4.cpp b/fs/Ext4.cpp index adb8f2e..0cf4f9e 100644 --- a/fs/Ext4.cpp +++ b/fs/Ext4.cpp @@ -38,6 +38,7 @@ #define LOG_TAG "Vold" #include +#include #include #include #include @@ -176,7 +177,10 @@ status_t Format(const std::string& source, unsigned long numSectors, cmd.push_back("-M"); cmd.push_back(target); - std::string options("has_journal,quota"); + std::string options("has_journal"); + if (android::base::GetBoolProperty("vold.has_quota", false)) { + options += ",quota"; + } if (e4crypt_is_native()) { options += ",encrypt"; } diff --git a/main.cpp b/main.cpp index 4657377..30c839e 100644 --- a/main.cpp +++ b/main.cpp @@ -39,7 +39,7 @@ #include #include -static int process_config(VolumeManager *vm, bool* has_adoptable); +static int process_config(VolumeManager *vm, bool* has_adoptable, bool* has_quota); static void coldboot(const char *path); static void parse_args(int argc, char** argv); @@ -107,8 +107,9 @@ int main(int argc, char** argv) { } bool has_adoptable; + bool has_quota; - if (process_config(vm, &has_adoptable)) { + if (process_config(vm, &has_adoptable, &has_quota)) { PLOG(ERROR) << "Error reading configuration... continuing anyways"; } @@ -133,6 +134,7 @@ int main(int argc, char** argv) { // This call should go after listeners are started to avoid // a deadlock between vold and init (see b/34278978 for details) property_set("vold.has_adoptable", has_adoptable ? "1" : "0"); + property_set("vold.has_quota", has_quota ? "1" : "0"); // Do coldboot here so it won't block booting, // also the cold boot is needed in case we have flash drive @@ -214,7 +216,7 @@ static void coldboot(const char *path) { } } -static int process_config(VolumeManager *vm, bool* has_adoptable) { +static int process_config(VolumeManager *vm, bool* has_adoptable, bool* has_quota) { fstab = fs_mgr_read_fstab_default(); if (!fstab) { PLOG(ERROR) << "Failed to open default fstab"; @@ -223,7 +225,12 @@ static int process_config(VolumeManager *vm, bool* has_adoptable) { /* Loop through entries looking for ones that vold manages */ *has_adoptable = false; + *has_quota = false; for (int i = 0; i < fstab->num_entries; i++) { + if (fs_mgr_is_quota(&fstab->recs[i])) { + *has_quota = true; + } + if (fs_mgr_is_voldmanaged(&fstab->recs[i])) { if (fs_mgr_is_nonremovable(&fstab->recs[i])) { LOG(WARNING) << "nonremovable no longer supported; ignoring volume";