From 489b883b354353662ebb19c40c0f3816240d7ca3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Dec 2024 16:46:46 +0800 Subject: [PATCH] add mount.exfat Signed-off-by: unknown --- services/fs_manager/mount.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/services/fs_manager/mount.cpp b/services/fs_manager/mount.cpp index 0252db64..f1897f0f 100644 --- a/services/fs_manager/mount.cpp +++ b/services/fs_manager/mount.cpp @@ -122,11 +122,8 @@ int UmountForPath(const std::string& path) } return 0; } - -static int MountNtfsWithRetry(std::string source, std::string target) +static int LoopToMount(char *argv[], std::string source, std::string target) { - char *argv[] = {const_cast("system/bin/mount.ntfs"), - const_cast(source.c_str()), const_cast(target.c_str()), nullptr}; int num = 0; do { pid_t child = fork(); @@ -163,6 +160,20 @@ static int MountNtfsWithRetry(std::string source, std::string target) return -1; } +static int MountNtfsWithRetry(std::string source, std::string target) +{ + char *argv[] = {const_cast("system/bin/mount.ntfs"), + const_cast(source.c_str()), const_cast(target.c_str()), nullptr}; + return LoopToMount(argv, source, target); +} + +static int MountExfatWithRetry(std::string source, std::string target) +{ + char *argv[] = {const_cast("system/bin/mount.exfat"), + const_cast(source.c_str()), const_cast(target.c_str()), nullptr}; + return LoopToMount(argv, source, target); +} + int MountSdcard(std::string &path, std::string &mountPoint) { if (path.empty() || mountPoint.empty()) { @@ -187,6 +198,10 @@ int MountSdcard(std::string &path, std::string &mountPoint) LOG(INFO) << "mount success, sdcard type is ntfs"; return 0; } + if (MountExfatWithRetry(path, mountPoint) == 0) { + LOG(INFO) << "mount success, sdcard type is exfat"; + return 0; + } return -1; } -- Gitee