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