From f25b977740e388b458fcdbb8e3c43b957f0beaf3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Mon, 16 Dec 2019 18:32:00 -0800 Subject: Set Casefold and PrjQuotas in Factory Reset This sets up devices to have casefolding and project quotas if they have enabled the relevant product properties. For ext4, we must set wide inodes at makefs time, but other things are enabled by fs_mgr with tune2fs at boot time. Bug: 138321217 Bug: 138322712 Test: Enable on a device. Reformat from recovery. Check that /data has the expected values using tune2fs/f2fs.fsck Change-Id: If706a3cad591f311eb904df4deca531d0b3fe0c4 --- recovery_utils/roots.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/recovery_utils/roots.cpp b/recovery_utils/roots.cpp index fe3a07aa2..127039872 100644 --- a/recovery_utils/roots.cpp +++ b/recovery_utils/roots.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -152,6 +153,14 @@ int format_volume(const std::string& volume, const std::string& directory) { return -1; } + bool needs_casefold = false; + bool needs_projid = false; + + if (volume == "/data") { + needs_casefold = android::base::GetBoolProperty("ro.emulated_storage.casefold", false); + needs_projid = android::base::GetBoolProperty("ro.emulated_storage.projid", false); + } + // If there's a key_loc that looks like a path, it should be a block device for storing encryption // metadata. Wipe it too. if (!v->key_loc.empty() && v->key_loc[0] == '/') { @@ -187,6 +196,12 @@ int format_volume(const std::string& volume, const std::string& directory) { "/system/bin/mke2fs", "-F", "-t", "ext4", "-b", std::to_string(kBlockSize), }; + // Project ID's require wider inodes. The Quotas themselves are enabled by tune2fs on boot. + if (needs_projid) { + mke2fs_args.push_back("-I"); + mke2fs_args.push_back("512"); + } + int raid_stride = v->logical_blk_size / kBlockSize; int raid_stripe_width = v->erase_blk_size / kBlockSize; // stride should be the max of 8KB and logical block size @@ -224,8 +239,18 @@ int format_volume(const std::string& volume, const std::string& directory) { "/system/bin/make_f2fs", "-g", "android", - v->blk_device, }; + if (needs_projid) { + make_f2fs_cmd.push_back("-O"); + make_f2fs_cmd.push_back("project_quota,extra_attr"); + } + if (needs_casefold) { + make_f2fs_cmd.push_back("-O"); + make_f2fs_cmd.push_back("casefold"); + make_f2fs_cmd.push_back("-C"); + make_f2fs_cmd.push_back("utf8"); + } + make_f2fs_cmd.push_back(v->blk_device); if (length >= kSectorSize) { make_f2fs_cmd.push_back(std::to_string(length / kSectorSize)); } -- cgit v1.2.3