San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 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 | |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER |
| 18 | |
Yabin Cui | d1104f7 | 2015-01-02 13:28:28 -0800 | [diff] [blame] | 19 | #include <dirent.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 20 | #include <errno.h> |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 21 | #include <fcntl.h> |
Ricky Wai | e96b34f | 2020-05-07 16:01:33 +0100 | [diff] [blame] | 22 | #include <limits.h> |
Yabin Cui | d1104f7 | 2015-01-02 13:28:28 -0800 | [diff] [blame] | 23 | #include <mntent.h> |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
| 27 | #include <sys/ioctl.h> |
| 28 | #include <sys/mount.h> |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 29 | #include <sys/stat.h> |
Elliott Hughes | 0e08e84 | 2017-05-18 09:08:24 -0700 | [diff] [blame] | 30 | #include <sys/sysmacros.h> |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 31 | #include <sys/types.h> |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 32 | #include <sys/wait.h> |
Yabin Cui | d1104f7 | 2015-01-02 13:28:28 -0800 | [diff] [blame] | 33 | #include <unistd.h> |
Sudheer Shanka | 40ab674 | 2018-09-18 13:07:45 -0700 | [diff] [blame] | 34 | #include <array> |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 35 | |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 36 | #include <linux/kdev_t.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 37 | |
Jiyong Park | 8d21c92 | 2019-01-04 13:35:25 +0900 | [diff] [blame] | 38 | #include <ApexProperties.sysprop.h> |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 39 | #include <android-base/logging.h> |
Jeff Vander Stoep | 5889083 | 2017-10-23 17:12:31 -0700 | [diff] [blame] | 40 | #include <android-base/parseint.h> |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 41 | #include <android-base/properties.h> |
Elliott Hughes | 7e128fb | 2015-12-04 15:50:53 -0800 | [diff] [blame] | 42 | #include <android-base/stringprintf.h> |
Jeff Vander Stoep | 5889083 | 2017-10-23 17:12:31 -0700 | [diff] [blame] | 43 | #include <android-base/strings.h> |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 44 | #include <async_safe/log.h> |
Jeff Vander Stoep | 5889083 | 2017-10-23 17:12:31 -0700 | [diff] [blame] | 45 | |
Jeff Sharkey | 71ebe15 | 2013-09-17 17:24:38 -0700 | [diff] [blame] | 46 | #include <cutils/fs.h> |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 47 | #include <utils/Trace.h> |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 48 | |
Robert Craig | b9e3ba5 | 2014-02-04 10:53:00 -0500 | [diff] [blame] | 49 | #include <selinux/android.h> |
| 50 | |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 51 | #include <sysutils/NetlinkEvent.h> |
| 52 | |
Kenny Root | 344ca10 | 2012-04-03 17:23:01 -0700 | [diff] [blame] | 53 | #include <private/android_filesystem_config.h> |
| 54 | |
Eric Biggers | a701c45 | 2018-10-23 13:06:55 -0700 | [diff] [blame] | 55 | #include <fscrypt/fscrypt.h> |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 56 | |
Risan | ac02a48 | 2018-10-31 21:59:47 -0600 | [diff] [blame] | 57 | #include "AppFuseUtil.h" |
Eric Biggers | a701c45 | 2018-10-23 13:06:55 -0700 | [diff] [blame] | 58 | #include "FsCrypt.h" |
San Mehat | a19b250 | 2010-01-06 10:33:53 -0800 | [diff] [blame] | 59 | #include "Loop.h" |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 60 | #include "NetlinkManager.h" |
| 61 | #include "Process.h" |
| 62 | #include "Utils.h" |
Sudheer Shanka | 40ab674 | 2018-09-18 13:07:45 -0700 | [diff] [blame] | 63 | #include "VoldNativeService.h" |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 64 | #include "VoldUtil.h" |
| 65 | #include "VolumeManager.h" |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 66 | #include "fs/Ext4.h" |
| 67 | #include "fs/Vfat.h" |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 68 | #include "model/EmulatedVolume.h" |
| 69 | #include "model/ObbVolume.h" |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 70 | #include "model/PrivateVolume.h" |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 71 | #include "model/StubVolume.h" |
San Mehat | 2396993 | 2010-01-09 07:08:06 -0800 | [diff] [blame] | 72 | |
Sudheer Shanka | f9b38a5 | 2019-02-14 19:09:51 +0000 | [diff] [blame] | 73 | using android::OK; |
Sudheer Shanka | 53947a3 | 2018-08-01 10:24:13 -0700 | [diff] [blame] | 74 | using android::base::GetBoolProperty; |
Mark Salyzyn | 86e81e7 | 2018-09-20 10:09:27 -0700 | [diff] [blame] | 75 | using android::base::StartsWith; |
Sudheer Shanka | 53947a3 | 2018-08-01 10:24:13 -0700 | [diff] [blame] | 76 | using android::base::StringAppendF; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 77 | using android::base::StringPrintf; |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 78 | using android::base::unique_fd; |
Sudheer Shanka | 023b539 | 2019-02-06 12:39:19 -0800 | [diff] [blame] | 79 | using android::vold::BindMount; |
Sudheer Shanka | f9b38a5 | 2019-02-14 19:09:51 +0000 | [diff] [blame] | 80 | using android::vold::CreateDir; |
Sudheer Shanka | 30df1c6 | 2019-02-22 17:03:02 -0800 | [diff] [blame] | 81 | using android::vold::DeleteDirContents; |
Sudheer Shanka | 023b539 | 2019-02-06 12:39:19 -0800 | [diff] [blame] | 82 | using android::vold::DeleteDirContentsAndDir; |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 83 | using android::vold::EnsureDirExists; |
Martijn Coenen | 62a4b27 | 2020-01-31 15:23:09 +0100 | [diff] [blame] | 84 | using android::vold::IsFilesystemSupported; |
Daniel Rosenberg | f36bddd | 2020-05-11 22:58:42 -0700 | [diff] [blame] | 85 | using android::vold::IsSdcardfsUsed; |
Alistair Delva | ff1fc9b | 2020-05-14 16:35:03 -0700 | [diff] [blame] | 86 | using android::vold::IsVirtioBlkDevice; |
Martijn Coenen | 62a4b27 | 2020-01-31 15:23:09 +0100 | [diff] [blame] | 87 | using android::vold::PrepareAndroidDirs; |
Martijn Coenen | 04bb17f | 2020-02-10 23:48:11 +0100 | [diff] [blame] | 88 | using android::vold::PrepareAppDirFromRoot; |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 89 | using android::vold::PrivateVolume; |
Sudheer Shanka | 023b539 | 2019-02-06 12:39:19 -0800 | [diff] [blame] | 90 | using android::vold::Symlink; |
| 91 | using android::vold::Unlink; |
| 92 | using android::vold::UnmountTree; |
Sudheer Shanka | 03992e3 | 2018-12-12 12:43:38 -0800 | [diff] [blame] | 93 | using android::vold::VoldNativeService; |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 94 | using android::vold::VolumeBase; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 95 | |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 96 | static const char* kPathUserMount = "/mnt/user"; |
| 97 | static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk"; |
| 98 | |
| 99 | static const char* kPropVirtualDisk = "persist.sys.virtual_disk"; |
| 100 | |
Sudheer Shanka | 53947a3 | 2018-08-01 10:24:13 -0700 | [diff] [blame] | 101 | static const std::string kEmptyString(""); |
| 102 | |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 103 | /* 512MiB is large enough for testing purposes */ |
| 104 | static const unsigned int kSizeVirtualDisk = 536870912; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 105 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 106 | static const unsigned int kMajorBlockMmc = 179; |
| 107 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 108 | using ScanProcCallback = bool(*)(uid_t uid, pid_t pid, int nsFd, const char* name, void* params); |
| 109 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 110 | VolumeManager* VolumeManager::sInstance = NULL; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 111 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 112 | VolumeManager* VolumeManager::Instance() { |
| 113 | if (!sInstance) sInstance = new VolumeManager(); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 114 | return sInstance; |
| 115 | } |
| 116 | |
| 117 | VolumeManager::VolumeManager() { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 118 | mDebug = false; |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 119 | mNextObbId = 0; |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 120 | mNextStubId = 0; |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 121 | // For security reasons, assume that a secure keyguard is |
| 122 | // showing until we hear otherwise |
| 123 | mSecureKeyguardShowing = true; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 126 | VolumeManager::~VolumeManager() {} |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 127 | |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 128 | int VolumeManager::updateVirtualDisk() { |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 129 | ATRACE_NAME("VolumeManager::updateVirtualDisk"); |
Mark Salyzyn | 86e81e7 | 2018-09-20 10:09:27 -0700 | [diff] [blame] | 130 | if (GetBoolProperty(kPropVirtualDisk, false)) { |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 131 | if (access(kPathVirtualDisk, F_OK) != 0) { |
| 132 | Loop::createImageFile(kPathVirtualDisk, kSizeVirtualDisk / 512); |
| 133 | } |
| 134 | |
| 135 | if (mVirtualDisk == nullptr) { |
| 136 | if (Loop::create(kPathVirtualDisk, mVirtualDiskPath) != 0) { |
| 137 | LOG(ERROR) << "Failed to create virtual disk"; |
| 138 | return -1; |
| 139 | } |
| 140 | |
| 141 | struct stat buf; |
| 142 | if (stat(mVirtualDiskPath.c_str(), &buf) < 0) { |
| 143 | PLOG(ERROR) << "Failed to stat " << mVirtualDiskPath; |
| 144 | return -1; |
| 145 | } |
| 146 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 147 | auto disk = new android::vold::Disk( |
| 148 | "virtual", buf.st_rdev, "virtual", |
| 149 | android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd); |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 150 | mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 151 | handleDiskAdded(mVirtualDisk); |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 152 | } |
| 153 | } else { |
| 154 | if (mVirtualDisk != nullptr) { |
| 155 | dev_t device = mVirtualDisk->getDevice(); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 156 | handleDiskRemoved(device); |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 157 | |
| 158 | Loop::destroyByDevice(mVirtualDiskPath.c_str()); |
| 159 | mVirtualDisk = nullptr; |
| 160 | } |
| 161 | |
| 162 | if (access(kPathVirtualDisk, F_OK) == 0) { |
| 163 | unlink(kPathVirtualDisk); |
| 164 | } |
| 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 169 | int VolumeManager::setDebug(bool enable) { |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 170 | mDebug = enable; |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 171 | return 0; |
San Mehat | d9a4e35 | 2010-03-12 13:32:47 -0800 | [diff] [blame] | 172 | } |
| 173 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 174 | int VolumeManager::start() { |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 175 | ATRACE_NAME("VolumeManager::start"); |
| 176 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 177 | // Always start from a clean slate by unmounting everything in |
| 178 | // directories that we own, in case we crashed. |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 179 | unmountAll(); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 180 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 181 | Loop::destroyAll(); |
| 182 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 183 | // Assume that we always have an emulated volume on internal |
| 184 | // storage; the framework will decide if it should be mounted. |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 185 | CHECK(mInternalEmulatedVolumes.empty()); |
| 186 | |
| 187 | auto vol = std::shared_ptr<android::vold::VolumeBase>( |
| 188 | new android::vold::EmulatedVolume("/data/media", 0)); |
| 189 | vol->setMountUserId(0); |
| 190 | vol->create(); |
| 191 | mInternalEmulatedVolumes.push_back(vol); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 192 | |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 193 | // Consider creating a virtual disk |
| 194 | updateVirtualDisk(); |
| 195 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 196 | return 0; |
| 197 | } |
| 198 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 199 | void VolumeManager::handleBlockEvent(NetlinkEvent* evt) { |
Jeff Sharkey | c8e04c5 | 2015-04-21 12:14:17 -0700 | [diff] [blame] | 200 | std::lock_guard<std::mutex> lock(mLock); |
| 201 | |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 202 | if (mDebug) { |
Sudheer Shanka | 4b6ca4e | 2018-09-21 10:54:54 -0700 | [diff] [blame] | 203 | LOG(DEBUG) << "----------------"; |
| 204 | LOG(DEBUG) << "handleBlockEvent with action " << (int)evt->getAction(); |
Jeff Sharkey | f1b996d | 2015-04-17 17:35:20 -0700 | [diff] [blame] | 205 | evt->dump(); |
| 206 | } |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 207 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 208 | std::string eventPath(evt->findParam("DEVPATH") ? evt->findParam("DEVPATH") : ""); |
| 209 | std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : ""); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 210 | |
| 211 | if (devType != "disk") return; |
| 212 | |
Jeff Sharkey | 95440eb | 2017-09-18 18:19:28 -0600 | [diff] [blame] | 213 | int major = std::stoi(evt->findParam("MAJOR")); |
| 214 | int minor = std::stoi(evt->findParam("MINOR")); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 215 | dev_t device = makedev(major, minor); |
| 216 | |
| 217 | switch (evt->getAction()) { |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 218 | case NetlinkEvent::Action::kAdd: { |
| 219 | for (const auto& source : mDiskSources) { |
| 220 | if (source->matches(eventPath)) { |
| 221 | // For now, assume that MMC and virtio-blk (the latter is |
Alistair Delva | ff1fc9b | 2020-05-14 16:35:03 -0700 | [diff] [blame] | 222 | // specific to virtual platforms; see Utils.cpp for details) |
| 223 | // devices are SD, and that everything else is USB |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 224 | int flags = source->getFlags(); |
Alistair Delva | ff1fc9b | 2020-05-14 16:35:03 -0700 | [diff] [blame] | 225 | if (major == kMajorBlockMmc || IsVirtioBlkDevice(major)) { |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 226 | flags |= android::vold::Disk::Flags::kSd; |
| 227 | } else { |
| 228 | flags |= android::vold::Disk::Flags::kUsb; |
| 229 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 230 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 231 | auto disk = |
| 232 | new android::vold::Disk(eventPath, device, source->getNickname(), flags); |
| 233 | handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk)); |
| 234 | break; |
| 235 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 236 | } |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 237 | break; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 238 | } |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 239 | case NetlinkEvent::Action::kChange: { |
Nikita Ioffe | b881fc4 | 2021-07-28 02:58:57 +0100 | [diff] [blame] | 240 | LOG(VERBOSE) << "Disk at " << major << ":" << minor << " changed"; |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 241 | handleDiskChanged(device); |
| 242 | break; |
| 243 | } |
| 244 | case NetlinkEvent::Action::kRemove: { |
| 245 | handleDiskRemoved(device); |
| 246 | break; |
| 247 | } |
| 248 | default: { |
| 249 | LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction(); |
| 250 | break; |
| 251 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 255 | void VolumeManager::handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk) { |
| 256 | // For security reasons, if secure keyguard is showing, wait |
| 257 | // until the user unlocks the device to actually touch it |
Martijn Coenen | cf5916f | 2020-01-03 14:36:45 +0100 | [diff] [blame] | 258 | // Additionally, wait until user 0 is actually started, since we need |
| 259 | // the user to be up before we can mount a FUSE daemon to handle the disk. |
| 260 | bool userZeroStarted = mStartedUsers.find(0) != mStartedUsers.end(); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 261 | if (mSecureKeyguardShowing) { |
| 262 | LOG(INFO) << "Found disk at " << disk->getEventPath() |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 263 | << " but delaying scan due to secure keyguard"; |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 264 | mPendingDisks.push_back(disk); |
Martijn Coenen | cf5916f | 2020-01-03 14:36:45 +0100 | [diff] [blame] | 265 | } else if (!userZeroStarted) { |
| 266 | LOG(INFO) << "Found disk at " << disk->getEventPath() |
| 267 | << " but delaying scan due to user zero not having started"; |
| 268 | mPendingDisks.push_back(disk); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 269 | } else { |
| 270 | disk->create(); |
| 271 | mDisks.push_back(disk); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | void VolumeManager::handleDiskChanged(dev_t device) { |
| 276 | for (const auto& disk : mDisks) { |
| 277 | if (disk->getDevice() == device) { |
| 278 | disk->readMetadata(); |
| 279 | disk->readPartitions(); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | // For security reasons, we ignore all pending disks, since |
| 284 | // we'll scan them once the device is unlocked |
| 285 | } |
| 286 | |
| 287 | void VolumeManager::handleDiskRemoved(dev_t device) { |
| 288 | auto i = mDisks.begin(); |
| 289 | while (i != mDisks.end()) { |
| 290 | if ((*i)->getDevice() == device) { |
| 291 | (*i)->destroy(); |
| 292 | i = mDisks.erase(i); |
| 293 | } else { |
| 294 | ++i; |
| 295 | } |
| 296 | } |
| 297 | auto j = mPendingDisks.begin(); |
| 298 | while (j != mPendingDisks.end()) { |
| 299 | if ((*j)->getDevice() == device) { |
| 300 | j = mPendingDisks.erase(j); |
| 301 | } else { |
| 302 | ++j; |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 307 | void VolumeManager::addDiskSource(const std::shared_ptr<DiskSource>& diskSource) { |
Wei Wang | 6b455c2 | 2017-01-20 11:52:33 -0800 | [diff] [blame] | 308 | std::lock_guard<std::mutex> lock(mLock); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 309 | mDiskSources.push_back(diskSource); |
| 310 | } |
| 311 | |
| 312 | std::shared_ptr<android::vold::Disk> VolumeManager::findDisk(const std::string& id) { |
| 313 | for (auto disk : mDisks) { |
| 314 | if (disk->getId() == id) { |
| 315 | return disk; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 316 | } |
| 317 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 318 | return nullptr; |
| 319 | } |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 320 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 321 | std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::string& id) { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 322 | for (const auto& vol : mInternalEmulatedVolumes) { |
| 323 | if (vol->getId() == id) { |
| 324 | return vol; |
| 325 | } |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 326 | } |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 327 | for (const auto& disk : mDisks) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 328 | auto vol = disk->findVolume(id); |
| 329 | if (vol != nullptr) { |
| 330 | return vol; |
| 331 | } |
| 332 | } |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 333 | for (const auto& vol : mObbVolumes) { |
| 334 | if (vol->getId() == id) { |
| 335 | return vol; |
| 336 | } |
| 337 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 338 | return nullptr; |
| 339 | } |
| 340 | |
Greg Kaiser | 2bc201e | 2018-12-18 08:42:08 -0800 | [diff] [blame] | 341 | void VolumeManager::listVolumes(android::vold::VolumeBase::Type type, |
| 342 | std::list<std::string>& list) const { |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 343 | list.clear(); |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 344 | for (const auto& disk : mDisks) { |
Jeff Sharkey | c86ab6f | 2015-06-26 14:02:09 -0700 | [diff] [blame] | 345 | disk->listVolumes(type, list); |
| 346 | } |
| 347 | } |
| 348 | |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 349 | int VolumeManager::forgetPartition(const std::string& partGuid, const std::string& fsUuid) { |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 350 | std::string normalizedGuid; |
| 351 | if (android::vold::NormalizeHex(partGuid, normalizedGuid)) { |
| 352 | LOG(WARNING) << "Invalid GUID " << partGuid; |
| 353 | return -1; |
| 354 | } |
| 355 | |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 356 | bool success = true; |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 357 | std::string keyPath = android::vold::BuildKeyPath(normalizedGuid); |
| 358 | if (unlink(keyPath.c_str()) != 0) { |
| 359 | LOG(ERROR) << "Failed to unlink " << keyPath; |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 360 | success = false; |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 361 | } |
Eric Biggers | a701c45 | 2018-10-23 13:06:55 -0700 | [diff] [blame] | 362 | if (fscrypt_is_native()) { |
| 363 | if (!fscrypt_destroy_volume_keys(fsUuid)) { |
Paul Crowley | c6433a2 | 2017-10-24 14:54:43 -0700 | [diff] [blame] | 364 | success = false; |
| 365 | } |
| 366 | } |
| 367 | return success ? 0 : -1; |
Jeff Sharkey | bc40cc8 | 2015-06-18 14:25:08 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 370 | void VolumeManager::destroyEmulatedVolumesForUser(userid_t userId) { |
| 371 | // Destroy and remove all unstacked EmulatedVolumes for the user |
| 372 | auto i = mInternalEmulatedVolumes.begin(); |
| 373 | while (i != mInternalEmulatedVolumes.end()) { |
| 374 | auto vol = *i; |
| 375 | if (vol->getMountUserId() == userId) { |
| 376 | vol->destroy(); |
| 377 | i = mInternalEmulatedVolumes.erase(i); |
| 378 | } else { |
| 379 | i++; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | // Destroy and remove all stacked EmulatedVolumes for the user on each mounted private volume |
| 384 | std::list<std::string> private_vols; |
| 385 | listVolumes(VolumeBase::Type::kPrivate, private_vols); |
| 386 | for (const std::string& id : private_vols) { |
| 387 | PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get()); |
| 388 | std::list<std::shared_ptr<VolumeBase>> vols_to_remove; |
| 389 | if (pvol->getState() == VolumeBase::State::kMounted) { |
| 390 | for (const auto& vol : pvol->getVolumes()) { |
| 391 | if (vol->getMountUserId() == userId) { |
| 392 | vols_to_remove.push_back(vol); |
| 393 | } |
| 394 | } |
| 395 | for (const auto& vol : vols_to_remove) { |
| 396 | vol->destroy(); |
| 397 | pvol->removeVolume(vol); |
| 398 | } |
| 399 | } // else EmulatedVolumes will be destroyed on VolumeBase#unmount |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | void VolumeManager::createEmulatedVolumesForUser(userid_t userId) { |
| 404 | // Create unstacked EmulatedVolumes for the user |
| 405 | auto vol = std::shared_ptr<android::vold::VolumeBase>( |
| 406 | new android::vold::EmulatedVolume("/data/media", userId)); |
| 407 | vol->setMountUserId(userId); |
| 408 | mInternalEmulatedVolumes.push_back(vol); |
| 409 | vol->create(); |
| 410 | |
| 411 | // Create stacked EmulatedVolumes for the user on each PrivateVolume |
| 412 | std::list<std::string> private_vols; |
| 413 | listVolumes(VolumeBase::Type::kPrivate, private_vols); |
| 414 | for (const std::string& id : private_vols) { |
| 415 | PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get()); |
| 416 | if (pvol->getState() == VolumeBase::State::kMounted) { |
| 417 | auto evol = |
| 418 | std::shared_ptr<android::vold::VolumeBase>(new android::vold::EmulatedVolume( |
| 419 | pvol->getPath() + "/media", pvol->getRawDevice(), pvol->getFsUuid(), |
| 420 | userId)); |
| 421 | evol->setMountUserId(userId); |
| 422 | pvol->addVolume(evol); |
| 423 | evol->create(); |
| 424 | } // else EmulatedVolumes will be created per user when on PrivateVolume#doMount |
| 425 | } |
| 426 | } |
| 427 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 428 | int VolumeManager::onUserAdded(userid_t userId, int userSerialNumber) { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 429 | LOG(INFO) << "onUserAdded: " << userId; |
| 430 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 431 | mAddedUsers[userId] = userSerialNumber; |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | int VolumeManager::onUserRemoved(userid_t userId) { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 436 | LOG(INFO) << "onUserRemoved: " << userId; |
| 437 | |
Zim | 2d45d9b | 2019-11-14 16:19:05 +0000 | [diff] [blame] | 438 | onUserStopped(userId); |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 439 | mAddedUsers.erase(userId); |
| 440 | return 0; |
| 441 | } |
| 442 | |
Sudheer Shanka | ebce4cc | 2019-04-29 10:46:35 -0700 | [diff] [blame] | 443 | int VolumeManager::onUserStarted(userid_t userId) { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 444 | LOG(INFO) << "onUserStarted: " << userId; |
| 445 | |
Zim | 2d45d9b | 2019-11-14 16:19:05 +0000 | [diff] [blame] | 446 | if (mStartedUsers.find(userId) == mStartedUsers.end()) { |
| 447 | createEmulatedVolumesForUser(userId); |
| 448 | } |
| 449 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 450 | mStartedUsers.insert(userId); |
Martijn Coenen | cf5916f | 2020-01-03 14:36:45 +0100 | [diff] [blame] | 451 | |
| 452 | createPendingDisksIfNeeded(); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 453 | return 0; |
| 454 | } |
| 455 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 456 | int VolumeManager::onUserStopped(userid_t userId) { |
Sudheer Shanka | 40ab674 | 2018-09-18 13:07:45 -0700 | [diff] [blame] | 457 | LOG(VERBOSE) << "onUserStopped: " << userId; |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 458 | |
Zim | 2d45d9b | 2019-11-14 16:19:05 +0000 | [diff] [blame] | 459 | if (mStartedUsers.find(userId) != mStartedUsers.end()) { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 460 | destroyEmulatedVolumesForUser(userId); |
| 461 | } |
| 462 | |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 463 | mStartedUsers.erase(userId); |
Sudheer Shanka | fa6a174 | 2018-10-04 16:26:22 -0700 | [diff] [blame] | 464 | return 0; |
| 465 | } |
| 466 | |
Martijn Coenen | cf5916f | 2020-01-03 14:36:45 +0100 | [diff] [blame] | 467 | void VolumeManager::createPendingDisksIfNeeded() { |
| 468 | bool userZeroStarted = mStartedUsers.find(0) != mStartedUsers.end(); |
| 469 | if (!mSecureKeyguardShowing && userZeroStarted) { |
| 470 | // Now that secure keyguard has been dismissed and user 0 has |
| 471 | // started, process any pending disks |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 472 | for (const auto& disk : mPendingDisks) { |
| 473 | disk->create(); |
| 474 | mDisks.push_back(disk); |
| 475 | } |
| 476 | mPendingDisks.clear(); |
| 477 | } |
Martijn Coenen | cf5916f | 2020-01-03 14:36:45 +0100 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | int VolumeManager::onSecureKeyguardStateChanged(bool isShowing) { |
| 481 | mSecureKeyguardShowing = isShowing; |
| 482 | createPendingDisksIfNeeded(); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 483 | return 0; |
| 484 | } |
| 485 | |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 486 | // This code is executed after a fork so it's very important that the set of |
| 487 | // methods we call here is strictly limited. |
| 488 | // |
| 489 | // TODO: Get rid of this guesswork altogether and instead exec a process |
| 490 | // immediately after fork to do our bindding for us. |
| 491 | static bool childProcess(const char* storageSource, const char* userSource, int nsFd, |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 492 | const char* name) { |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 493 | if (setns(nsFd, CLONE_NEWNS) != 0) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 494 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns for %s :%s", name, |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 495 | strerror(errno)); |
| 496 | return false; |
| 497 | } |
| 498 | |
| 499 | // NOTE: Inlined from vold::UnmountTree here to avoid using PLOG methods and |
| 500 | // to also protect against future changes that may cause issues across a |
| 501 | // fork. |
| 502 | if (TEMP_FAILURE_RETRY(umount2("/storage/", MNT_DETACH)) < 0 && errno != EINVAL && |
| 503 | errno != ENOENT) { |
| 504 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to unmount /storage/ :%s", |
| 505 | strerror(errno)); |
| 506 | return false; |
| 507 | } |
| 508 | |
| 509 | if (TEMP_FAILURE_RETRY(mount(storageSource, "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) { |
| 510 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s for %s :%s", |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 511 | storageSource, name, strerror(errno)); |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 512 | return false; |
| 513 | } |
| 514 | |
| 515 | if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) { |
| 516 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 517 | "Failed to set MS_SLAVE to /storage for %s :%s", name, |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 518 | strerror(errno)); |
| 519 | return false; |
| 520 | } |
| 521 | |
| 522 | if (TEMP_FAILURE_RETRY(mount(userSource, "/storage/self", NULL, MS_BIND, NULL)) == -1) { |
| 523 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s for %s :%s", |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 524 | userSource, name, strerror(errno)); |
Narayan Kamath | 02efdf5 | 2019-11-27 10:53:51 +0000 | [diff] [blame] | 525 | return false; |
| 526 | } |
| 527 | |
| 528 | return true; |
| 529 | } |
| 530 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 531 | // Fork the process and remount storage |
| 532 | bool forkAndRemountChild(uid_t uid, pid_t pid, int nsFd, const char* name, void* params) { |
| 533 | int32_t mountMode = *static_cast<int32_t*>(params); |
| 534 | std::string userSource; |
| 535 | std::string storageSource; |
| 536 | pid_t child; |
| 537 | // Need to fix these paths to account for when sdcardfs is gone |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 538 | switch (mountMode) { |
| 539 | case VoldNativeService::REMOUNT_MODE_NONE: |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 540 | return true; |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 541 | case VoldNativeService::REMOUNT_MODE_DEFAULT: |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 542 | storageSource = "/mnt/runtime/default"; |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 543 | break; |
Abhijeet Kaur | e715ec1 | 2021-02-24 12:33:25 +0000 | [diff] [blame] | 544 | case VoldNativeService::REMOUNT_MODE_ANDROID_WRITABLE: |
Sudheer Shanka | a05ea74 | 2019-04-12 13:55:28 -0700 | [diff] [blame] | 545 | case VoldNativeService::REMOUNT_MODE_INSTALLER: |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 546 | storageSource = "/mnt/runtime/write"; |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 547 | break; |
Zim | 981222f | 2019-09-09 10:24:44 +0100 | [diff] [blame] | 548 | case VoldNativeService::REMOUNT_MODE_PASS_THROUGH: |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 549 | return true; |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 550 | default: |
| 551 | PLOG(ERROR) << "Unknown mode " << std::to_string(mountMode); |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 552 | return false; |
Sudheer Shanka | 817b911 | 2018-12-13 17:40:28 -0800 | [diff] [blame] | 553 | } |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 554 | LOG(DEBUG) << "Remounting " << uid << " as " << storageSource; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 555 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 556 | // Fork a child to mount user-specific symlink helper into place |
| 557 | userSource = StringPrintf("/mnt/user/%d", multiuser_get_user_id(uid)); |
| 558 | if (!(child = fork())) { |
| 559 | if (childProcess(storageSource.c_str(), userSource.c_str(), nsFd, name)) { |
| 560 | _exit(0); |
| 561 | } else { |
| 562 | _exit(1); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | if (child == -1) { |
| 567 | PLOG(ERROR) << "Failed to fork"; |
| 568 | return false; |
| 569 | } else { |
| 570 | TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0)); |
| 571 | } |
| 572 | return true; |
| 573 | } |
| 574 | |
| 575 | // Helper function to scan all processes in /proc and call the callback if: |
| 576 | // 1). pid belongs to an app process |
| 577 | // 2). If input uid is 0 or it matches the process uid |
| 578 | // 3). If userId is not -1 or userId matches the process userId |
| 579 | bool scanProcProcesses(uid_t uid, userid_t userId, ScanProcCallback callback, void* params) { |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 580 | DIR* dir; |
| 581 | struct dirent* de; |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 582 | std::string rootName; |
| 583 | std::string pidName; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 584 | int pidFd; |
| 585 | int nsFd; |
| 586 | struct stat sb; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 587 | |
Jiyong Park | 8d21c92 | 2019-01-04 13:35:25 +0900 | [diff] [blame] | 588 | static bool apexUpdatable = android::sysprop::ApexProperties::updatable().value_or(false); |
| 589 | |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 590 | if (!(dir = opendir("/proc"))) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 591 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to opendir"); |
| 592 | return false; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | // Figure out root namespace to compare against below |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 596 | if (!android::vold::Readlinkat(dirfd(dir), "1/ns/mnt", &rootName)) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 597 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to read root namespace"); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 598 | closedir(dir); |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 599 | return false; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 600 | } |
| 601 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 602 | async_safe_format_log(ANDROID_LOG_INFO, "vold", "Start scanning all processes"); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 603 | // Poke through all running PIDs look for apps running as UID |
| 604 | while ((de = readdir(dir))) { |
Jeff Vander Stoep | 5889083 | 2017-10-23 17:12:31 -0700 | [diff] [blame] | 605 | pid_t pid; |
| 606 | if (de->d_type != DT_DIR) continue; |
| 607 | if (!android::base::ParseInt(de->d_name, &pid)) continue; |
| 608 | |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 609 | pidFd = -1; |
| 610 | nsFd = -1; |
| 611 | |
| 612 | pidFd = openat(dirfd(dir), de->d_name, O_RDONLY | O_DIRECTORY | O_CLOEXEC); |
| 613 | if (pidFd < 0) { |
| 614 | goto next; |
| 615 | } |
| 616 | if (fstat(pidFd, &sb) != 0) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 617 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to stat %s", de->d_name); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 618 | goto next; |
| 619 | } |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 620 | if (uid != 0 && sb.st_uid != uid) { |
| 621 | goto next; |
| 622 | } |
| 623 | if (userId != static_cast<userid_t>(-1) && multiuser_get_user_id(sb.st_uid) != userId) { |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 624 | goto next; |
| 625 | } |
| 626 | |
| 627 | // Matches so far, but refuse to touch if in root namespace |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 628 | if (!android::vold::Readlinkat(pidFd, "ns/mnt", &pidName)) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 629 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", |
| 630 | "Failed to read namespacefor %s", de->d_name); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 631 | goto next; |
| 632 | } |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 633 | if (rootName == pidName) { |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 634 | goto next; |
| 635 | } |
| 636 | |
Jiyong Park | 8d21c92 | 2019-01-04 13:35:25 +0900 | [diff] [blame] | 637 | if (apexUpdatable) { |
| 638 | std::string exeName; |
| 639 | // When ro.apex.bionic_updatable is set to true, |
| 640 | // some early native processes have mount namespaces that are different |
| 641 | // from that of the init. Therefore, above check can't filter them out. |
| 642 | // Since the propagation type of / is 'shared', unmounting /storage |
| 643 | // for the early native processes affects other processes including |
| 644 | // init. Filter out such processes by skipping if a process is a |
| 645 | // non-Java process whose UID is < AID_APP_START. (The UID condition |
| 646 | // is required to not filter out child processes spawned by apps.) |
| 647 | if (!android::vold::Readlinkat(pidFd, "exe", &exeName)) { |
Jiyong Park | 8d21c92 | 2019-01-04 13:35:25 +0900 | [diff] [blame] | 648 | goto next; |
| 649 | } |
| 650 | if (!StartsWith(exeName, "/system/bin/app_process") && sb.st_uid < AID_APP_START) { |
Jiyong Park | 8d21c92 | 2019-01-04 13:35:25 +0900 | [diff] [blame] | 651 | goto next; |
| 652 | } |
| 653 | } |
| 654 | |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 655 | // We purposefully leave the namespace open across the fork |
Nick Kralevich | e7e89ac | 2019-03-29 16:03:51 -0700 | [diff] [blame] | 656 | // NOLINTNEXTLINE(android-cloexec-open): Deliberately not O_CLOEXEC |
| 657 | nsFd = openat(pidFd, "ns/mnt", O_RDONLY); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 658 | if (nsFd < 0) { |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 659 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", |
| 660 | "Failed to open namespace for %s", de->d_name); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 661 | goto next; |
| 662 | } |
| 663 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 664 | if (!callback(sb.st_uid, pid, nsFd, de->d_name, params)) { |
| 665 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed in callback"); |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 666 | } |
| 667 | |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 668 | next: |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 669 | close(nsFd); |
| 670 | close(pidFd); |
| 671 | } |
| 672 | closedir(dir); |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 673 | async_safe_format_log(ANDROID_LOG_INFO, "vold", "Finished scanning all processes"); |
| 674 | return true; |
| 675 | } |
| 676 | |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 677 | // In each app's namespace, unmount obb and data dirs |
| 678 | static bool umountStorageDirs(int nsFd, const char* android_data_dir, const char* android_obb_dir, |
| 679 | int uid, const char* targets[], int size) { |
| 680 | // This code is executed after a fork so it's very important that the set of |
| 681 | // methods we call here is strictly limited. |
| 682 | if (setns(nsFd, CLONE_NEWNS) != 0) { |
| 683 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns %s", strerror(errno)); |
| 684 | return false; |
| 685 | } |
| 686 | |
| 687 | // Unmount of Android/data/foo needs to be done before Android/data below. |
| 688 | bool result = true; |
| 689 | for (int i = 0; i < size; i++) { |
| 690 | if (TEMP_FAILURE_RETRY(umount2(targets[i], MNT_DETACH)) < 0 && errno != EINVAL && |
| 691 | errno != ENOENT) { |
| 692 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s: %s", |
| 693 | targets[i], strerror(errno)); |
| 694 | result = false; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | // Mount tmpfs on Android/data and Android/obb |
| 699 | if (TEMP_FAILURE_RETRY(umount2(android_data_dir, MNT_DETACH)) < 0 && errno != EINVAL && |
| 700 | errno != ENOENT) { |
| 701 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s :%s", |
| 702 | android_data_dir, strerror(errno)); |
| 703 | result = false; |
| 704 | } |
| 705 | if (TEMP_FAILURE_RETRY(umount2(android_obb_dir, MNT_DETACH)) < 0 && errno != EINVAL && |
| 706 | errno != ENOENT) { |
| 707 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s :%s", |
| 708 | android_obb_dir, strerror(errno)); |
| 709 | result = false; |
| 710 | } |
| 711 | return result; |
| 712 | } |
| 713 | |
Ricky Wai | e96b34f | 2020-05-07 16:01:33 +0100 | [diff] [blame] | 714 | // In each app's namespace, mount tmpfs on obb and data dir, and bind mount obb and data |
| 715 | // package dirs. |
| 716 | static bool remountStorageDirs(int nsFd, const char* android_data_dir, const char* android_obb_dir, |
| 717 | int uid, const char* sources[], const char* targets[], int size) { |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 718 | // This code is executed after a fork so it's very important that the set of |
| 719 | // methods we call here is strictly limited. |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 720 | if (setns(nsFd, CLONE_NEWNS) != 0) { |
| 721 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns %s", strerror(errno)); |
| 722 | return false; |
| 723 | } |
| 724 | |
Ricky Wai | e96b34f | 2020-05-07 16:01:33 +0100 | [diff] [blame] | 725 | // Mount tmpfs on Android/data and Android/obb |
| 726 | if (TEMP_FAILURE_RETRY(mount("tmpfs", android_data_dir, "tmpfs", |
| 727 | MS_NOSUID | MS_NODEV | MS_NOEXEC, "uid=0,gid=0,mode=0751")) == -1) { |
| 728 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount tmpfs to %s :%s", |
| 729 | android_data_dir, strerror(errno)); |
| 730 | return false; |
| 731 | } |
| 732 | if (TEMP_FAILURE_RETRY(mount("tmpfs", android_obb_dir, "tmpfs", |
| 733 | MS_NOSUID | MS_NODEV | MS_NOEXEC, "uid=0,gid=0,mode=0751")) == -1) { |
| 734 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount tmpfs to %s :%s", |
| 735 | android_obb_dir, strerror(errno)); |
| 736 | return false; |
| 737 | } |
| 738 | |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 739 | for (int i = 0; i < size; i++) { |
Ricky Wai | e96b34f | 2020-05-07 16:01:33 +0100 | [diff] [blame] | 740 | // Create package dir and bind mount it to the actual one. |
| 741 | if (TEMP_FAILURE_RETRY(mkdir(targets[i], 0700)) == -1) { |
| 742 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mkdir %s %s", |
| 743 | targets[i], strerror(errno)); |
| 744 | return false; |
| 745 | } |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 746 | if (TEMP_FAILURE_RETRY(mount(sources[i], targets[i], NULL, MS_BIND | MS_REC, NULL)) == -1) { |
| 747 | async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s to %s :%s", |
| 748 | sources[i], targets[i], strerror(errno)); |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 749 | return false; |
| 750 | } |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 751 | } |
| 752 | return true; |
| 753 | } |
| 754 | |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 755 | static std::string getStorageDirSrc(userid_t userId, const std::string& dirName, |
| 756 | const std::string& packageName) { |
Daniel Rosenberg | f36bddd | 2020-05-11 22:58:42 -0700 | [diff] [blame] | 757 | if (IsSdcardfsUsed()) { |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 758 | return StringPrintf("/mnt/runtime/default/emulated/%d/%s/%s", |
| 759 | userId, dirName.c_str(), packageName.c_str()); |
| 760 | } else { |
| 761 | return StringPrintf("/mnt/pass_through/%d/emulated/%d/%s/%s", |
| 762 | userId, userId, dirName.c_str(), packageName.c_str()); |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 763 | } |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | static std::string getStorageDirTarget(userid_t userId, std::string dirName, |
| 767 | std::string packageName) { |
| 768 | return StringPrintf("/storage/emulated/%d/%s/%s", |
| 769 | userId, dirName.c_str(), packageName.c_str()); |
| 770 | } |
| 771 | |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 772 | // Fork the process and remount / unmount app data and obb dirs |
| 773 | bool VolumeManager::forkAndRemountStorage(int uid, int pid, bool doUnmount, |
Linus Tufvesson | 75973cb | 2020-03-23 11:59:43 +0000 | [diff] [blame] | 774 | const std::vector<std::string>& packageNames) { |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 775 | userid_t userId = multiuser_get_user_id(uid); |
| 776 | std::string mnt_path = StringPrintf("/proc/%d/ns/mnt", pid); |
| 777 | android::base::unique_fd nsFd( |
| 778 | TEMP_FAILURE_RETRY(open(mnt_path.c_str(), O_RDONLY | O_CLOEXEC))); |
| 779 | if (nsFd == -1) { |
| 780 | PLOG(ERROR) << "Unable to open " << mnt_path.c_str(); |
| 781 | return false; |
| 782 | } |
| 783 | // Storing both Android/obb and Android/data paths. |
| 784 | int size = packageNames.size() * 2; |
| 785 | |
| 786 | std::unique_ptr<std::string[]> sources(new std::string[size]); |
| 787 | std::unique_ptr<std::string[]> targets(new std::string[size]); |
| 788 | std::unique_ptr<const char*[]> sources_uptr(new const char*[size]); |
| 789 | std::unique_ptr<const char*[]> targets_uptr(new const char*[size]); |
| 790 | const char** sources_cstr = sources_uptr.get(); |
| 791 | const char** targets_cstr = targets_uptr.get(); |
| 792 | |
| 793 | for (int i = 0; i < size; i += 2) { |
| 794 | std::string const& packageName = packageNames[i/2]; |
| 795 | sources[i] = getStorageDirSrc(userId, "Android/data", packageName); |
| 796 | targets[i] = getStorageDirTarget(userId, "Android/data", packageName); |
| 797 | sources[i+1] = getStorageDirSrc(userId, "Android/obb", packageName); |
| 798 | targets[i+1] = getStorageDirTarget(userId, "Android/obb", packageName); |
| 799 | |
| 800 | sources_cstr[i] = sources[i].c_str(); |
| 801 | targets_cstr[i] = targets[i].c_str(); |
| 802 | sources_cstr[i+1] = sources[i+1].c_str(); |
| 803 | targets_cstr[i+1] = targets[i+1].c_str(); |
| 804 | } |
| 805 | |
| 806 | for (int i = 0; i < size; i++) { |
Linus Tufvesson | 75973cb | 2020-03-23 11:59:43 +0000 | [diff] [blame] | 807 | // Make sure /storage/emulated/... paths are setup correctly |
Ricky Wai | f6da79c | 2021-01-19 11:27:36 +0000 | [diff] [blame] | 808 | // This needs to be done before EnsureDirExists to ensure Android/ is created. |
| 809 | auto status = setupAppDir(targets_cstr[i], uid, false /* fixupExistingOnly */); |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 810 | if (status != OK) { |
| 811 | PLOG(ERROR) << "Failed to create dir: " << targets_cstr[i]; |
| 812 | return false; |
| 813 | } |
Ricky Wai | f6da79c | 2021-01-19 11:27:36 +0000 | [diff] [blame] | 814 | status = EnsureDirExists(sources_cstr[i], 0771, AID_MEDIA_RW, AID_MEDIA_RW); |
| 815 | if (status != OK) { |
| 816 | PLOG(ERROR) << "Failed to create dir: " << sources_cstr[i]; |
| 817 | return false; |
| 818 | } |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 819 | } |
| 820 | |
Ricky Wai | e96b34f | 2020-05-07 16:01:33 +0100 | [diff] [blame] | 821 | char android_data_dir[PATH_MAX]; |
| 822 | char android_obb_dir[PATH_MAX]; |
| 823 | snprintf(android_data_dir, PATH_MAX, "/storage/emulated/%d/Android/data", userId); |
| 824 | snprintf(android_obb_dir, PATH_MAX, "/storage/emulated/%d/Android/obb", userId); |
| 825 | |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 826 | pid_t child; |
| 827 | // Fork a child to mount Android/obb android Android/data dirs, as we don't want it to affect |
| 828 | // original vold process mount namespace. |
| 829 | if (!(child = fork())) { |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 830 | if (doUnmount) { |
| 831 | if (umountStorageDirs(nsFd, android_data_dir, android_obb_dir, uid, |
| 832 | targets_cstr, size)) { |
| 833 | _exit(0); |
| 834 | } else { |
| 835 | _exit(1); |
| 836 | } |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 837 | } else { |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 838 | if (remountStorageDirs(nsFd, android_data_dir, android_obb_dir, uid, |
| 839 | sources_cstr, targets_cstr, size)) { |
| 840 | _exit(0); |
| 841 | } else { |
| 842 | _exit(1); |
| 843 | } |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 844 | } |
| 845 | } |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 846 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 847 | if (child == -1) { |
| 848 | PLOG(ERROR) << "Failed to fork"; |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 849 | return false; |
| 850 | } else { |
| 851 | int status; |
| 852 | if (TEMP_FAILURE_RETRY(waitpid(child, &status, 0)) == -1) { |
| 853 | PLOG(ERROR) << "Failed to waitpid: " << child; |
| 854 | return false; |
| 855 | } |
| 856 | if (!WIFEXITED(status)) { |
| 857 | PLOG(ERROR) << "Process did not exit normally, status: " << status; |
| 858 | return false; |
| 859 | } |
| 860 | if (WEXITSTATUS(status)) { |
| 861 | PLOG(ERROR) << "Process exited with code: " << WEXITSTATUS(status); |
| 862 | return false; |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame] | 863 | } |
| 864 | } |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 865 | return true; |
| 866 | } |
| 867 | |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 868 | int VolumeManager::handleAppStorageDirs(int uid, int pid, |
| 869 | bool doUnmount, const std::vector<std::string>& packageNames) { |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 870 | // Only run the remount if fuse is mounted for that user. |
| 871 | userid_t userId = multiuser_get_user_id(uid); |
| 872 | bool fuseMounted = false; |
| 873 | for (auto& vol : mInternalEmulatedVolumes) { |
| 874 | if (vol->getMountUserId() == userId && vol->getState() == VolumeBase::State::kMounted) { |
| 875 | auto* emulatedVol = static_cast<android::vold::EmulatedVolume*>(vol.get()); |
| 876 | if (emulatedVol) { |
| 877 | fuseMounted = emulatedVol->isFuseMounted(); |
| 878 | } |
| 879 | break; |
| 880 | } |
| 881 | } |
| 882 | if (fuseMounted) { |
Ricky Wai | a2ca11e | 2021-01-15 14:03:23 +0000 | [diff] [blame] | 883 | forkAndRemountStorage(uid, pid, doUnmount, packageNames); |
Ricky Wai | 6b12257 | 2020-02-28 16:30:47 +0000 | [diff] [blame] | 884 | } |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
Martijn Coenen | 23c0445 | 2020-04-29 07:49:41 +0200 | [diff] [blame] | 888 | int VolumeManager::abortFuse() { |
| 889 | return android::vold::AbortFuseConnections(); |
| 890 | } |
| 891 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 892 | int VolumeManager::reset() { |
| 893 | // Tear down all existing disks/volumes and start from a blank slate so |
| 894 | // newly connected framework hears all events. |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 895 | for (const auto& vol : mInternalEmulatedVolumes) { |
| 896 | vol->destroy(); |
Gao Xiang | d263da8 | 2017-08-14 11:32:13 +0800 | [diff] [blame] | 897 | } |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 898 | mInternalEmulatedVolumes.clear(); |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 899 | |
Youkichi Hosoi | dfaff1d | 2021-11-25 16:24:35 +0900 | [diff] [blame] | 900 | // Destroy and recreate all disks except that StubVolume disks are just |
| 901 | // destroyed and removed from both mDisks and mPendingDisks. |
| 902 | // StubVolumes are managed from outside Android (e.g. from Chrome OS) and |
| 903 | // their disk recreation on reset events should be handled from outside by |
| 904 | // calling createStubVolume() again. |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 905 | for (const auto& disk : mDisks) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 906 | disk->destroy(); |
Youkichi Hosoi | dfaff1d | 2021-11-25 16:24:35 +0900 | [diff] [blame] | 907 | if (!disk->isStub()) { |
| 908 | disk->create(); |
| 909 | } |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 910 | } |
Youkichi Hosoi | dfaff1d | 2021-11-25 16:24:35 +0900 | [diff] [blame] | 911 | const auto isStub = [](const auto& disk) { return disk->isStub(); }; |
| 912 | mDisks.remove_if(isStub); |
| 913 | mPendingDisks.remove_if(isStub); |
| 914 | |
Jeff Sharkey | fa1c677 | 2017-03-25 22:49:13 -0600 | [diff] [blame] | 915 | updateVirtualDisk(); |
Jeff Sharkey | bd3038d | 2015-06-10 09:42:01 -0700 | [diff] [blame] | 916 | mAddedUsers.clear(); |
Sudheer Shanka | 023b539 | 2019-02-06 12:39:19 -0800 | [diff] [blame] | 917 | mStartedUsers.clear(); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 918 | return 0; |
| 919 | } |
| 920 | |
Keun-young Park | a5bbb5e | 2017-03-13 18:02:50 -0700 | [diff] [blame] | 921 | // Can be called twice (sequentially) during shutdown. should be safe for that. |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 922 | int VolumeManager::shutdown() { |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 923 | if (mInternalEmulatedVolumes.empty()) { |
Paul Crowley | edf7a4e | 2018-09-18 15:14:18 -0700 | [diff] [blame] | 924 | return 0; // already shutdown |
Keun-young Park | a5bbb5e | 2017-03-13 18:02:50 -0700 | [diff] [blame] | 925 | } |
Paul Crowley | 56292ef | 2017-10-20 08:07:53 -0700 | [diff] [blame] | 926 | android::vold::sSleepOnUnmount = false; |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 927 | for (const auto& vol : mInternalEmulatedVolumes) { |
| 928 | vol->destroy(); |
| 929 | } |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 930 | for (const auto& disk : mDisks) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 931 | disk->destroy(); |
| 932 | } |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 933 | |
| 934 | mInternalEmulatedVolumes.clear(); |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 935 | mDisks.clear(); |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame] | 936 | mPendingDisks.clear(); |
Paul Crowley | 56292ef | 2017-10-20 08:07:53 -0700 | [diff] [blame] | 937 | android::vold::sSleepOnUnmount = true; |
Martijn Coenen | 23c0445 | 2020-04-29 07:49:41 +0200 | [diff] [blame] | 938 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 939 | return 0; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 940 | } |
| 941 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 942 | int VolumeManager::unmountAll() { |
Jeff Sharkey | c8e04c5 | 2015-04-21 12:14:17 -0700 | [diff] [blame] | 943 | std::lock_guard<std::mutex> lock(mLock); |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 944 | ATRACE_NAME("VolumeManager::unmountAll()"); |
Jeff Sharkey | c8e04c5 | 2015-04-21 12:14:17 -0700 | [diff] [blame] | 945 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 946 | // First, try gracefully unmounting all known devices |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 947 | for (const auto& vol : mInternalEmulatedVolumes) { |
| 948 | vol->unmount(); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 949 | } |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 950 | for (const auto& disk : mDisks) { |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 951 | disk->unmountAll(); |
| 952 | } |
| 953 | |
| 954 | // Worst case we might have some stale mounts lurking around, so |
| 955 | // force unmount those just to be safe. |
LongPing.WEI | 4f04606 | 2018-11-23 19:27:35 +0800 | [diff] [blame] | 956 | FILE* fp = setmntent("/proc/mounts", "re"); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 957 | if (fp == NULL) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 958 | PLOG(ERROR) << "Failed to open /proc/mounts"; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 959 | return -errno; |
| 960 | } |
| 961 | |
| 962 | // Some volumes can be stacked on each other, so force unmount in |
| 963 | // reverse order to give us the best chance of success. |
| 964 | std::list<std::string> toUnmount; |
| 965 | mntent* mentry; |
| 966 | while ((mentry = getmntent(fp)) != NULL) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 967 | auto test = std::string(mentry->mnt_dir); |
Mark Salyzyn | 86e81e7 | 2018-09-20 10:09:27 -0700 | [diff] [blame] | 968 | if ((StartsWith(test, "/mnt/") && |
| 969 | #ifdef __ANDROID_DEBUGGABLE__ |
| 970 | !StartsWith(test, "/mnt/scratch") && |
| 971 | #endif |
Martijn Coenen | b0e977a | 2020-01-11 19:24:26 +0100 | [diff] [blame] | 972 | !StartsWith(test, "/mnt/vendor") && !StartsWith(test, "/mnt/product") && |
Ricky Wai | ef63921 | 2020-04-07 13:43:20 +0100 | [diff] [blame] | 973 | !StartsWith(test, "/mnt/installer") && !StartsWith(test, "/mnt/androidwritable")) || |
Mark Salyzyn | 86e81e7 | 2018-09-20 10:09:27 -0700 | [diff] [blame] | 974 | StartsWith(test, "/storage/")) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 975 | toUnmount.push_front(test); |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 976 | } |
| 977 | } |
| 978 | endmntent(fp); |
| 979 | |
Chih-Hung Hsieh | 11a2ce8 | 2016-07-27 14:11:02 -0700 | [diff] [blame] | 980 | for (const auto& path : toUnmount) { |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 981 | LOG(DEBUG) << "Tearing down stale mount " << path; |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 982 | android::vold::ForceUnmount(path); |
| 983 | } |
| 984 | |
| 985 | return 0; |
| 986 | } |
| 987 | |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 988 | int VolumeManager::ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid) { |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 989 | int size = paths.size(); |
| 990 | for (int i = 0; i < size; i++) { |
| 991 | int result = setupAppDir(paths[i], appUid, false /* fixupExistingOnly */, |
| 992 | true /* skipIfDirExists */); |
| 993 | if (result != OK) { |
| 994 | return result; |
| 995 | } |
| 996 | } |
| 997 | return OK; |
| 998 | } |
| 999 | |
| 1000 | int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly, |
| 1001 | bool skipIfDirExists) { |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 1002 | // Only offer to create directories for paths managed by vold |
Martijn Coenen | 13ff668 | 2019-12-24 12:57:16 +0100 | [diff] [blame] | 1003 | if (!StartsWith(path, "/storage/")) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 1004 | LOG(ERROR) << "Failed to find mounted volume for " << path; |
Jeff Sharkey | 71ebe15 | 2013-09-17 17:24:38 -0700 | [diff] [blame] | 1005 | return -EINVAL; |
| 1006 | } |
Martijn Coenen | 13ff668 | 2019-12-24 12:57:16 +0100 | [diff] [blame] | 1007 | |
Martijn Coenen | 0a7e992 | 2020-01-24 16:17:32 +0100 | [diff] [blame] | 1008 | // Find the volume it belongs to |
| 1009 | auto filter_fn = [&](const VolumeBase& vol) { |
| 1010 | if (vol.getState() != VolumeBase::State::kMounted) { |
| 1011 | // The volume must be mounted |
| 1012 | return false; |
| 1013 | } |
Youkichi Hosoi | 2991cbe | 2021-11-11 11:23:01 +0900 | [diff] [blame] | 1014 | if (!vol.isVisibleForWrite()) { |
| 1015 | // App dirs should only be created for writable volumes. |
Martijn Coenen | 0a7e992 | 2020-01-24 16:17:32 +0100 | [diff] [blame] | 1016 | return false; |
| 1017 | } |
| 1018 | if (vol.getInternalPath().empty()) { |
| 1019 | return false; |
| 1020 | } |
| 1021 | if (vol.getMountUserId() != USER_UNKNOWN && |
| 1022 | vol.getMountUserId() != multiuser_get_user_id(appUid)) { |
| 1023 | // The app dir must be created on a volume with the same user-id |
| 1024 | return false; |
| 1025 | } |
| 1026 | if (!path.empty() && StartsWith(path, vol.getPath())) { |
| 1027 | return true; |
| 1028 | } |
| 1029 | |
| 1030 | return false; |
| 1031 | }; |
| 1032 | auto volume = findVolumeWithFilter(filter_fn); |
| 1033 | if (volume == nullptr) { |
| 1034 | LOG(ERROR) << "Failed to find mounted volume for " << path; |
| 1035 | return -EINVAL; |
| 1036 | } |
Zim | c59d774 | 2020-01-06 21:48:16 +0000 | [diff] [blame] | 1037 | // Convert paths to lower filesystem paths to avoid making FUSE requests for these reasons: |
| 1038 | // 1. A FUSE request from vold puts vold at risk of hanging if the FUSE daemon is down |
| 1039 | // 2. The FUSE daemon prevents requests on /mnt/user/0/emulated/<userid != 0> and a request |
| 1040 | // on /storage/emulated/10 means /mnt/user/0/emulated/10 |
Martijn Coenen | 0a7e992 | 2020-01-24 16:17:32 +0100 | [diff] [blame] | 1041 | const std::string lowerPath = |
| 1042 | volume->getInternalPath() + path.substr(volume->getPath().length()); |
Zim | c59d774 | 2020-01-06 21:48:16 +0000 | [diff] [blame] | 1043 | |
Martijn Coenen | 62a4b27 | 2020-01-31 15:23:09 +0100 | [diff] [blame] | 1044 | const std::string volumeRoot = volume->getRootPath(); // eg /data/media/0 |
| 1045 | |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 1046 | const int access_result = access(lowerPath.c_str(), F_OK); |
| 1047 | if (fixupExistingOnly && access_result != 0) { |
Martijn Coenen | 816f4d9 | 2020-02-18 15:06:37 +0100 | [diff] [blame] | 1048 | // Nothing to fixup |
| 1049 | return OK; |
| 1050 | } |
| 1051 | |
Ricky Wai | bbfb6ea | 2020-12-03 15:32:52 +0000 | [diff] [blame] | 1052 | if (skipIfDirExists && access_result == 0) { |
| 1053 | // It's safe to assume it's ok as it will be used for zygote to bind mount dir only, |
| 1054 | // which the dir doesn't need to have correct permission for now yet. |
| 1055 | return OK; |
| 1056 | } |
| 1057 | |
Martijn Coenen | bf205ab | 2020-04-20 15:14:48 +0200 | [diff] [blame] | 1058 | if (volume->getType() == VolumeBase::Type::kPublic) { |
| 1059 | // On public volumes, we don't need to setup permissions, as everything goes through |
| 1060 | // FUSE; just create the dirs and be done with it. |
| 1061 | return fs_mkdirs(lowerPath.c_str(), 0700); |
| 1062 | } |
| 1063 | |
Martijn Coenen | b5a31c9 | 2020-02-13 23:30:38 +0100 | [diff] [blame] | 1064 | // Create the app paths we need from the root |
Martijn Coenen | 816f4d9 | 2020-02-18 15:06:37 +0100 | [diff] [blame] | 1065 | return PrepareAppDirFromRoot(lowerPath, volumeRoot, appUid, fixupExistingOnly); |
| 1066 | } |
| 1067 | |
| 1068 | int VolumeManager::fixupAppDir(const std::string& path, int32_t appUid) { |
Daniel Rosenberg | f36bddd | 2020-05-11 22:58:42 -0700 | [diff] [blame] | 1069 | if (IsSdcardfsUsed()) { |
Martijn Coenen | 816f4d9 | 2020-02-18 15:06:37 +0100 | [diff] [blame] | 1070 | //sdcardfs magically does this for us |
| 1071 | return OK; |
| 1072 | } |
| 1073 | return setupAppDir(path, appUid, true /* fixupExistingOnly */); |
Jeff Sharkey | 71ebe15 | 2013-09-17 17:24:38 -0700 | [diff] [blame] | 1074 | } |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1075 | |
Eric Biggers | 7e79a43 | 2022-03-01 21:19:18 +0000 | [diff] [blame^] | 1076 | int VolumeManager::createObb(const std::string& sourcePath, int32_t ownerGid, |
| 1077 | std::string* outVolId) { |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1078 | int id = mNextObbId++; |
| 1079 | |
Martijn Coenen | d6a612a | 2020-11-19 10:49:45 +0100 | [diff] [blame] | 1080 | std::string lowerSourcePath; |
| 1081 | |
| 1082 | // Convert to lower filesystem path |
| 1083 | if (StartsWith(sourcePath, "/storage/")) { |
| 1084 | auto filter_fn = [&](const VolumeBase& vol) { |
| 1085 | if (vol.getState() != VolumeBase::State::kMounted) { |
| 1086 | // The volume must be mounted |
| 1087 | return false; |
| 1088 | } |
Youkichi Hosoi | 2991cbe | 2021-11-11 11:23:01 +0900 | [diff] [blame] | 1089 | if (!vol.isVisibleForWrite()) { |
| 1090 | // Obb volume should only be created for writable volumes. |
Martijn Coenen | d6a612a | 2020-11-19 10:49:45 +0100 | [diff] [blame] | 1091 | return false; |
| 1092 | } |
| 1093 | if (vol.getInternalPath().empty()) { |
| 1094 | return false; |
| 1095 | } |
| 1096 | if (!sourcePath.empty() && StartsWith(sourcePath, vol.getPath())) { |
| 1097 | return true; |
| 1098 | } |
| 1099 | |
| 1100 | return false; |
| 1101 | }; |
| 1102 | auto volume = findVolumeWithFilter(filter_fn); |
| 1103 | if (volume == nullptr) { |
| 1104 | LOG(ERROR) << "Failed to find mounted volume for " << sourcePath; |
| 1105 | return -EINVAL; |
| 1106 | } else { |
| 1107 | lowerSourcePath = |
| 1108 | volume->getInternalPath() + sourcePath.substr(volume->getPath().length()); |
| 1109 | } |
| 1110 | } else { |
| 1111 | lowerSourcePath = sourcePath; |
| 1112 | } |
| 1113 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1114 | auto vol = std::shared_ptr<android::vold::VolumeBase>( |
Eric Biggers | 7e79a43 | 2022-03-01 21:19:18 +0000 | [diff] [blame^] | 1115 | new android::vold::ObbVolume(id, lowerSourcePath, ownerGid)); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1116 | vol->create(); |
| 1117 | |
| 1118 | mObbVolumes.push_back(vol); |
| 1119 | *outVolId = vol->getId(); |
| 1120 | return android::OK; |
| 1121 | } |
| 1122 | |
| 1123 | int VolumeManager::destroyObb(const std::string& volId) { |
| 1124 | auto i = mObbVolumes.begin(); |
| 1125 | while (i != mObbVolumes.end()) { |
| 1126 | if ((*i)->getId() == volId) { |
| 1127 | (*i)->destroy(); |
| 1128 | i = mObbVolumes.erase(i); |
| 1129 | } else { |
| 1130 | ++i; |
| 1131 | } |
| 1132 | } |
| 1133 | return android::OK; |
| 1134 | } |
| 1135 | |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 1136 | int VolumeManager::createStubVolume(const std::string& sourcePath, const std::string& mountPath, |
| 1137 | const std::string& fsType, const std::string& fsUuid, |
Risan | 73a7a85 | 2020-02-07 18:03:44 +0900 | [diff] [blame] | 1138 | const std::string& fsLabel, int32_t flags, |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 1139 | std::string* outVolId) { |
| 1140 | dev_t stubId = --mNextStubId; |
| 1141 | auto vol = std::shared_ptr<android::vold::StubVolume>( |
| 1142 | new android::vold::StubVolume(stubId, sourcePath, mountPath, fsType, fsUuid, fsLabel)); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 1143 | |
Youkichi Hosoi | defc045 | 2020-07-08 06:08:48 +0900 | [diff] [blame] | 1144 | int32_t passedFlags = 0; |
Risan | 73a7a85 | 2020-02-07 18:03:44 +0900 | [diff] [blame] | 1145 | passedFlags |= (flags & android::vold::Disk::Flags::kUsb); |
| 1146 | passedFlags |= (flags & android::vold::Disk::Flags::kSd); |
Youkichi Hosoi | defc045 | 2020-07-08 06:08:48 +0900 | [diff] [blame] | 1147 | if (flags & android::vold::Disk::Flags::kStubVisible) { |
| 1148 | passedFlags |= (flags & android::vold::Disk::Flags::kStubVisible); |
| 1149 | } else { |
| 1150 | passedFlags |= (flags & android::vold::Disk::Flags::kStubInvisible); |
| 1151 | } |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 1152 | // StubDisk doesn't have device node corresponds to it. So, a fake device |
Risan | 73a7a85 | 2020-02-07 18:03:44 +0900 | [diff] [blame] | 1153 | // number is used. |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 1154 | auto disk = std::shared_ptr<android::vold::Disk>( |
Risan | 73a7a85 | 2020-02-07 18:03:44 +0900 | [diff] [blame] | 1155 | new android::vold::Disk("stub", stubId, "stub", passedFlags)); |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 1156 | disk->initializePartition(vol); |
| 1157 | handleDiskAdded(disk); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 1158 | *outVolId = vol->getId(); |
| 1159 | return android::OK; |
| 1160 | } |
| 1161 | |
| 1162 | int VolumeManager::destroyStubVolume(const std::string& volId) { |
Risan | 82e90de | 2020-02-04 16:07:21 +0900 | [diff] [blame] | 1163 | auto tokens = android::base::Split(volId, ":"); |
| 1164 | CHECK(tokens.size() == 2); |
| 1165 | dev_t stubId; |
| 1166 | CHECK(android::base::ParseUint(tokens[1], &stubId)); |
| 1167 | handleDiskRemoved(stubId); |
Risan | 8c9f332 | 2018-10-29 08:52:56 +0900 | [diff] [blame] | 1168 | return android::OK; |
| 1169 | } |
| 1170 | |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 1171 | int VolumeManager::mountAppFuse(uid_t uid, int mountId, unique_fd* device_fd) { |
Risan | ac02a48 | 2018-10-31 21:59:47 -0600 | [diff] [blame] | 1172 | return android::vold::MountAppFuse(uid, mountId, device_fd); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1173 | } |
| 1174 | |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 1175 | int VolumeManager::unmountAppFuse(uid_t uid, int mountId) { |
Risan | ac02a48 | 2018-10-31 21:59:47 -0600 | [diff] [blame] | 1176 | return android::vold::UnmountAppFuse(uid, mountId); |
Risan | 8f6198d | 2018-10-26 20:56:45 -0600 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | int VolumeManager::openAppFuseFile(uid_t uid, int mountId, int fileId, int flags) { |
Risan | ac02a48 | 2018-10-31 21:59:47 -0600 | [diff] [blame] | 1180 | return android::vold::OpenAppFuseFile(uid, mountId, fileId, flags); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 1181 | } |