From c6717310750c1cdd4fbde2479e0966a6c444022f Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Tue, 19 May 2020 15:49:26 -0700 Subject: [PATCH] Handle virtio in private fs mapping When the vold core decides if a device is SD or USB, it checks for MMC or virtio, however when the filesystem type is decided, it does not check for virtio, only MMC. This causes virtio SD cards to be formatted with ext4 unconditionally. This fix is independently correct, but it incidentally gets adopted storage working on cuttlefish (and Android Emulator) because f2fs can support fscrypt and casefolding at the same time; ext4 currently cannot. Bug: 156286088 Change-Id: I0b41670d5f76b2506dad437917c2276f8e0aaccf --- model/PrivateVolume.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/PrivateVolume.cpp b/model/PrivateVolume.cpp index e146633..39a946c 100644 --- a/model/PrivateVolume.cpp +++ b/model/PrivateVolume.cpp @@ -39,6 +39,7 @@ #include using android::base::StringPrintf; +using android::vold::IsVirtioBlkDevice; namespace android { namespace vold { @@ -210,9 +211,10 @@ 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. - // Additionally, prefer f2fs for loop-bases devices - if ((major(mRawDevice) == kMajorBlockMmc || major(mRawDevice) == kMajorBlockLoop) && - f2fs::IsSupported()) { + // Additionally, prefer f2fs for loop-based devices + if ((major(mRawDevice) == kMajorBlockMmc || + major(mRawDevice) == kMajorBlockLoop || + IsVirtioBlkDevice(major(mRawDevice))) && f2fs::IsSupported()) { resolvedFsType = "f2fs"; } else { resolvedFsType = "ext4";