(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/Android.bp b/Android.bp
index 81cd274..8f413c4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -134,10 +134,8 @@
         "fs/Exfat.cpp",
         "fs/Ext4.cpp",
         "fs/F2fs.cpp",
-        "fs/Ntfs.cpp",
         "fs/Vfat.cpp",
         "model/Disk.cpp",
-        "model/DiskPartition.cpp",
         "model/EmulatedVolume.cpp",
         "model/ObbVolume.cpp",
         "model/PrivateVolume.cpp",
diff --git a/Utils.cpp b/Utils.cpp
index a7e85f2..e8049ed 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -1055,10 +1055,6 @@
         PLOG(ERROR) << "Failed to read supported filesystems";
         return false;
     }
-
-    /* fuse filesystems */
-    supported.append("fuse\tntfs\n");
-
     return supported.find(fsType + "\n") != std::string::npos;
 }
 
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 8190e7e..a7d39c1 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -227,13 +227,8 @@
                         flags |= android::vold::Disk::Flags::kUsb;
                     }
 
-                    android::vold::Disk* disk = (source->getPartNum() == -1) ?
-                            new android::vold::Disk(eventPath, device,
-                                    source->getNickname(), flags) :
-                            new android::vold::DiskPartition(eventPath, device,
-                                    source->getNickname(), flags,
-                                    source->getPartNum(),
-                                    source->getFsType(), source->getMntOpts());
+                    auto disk =
+                        new android::vold::Disk(eventPath, device, source->getNickname(), flags);
                     handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
                     break;
                 }
diff --git a/VolumeManager.h b/VolumeManager.h
index e664e49..a8117c9 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -37,7 +37,6 @@
 #include "android/os/IVoldListener.h"
 
 #include "model/Disk.h"
-#include "model/DiskPartition.h"
 #include "model/VolumeBase.h"
 
 class VolumeManager {
@@ -62,30 +61,20 @@
 
     class DiskSource {
       public:
-        DiskSource(const std::string& sysPattern, const std::string& nickname,
-                int partnum, int flags,
-                const std::string& fstype, const std::string mntopts)
-                : mSysPattern(sysPattern), mNickname(nickname),
-                mPartNum(partnum), mFlags(flags),
-                mFsType(fstype), mMntOpts(mntopts) {}
+        DiskSource(const std::string& sysPattern, const std::string& nickname, int flags)
+            : mSysPattern(sysPattern), mNickname(nickname), mFlags(flags) {}
 
         bool matches(const std::string& sysPath) {
             return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
         }
 
         const std::string& getNickname() const { return mNickname; }
-        int getPartNum() const { return mPartNum; }
         int getFlags() const { return mFlags; }
-        const std::string& getFsType() { return mFsType; }
-        const std::string& getMntOpts() { return mMntOpts; }
 
       private:
         std::string mSysPattern;
         std::string mNickname;
-        int mPartNum;
         int mFlags;
-        std::string mFsType;
-        std::string mMntOpts;
     };
 
     void addDiskSource(const std::shared_ptr<DiskSource>& diskSource);
diff --git a/fs/Ext4.cpp b/fs/Ext4.cpp
index 0ae5cb3..52f6772 100644
--- a/fs/Ext4.cpp
+++ b/fs/Ext4.cpp
@@ -38,7 +38,6 @@
 #include <cutils/properties.h>
 #include <fscrypt/fscrypt.h>
 #include <logwrap/logwrap.h>
-#include <private/android_filesystem_config.h>
 #include <selinux/selinux.h>
 
 #include "Ext4.h"
@@ -61,7 +60,7 @@
            IsFilesystemSupported("ext4");
 }
 
-status_t Check(const std::string& source, const std::string& target, bool trusted) {
+status_t Check(const std::string& source, const std::string& target) {
     // The following is shamelessly borrowed from fs_mgr.c, so it should be
     // kept in sync with any changes over there.
 
@@ -115,50 +114,33 @@
         cmd.push_back("-y");
         cmd.push_back(c_source);
 
-        return ForkExecvp(cmd, nullptr, trusted ? sFsckContext : sFsckUntrustedContext);
+        // ext4 devices are currently always trusted
+        return ForkExecvp(cmd, nullptr, sFsckContext);
     }
 
     return 0;
 }
 
 status_t Mount(const std::string& source, const std::string& target, bool ro, bool remount,
-               bool executable, const std::string& opts /* = "" */, bool trusted, bool portable) {
+               bool executable) {
     int rc;
     unsigned long flags;
 
-    std::string data(opts);
-
-    if (portable) {
-        if (!data.empty()) {
-            data += ",";
-        }
-        data += "context=u:object_r:sdcard_posix:s0";
-    }
     const char* c_source = source.c_str();
     const char* c_target = target.c_str();
-    const char* c_data = data.c_str();
 
-    flags = MS_NOATIME | MS_NODEV | MS_NOSUID;
-
-    // Only use MS_DIRSYNC if we're not mounting adopted storage
-    if (!trusted) {
-        flags |= MS_DIRSYNC;
-    }
+    flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;
 
     flags |= (executable ? 0 : MS_NOEXEC);
     flags |= (ro ? MS_RDONLY : 0);
     flags |= (remount ? MS_REMOUNT : 0);
 
-    rc = mount(c_source, c_target, "ext4", flags, c_data);
-    if (portable && rc == 0) {
-        chown(c_target, AID_MEDIA_RW, AID_MEDIA_RW);
-        chmod(c_target, 0775);
-    }
+    rc = mount(c_source, c_target, "ext4", flags, NULL);
 
     if (rc && errno == EROFS) {
         LOG(ERROR) << source << " appears to be a read only filesystem - retrying mount RO";
         flags |= MS_RDONLY;
-        rc = mount(c_source, c_target, "ext4", flags, c_data);
+        rc = mount(c_source, c_target, "ext4", flags, NULL);
     }
 
     return rc;
diff --git a/fs/Ext4.h b/fs/Ext4.h
index ad2c966..329f302 100644
--- a/fs/Ext4.h
+++ b/fs/Ext4.h
@@ -27,10 +27,9 @@
 
 bool IsSupported();
 
-status_t Check(const std::string& source, const std::string& target, bool trusted);
+status_t Check(const std::string& source, const std::string& target);
 status_t Mount(const std::string& source, const std::string& target, bool ro, bool remount,
-               bool executable, const std::string& opts = "", bool trusted = false,
-               bool portable = false);
+               bool executable);
 status_t Format(const std::string& source, unsigned long numSectors, const std::string& target);
 status_t Resize(const std::string& source, unsigned long numSectors);
 
diff --git a/fs/F2fs.cpp b/fs/F2fs.cpp
index 4bab9e4..55b0823 100644
--- a/fs/F2fs.cpp
+++ b/fs/F2fs.cpp
@@ -22,12 +22,10 @@
 #include <android-base/stringprintf.h>
 #include <logwrap/logwrap.h>
 #include <fscrypt/fscrypt.h>
-#include <private/android_filesystem_config.h>
 
 #include <string>
 #include <vector>
 
-#include <sys/stat.h>
 #include <sys/mount.h>
 
 using android::base::StringPrintf;
@@ -44,47 +42,26 @@
            IsFilesystemSupported("f2fs");
 }
 
-status_t Check(const std::string& source, bool trusted) {
+status_t Check(const std::string& source) {
     std::vector<std::string> cmd;
     cmd.push_back(kFsckPath);
     cmd.push_back("-a");
     cmd.push_back(source);
 
-    return ForkExecvp(cmd, nullptr, trusted ? sFsckContext : sFsckUntrustedContext);
+    // f2fs devices are currently always trusted
+    return ForkExecvp(cmd, nullptr, sFsckContext);
 }
 
-status_t Mount(const std::string& source, const std::string& target,
-        const std::string& opts /* = "" */, bool trusted, bool portable) {
-    std::string data(opts);
-
-    if (portable) {
-        if (!data.empty()) {
-            data += ",";
-        }
-        data += "context=u:object_r:sdcard_posix:s0";
-    }
-
+status_t Mount(const std::string& source, const std::string& target) {
     const char* c_source = source.c_str();
     const char* c_target = target.c_str();
-    const char* c_data = data.c_str();
+    unsigned long flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;
 
-    unsigned long flags = MS_NOATIME | MS_NODEV | MS_NOSUID;
-
-    // Only use MS_DIRSYNC if we're not mounting adopted storage
-    if (!trusted) {
-        flags |= MS_DIRSYNC;
-    }
-
-    int res = mount(c_source, c_target, "f2fs", flags, c_data);
-    if (portable && res == 0) {
-        chown(c_target, AID_MEDIA_RW, AID_MEDIA_RW);
-        chmod(c_target, 0775);
-    }
-
+    int res = mount(c_source, c_target, "f2fs", flags, NULL);
     if (res != 0) {
         PLOG(ERROR) << "Failed to mount " << source;
         if (errno == EROFS) {
-            res = mount(c_source, c_target, "f2fs", flags | MS_RDONLY, c_data);
+            res = mount(c_source, c_target, "f2fs", flags | MS_RDONLY, NULL);
             if (res != 0) {
                 PLOG(ERROR) << "Failed to mount read-only " << source;
             }
diff --git a/fs/F2fs.h b/fs/F2fs.h
index ecfc0c7..f710212 100644
--- a/fs/F2fs.h
+++ b/fs/F2fs.h
@@ -27,10 +27,8 @@
 
 bool IsSupported();
 
-status_t Check(const std::string& source, bool trusted);
-status_t Mount(const std::string& source, const std::string& target,
-        const std::string& opts = "", bool trusted = false,
-        bool portable = false);
+status_t Check(const std::string& source);
+status_t Mount(const std::string& source, const std::string& target);
 status_t Format(const std::string& source);
 
 }  // namespace f2fs
diff --git a/fs/Ntfs.cpp b/fs/Ntfs.cpp
deleted file mode 100644
index 6be65bc..0000000
--- a/fs/Ntfs.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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
diff --git a/fs/Ntfs.h b/fs/Ntfs.h
deleted file mode 100644
index 2f002b2..0000000
--- a/fs/Ntfs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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
diff --git a/main.cpp b/main.cpp
index 5b1bdf7..b07ee68 100644
--- a/main.cpp
+++ b/main.cpp
@@ -72,10 +72,8 @@
     ATRACE_BEGIN("main");
 
     LOG(DEBUG) << "Detected support for:"
-               << (android::vold::IsFilesystemSupported("exfat") ? " exfat" : "")
                << (android::vold::IsFilesystemSupported("ext4") ? " ext4" : "")
                << (android::vold::IsFilesystemSupported("f2fs") ? " f2fs" : "")
-               << (android::vold::IsFilesystemSupported("ntfs") ? " ntfs" : "")
                << (android::vold::IsFilesystemSupported("vfat") ? " vfat" : "");
 
     VolumeManager* vm;
@@ -260,17 +258,13 @@
         }
 
         if (entry.fs_mgr_flags.vold_managed) {
+            if (entry.fs_mgr_flags.nonremovable) {
+                LOG(WARNING) << "nonremovable no longer supported; ignoring volume";
+                continue;
+            }
+
             std::string sysPattern(entry.blk_device);
-            std::string fstype;
-            if (!entry.fs_type.empty()) {
-                fstype = entry.fs_type;
-            }
-            std::string mntopts;
-            if (!entry.fs_options.empty()) {
-                mntopts = entry.fs_options;
-            }
             std::string nickname(entry.label);
-            int partnum = entry.partnum;
             int flags = 0;
 
             if (entry.is_encryptable()) {
@@ -281,13 +275,9 @@
                 android::base::GetBoolProperty("vold.debug.default_primary", false)) {
                 flags |= android::vold::Disk::Flags::kDefaultPrimary;
             }
-            if (entry.fs_mgr_flags.nonremovable) {
-                flags |= android::vold::Disk::Flags::kNonRemovable;
-            }
 
             vm->addDiskSource(std::shared_ptr<VolumeManager::DiskSource>(
-                new VolumeManager::DiskSource(sysPattern, nickname, partnum, flags,
-                        fstype, mntopts)));
+                new VolumeManager::DiskSource(sysPattern, nickname, flags)));
         }
     }
     return 0;
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);
 };