OSDN Git Service

vold3: support UDF (Universal Disk Format)
authorChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 25 Mar 2017 16:46:42 +0000 (00:46 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 29 Mar 2019 10:37:17 +0000 (18:37 +0800)
Refer to https://en.wikipedia.org/wiki/Universal_Disk_Format.

fs/Iso9660.cpp
fs/Iso9660.h
model/Disk.cpp
model/PublicVolume.cpp

index 3bbfaee..a9e3e6f 100644 (file)
@@ -29,8 +29,7 @@ bool IsSupported() {
 }
 
 status_t Mount(const std::string& source, const std::string& target,
-        int ownerUid, int ownerGid ) {
-    int rc;
+        int ownerUid, int ownerGid, const char* type) {
     unsigned long flags;
     char mountData[256];
 
@@ -42,12 +41,7 @@ status_t Mount(const std::string& source, const std::string& target,
     snprintf(mountData, sizeof(mountData),
             "utf8,uid=%d,gid=%d", ownerUid, ownerGid);
 
-    rc = mount(c_source, c_target, "iso9660", flags, mountData);
-    if (rc != 0) {
-        rc = mount(c_source, c_target, "udf", flags, mountData);
-    }
-
-    return rc;
+    return mount(c_source, c_target, type, flags, mountData);
 }
 
 }  // namespace iso9660
index 3bd57bc..1d730a6 100644 (file)
@@ -25,7 +25,7 @@ namespace iso9660 {
 
 bool IsSupported();
 status_t Mount(const std::string& source, const std::string& target,
-        int ownerUid, int ownerGid );
+        int ownerUid, int ownerGid, const char* type);
 
 }  // namespace iso9660
 }  // namespace vold
index bdba1cb..629a729 100644 (file)
@@ -322,8 +322,8 @@ status_t Disk::readPartitions() {
 
         std::string fsType, unused;
         if (ReadMetadataUntrusted(mDevPath, &fsType, &unused, &unused) == OK) {
-            if (fsType == "iso9660") {
-                LOG(INFO) << "Detect iso9660";
+            if (fsType == "iso9660" || fsType == "udf") {
+                LOG(INFO) << "Detect " << fsType;
                 createPublicVolume(mDevice);
                 res = OK;
             }
@@ -373,6 +373,7 @@ status_t Disk::readPartitions() {
                 }
 
                 switch (type) {
+                    case 0x00: // ISO9660
                     case 0x06:  // FAT16
                     case 0x07:  // HPFS/NTFS/exFAT
                     case 0x0b:  // W95 FAT32 (LBA)
index 5c91175..7182a42 100644 (file)
@@ -62,7 +62,7 @@ status_t PublicVolume::readMetadata() {
     status_t res = ReadMetadataUntrusted(mDevPath, &mFsType, &mFsUuid, &mFsLabel);
 
     // iso9660 has no UUID, we use label as UUID
-    if (mFsType == "iso9660" && mFsUuid.empty() && !mFsLabel.empty()) {
+    if ((mFsType == "iso9660" || mFsType == "udf") && mFsUuid.empty() && !mFsLabel.empty()) {
         std::replace(mFsLabel.begin(), mFsLabel.end(), ' ', '_');
         mFsUuid = mFsLabel;
     }
@@ -148,7 +148,7 @@ status_t PublicVolume::doMount() {
         ret = ntfs::Check(mDevPath);
     } else if (mFsType == "vfat") {
         ret = vfat::Check(mDevPath);
-    } else if (mFsType != "iso9660") {
+    } else if (mFsType != "iso9660" && mFsType != "udf") {
         LOG(WARNING) << getId() << " unsupported filesystem check, skipping";
     }
     if (ret) {
@@ -163,8 +163,9 @@ status_t PublicVolume::doMount() {
                 false, true);
     } else if (mFsType == "f2fs") {
         ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts, false, true);
-    } else if (mFsType == "iso9660") {
-        ret = iso9660::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW);
+    } else if (mFsType == "iso9660" || mFsType == "udf") {
+        ret = iso9660::Mount(mDevPath, mRawPath,
+                AID_MEDIA_RW, AID_MEDIA_RW, mFsType.c_str());
     } else if (mFsType == "ntfs") {
         ret = ntfs::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW, 0007);
     } else if (mFsType == "vfat") {