(SQUASHED) Revert ext4/f2fs/ntfs support for external sdcards
----------
Revert "vold: Accept Linux GPT partitions on external SD cards"
- This reverts commit 4c9b0b10431e6b0ae9b2853b4f0e858c0459e43c.
Revert "Fix the group permissions of the sdcard root."
- This reverts commit c18032ad6b5ab204c7a83dc08a114814c7f16f50.
Revert "vold ext4/f2fs: do not use dirsync if we're mounting adopted storage"
- This reverts commit c0871375fcc398ca13cf325ab11e41b38f866b25.
Revert "vold: Mount ext4/f2fs portable storage with sdcard_posix"
- This reverts commit c28dd585e6f4efa2d5be0ef65be6d17f362f7cc6.
Revert "vold: Honor mount options for ext4/f2fs partitions"
- This reverts commit 9f8b4689157a6460f6f55b88f4ffb3511a6bbf3f.
Revert "vold: Support internal storage partitions"
- This reverts commit 34e1e5dbbd9509e9410bffacbc589b74d49d56ff.
Revert "vold: Fix fsck on public volumes"
- This reverts commit 779baf99cfa4590f7847d6c7c5f8a0697e085ab7.
Revert "vold: add support for more filesystems for public storage"
- This reverts commit 16cbb8dbc85db045c359c40fc29deacfa5146386.
----------
Change-Id: Ib0eb075545490e3cb7df73bfa9d55a51262fca6a
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
diff --git a/model/Disk.cpp b/model/Disk.cpp
index c1453b8..42dbd4f 100644
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -77,7 +77,6 @@
static const unsigned int kMajorBlockDynamicMax = 512;
static const char* kGptBasicData = "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7";
-static const char* kGptLinuxFilesystem = "0FC63DAF-8483-4772-8E79-3D69D8477DE4";
static const char* kGptAndroidMeta = "19A710A2-B3CA-11E4-B026-10604B889DCF";
static const char* kGptAndroidExpand = "193D1EA4-B3CA-11E4-B075-10604B889DCF";
@@ -172,10 +171,8 @@
return OK;
}
-void Disk::createPublicVolume(dev_t device,
- const std::string& fstype /* = "" */,
- const std::string& mntopts /* = "" */) {
- auto vol = std::shared_ptr<VolumeBase>(new PublicVolume(device, fstype, mntopts));
+void Disk::createPublicVolume(dev_t device) {
+ auto vol = std::shared_ptr<VolumeBase>(new PublicVolume(device));
if (mJustPartitioned) {
LOG(DEBUG) << "Device just partitioned; silently formatting";
vol->setSilent(true);
@@ -404,7 +401,6 @@
case 0x0b: // W95 FAT32 (LBA)
case 0x0c: // W95 FAT32 (LBA)
case 0x0e: // W95 FAT16 (LBA)
- case 0x83: // Linux EXT4/F2FS/...
createPublicVolume(partDevice);
break;
}
@@ -414,8 +410,7 @@
if (++it == split.end()) continue;
auto partGuid = *it;
- if (android::base::EqualsIgnoreCase(typeGuid, kGptBasicData)
- || android::base::EqualsIgnoreCase(typeGuid, kGptLinuxFilesystem)) {
+ if (android::base::EqualsIgnoreCase(typeGuid, kGptBasicData)) {
createPublicVolume(partDevice);
} else if (android::base::EqualsIgnoreCase(typeGuid, kGptAndroidExpand)) {
createPrivateVolume(partDevice, partGuid);
diff --git a/model/Disk.h b/model/Disk.h
index 7e90c85..cc1d66d 100644
--- a/model/Disk.h
+++ b/model/Disk.h
@@ -59,8 +59,6 @@
/* Flag that disk is a visible Stub disk, i.e., disk that is managed from outside
* Android (e.g., ARC++) and visible to apps. */
kStubVisible = 1 << 6,
- /* Flag that disk is non-removable */
- kNonRemovable = 1 << 7,
};
const std::string& getId() const { return mId; }
@@ -80,20 +78,20 @@
std::vector<std::shared_ptr<VolumeBase>> getVolumes() const;
- virtual status_t create();
- virtual status_t destroy();
+ status_t create();
+ status_t destroy();
- virtual status_t readMetadata();
- virtual status_t readPartitions();
+ status_t readMetadata();
+ status_t readPartitions();
void initializePartition(std::shared_ptr<StubVolume> vol);
status_t unmountAll();
- virtual status_t partitionPublic();
- virtual status_t partitionPrivate();
- virtual status_t partitionMixed(int8_t ratio);
+ status_t partitionPublic();
+ status_t partitionPrivate();
+ status_t partitionMixed(int8_t ratio);
- protected:
+ private:
/* ID that uniquely references this disk */
std::string mId;
/* Original event path */
@@ -121,9 +119,7 @@
/* Flag that we need to skip first disk change events after partitioning*/
bool mSkipChange;
- void createPublicVolume(dev_t device,
- const std::string& fstype = "",
- const std::string& mntopts = "");
+ void createPublicVolume(dev_t device);
void createPrivateVolume(dev_t device, const std::string& partGuid);
void createStubVolume();
diff --git a/model/DiskPartition.cpp b/model/DiskPartition.cpp
deleted file mode 100644
index 10b2f95..0000000
--- a/model/DiskPartition.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2015 Cyanogen, Inc.
- *
- * 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 "DiskPartition.h"
-#include "PublicVolume.h"
-#include "PrivateVolume.h"
-#include "Utils.h"
-#include "VolumeBase.h"
-#include "VolumeManager.h"
-
-#include <android-base/file.h>
-#include <android-base/stringprintf.h>
-#include <android-base/logging.h>
-#include <diskconfig/diskconfig.h>
-
-#include <vector>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/sysmacros.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-
-using android::base::ReadFileToString;
-using android::base::WriteStringToFile;
-using android::base::StringPrintf;
-
-namespace android {
-namespace vold {
-
-DiskPartition::DiskPartition(const std::string& eventPath, dev_t device,
- const std::string& nickname, int flags, int partnum,
- const std::string& fstype /* = "" */, const std::string& mntopts /* = "" */) :
- Disk(eventPath, device, nickname, flags),
- mPartNum(partnum),
- mFsType(fstype),
- mMntOpts(mntopts) {
- // Empty
-}
-
-DiskPartition::~DiskPartition() {
- // Empty
-}
-
-status_t DiskPartition::create() {
- CHECK(!mCreated);
- mCreated = true;
- auto listener = VolumeManager::Instance()->getListener();
- if (listener) listener->onDiskCreated(getId(), mFlags);
- dev_t partDevice = makedev(major(mDevice), minor(mDevice) + mPartNum);
- createPublicVolume(partDevice, mFsType, mMntOpts);
- return OK;
-}
-
-status_t DiskPartition::destroy() {
- CHECK(mCreated);
- destroyAllVolumes();
- mCreated = false;
- auto listener = VolumeManager::Instance()->getListener();
- if (listener) listener->onDiskDestroyed(getId());
- return OK;
-}
-
-status_t DiskPartition::partitionPublic() {
- return -1;
-}
-
-status_t DiskPartition::partitionPrivate() {
- return -1;
-}
-
-status_t DiskPartition::partitionMixed(int8_t ratio) {
- return -1;
-}
-
-} // namespace vold
-} // namespace android
-
diff --git a/model/DiskPartition.h b/model/DiskPartition.h
deleted file mode 100644
index 4c9ab08..0000000
--- a/model/DiskPartition.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015 Cyanogen, Inc.
- *
- * 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_DISKPARTITION_H
-#define ANDROID_VOLD_DISKPARTITION_H
-
-#include "Disk.h"
-
-namespace android {
-namespace vold {
-
-/*
- * Representation of a single partition on physical media. Useful for
- * single media partitions such as "internal" sdcard partitions.
- */
-
-class DiskPartition : public Disk {
-public:
- DiskPartition(const std::string& eventPath, dev_t device,
- const std::string& nickname,
- int flags, int partnum,
- const std::string& fstype = "", const std::string& mntopts = "");
- virtual ~DiskPartition();
-
- virtual status_t create();
- virtual status_t destroy();
-
- virtual status_t partitionPublic();
- virtual status_t partitionPrivate();
- virtual status_t partitionMixed(int8_t ratio);
-
-private:
- /* Partition number */
- int mPartNum;
- /* Filesystem type */
- std::string mFsType;
- /* Mount options */
- std::string mMntOpts;
-};
-
-} // namespace vold
-} // namespace android
-
-#endif
-
diff --git a/model/PrivateVolume.cpp b/model/PrivateVolume.cpp
index c794a8c..3334cbb 100644
--- a/model/PrivateVolume.cpp
+++ b/model/PrivateVolume.cpp
@@ -155,7 +155,7 @@
}
if (mFsType == "ext4") {
- int res = ext4::Check(mDmDevPath, mPath, true);
+ int res = ext4::Check(mDmDevPath, mPath);
if (res == 0 || res == 1) {
LOG(DEBUG) << getId() << " passed filesystem check";
} else {
@@ -163,13 +163,13 @@
return -EIO;
}
- if (ext4::Mount(mDmDevPath, mPath, false, false, true, "", true)) {
+ if (ext4::Mount(mDmDevPath, mPath, false, false, true)) {
PLOG(ERROR) << getId() << " failed to mount";
return -EIO;
}
} else if (mFsType == "f2fs") {
- int res = f2fs::Check(mDmDevPath, true);
+ int res = f2fs::Check(mDmDevPath);
if (res == 0) {
LOG(DEBUG) << getId() << " passed filesystem check";
} else {
@@ -177,7 +177,7 @@
return -EIO;
}
- if (f2fs::Mount(mDmDevPath, mPath, "", true)) {
+ if (f2fs::Mount(mDmDevPath, mPath)) {
PLOG(ERROR) << getId() << " failed to mount";
return -EIO;
}
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index d2bc5e3..bf54c95 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -20,9 +20,6 @@
#include "Utils.h"
#include "VolumeManager.h"
#include "fs/Exfat.h"
-#include "fs/Ext4.h"
-#include "fs/F2fs.h"
-#include "fs/Ntfs.h"
#include "fs/Vfat.h"
#include <android-base/logging.h>
@@ -50,10 +47,7 @@
static const char* kAsecPath = "/mnt/secure/asec";
-PublicVolume::PublicVolume(dev_t device, const std::string& fstype /* = "" */,
- const std::string& mntopts /* = "" */)
- : VolumeBase(Type::kPublic), mDevice(device),
- mFsType(fstype), mMntOpts(mntopts) {
+PublicVolume::PublicVolume(dev_t device) : VolumeBase(Type::kPublic), mDevice(device) {
setId(StringPrintf("public:%u,%u", major(device), minor(device)));
mDevPath = StringPrintf("/dev/block/vold/%s", getId().c_str());
mFuseMounted = false;
@@ -106,7 +100,17 @@
bool isVisible = isVisibleForWrite();
readMetadata();
- if (!IsFilesystemSupported(mFsType)) {
+ if (mFsType == "vfat" && vfat::IsSupported()) {
+ if (vfat::Check(mDevPath)) {
+ LOG(ERROR) << getId() << " failed filesystem check";
+ return -EIO;
+ }
+ } else if (mFsType == "exfat" && exfat::IsSupported()) {
+ if (exfat::Check(mDevPath)) {
+ LOG(ERROR) << getId() << " failed filesystem check";
+ return -EIO;
+ }
+ } else {
LOG(ERROR) << getId() << " unsupported filesystem " << mFsType;
return -EIO;
}
@@ -136,45 +140,18 @@
return -errno;
}
- int ret = 0;
- if (mFsType == "exfat") {
- ret = exfat::Check(mDevPath);
- } else if (mFsType == "ext4") {
- ret = ext4::Check(mDevPath, mRawPath, false);
- } else if (mFsType == "f2fs") {
- ret = f2fs::Check(mDevPath, false);
- } else if (mFsType == "ntfs") {
- ret = ntfs::Check(mDevPath);
- } else if (mFsType == "vfat") {
- ret = vfat::Check(mDevPath);
- } else {
- LOG(WARNING) << getId() << " unsupported filesystem check, skipping";
- }
- if (ret) {
- LOG(ERROR) << getId() << " failed filesystem check";
- return -EIO;
- }
-
- if (mFsType == "exfat") {
- ret = exfat::Mount(mDevPath, mRawPath, AID_ROOT,
- (isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007);
- } else if (mFsType == "ext4") {
- ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts,
- false, true);
- } else if (mFsType == "f2fs") {
- ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts, false, true);
- } else if (mFsType == "ntfs") {
- ret = ntfs::Mount(mDevPath, mRawPath, AID_ROOT,
- (isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007);
- } else if (mFsType == "vfat") {
- ret = vfat::Mount(mDevPath, mRawPath, false, false, false, AID_ROOT,
- (isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007, true);
- } else {
- ret = ::mount(mDevPath.c_str(), mRawPath.c_str(), mFsType.c_str(), 0, NULL);
- }
- if (ret) {
- PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
- return -EIO;
+ if (mFsType == "vfat") {
+ if (vfat::Mount(mDevPath, mRawPath, false, false, false, AID_ROOT,
+ (isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007, true)) {
+ PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
+ return -EIO;
+ }
+ } else if (mFsType == "exfat") {
+ if (exfat::Mount(mDevPath, mRawPath, AID_ROOT,
+ (isVisible ? AID_MEDIA_RW : AID_EXTERNAL_STORAGE), 0007)) {
+ PLOG(ERROR) << getId() << " failed to mount " << mDevPath;
+ return -EIO;
+ }
}
if (getMountFlags() & MountFlags::kPrimary) {
@@ -357,7 +334,7 @@
useVfat = false;
}
- if (!IsFilesystemSupported(fsType) && !useVfat && !useExfat) {
+ if (!useVfat && !useExfat) {
LOG(ERROR) << "Unsupported filesystem " << fsType;
return -EINVAL;
}
@@ -370,16 +347,6 @@
res = vfat::Format(mDevPath, 0);
} else if (useExfat) {
res = exfat::Format(mDevPath);
- } else if (fsType == "ext4") {
- res = ext4::Format(mDevPath, 0, mRawPath);
- } else if (fsType == "f2fs") {
- res = f2fs::Format(mDevPath);
- } else if (fsType == "ntfs") {
- res = ntfs::Format(mDevPath);
- } else {
- LOG(ERROR) << getId() << " unrecognized filesystem " << fsType;
- res = -1;
- errno = EIO;
}
if (res != OK) {
diff --git a/model/PublicVolume.h b/model/PublicVolume.h
index 9235bad..3156b53 100644
--- a/model/PublicVolume.h
+++ b/model/PublicVolume.h
@@ -39,8 +39,7 @@
*/
class PublicVolume : public VolumeBase {
public:
- explicit PublicVolume(dev_t device, const std::string& mntopts = "",
- const std::string& fstype = "");
+ explicit PublicVolume(dev_t device);
virtual ~PublicVolume();
protected:
@@ -78,8 +77,6 @@
std::string mFsUuid;
/* User-visible filesystem label */
std::string mFsLabel;
- /* Mount options */
- std::string mMntOpts;
DISALLOW_COPY_AND_ASSIGN(PublicVolume);
};