Prefer f2fs for virtual (private) storage volumes.

Since ext4 currently doesn't have the required kernel patches in place
on cuttlefish.

Bug: 150935323
Test: sm set-virtual-disk true
      sm partition disk:7,xyz private
      inspect mount output
Change-Id: Ief5bd9ace9d39bdfbae8d3857044a2143801f6be
This commit is contained in:
Martijn Coenen 2020-03-11 15:33:22 +01:00
parent 2f1c983240
commit 6c695ef1d9

View file

@ -43,6 +43,7 @@ using android::base::StringPrintf;
namespace android {
namespace vold {
static const unsigned int kMajorBlockLoop = 7;
static const unsigned int kMajorBlockMmc = 179;
PrivateVolume::PrivateVolume(dev_t device, const KeyBuffer& keyRaw)
@ -207,7 +208,9 @@ status_t PrivateVolume::doFormat(const std::string& fsType) {
if (fsType == "auto") {
// For now, assume that all MMC devices are flash-based SD cards, and
// give everyone else ext4 because sysfs rotational isn't reliable.
if ((major(mRawDevice) == kMajorBlockMmc) && f2fs::IsSupported()) {
// Additionally, prefer f2fs for loop-bases devices
if ((major(mRawDevice) == kMajorBlockMmc || major(mRawDevice) == kMajorBlockLoop) &&
f2fs::IsSupported()) {
resolvedFsType = "f2fs";
} else {
resolvedFsType = "ext4";