blob: 3e7101c30d7c1c1e793e70931891e050a34a4ccd [file] [log] [blame]
San Mehatf1b736b2009-10-10 17:22:08 -07001/*
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 Sharkey67b8c492017-09-21 17:08:43 -060017#define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER
18
Yabin Cuid1104f72015-01-02 13:28:28 -080019#include <dirent.h>
San Mehatf1b736b2009-10-10 17:22:08 -070020#include <errno.h>
San Mehata2677e42009-12-13 10:40:18 -080021#include <fcntl.h>
Yabin Cuid1104f72015-01-02 13:28:28 -080022#include <mntent.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <sys/ioctl.h>
27#include <sys/mount.h>
San Mehata19b2502010-01-06 10:33:53 -080028#include <sys/stat.h>
Elliott Hughes0e08e842017-05-18 09:08:24 -070029#include <sys/sysmacros.h>
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070030#include <sys/types.h>
Jeff Sharkey66270a22015-06-24 11:49:24 -070031#include <sys/wait.h>
Yabin Cuid1104f72015-01-02 13:28:28 -080032#include <unistd.h>
Sudheer Shanka40ab6742018-09-18 13:07:45 -070033#include <array>
San Mehata19b2502010-01-06 10:33:53 -080034
San Mehata2677e42009-12-13 10:40:18 -080035#include <linux/kdev_t.h>
San Mehatf1b736b2009-10-10 17:22:08 -070036
Jiyong Park8d21c922019-01-04 13:35:25 +090037#include <ApexProperties.sysprop.h>
Elliott Hughes7e128fb2015-12-04 15:50:53 -080038#include <android-base/logging.h>
Jeff Vander Stoep58890832017-10-23 17:12:31 -070039#include <android-base/parseint.h>
Jeff Sharkey3472e522017-10-06 18:02:53 -060040#include <android-base/properties.h>
Elliott Hughes7e128fb2015-12-04 15:50:53 -080041#include <android-base/stringprintf.h>
Jeff Vander Stoep58890832017-10-23 17:12:31 -070042#include <android-base/strings.h>
43
Jeff Sharkey71ebe152013-09-17 17:24:38 -070044#include <cutils/fs.h>
Jeff Sharkey67b8c492017-09-21 17:08:43 -060045#include <utils/Trace.h>
San Mehatf1b736b2009-10-10 17:22:08 -070046
Robert Craigb9e3ba52014-02-04 10:53:00 -050047#include <selinux/android.h>
48
San Mehatfd7f5872009-10-12 11:32:47 -070049#include <sysutils/NetlinkEvent.h>
50
Kenny Root344ca102012-04-03 17:23:01 -070051#include <private/android_filesystem_config.h>
52
Eric Biggersa701c452018-10-23 13:06:55 -070053#include <fscrypt/fscrypt.h>
Paul Crowleyc6433a22017-10-24 14:54:43 -070054
Risanac02a482018-10-31 21:59:47 -060055#include "AppFuseUtil.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070056#include "Devmapper.h"
Eric Biggersa701c452018-10-23 13:06:55 -070057#include "FsCrypt.h"
San Mehata19b2502010-01-06 10:33:53 -080058#include "Loop.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070059#include "NetlinkManager.h"
60#include "Process.h"
61#include "Utils.h"
Sudheer Shanka40ab6742018-09-18 13:07:45 -070062#include "VoldNativeService.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070063#include "VoldUtil.h"
64#include "VolumeManager.h"
65#include "cryptfs.h"
Jeff Sharkeyd0640f62015-05-21 22:35:42 -070066#include "fs/Ext4.h"
67#include "fs/Vfat.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070068#include "model/EmulatedVolume.h"
69#include "model/ObbVolume.h"
Zima438b242019-09-25 14:37:38 +010070#include "model/PrivateVolume.h"
Risan8c9f3322018-10-29 08:52:56 +090071#include "model/StubVolume.h"
San Mehat23969932010-01-09 07:08:06 -080072
Sudheer Shankaf9b38a52019-02-14 19:09:51 +000073using android::OK;
Sudheer Shanka53947a32018-08-01 10:24:13 -070074using android::base::GetBoolProperty;
Mark Salyzyn86e81e72018-09-20 10:09:27 -070075using android::base::StartsWith;
Sudheer Shanka53947a32018-08-01 10:24:13 -070076using android::base::StringAppendF;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070077using android::base::StringPrintf;
Jeff Sharkey11c2d382017-09-11 10:32:01 -060078using android::base::unique_fd;
Sudheer Shanka023b5392019-02-06 12:39:19 -080079using android::vold::BindMount;
Sudheer Shankaf9b38a52019-02-14 19:09:51 +000080using android::vold::CreateDir;
Sudheer Shanka30df1c62019-02-22 17:03:02 -080081using android::vold::DeleteDirContents;
Sudheer Shanka023b5392019-02-06 12:39:19 -080082using android::vold::DeleteDirContentsAndDir;
Zima438b242019-09-25 14:37:38 +010083using android::vold::PrivateVolume;
Sudheer Shanka023b5392019-02-06 12:39:19 -080084using android::vold::Symlink;
85using android::vold::Unlink;
86using android::vold::UnmountTree;
Sudheer Shanka03992e32018-12-12 12:43:38 -080087using android::vold::VoldNativeService;
Zima438b242019-09-25 14:37:38 +010088using android::vold::VolumeBase;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070089
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -060090static const char* kPathUserMount = "/mnt/user";
91static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
92
93static const char* kPropVirtualDisk = "persist.sys.virtual_disk";
94
Sudheer Shanka53947a32018-08-01 10:24:13 -070095static const std::string kEmptyString("");
96
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -060097/* 512MiB is large enough for testing purposes */
98static const unsigned int kSizeVirtualDisk = 536870912;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070099
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700100static const unsigned int kMajorBlockMmc = 179;
Yu Ning942d4e82016-01-08 17:36:47 +0800101static const unsigned int kMajorBlockExperimentalMin = 240;
102static const unsigned int kMajorBlockExperimentalMax = 254;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700103
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700104VolumeManager* VolumeManager::sInstance = NULL;
San Mehatf1b736b2009-10-10 17:22:08 -0700105
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700106VolumeManager* VolumeManager::Instance() {
107 if (!sInstance) sInstance = new VolumeManager();
San Mehatf1b736b2009-10-10 17:22:08 -0700108 return sInstance;
109}
110
111VolumeManager::VolumeManager() {
San Mehatd9a4e352010-03-12 13:32:47 -0800112 mDebug = false;
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600113 mNextObbId = 0;
Risan8c9f3322018-10-29 08:52:56 +0900114 mNextStubVolumeId = 0;
Jeff Sharkey401b2602017-12-14 22:15:20 -0700115 // For security reasons, assume that a secure keyguard is
116 // showing until we hear otherwise
117 mSecureKeyguardShowing = true;
San Mehatf1b736b2009-10-10 17:22:08 -0700118}
119
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700120VolumeManager::~VolumeManager() {}
San Mehatd9a4e352010-03-12 13:32:47 -0800121
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600122int VolumeManager::updateVirtualDisk() {
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600123 ATRACE_NAME("VolumeManager::updateVirtualDisk");
Mark Salyzyn86e81e72018-09-20 10:09:27 -0700124 if (GetBoolProperty(kPropVirtualDisk, false)) {
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600125 if (access(kPathVirtualDisk, F_OK) != 0) {
126 Loop::createImageFile(kPathVirtualDisk, kSizeVirtualDisk / 512);
127 }
128
129 if (mVirtualDisk == nullptr) {
130 if (Loop::create(kPathVirtualDisk, mVirtualDiskPath) != 0) {
131 LOG(ERROR) << "Failed to create virtual disk";
132 return -1;
133 }
134
135 struct stat buf;
136 if (stat(mVirtualDiskPath.c_str(), &buf) < 0) {
137 PLOG(ERROR) << "Failed to stat " << mVirtualDiskPath;
138 return -1;
139 }
140
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700141 auto disk = new android::vold::Disk(
142 "virtual", buf.st_rdev, "virtual",
143 android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600144 mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk);
Jeff Sharkey401b2602017-12-14 22:15:20 -0700145 handleDiskAdded(mVirtualDisk);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600146 }
147 } else {
148 if (mVirtualDisk != nullptr) {
149 dev_t device = mVirtualDisk->getDevice();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700150 handleDiskRemoved(device);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600151
152 Loop::destroyByDevice(mVirtualDiskPath.c_str());
153 mVirtualDisk = nullptr;
154 }
155
156 if (access(kPathVirtualDisk, F_OK) == 0) {
157 unlink(kPathVirtualDisk);
158 }
159 }
160 return 0;
161}
162
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700163int VolumeManager::setDebug(bool enable) {
San Mehatd9a4e352010-03-12 13:32:47 -0800164 mDebug = enable;
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700165 return 0;
San Mehatd9a4e352010-03-12 13:32:47 -0800166}
167
San Mehatf1b736b2009-10-10 17:22:08 -0700168int VolumeManager::start() {
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600169 ATRACE_NAME("VolumeManager::start");
170
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700171 // Always start from a clean slate by unmounting everything in
172 // directories that we own, in case we crashed.
Jeff Sharkey9c484982015-03-31 10:35:33 -0700173 unmountAll();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700174
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600175 Devmapper::destroyAll();
176 Loop::destroyAll();
177
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700178 // Assume that we always have an emulated volume on internal
179 // storage; the framework will decide if it should be mounted.
Zima438b242019-09-25 14:37:38 +0100180 CHECK(mInternalEmulatedVolumes.empty());
181
182 auto vol = std::shared_ptr<android::vold::VolumeBase>(
183 new android::vold::EmulatedVolume("/data/media", 0));
184 vol->setMountUserId(0);
185 vol->create();
186 mInternalEmulatedVolumes.push_back(vol);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700187
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600188 // Consider creating a virtual disk
189 updateVirtualDisk();
190
San Mehatf1b736b2009-10-10 17:22:08 -0700191 return 0;
192}
193
194int VolumeManager::stop() {
Zima438b242019-09-25 14:37:38 +0100195 CHECK(!mInternalEmulatedVolumes.empty());
196 for (const auto& vol : mInternalEmulatedVolumes) {
197 vol->destroy();
198 }
199 mInternalEmulatedVolumes.clear();
200
San Mehatf1b736b2009-10-10 17:22:08 -0700201 return 0;
202}
203
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700204void VolumeManager::handleBlockEvent(NetlinkEvent* evt) {
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700205 std::lock_guard<std::mutex> lock(mLock);
206
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700207 if (mDebug) {
Sudheer Shanka4b6ca4e2018-09-21 10:54:54 -0700208 LOG(DEBUG) << "----------------";
209 LOG(DEBUG) << "handleBlockEvent with action " << (int)evt->getAction();
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700210 evt->dump();
211 }
San Mehatf1b736b2009-10-10 17:22:08 -0700212
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700213 std::string eventPath(evt->findParam("DEVPATH") ? evt->findParam("DEVPATH") : "");
214 std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : "");
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700215
216 if (devType != "disk") return;
217
Jeff Sharkey95440eb2017-09-18 18:19:28 -0600218 int major = std::stoi(evt->findParam("MAJOR"));
219 int minor = std::stoi(evt->findParam("MINOR"));
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700220 dev_t device = makedev(major, minor);
221
222 switch (evt->getAction()) {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700223 case NetlinkEvent::Action::kAdd: {
224 for (const auto& source : mDiskSources) {
225 if (source->matches(eventPath)) {
226 // For now, assume that MMC and virtio-blk (the latter is
227 // emulator-specific; see Disk.cpp for details) devices are SD,
228 // and that everything else is USB
229 int flags = source->getFlags();
230 if (major == kMajorBlockMmc || (android::vold::IsRunningInEmulator() &&
231 major >= (int)kMajorBlockExperimentalMin &&
232 major <= (int)kMajorBlockExperimentalMax)) {
233 flags |= android::vold::Disk::Flags::kSd;
234 } else {
235 flags |= android::vold::Disk::Flags::kUsb;
236 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700237
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700238 auto disk =
239 new android::vold::Disk(eventPath, device, source->getNickname(), flags);
240 handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
241 break;
242 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700243 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700244 break;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700245 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700246 case NetlinkEvent::Action::kChange: {
247 LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
248 handleDiskChanged(device);
249 break;
250 }
251 case NetlinkEvent::Action::kRemove: {
252 handleDiskRemoved(device);
253 break;
254 }
255 default: {
256 LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction();
257 break;
258 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700259 }
260}
261
Jeff Sharkey401b2602017-12-14 22:15:20 -0700262void VolumeManager::handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk) {
263 // For security reasons, if secure keyguard is showing, wait
264 // until the user unlocks the device to actually touch it
265 if (mSecureKeyguardShowing) {
266 LOG(INFO) << "Found disk at " << disk->getEventPath()
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700267 << " but delaying scan due to secure keyguard";
Jeff Sharkey401b2602017-12-14 22:15:20 -0700268 mPendingDisks.push_back(disk);
269 } else {
270 disk->create();
271 mDisks.push_back(disk);
272 }
273}
274
275void 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
287void 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 Sharkey36801cc2015-03-13 16:09:20 -0700307void VolumeManager::addDiskSource(const std::shared_ptr<DiskSource>& diskSource) {
Wei Wang6b455c22017-01-20 11:52:33 -0800308 std::lock_guard<std::mutex> lock(mLock);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700309 mDiskSources.push_back(diskSource);
310}
311
312std::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 Mehatf1b736b2009-10-10 17:22:08 -0700316 }
317 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700318 return nullptr;
319}
San Mehatf1b736b2009-10-10 17:22:08 -0700320
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700321std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::string& id) {
Zima438b242019-09-25 14:37:38 +0100322 for (const auto& vol : mInternalEmulatedVolumes) {
323 if (vol->getId() == id) {
324 return vol;
325 }
San Mehatf1b736b2009-10-10 17:22:08 -0700326 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700327 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700328 auto vol = disk->findVolume(id);
329 if (vol != nullptr) {
330 return vol;
331 }
332 }
Risan8c9f3322018-10-29 08:52:56 +0900333 for (const auto& vol : mStubVolumes) {
334 if (vol->getId() == id) {
335 return vol;
336 }
337 }
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600338 for (const auto& vol : mObbVolumes) {
339 if (vol->getId() == id) {
340 return vol;
341 }
342 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700343 return nullptr;
344}
345
Greg Kaiser2bc201e2018-12-18 08:42:08 -0800346void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
347 std::list<std::string>& list) const {
Jeff Sharkeyc86ab6f2015-06-26 14:02:09 -0700348 list.clear();
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700349 for (const auto& disk : mDisks) {
Jeff Sharkeyc86ab6f2015-06-26 14:02:09 -0700350 disk->listVolumes(type, list);
351 }
352}
353
Jeff Sharkey3ce18252017-10-24 11:08:45 -0600354int VolumeManager::forgetPartition(const std::string& partGuid, const std::string& fsUuid) {
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700355 std::string normalizedGuid;
356 if (android::vold::NormalizeHex(partGuid, normalizedGuid)) {
357 LOG(WARNING) << "Invalid GUID " << partGuid;
358 return -1;
359 }
360
Paul Crowleyc6433a22017-10-24 14:54:43 -0700361 bool success = true;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700362 std::string keyPath = android::vold::BuildKeyPath(normalizedGuid);
363 if (unlink(keyPath.c_str()) != 0) {
364 LOG(ERROR) << "Failed to unlink " << keyPath;
Paul Crowleyc6433a22017-10-24 14:54:43 -0700365 success = false;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700366 }
Eric Biggersa701c452018-10-23 13:06:55 -0700367 if (fscrypt_is_native()) {
368 if (!fscrypt_destroy_volume_keys(fsUuid)) {
Paul Crowleyc6433a22017-10-24 14:54:43 -0700369 success = false;
370 }
371 }
372 return success ? 0 : -1;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700373}
374
Sudheer Shanka40ab6742018-09-18 13:07:45 -0700375int VolumeManager::linkPrimary(userid_t userId) {
Zima438b242019-09-25 14:37:38 +0100376 if (!GetBoolProperty(android::vold::kPropFuseSnapshot, false)) {
377 std::string source(mPrimary->getPath());
378 if (mPrimary->isEmulated()) {
379 source = StringPrintf("%s/%d", source.c_str(), userId);
380 fs_prepare_dir(source.c_str(), 0755, AID_ROOT, AID_ROOT);
381 }
Zim3623a212019-07-19 16:46:53 +0100382
Zima438b242019-09-25 14:37:38 +0100383 std::string target(StringPrintf("/mnt/user/%d/primary", userId));
384 LOG(DEBUG) << "Linking " << source << " to " << target;
385 Symlink(source, target);
Zim3623a212019-07-19 16:46:53 +0100386 }
Sudheer Shanka40ab6742018-09-18 13:07:45 -0700387 return 0;
388}
389
Zima438b242019-09-25 14:37:38 +0100390void VolumeManager::destroyEmulatedVolumesForUser(userid_t userId) {
391 // Destroy and remove all unstacked EmulatedVolumes for the user
392 auto i = mInternalEmulatedVolumes.begin();
393 while (i != mInternalEmulatedVolumes.end()) {
394 auto vol = *i;
395 if (vol->getMountUserId() == userId) {
396 vol->destroy();
397 i = mInternalEmulatedVolumes.erase(i);
398 } else {
399 i++;
400 }
401 }
402
403 // Destroy and remove all stacked EmulatedVolumes for the user on each mounted private volume
404 std::list<std::string> private_vols;
405 listVolumes(VolumeBase::Type::kPrivate, private_vols);
406 for (const std::string& id : private_vols) {
407 PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get());
408 std::list<std::shared_ptr<VolumeBase>> vols_to_remove;
409 if (pvol->getState() == VolumeBase::State::kMounted) {
410 for (const auto& vol : pvol->getVolumes()) {
411 if (vol->getMountUserId() == userId) {
412 vols_to_remove.push_back(vol);
413 }
414 }
415 for (const auto& vol : vols_to_remove) {
416 vol->destroy();
417 pvol->removeVolume(vol);
418 }
419 } // else EmulatedVolumes will be destroyed on VolumeBase#unmount
420 }
421}
422
423void VolumeManager::createEmulatedVolumesForUser(userid_t userId) {
424 // Create unstacked EmulatedVolumes for the user
425 auto vol = std::shared_ptr<android::vold::VolumeBase>(
426 new android::vold::EmulatedVolume("/data/media", userId));
427 vol->setMountUserId(userId);
428 mInternalEmulatedVolumes.push_back(vol);
429 vol->create();
430
431 // Create stacked EmulatedVolumes for the user on each PrivateVolume
432 std::list<std::string> private_vols;
433 listVolumes(VolumeBase::Type::kPrivate, private_vols);
434 for (const std::string& id : private_vols) {
435 PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get());
436 if (pvol->getState() == VolumeBase::State::kMounted) {
437 auto evol =
438 std::shared_ptr<android::vold::VolumeBase>(new android::vold::EmulatedVolume(
439 pvol->getPath() + "/media", pvol->getRawDevice(), pvol->getFsUuid(),
440 userId));
441 evol->setMountUserId(userId);
442 pvol->addVolume(evol);
443 evol->create();
444 } // else EmulatedVolumes will be created per user when on PrivateVolume#doMount
445 }
446}
447
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700448int VolumeManager::onUserAdded(userid_t userId, int userSerialNumber) {
Zima438b242019-09-25 14:37:38 +0100449 LOG(INFO) << "onUserAdded: " << userId;
450
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700451 mAddedUsers[userId] = userSerialNumber;
452 return 0;
453}
454
455int VolumeManager::onUserRemoved(userid_t userId) {
Zima438b242019-09-25 14:37:38 +0100456 LOG(INFO) << "onUserRemoved: " << userId;
457
458 if (GetBoolProperty(android::vold::kPropFuseSnapshot, false) &&
459 mAddedUsers.find(userId) != mAddedUsers.end()) {
460 destroyEmulatedVolumesForUser(userId);
461 }
462
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700463 mAddedUsers.erase(userId);
Zima438b242019-09-25 14:37:38 +0100464 mStartedUsers.erase(userId);
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700465 return 0;
466}
467
Sudheer Shankaebce4cc2019-04-29 10:46:35 -0700468int VolumeManager::onUserStarted(userid_t userId) {
Zima438b242019-09-25 14:37:38 +0100469 LOG(INFO) << "onUserStarted: " << userId;
470
471 if (GetBoolProperty(android::vold::kPropFuseSnapshot, false)) {
472 if (mStartedUsers.find(userId) == mStartedUsers.end()) {
473 createEmulatedVolumesForUser(userId);
474 }
475 } else {
476 // Note that sometimes the system will spin up processes from Zygote
477 // before actually starting the user, so we're okay if Zygote
478 // already created this directory.
479 std::string path(StringPrintf("%s/%d", kPathUserMount, userId));
480 fs_prepare_dir(path.c_str(), 0755, AID_ROOT, AID_ROOT);
481
482 if (mPrimary) {
483 linkPrimary(userId);
484 }
485 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700486
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700487 mStartedUsers.insert(userId);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700488 return 0;
489}
490
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700491int VolumeManager::onUserStopped(userid_t userId) {
Sudheer Shanka40ab6742018-09-18 13:07:45 -0700492 LOG(VERBOSE) << "onUserStopped: " << userId;
Zima438b242019-09-25 14:37:38 +0100493
494 if (GetBoolProperty(android::vold::kPropFuseSnapshot, false) &&
495 mStartedUsers.find(userId) != mStartedUsers.end()) {
496 destroyEmulatedVolumesForUser(userId);
497 }
498
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700499 mStartedUsers.erase(userId);
Sudheer Shankafa6a1742018-10-04 16:26:22 -0700500 return 0;
501}
502
Jeff Sharkey401b2602017-12-14 22:15:20 -0700503int VolumeManager::onSecureKeyguardStateChanged(bool isShowing) {
504 mSecureKeyguardShowing = isShowing;
505 if (!mSecureKeyguardShowing) {
506 // Now that secure keyguard has been dismissed, process
507 // any pending disks
508 for (const auto& disk : mPendingDisks) {
509 disk->create();
510 mDisks.push_back(disk);
511 }
512 mPendingDisks.clear();
513 }
514 return 0;
515}
516
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700517int VolumeManager::setPrimary(const std::shared_ptr<android::vold::VolumeBase>& vol) {
518 mPrimary = vol;
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700519 for (userid_t userId : mStartedUsers) {
Sudheer Shanka40ab6742018-09-18 13:07:45 -0700520 linkPrimary(userId);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700521 }
522 return 0;
523}
524
Sudheer Shanka817b9112018-12-13 17:40:28 -0800525int VolumeManager::remountUid(uid_t uid, int32_t mountMode) {
shafik5cf32b52019-09-25 13:56:01 +0100526 if (GetBoolProperty(android::vold::kPropFuseSnapshot, false)) {
Zim3623a212019-07-19 16:46:53 +0100527 // TODO(135341433): Implement fuse specific logic.
528 return 0;
529 }
Sudheer Shanka817b9112018-12-13 17:40:28 -0800530 std::string mode;
531 switch (mountMode) {
532 case VoldNativeService::REMOUNT_MODE_NONE:
533 mode = "none";
534 break;
535 case VoldNativeService::REMOUNT_MODE_DEFAULT:
536 mode = "default";
537 break;
538 case VoldNativeService::REMOUNT_MODE_READ:
539 mode = "read";
540 break;
541 case VoldNativeService::REMOUNT_MODE_WRITE:
Sudheer Shankaa05ea742019-04-12 13:55:28 -0700542 case VoldNativeService::REMOUNT_MODE_LEGACY:
543 case VoldNativeService::REMOUNT_MODE_INSTALLER:
Sudheer Shanka817b9112018-12-13 17:40:28 -0800544 mode = "write";
545 break;
Sudheer Shanka36bdf7a2019-04-18 15:18:30 -0700546 case VoldNativeService::REMOUNT_MODE_FULL:
547 mode = "full";
548 break;
Zim981222f2019-09-09 10:24:44 +0100549 case VoldNativeService::REMOUNT_MODE_PASS_THROUGH:
550 mode = "pass_through";
551 break;
Sudheer Shanka817b9112018-12-13 17:40:28 -0800552 default:
553 PLOG(ERROR) << "Unknown mode " << std::to_string(mountMode);
554 return -1;
555 }
Jeff Sharkey66270a22015-06-24 11:49:24 -0700556 LOG(DEBUG) << "Remounting " << uid << " as mode " << mode;
557
558 DIR* dir;
559 struct dirent* de;
Jeff Sharkey3472e522017-10-06 18:02:53 -0600560 std::string rootName;
561 std::string pidName;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700562 int pidFd;
563 int nsFd;
564 struct stat sb;
565 pid_t child;
566
Jiyong Park8d21c922019-01-04 13:35:25 +0900567 static bool apexUpdatable = android::sysprop::ApexProperties::updatable().value_or(false);
568
Jeff Sharkey66270a22015-06-24 11:49:24 -0700569 if (!(dir = opendir("/proc"))) {
570 PLOG(ERROR) << "Failed to opendir";
571 return -1;
572 }
573
574 // Figure out root namespace to compare against below
Jeff Sharkey3472e522017-10-06 18:02:53 -0600575 if (!android::vold::Readlinkat(dirfd(dir), "1/ns/mnt", &rootName)) {
576 PLOG(ERROR) << "Failed to read root namespace";
Jeff Sharkey66270a22015-06-24 11:49:24 -0700577 closedir(dir);
578 return -1;
579 }
580
581 // Poke through all running PIDs look for apps running as UID
582 while ((de = readdir(dir))) {
Jeff Vander Stoep58890832017-10-23 17:12:31 -0700583 pid_t pid;
584 if (de->d_type != DT_DIR) continue;
585 if (!android::base::ParseInt(de->d_name, &pid)) continue;
586
Jeff Sharkey66270a22015-06-24 11:49:24 -0700587 pidFd = -1;
588 nsFd = -1;
589
590 pidFd = openat(dirfd(dir), de->d_name, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
591 if (pidFd < 0) {
592 goto next;
593 }
594 if (fstat(pidFd, &sb) != 0) {
595 PLOG(WARNING) << "Failed to stat " << de->d_name;
596 goto next;
597 }
598 if (sb.st_uid != uid) {
599 goto next;
600 }
601
602 // Matches so far, but refuse to touch if in root namespace
603 LOG(DEBUG) << "Found matching PID " << de->d_name;
Jeff Sharkey3472e522017-10-06 18:02:53 -0600604 if (!android::vold::Readlinkat(pidFd, "ns/mnt", &pidName)) {
Jeff Sharkey66270a22015-06-24 11:49:24 -0700605 PLOG(WARNING) << "Failed to read namespace for " << de->d_name;
606 goto next;
607 }
Jeff Sharkey3472e522017-10-06 18:02:53 -0600608 if (rootName == pidName) {
Jeff Sharkey66270a22015-06-24 11:49:24 -0700609 LOG(WARNING) << "Skipping due to root namespace";
610 goto next;
611 }
612
Jiyong Park8d21c922019-01-04 13:35:25 +0900613 if (apexUpdatable) {
614 std::string exeName;
615 // When ro.apex.bionic_updatable is set to true,
616 // some early native processes have mount namespaces that are different
617 // from that of the init. Therefore, above check can't filter them out.
618 // Since the propagation type of / is 'shared', unmounting /storage
619 // for the early native processes affects other processes including
620 // init. Filter out such processes by skipping if a process is a
621 // non-Java process whose UID is < AID_APP_START. (The UID condition
622 // is required to not filter out child processes spawned by apps.)
623 if (!android::vold::Readlinkat(pidFd, "exe", &exeName)) {
624 PLOG(WARNING) << "Failed to read exe name for " << de->d_name;
625 goto next;
626 }
627 if (!StartsWith(exeName, "/system/bin/app_process") && sb.st_uid < AID_APP_START) {
628 LOG(WARNING) << "Skipping due to native system process";
629 goto next;
630 }
631 }
632
Jeff Sharkey66270a22015-06-24 11:49:24 -0700633 // We purposefully leave the namespace open across the fork
Nick Kraleviche7e89ac2019-03-29 16:03:51 -0700634 // NOLINTNEXTLINE(android-cloexec-open): Deliberately not O_CLOEXEC
635 nsFd = openat(pidFd, "ns/mnt", O_RDONLY);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700636 if (nsFd < 0) {
Jeff Sharkeyc7b5b572015-06-30 15:54:17 -0700637 PLOG(WARNING) << "Failed to open namespace for " << de->d_name;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700638 goto next;
639 }
640
641 if (!(child = fork())) {
642 if (setns(nsFd, CLONE_NEWNS) != 0) {
Jeff Sharkeyc7b5b572015-06-30 15:54:17 -0700643 PLOG(ERROR) << "Failed to setns for " << de->d_name;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700644 _exit(1);
645 }
646
Sudheer Shanka99d304a2018-09-27 14:53:51 -0700647 android::vold::UnmountTree("/storage/");
Jeff Sharkey66270a22015-06-24 11:49:24 -0700648
649 std::string storageSource;
650 if (mode == "default") {
Jeff Sharkey1bd078f2015-08-06 11:40:00 -0700651 storageSource = "/mnt/runtime/default";
Jeff Sharkey66270a22015-06-24 11:49:24 -0700652 } else if (mode == "read") {
Jeff Sharkey1bd078f2015-08-06 11:40:00 -0700653 storageSource = "/mnt/runtime/read";
Jeff Sharkey66270a22015-06-24 11:49:24 -0700654 } else if (mode == "write") {
Jeff Sharkey1bd078f2015-08-06 11:40:00 -0700655 storageSource = "/mnt/runtime/write";
Sudheer Shanka8f2ff802019-05-30 16:40:20 -0700656 } else if (mode == "full") {
657 storageSource = "/mnt/runtime/full";
Jeff Sharkey66270a22015-06-24 11:49:24 -0700658 } else {
659 // Sane default of no storage visible
660 _exit(0);
661 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700662 if (TEMP_FAILURE_RETRY(
663 mount(storageSource.c_str(), "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) {
664 PLOG(ERROR) << "Failed to mount " << storageSource << " for " << de->d_name;
Jeff Sharkeyc7b5b572015-06-30 15:54:17 -0700665 _exit(1);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700666 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700667 if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) {
668 PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for " << de->d_name;
Hidehiko Abe674bed12016-03-09 16:42:10 +0900669 _exit(1);
670 }
Jeff Sharkeyc7b5b572015-06-30 15:54:17 -0700671
672 // Mount user-specific symlink helper into place
673 userid_t user_id = multiuser_get_user_id(uid);
674 std::string userSource(StringPrintf("/mnt/user/%d", user_id));
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700675 if (TEMP_FAILURE_RETRY(
676 mount(userSource.c_str(), "/storage/self", NULL, MS_BIND, NULL)) == -1) {
677 PLOG(ERROR) << "Failed to mount " << userSource << " for " << de->d_name;
Jeff Sharkeyc7b5b572015-06-30 15:54:17 -0700678 _exit(1);
679 }
680
Jeff Sharkey66270a22015-06-24 11:49:24 -0700681 _exit(0);
682 }
683
684 if (child == -1) {
685 PLOG(ERROR) << "Failed to fork";
686 goto next;
687 } else {
688 TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0));
689 }
690
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700691 next:
Jeff Sharkey66270a22015-06-24 11:49:24 -0700692 close(nsFd);
693 close(pidFd);
694 }
695 closedir(dir);
696 return 0;
697}
698
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700699int VolumeManager::reset() {
700 // Tear down all existing disks/volumes and start from a blank slate so
701 // newly connected framework hears all events.
Zima438b242019-09-25 14:37:38 +0100702 for (const auto& vol : mInternalEmulatedVolumes) {
703 vol->destroy();
Gao Xiangd263da82017-08-14 11:32:13 +0800704 }
Zima438b242019-09-25 14:37:38 +0100705 mInternalEmulatedVolumes.clear();
706 // Add user 0 cos it's always running and started
707 auto vol = std::shared_ptr<android::vold::VolumeBase>(
708 new android::vold::EmulatedVolume("/data/media", 0));
709 vol->setMountUserId(0);
710 vol->create();
711 mInternalEmulatedVolumes.push_back(vol);
712
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700713 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700714 disk->destroy();
715 disk->create();
716 }
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600717 updateVirtualDisk();
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700718 mAddedUsers.clear();
Sudheer Shanka023b5392019-02-06 12:39:19 -0800719 mStartedUsers.clear();
Zima438b242019-09-25 14:37:38 +0100720
721 mStartedUsers.insert(0);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700722 return 0;
723}
724
Keun-young Parka5bbb5e2017-03-13 18:02:50 -0700725// Can be called twice (sequentially) during shutdown. should be safe for that.
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700726int VolumeManager::shutdown() {
Zima438b242019-09-25 14:37:38 +0100727 if (mInternalEmulatedVolumes.empty()) {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700728 return 0; // already shutdown
Keun-young Parka5bbb5e2017-03-13 18:02:50 -0700729 }
Paul Crowley56292ef2017-10-20 08:07:53 -0700730 android::vold::sSleepOnUnmount = false;
Zima438b242019-09-25 14:37:38 +0100731 for (const auto& vol : mInternalEmulatedVolumes) {
732 vol->destroy();
733 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700734 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700735 disk->destroy();
736 }
Zima438b242019-09-25 14:37:38 +0100737
738 mInternalEmulatedVolumes.clear();
Risan8c9f3322018-10-29 08:52:56 +0900739 mStubVolumes.clear();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700740 mDisks.clear();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700741 mPendingDisks.clear();
Paul Crowley56292ef2017-10-20 08:07:53 -0700742 android::vold::sSleepOnUnmount = true;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700743 return 0;
San Mehatf1b736b2009-10-10 17:22:08 -0700744}
745
Jeff Sharkey9c484982015-03-31 10:35:33 -0700746int VolumeManager::unmountAll() {
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700747 std::lock_guard<std::mutex> lock(mLock);
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600748 ATRACE_NAME("VolumeManager::unmountAll()");
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700749
Jeff Sharkey9c484982015-03-31 10:35:33 -0700750 // First, try gracefully unmounting all known devices
Zima438b242019-09-25 14:37:38 +0100751 for (const auto& vol : mInternalEmulatedVolumes) {
752 vol->unmount();
Jeff Sharkey9c484982015-03-31 10:35:33 -0700753 }
Risan8c9f3322018-10-29 08:52:56 +0900754 for (const auto& stub : mStubVolumes) {
755 stub->unmount();
756 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700757 for (const auto& disk : mDisks) {
Jeff Sharkey9c484982015-03-31 10:35:33 -0700758 disk->unmountAll();
759 }
760
761 // Worst case we might have some stale mounts lurking around, so
762 // force unmount those just to be safe.
LongPing.WEI4f046062018-11-23 19:27:35 +0800763 FILE* fp = setmntent("/proc/mounts", "re");
Jeff Sharkey9c484982015-03-31 10:35:33 -0700764 if (fp == NULL) {
Jeff Sharkey3472e522017-10-06 18:02:53 -0600765 PLOG(ERROR) << "Failed to open /proc/mounts";
Jeff Sharkey9c484982015-03-31 10:35:33 -0700766 return -errno;
767 }
768
769 // Some volumes can be stacked on each other, so force unmount in
770 // reverse order to give us the best chance of success.
771 std::list<std::string> toUnmount;
772 mntent* mentry;
773 while ((mentry = getmntent(fp)) != NULL) {
Jeff Sharkey3472e522017-10-06 18:02:53 -0600774 auto test = std::string(mentry->mnt_dir);
Mark Salyzyn86e81e72018-09-20 10:09:27 -0700775 if ((StartsWith(test, "/mnt/") &&
776#ifdef __ANDROID_DEBUGGABLE__
777 !StartsWith(test, "/mnt/scratch") &&
778#endif
779 !StartsWith(test, "/mnt/vendor") && !StartsWith(test, "/mnt/product")) ||
780 StartsWith(test, "/storage/")) {
Jeff Sharkey3472e522017-10-06 18:02:53 -0600781 toUnmount.push_front(test);
Jeff Sharkey9c484982015-03-31 10:35:33 -0700782 }
783 }
784 endmntent(fp);
785
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700786 for (const auto& path : toUnmount) {
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600787 LOG(DEBUG) << "Tearing down stale mount " << path;
Jeff Sharkey9c484982015-03-31 10:35:33 -0700788 android::vold::ForceUnmount(path);
789 }
790
791 return 0;
792}
793
Jeff Sharkey3472e522017-10-06 18:02:53 -0600794int VolumeManager::mkdirs(const std::string& path) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700795 // Only offer to create directories for paths managed by vold
Mark Salyzyn86e81e72018-09-20 10:09:27 -0700796 if (StartsWith(path, "/storage/")) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700797 // fs_mkdirs() does symlink checking and relative path enforcement
Jeff Sharkey3472e522017-10-06 18:02:53 -0600798 return fs_mkdirs(path.c_str(), 0700);
Jeff Sharkey71ebe152013-09-17 17:24:38 -0700799 } else {
Jeff Sharkey3472e522017-10-06 18:02:53 -0600800 LOG(ERROR) << "Failed to find mounted volume for " << path;
Jeff Sharkey71ebe152013-09-17 17:24:38 -0700801 return -EINVAL;
802 }
Jeff Sharkey71ebe152013-09-17 17:24:38 -0700803}
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600804
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600805int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700806 int32_t ownerGid, std::string* outVolId) {
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600807 int id = mNextObbId++;
808
809 auto vol = std::shared_ptr<android::vold::VolumeBase>(
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700810 new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600811 vol->create();
812
813 mObbVolumes.push_back(vol);
814 *outVolId = vol->getId();
815 return android::OK;
816}
817
818int VolumeManager::destroyObb(const std::string& volId) {
819 auto i = mObbVolumes.begin();
820 while (i != mObbVolumes.end()) {
821 if ((*i)->getId() == volId) {
822 (*i)->destroy();
823 i = mObbVolumes.erase(i);
824 } else {
825 ++i;
826 }
827 }
828 return android::OK;
829}
830
Risan8c9f3322018-10-29 08:52:56 +0900831int VolumeManager::createStubVolume(const std::string& sourcePath, const std::string& mountPath,
832 const std::string& fsType, const std::string& fsUuid,
833 const std::string& fsLabel, std::string* outVolId) {
834 int id = mNextStubVolumeId++;
835 auto vol = std::shared_ptr<android::vold::VolumeBase>(
836 new android::vold::StubVolume(id, sourcePath, mountPath, fsType, fsUuid, fsLabel));
837 vol->create();
838
839 mStubVolumes.push_back(vol);
840 *outVolId = vol->getId();
841 return android::OK;
842}
843
844int VolumeManager::destroyStubVolume(const std::string& volId) {
845 auto i = mStubVolumes.begin();
846 while (i != mStubVolumes.end()) {
847 if ((*i)->getId() == volId) {
848 (*i)->destroy();
849 i = mStubVolumes.erase(i);
850 } else {
851 ++i;
852 }
853 }
854 return android::OK;
855}
856
Risan8f6198d2018-10-26 20:56:45 -0600857int VolumeManager::mountAppFuse(uid_t uid, int mountId, unique_fd* device_fd) {
Risanac02a482018-10-31 21:59:47 -0600858 return android::vold::MountAppFuse(uid, mountId, device_fd);
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600859}
860
Risan8f6198d2018-10-26 20:56:45 -0600861int VolumeManager::unmountAppFuse(uid_t uid, int mountId) {
Risanac02a482018-10-31 21:59:47 -0600862 return android::vold::UnmountAppFuse(uid, mountId);
Risan8f6198d2018-10-26 20:56:45 -0600863}
864
865int VolumeManager::openAppFuseFile(uid_t uid, int mountId, int fileId, int flags) {
Risanac02a482018-10-31 21:59:47 -0600866 return android::vold::OpenAppFuseFile(uid, mountId, fileId, flags);
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600867}