Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-vold: Commit

system/vold


Commit MetaInfo

Revisión475e6768f61544feef6f00b9c58dffa4e3108b4f (tree)
Tiempo2019-12-17 14:19:56
AutorLuo Chunbo <luochunbo@jide...>
CommiterChih-Wei Huang

Log Message

vold: ISO9660 support

Ref: T7691

Change-Id: Ifc602781e7d87aea9f3181263e09ffe143e9a231
Signed-off-by: Luo Chunbo <luochunbo@jidemail.com>

Cambiar Resumen

Diferencia incremental

--- a/Android.bp
+++ b/Android.bp
@@ -125,6 +125,7 @@ cc_library_static {
125125 "fs/Exfat.cpp",
126126 "fs/Ext4.cpp",
127127 "fs/F2fs.cpp",
128+ "fs/Iso9660.cpp",
128129 "fs/Ntfs.cpp",
129130 "fs/Vfat.cpp",
130131 "model/Disk.cpp",
--- /dev/null
+++ b/fs/Iso9660.cpp
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (C) 2008 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#include <stdio.h>
18+#include <sys/mount.h>
19+#include <utils/Errors.h>
20+#include "Iso9660.h"
21+#include "Utils.h"
22+
23+namespace android {
24+namespace vold {
25+namespace iso9660 {
26+
27+bool IsSupported() {
28+ return IsFilesystemSupported("iso9660");
29+}
30+
31+status_t Mount(const std::string& source, const std::string& target,
32+ int ownerUid, int ownerGid ) {
33+ int rc;
34+ unsigned long flags;
35+ char mountData[256];
36+
37+ const char* c_source = source.c_str();
38+ const char* c_target = target.c_str();
39+
40+ flags = MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_DIRSYNC | MS_RDONLY;
41+
42+ snprintf(mountData, sizeof(mountData),
43+ "utf8,uid=%d,gid=%d", ownerUid, ownerGid);
44+
45+ rc = mount(c_source, c_target, "iso9660", flags, mountData);
46+ if (rc != 0) {
47+ rc = mount(c_source, c_target, "udf", flags, mountData);
48+ }
49+
50+ return rc;
51+}
52+
53+} // namespace iso9660
54+} // namespace vold
55+} // namespace android
--- /dev/null
+++ b/fs/Iso9660.h
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2008 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef _ISO9660_H
18+#define _ISO9660_H
19+
20+#include <string>
21+
22+namespace android {
23+namespace vold {
24+namespace iso9660 {
25+
26+bool IsSupported();
27+status_t Mount(const std::string& source, const std::string& target,
28+ int ownerUid, int ownerGid );
29+
30+} // namespace iso9660
31+} // namespace vold
32+} // namespace android
33+
34+
35+#endif
--- a/main.cpp
+++ b/main.cpp
@@ -66,6 +66,7 @@ int main(int argc, char** argv) {
6666 << (android::vold::IsFilesystemSupported("exfat") ? " exfat" : "")
6767 << (android::vold::IsFilesystemSupported("ext4") ? " ext4" : "")
6868 << (android::vold::IsFilesystemSupported("f2fs") ? " f2fs" : "")
69+ << (android::vold::IsFilesystemSupported("iso9660") ? " iso9660" : "")
6970 << (android::vold::IsFilesystemSupported("ntfs") ? " ntfs" : "")
7071 << (android::vold::IsFilesystemSupported("vfat") ? " vfat" : "");
7172
--- a/model/Disk.cpp
+++ b/model/Disk.cpp
@@ -347,6 +347,15 @@ status_t Disk::readPartitions() {
347347 if (res != OK) {
348348 LOG(WARNING) << "sgdisk failed to scan " << mDevPath;
349349
350+ std::string fsType, unused;
351+ if (ReadMetadataUntrusted(mDevPath, &fsType, &unused, &unused) == OK) {
352+ if (fsType == "iso9660") {
353+ LOG(INFO) << "Detect iso9660";
354+ createPublicVolume(mDevice);
355+ res = OK;
356+ }
357+ }
358+
350359 auto listener = VolumeManager::Instance()->getListener();
351360 if (listener) listener->onDiskScanned(getId());
352361
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -20,6 +20,7 @@
2020 #include "fs/Exfat.h"
2121 #include "fs/Ext4.h"
2222 #include "fs/F2fs.h"
23+#include "fs/Iso9660.h"
2324 #include "fs/Ntfs.h"
2425 #include "fs/Vfat.h"
2526
@@ -61,6 +62,12 @@ PublicVolume::~PublicVolume() {}
6162 status_t PublicVolume::readMetadata() {
6263 status_t res = ReadMetadataUntrusted(mDevPath, &mFsType, &mFsUuid, &mFsLabel);
6364
65+ // iso9660 has no UUID, we use label as UUID
66+ if (mFsType == "iso9660" && mFsUuid.empty() && !mFsLabel.empty()) {
67+ std::replace(mFsLabel.begin(), mFsLabel.end(), ' ', '_');
68+ mFsUuid = mFsLabel;
69+ }
70+
6471 auto listener = getListener();
6572 if (listener) listener->onVolumeMetadataChanged(getId(), mFsType, mFsUuid, mFsLabel);
6673
@@ -156,6 +163,8 @@ status_t PublicVolume::doMount() {
156163 ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts);
157164 } else if (mFsType == "f2fs") {
158165 ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts);
166+ } else if (mFsType == "iso9660") {
167+ ret = iso9660::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW);
159168 } else if (mFsType == "ntfs") {
160169 ret = ntfs::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW, 0007);
161170 } else if (mFsType == "vfat") {
Show on old repository browser