-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vold: add support for more filesystems for public storage
* Add exfat and ntfs support based off f2fs and ported to use fuse * Add support for both along with f2fs and ext4 to PublicVolume * Also attempt to mount any volume if it's been determined that the kernel supports it Change-Id: I0a83761cefd97791e3ec84a18e199dfd27a5ed0b vold: fs: Fix build errors * Migrate from base to android-base * Add missing , in Ext4 Mount function [AdrianDC] Ignore unpatched ext4 arguments [mikeioannina] Update for Pie native exfat Change-Id: I875b5763c472aa7da2976ec7c5db7cf28c913876 vold: ntfs: Use strlcat Clang now enforces length checking :/ Change-Id: I495b4cb2ee530e72b1084248f0549d63589523b0 Change-Id: I0a83761cefd97791e3ec84a18e199dfd27a5ed0b
- Loading branch information
1 parent
cfe2849
commit 4bc0d40
Showing
7 changed files
with
193 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (C) 2015 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <sys/mount.h> | ||
|
||
#include <android-base/logging.h> | ||
#include <android-base/stringprintf.h> | ||
|
||
#include <logwrap/logwrap.h> | ||
|
||
#include "Ntfs.h" | ||
#include "Utils.h" | ||
|
||
using android::base::StringPrintf; | ||
|
||
namespace android { | ||
namespace vold { | ||
namespace ntfs { | ||
|
||
static const char* kMkfsPath = "/system/bin/mkfs.ntfs"; | ||
static const char* kFsckPath = "/system/bin/fsck.ntfs"; | ||
static const char* kMountPath = "/system/bin/mount.ntfs"; | ||
|
||
bool IsSupported() { | ||
return access(kMkfsPath, X_OK) == 0 | ||
&& access(kFsckPath, X_OK) == 0 | ||
&& access(kMountPath, X_OK) == 0 | ||
&& IsFilesystemSupported("ntfs"); | ||
} | ||
|
||
status_t Check(const std::string& source) { | ||
std::vector<std::string> cmd; | ||
cmd.push_back(kFsckPath); | ||
cmd.push_back("-n"); | ||
cmd.push_back(source); | ||
|
||
int rc = ForkExecvp(cmd, nullptr, sFsckUntrustedContext); | ||
if (rc == 0) { | ||
LOG(INFO) << "Check OK"; | ||
return 0; | ||
} else { | ||
LOG(ERROR) << "Check failed (code " << rc << ")"; | ||
errno = EIO; | ||
return -1; | ||
} | ||
} | ||
|
||
status_t Mount(const std::string& source, const std::string& target, int ownerUid, int ownerGid, | ||
int permMask) { | ||
auto mountData = android::base::StringPrintf("utf8,uid=%d,gid=%d,fmask=%o,dmask=%o," | ||
"shortname=mixed,nodev,nosuid,dirsync,noatime," | ||
"noexec", ownerUid, ownerGid, permMask, permMask); | ||
|
||
std::vector<std::string> cmd; | ||
cmd.push_back(kMountPath); | ||
cmd.push_back("-o"); | ||
cmd.push_back(mountData.c_str()); | ||
cmd.push_back(source.c_str()); | ||
cmd.push_back(target.c_str()); | ||
|
||
int rc = ForkExecvp(cmd); | ||
if (rc == 0) { | ||
LOG(INFO) << "Mount OK"; | ||
return 0; | ||
} else { | ||
LOG(ERROR) << "Mount failed (code " << rc << ")"; | ||
errno = EIO; | ||
return -1; | ||
} | ||
} | ||
|
||
status_t Format(const std::string& source) { | ||
std::vector<std::string> cmd; | ||
cmd.push_back(kMkfsPath); | ||
cmd.push_back(source); | ||
|
||
int rc = ForkExecvp(cmd); | ||
if (rc == 0) { | ||
LOG(INFO) << "Format OK"; | ||
return 0; | ||
} else { | ||
LOG(ERROR) << "Format failed (code " << rc << ")"; | ||
errno = EIO; | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
|
||
} // namespace ntfs | ||
} // namespace vold | ||
} // namespace android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2015 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef ANDROID_VOLD_NTFS_H | ||
#define ANDROID_VOLD_NTFS_H | ||
|
||
#include <utils/Errors.h> | ||
|
||
#include <string> | ||
|
||
namespace android { | ||
namespace vold { | ||
namespace ntfs { | ||
|
||
bool IsSupported(); | ||
|
||
status_t Check(const std::string& source); | ||
status_t Mount(const std::string& source, const std::string& target, int ownerUid, int ownerGid, | ||
int permMask); | ||
status_t Format(const std::string& source); | ||
|
||
} // namespace ntfs | ||
} // namespace vold | ||
} // namespace android | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters