lineage_patches_unified/patches_treble/system_vold/0001-Exfat-can-be-mounted-with-exfat-kernel-fs-driver-or-.patch

61 lines
2.0 KiB
Diff

From 1c1e3e209c687d9ef0e86c80a113208251a375b9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 18 Oct 2022 16:08:09 -0400
Subject: [PATCH] Exfat can be mounted with "exfat" kernel fs driver, or
"sdfat" or "texfat" (Samsung and Sony variants)
@AndyCGYan: Adapt to LineageOS vold
Change-Id: I331e66d8cb37664adbd493b9190123e29f01fd9d
---
Utils.cpp | 5 +++++
fs/Exfat.cpp | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Utils.cpp b/Utils.cpp
index a7e85f2..fb67067 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -1059,6 +1059,11 @@ bool IsFilesystemSupported(const std::string& fsType) {
/* fuse filesystems */
supported.append("fuse\tntfs\n");
+ /* treat sdfat/texfat as exfat */
+ if (supported.find("sdfat\n") != std::string::npos || supported.find("texfat\n") != std::string::npos) {
+ supported.append("\texfat\n");
+ }
+
return supported.find(fsType + "\n") != std::string::npos;
}
diff --git a/fs/Exfat.cpp b/fs/Exfat.cpp
index c8b19e0..46a0e2d 100644
--- a/fs/Exfat.cpp
+++ b/fs/Exfat.cpp
@@ -61,13 +61,20 @@ status_t Mount(const std::string& source, const std::string& target, int ownerUi
auto mountData = android::base::StringPrintf("uid=%d,gid=%d,fmask=%o,dmask=%o", ownerUid,
ownerGid, permMask, permMask);
- if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
+ const char *fs = "exfat";
+ if (IsFilesystemSupported("sdfat")) {
+ fs = "sdfat";
+ } else if (IsFilesystemSupported("texfat")) {
+ fs = "texfat";
+ }
+
+ if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
return 0;
}
PLOG(ERROR) << "Mount failed; attempting read-only";
mountFlags |= MS_RDONLY;
- if (mount(source.c_str(), target.c_str(), "exfat", mountFlags, mountData.c_str()) == 0) {
+ if (mount(source.c_str(), target.c_str(), fs, mountFlags, mountData.c_str()) == 0) {
return 0;
}
--
2.25.1