system/vold
Revisión | 475e6768f61544feef6f00b9c58dffa4e3108b4f (tree) |
---|---|
Tiempo | 2019-12-17 14:19:56 |
Autor | Luo Chunbo <luochunbo@jide...> |
Commiter | Chih-Wei Huang |
vold: ISO9660 support
Ref: T7691
Change-Id: Ifc602781e7d87aea9f3181263e09ffe143e9a231
Signed-off-by: Luo Chunbo <luochunbo@jidemail.com>
@@ -125,6 +125,7 @@ cc_library_static { | ||
125 | 125 | "fs/Exfat.cpp", |
126 | 126 | "fs/Ext4.cpp", |
127 | 127 | "fs/F2fs.cpp", |
128 | + "fs/Iso9660.cpp", | |
128 | 129 | "fs/Ntfs.cpp", |
129 | 130 | "fs/Vfat.cpp", |
130 | 131 | "model/Disk.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 |
@@ -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 |
@@ -66,6 +66,7 @@ int main(int argc, char** argv) { | ||
66 | 66 | << (android::vold::IsFilesystemSupported("exfat") ? " exfat" : "") |
67 | 67 | << (android::vold::IsFilesystemSupported("ext4") ? " ext4" : "") |
68 | 68 | << (android::vold::IsFilesystemSupported("f2fs") ? " f2fs" : "") |
69 | + << (android::vold::IsFilesystemSupported("iso9660") ? " iso9660" : "") | |
69 | 70 | << (android::vold::IsFilesystemSupported("ntfs") ? " ntfs" : "") |
70 | 71 | << (android::vold::IsFilesystemSupported("vfat") ? " vfat" : ""); |
71 | 72 |
@@ -347,6 +347,15 @@ status_t Disk::readPartitions() { | ||
347 | 347 | if (res != OK) { |
348 | 348 | LOG(WARNING) << "sgdisk failed to scan " << mDevPath; |
349 | 349 | |
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 | + | |
350 | 359 | auto listener = VolumeManager::Instance()->getListener(); |
351 | 360 | if (listener) listener->onDiskScanned(getId()); |
352 | 361 |
@@ -20,6 +20,7 @@ | ||
20 | 20 | #include "fs/Exfat.h" |
21 | 21 | #include "fs/Ext4.h" |
22 | 22 | #include "fs/F2fs.h" |
23 | +#include "fs/Iso9660.h" | |
23 | 24 | #include "fs/Ntfs.h" |
24 | 25 | #include "fs/Vfat.h" |
25 | 26 |
@@ -61,6 +62,12 @@ PublicVolume::~PublicVolume() {} | ||
61 | 62 | status_t PublicVolume::readMetadata() { |
62 | 63 | status_t res = ReadMetadataUntrusted(mDevPath, &mFsType, &mFsUuid, &mFsLabel); |
63 | 64 | |
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 | + | |
64 | 71 | auto listener = getListener(); |
65 | 72 | if (listener) listener->onVolumeMetadataChanged(getId(), mFsType, mFsUuid, mFsLabel); |
66 | 73 |
@@ -156,6 +163,8 @@ status_t PublicVolume::doMount() { | ||
156 | 163 | ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts); |
157 | 164 | } else if (mFsType == "f2fs") { |
158 | 165 | ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts); |
166 | + } else if (mFsType == "iso9660") { | |
167 | + ret = iso9660::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW); | |
159 | 168 | } else if (mFsType == "ntfs") { |
160 | 169 | ret = ntfs::Mount(mDevPath, mRawPath, AID_MEDIA_RW, AID_MEDIA_RW, 0007); |
161 | 170 | } else if (mFsType == "vfat") { |