Merge "Revert "Add NTFS support in vold"" am: 9355e48aaa
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2418459 Change-Id: Iaf9c69e73db2eca74666ffd21dea7cd1ad8a8538 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7ee09fb51b
5 changed files with 2 additions and 194 deletions
|
@ -138,7 +138,6 @@ cc_library_static {
|
|||
"fs/Ext4.cpp",
|
||||
"fs/F2fs.cpp",
|
||||
"fs/Vfat.cpp",
|
||||
"fs/Ntfs.cpp",
|
||||
"model/Disk.cpp",
|
||||
"model/EmulatedVolume.cpp",
|
||||
"model/ObbVolume.cpp",
|
||||
|
|
134
fs/Ntfs.cpp
134
fs/Ntfs.cpp
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2022 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 <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <linux/kdev_t.h>
|
||||
|
||||
#define LOG_TAG "Vold"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <cutils/log.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <selinux/selinux.h>
|
||||
|
||||
#include <logwrap/logwrap.h>
|
||||
|
||||
#include "Ntfs.h"
|
||||
#include "Utils.h"
|
||||
#include "VoldUtil.h"
|
||||
|
||||
using android::base::StringPrintf;
|
||||
|
||||
namespace android {
|
||||
namespace vold {
|
||||
namespace ntfs {
|
||||
|
||||
static const char* kFsckPath = "/system/bin/ntfsfix";
|
||||
static const char* kMkfsPath = "/system/bin/mkntfs";
|
||||
|
||||
static const char* fsName = "ntfs3";
|
||||
|
||||
bool IsSupported() {
|
||||
return access(kFsckPath, X_OK) == 0 && access(kMkfsPath, X_OK) == 0 &&
|
||||
IsFilesystemSupported(fsName);
|
||||
}
|
||||
|
||||
status_t Check(const std::string& source) {
|
||||
std::vector<std::string> cmd;
|
||||
cmd.push_back(kFsckPath);
|
||||
|
||||
// ntfsfix sets the dirty bit by default, which prevents mounting the drive.
|
||||
// -d tells it to instead reset the dirty bit. Technically, this could be dangerous,
|
||||
// but since ntfsfix should report any errors with the drive and separately return
|
||||
// a failed check, this should be relatively safe.
|
||||
cmd.push_back("-d");
|
||||
|
||||
cmd.push_back(source);
|
||||
|
||||
int rc = ForkExecvpTimeout(cmd, kUntrustedFsckSleepTime, sFsckUntrustedContext);
|
||||
if (rc == 0) {
|
||||
LOG(INFO) << "Check NTFS OK";
|
||||
return 0;
|
||||
} else {
|
||||
LOG(ERROR) << "Check NTFS failed (code " << rc << ")";
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
status_t Mount(const std::string& source, const std::string& target, bool ro, bool remount,
|
||||
bool executable, int ownerUid, int ownerGid, int permMask) {
|
||||
unsigned long flags = MS_NODEV | MS_NOSUID | MS_DIRSYNC | MS_NOATIME;
|
||||
|
||||
flags |= (executable ? 0 : MS_NOEXEC);
|
||||
flags |= (ro ? MS_RDONLY : 0);
|
||||
flags |= (remount ? MS_REMOUNT : 0);
|
||||
|
||||
// Android mount does not support "utf8" as an option. We use the deprecated iocharset instead.
|
||||
auto mountData = android::base::StringPrintf("uid=%d,gid=%d,fmask=%o,dmask=%o,iocharset=%s",
|
||||
ownerUid, ownerGid, permMask, permMask, "utf8");
|
||||
|
||||
int rc = mount(source.c_str(), target.c_str(), fsName, flags, mountData.c_str());
|
||||
|
||||
if (rc && errno == EROFS) {
|
||||
LOG(ERROR) << source << " appears to be a read only filesystem - retrying mount RO";
|
||||
flags |= MS_RDONLY;
|
||||
rc = mount(source.c_str(), target.c_str(), fsName, flags, mountData.c_str());
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
status_t Format(const std::string& source, unsigned int numSectors) {
|
||||
std::vector<std::string> cmd;
|
||||
cmd.push_back(kMkfsPath);
|
||||
cmd.push_back(source);
|
||||
|
||||
if (numSectors) {
|
||||
cmd.push_back(StringPrintf("%u", numSectors));
|
||||
}
|
||||
|
||||
int rc = ForkExecvp(cmd);
|
||||
if (rc == 0) {
|
||||
LOG(INFO) << "Filesystem formatted OK";
|
||||
return 0;
|
||||
} else {
|
||||
LOG(ERROR) << "Format failed with error code: " << rc;
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ntfs
|
||||
} // namespace vold
|
||||
} // namespace android
|
39
fs/Ntfs.h
39
fs/Ntfs.h
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2022 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, bool ro, bool remount,
|
||||
bool executable, int ownerUid, int ownerGid, int permMask);
|
||||
status_t Format(const std::string& source, unsigned int numSectors);
|
||||
|
||||
} // namespace ntfs
|
||||
} // namespace vold
|
||||
} // namespace android
|
||||
|
||||
#endif
|
3
main.cpp
3
main.cpp
|
@ -74,8 +74,7 @@ int main(int argc, char** argv) {
|
|||
LOG(DEBUG) << "Detected support for:"
|
||||
<< (android::vold::IsFilesystemSupported("ext4") ? " ext4" : "")
|
||||
<< (android::vold::IsFilesystemSupported("f2fs") ? " f2fs" : "")
|
||||
<< (android::vold::IsFilesystemSupported("vfat") ? " vfat" : "")
|
||||
<< (android::vold::IsFilesystemSupported("ntfs3") ? " ntfs3" : "");
|
||||
<< (android::vold::IsFilesystemSupported("vfat") ? " vfat" : "");
|
||||
|
||||
VolumeManager* vm;
|
||||
NetlinkManager* nm;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "Utils.h"
|
||||
#include "VolumeManager.h"
|
||||
#include "fs/Exfat.h"
|
||||
#include "fs/Ntfs.h"
|
||||
#include "fs/Vfat.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
@ -111,11 +110,6 @@ status_t PublicVolume::doMount() {
|
|||
LOG(ERROR) << getId() << " failed filesystem check";
|
||||
return -EIO;
|
||||
}
|
||||
} else if (mFsType == "ntfs" && ntfs::IsSupported()) {
|
||||
if (ntfs::Check(mDevPath)) {
|
||||
LOG(ERROR) << getId() << " failed filesystem check";
|
||||
return -EIO;
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << getId() << " unsupported filesystem " << mFsType;
|
||||
return -EIO;
|
||||
|
@ -158,12 +152,6 @@ status_t PublicVolume::doMount() {
|
|||
PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
|
||||
return -EIO;
|
||||
}
|
||||
} else if (mFsType == "ntfs") {
|
||||
if (ntfs::Mount(mDevPath, mRawPath, false, false, false, AID_ROOT,
|
||||
(isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007)) {
|
||||
PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
|
||||
return -EIO;
|
||||
}
|
||||
}
|
||||
|
||||
if (getMountFlags() & MountFlags::kPrimary) {
|
||||
|
@ -322,10 +310,9 @@ status_t PublicVolume::doUnmount() {
|
|||
status_t PublicVolume::doFormat(const std::string& fsType) {
|
||||
bool isVfatSup = vfat::IsSupported();
|
||||
bool isExfatSup = exfat::IsSupported();
|
||||
bool isNtfsSup = ntfs::IsSupported();
|
||||
status_t res = OK;
|
||||
|
||||
enum { NONE, VFAT, EXFAT, NTFS } fsPick = NONE;
|
||||
enum { NONE, VFAT, EXFAT } fsPick = NONE;
|
||||
|
||||
// Resolve auto requests
|
||||
if (fsType == "auto" && isVfatSup && isExfatSup) {
|
||||
|
@ -354,8 +341,6 @@ status_t PublicVolume::doFormat(const std::string& fsType) {
|
|||
fsPick = VFAT;
|
||||
} else if (fsType == "exfat" && isExfatSup) {
|
||||
fsPick = EXFAT;
|
||||
} else if (fsType == "ntfs" && isNtfsSup) {
|
||||
fsPick = NTFS;
|
||||
}
|
||||
|
||||
if (WipeBlockDevice(mDevPath) != OK) {
|
||||
|
@ -366,8 +351,6 @@ status_t PublicVolume::doFormat(const std::string& fsType) {
|
|||
res = vfat::Format(mDevPath, 0);
|
||||
} else if (fsPick == EXFAT) {
|
||||
res = exfat::Format(mDevPath);
|
||||
} else if (fsPick == NTFS) {
|
||||
res = ntfs::Format(mDevPath, 0);
|
||||
} else {
|
||||
LOG(ERROR) << "Unsupported filesystem " << fsType;
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Reference in a new issue