blob: d47d9f319b4c8711aca37b23c8376193f9536bb6 [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>
Ricky Waie96b34f2020-05-07 16:01:33 +010022#include <limits.h>
Yabin Cuid1104f72015-01-02 13:28:28 -080023#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 Mehata19b2502010-01-06 10:33:53 -080029#include <sys/stat.h>
Elliott Hughes0e08e842017-05-18 09:08:24 -070030#include <sys/sysmacros.h>
Paul Crowleyedf7a4e2018-09-18 15:14:18 -070031#include <sys/types.h>
Jeff Sharkey66270a22015-06-24 11:49:24 -070032#include <sys/wait.h>
Yabin Cuid1104f72015-01-02 13:28:28 -080033#include <unistd.h>
Sudheer Shanka40ab6742018-09-18 13:07:45 -070034#include <array>
San Mehata19b2502010-01-06 10:33:53 -080035
San Mehata2677e42009-12-13 10:40:18 -080036#include <linux/kdev_t.h>
San Mehatf1b736b2009-10-10 17:22:08 -070037
Jiyong Park8d21c922019-01-04 13:35:25 +090038#include <ApexProperties.sysprop.h>
Elliott Hughes7e128fb2015-12-04 15:50:53 -080039#include <android-base/logging.h>
Jeff Vander Stoep58890832017-10-23 17:12:31 -070040#include <android-base/parseint.h>
Jeff Sharkey3472e522017-10-06 18:02:53 -060041#include <android-base/properties.h>
Elliott Hughes7e128fb2015-12-04 15:50:53 -080042#include <android-base/stringprintf.h>
Jeff Vander Stoep58890832017-10-23 17:12:31 -070043#include <android-base/strings.h>
Narayan Kamath02efdf52019-11-27 10:53:51 +000044#include <async_safe/log.h>
Jeff Vander Stoep58890832017-10-23 17:12:31 -070045
Jeff Sharkey71ebe152013-09-17 17:24:38 -070046#include <cutils/fs.h>
Jeff Sharkey67b8c492017-09-21 17:08:43 -060047#include <utils/Trace.h>
San Mehatf1b736b2009-10-10 17:22:08 -070048
Robert Craigb9e3ba52014-02-04 10:53:00 -050049#include <selinux/android.h>
50
San Mehatfd7f5872009-10-12 11:32:47 -070051#include <sysutils/NetlinkEvent.h>
52
Kenny Root344ca102012-04-03 17:23:01 -070053#include <private/android_filesystem_config.h>
54
Eric Biggersa701c452018-10-23 13:06:55 -070055#include <fscrypt/fscrypt.h>
Paul Crowleyc6433a22017-10-24 14:54:43 -070056
Risanac02a482018-10-31 21:59:47 -060057#include "AppFuseUtil.h"
Eric Biggersa701c452018-10-23 13:06:55 -070058#include "FsCrypt.h"
San Mehata19b2502010-01-06 10:33:53 -080059#include "Loop.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070060#include "NetlinkManager.h"
61#include "Process.h"
62#include "Utils.h"
Sudheer Shanka40ab6742018-09-18 13:07:45 -070063#include "VoldNativeService.h"
Paul Crowleyc6433a22017-10-24 14:54:43 -070064#include "VoldUtil.h"
65#include "VolumeManager.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"
himanshuz0ad08622023-07-27 21:15:00 +000071#include "model/PublicVolume.h"
Risan8c9f3322018-10-29 08:52:56 +090072#include "model/StubVolume.h"
San Mehat23969932010-01-09 07:08:06 -080073
Sudheer Shankaf9b38a52019-02-14 19:09:51 +000074using android::OK;
Sudheer Shanka53947a32018-08-01 10:24:13 -070075using android::base::GetBoolProperty;
Mark Salyzyn86e81e72018-09-20 10:09:27 -070076using android::base::StartsWith;
Sudheer Shanka53947a32018-08-01 10:24:13 -070077using android::base::StringAppendF;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070078using android::base::StringPrintf;
Jeff Sharkey11c2d382017-09-11 10:32:01 -060079using android::base::unique_fd;
Sudheer Shanka023b5392019-02-06 12:39:19 -080080using android::vold::BindMount;
Sudheer Shankaf9b38a52019-02-14 19:09:51 +000081using android::vold::CreateDir;
Sudheer Shanka30df1c62019-02-22 17:03:02 -080082using android::vold::DeleteDirContents;
Sudheer Shanka023b5392019-02-06 12:39:19 -080083using android::vold::DeleteDirContentsAndDir;
Ricky Wai07e64a42020-02-11 14:31:24 +000084using android::vold::EnsureDirExists;
Martijn Coenen73e30102022-07-12 08:11:02 +000085using android::vold::GetFuseMountPathForUser;
Martijn Coenen62a4b272020-01-31 15:23:09 +010086using android::vold::IsFilesystemSupported;
Daniel Rosenbergf36bddd2020-05-11 22:58:42 -070087using android::vold::IsSdcardfsUsed;
Alistair Delvaff1fc9b2020-05-14 16:35:03 -070088using android::vold::IsVirtioBlkDevice;
Martijn Coenen62a4b272020-01-31 15:23:09 +010089using android::vold::PrepareAndroidDirs;
Martijn Coenen04bb17f2020-02-10 23:48:11 +010090using android::vold::PrepareAppDirFromRoot;
Zima438b242019-09-25 14:37:38 +010091using android::vold::PrivateVolume;
himanshuz0ad08622023-07-27 21:15:00 +000092using android::vold::PublicVolume;
Sudheer Shanka023b5392019-02-06 12:39:19 -080093using android::vold::Symlink;
94using android::vold::Unlink;
95using android::vold::UnmountTree;
Sudheer Shanka03992e32018-12-12 12:43:38 -080096using android::vold::VoldNativeService;
Zima438b242019-09-25 14:37:38 +010097using android::vold::VolumeBase;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070098
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -060099static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
100
101static const char* kPropVirtualDisk = "persist.sys.virtual_disk";
102
Sudheer Shanka53947a32018-08-01 10:24:13 -0700103static const std::string kEmptyString("");
104
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600105/* 512MiB is large enough for testing purposes */
106static const unsigned int kSizeVirtualDisk = 536870912;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700107
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700108static const unsigned int kMajorBlockMmc = 179;
109
Ricky Wai07e64a42020-02-11 14:31:24 +0000110using ScanProcCallback = bool(*)(uid_t uid, pid_t pid, int nsFd, const char* name, void* params);
111
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700112VolumeManager* VolumeManager::sInstance = NULL;
San Mehatf1b736b2009-10-10 17:22:08 -0700113
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700114VolumeManager* VolumeManager::Instance() {
115 if (!sInstance) sInstance = new VolumeManager();
San Mehatf1b736b2009-10-10 17:22:08 -0700116 return sInstance;
117}
118
119VolumeManager::VolumeManager() {
San Mehatd9a4e352010-03-12 13:32:47 -0800120 mDebug = false;
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600121 mNextObbId = 0;
Risan82e90de2020-02-04 16:07:21 +0900122 mNextStubId = 0;
Jeff Sharkey401b2602017-12-14 22:15:20 -0700123 // For security reasons, assume that a secure keyguard is
124 // showing until we hear otherwise
125 mSecureKeyguardShowing = true;
San Mehatf1b736b2009-10-10 17:22:08 -0700126}
127
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700128VolumeManager::~VolumeManager() {}
San Mehatd9a4e352010-03-12 13:32:47 -0800129
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600130int VolumeManager::updateVirtualDisk() {
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600131 ATRACE_NAME("VolumeManager::updateVirtualDisk");
Mark Salyzyn86e81e72018-09-20 10:09:27 -0700132 if (GetBoolProperty(kPropVirtualDisk, false)) {
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600133 if (access(kPathVirtualDisk, F_OK) != 0) {
134 Loop::createImageFile(kPathVirtualDisk, kSizeVirtualDisk / 512);
135 }
136
137 if (mVirtualDisk == nullptr) {
138 if (Loop::create(kPathVirtualDisk, mVirtualDiskPath) != 0) {
139 LOG(ERROR) << "Failed to create virtual disk";
140 return -1;
141 }
142
143 struct stat buf;
144 if (stat(mVirtualDiskPath.c_str(), &buf) < 0) {
145 PLOG(ERROR) << "Failed to stat " << mVirtualDiskPath;
146 return -1;
147 }
148
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700149 auto disk = new android::vold::Disk(
150 "virtual", buf.st_rdev, "virtual",
151 android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600152 mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk);
Jeff Sharkey401b2602017-12-14 22:15:20 -0700153 handleDiskAdded(mVirtualDisk);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600154 }
155 } else {
156 if (mVirtualDisk != nullptr) {
157 dev_t device = mVirtualDisk->getDevice();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700158 handleDiskRemoved(device);
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600159
160 Loop::destroyByDevice(mVirtualDiskPath.c_str());
161 mVirtualDisk = nullptr;
162 }
163
164 if (access(kPathVirtualDisk, F_OK) == 0) {
165 unlink(kPathVirtualDisk);
166 }
167 }
168 return 0;
169}
170
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700171int VolumeManager::setDebug(bool enable) {
San Mehatd9a4e352010-03-12 13:32:47 -0800172 mDebug = enable;
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700173 return 0;
San Mehatd9a4e352010-03-12 13:32:47 -0800174}
175
San Mehatf1b736b2009-10-10 17:22:08 -0700176int VolumeManager::start() {
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600177 ATRACE_NAME("VolumeManager::start");
178
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700179 // Always start from a clean slate by unmounting everything in
180 // directories that we own, in case we crashed.
Jeff Sharkey9c484982015-03-31 10:35:33 -0700181 unmountAll();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700182
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600183 Loop::destroyAll();
184
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700185 // Assume that we always have an emulated volume on internal
186 // storage; the framework will decide if it should be mounted.
Zima438b242019-09-25 14:37:38 +0100187 CHECK(mInternalEmulatedVolumes.empty());
188
189 auto vol = std::shared_ptr<android::vold::VolumeBase>(
190 new android::vold::EmulatedVolume("/data/media", 0));
191 vol->setMountUserId(0);
192 vol->create();
193 mInternalEmulatedVolumes.push_back(vol);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700194
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600195 // Consider creating a virtual disk
196 updateVirtualDisk();
197
San Mehatf1b736b2009-10-10 17:22:08 -0700198 return 0;
199}
200
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700201void VolumeManager::handleBlockEvent(NetlinkEvent* evt) {
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700202 std::lock_guard<std::mutex> lock(mLock);
203
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700204 if (mDebug) {
Sudheer Shanka4b6ca4e2018-09-21 10:54:54 -0700205 LOG(DEBUG) << "----------------";
206 LOG(DEBUG) << "handleBlockEvent with action " << (int)evt->getAction();
Jeff Sharkeyf1b996d2015-04-17 17:35:20 -0700207 evt->dump();
208 }
San Mehatf1b736b2009-10-10 17:22:08 -0700209
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700210 std::string eventPath(evt->findParam("DEVPATH") ? evt->findParam("DEVPATH") : "");
211 std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : "");
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700212
213 if (devType != "disk") return;
214
Jeff Sharkey95440eb2017-09-18 18:19:28 -0600215 int major = std::stoi(evt->findParam("MAJOR"));
216 int minor = std::stoi(evt->findParam("MINOR"));
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700217 dev_t device = makedev(major, minor);
218
219 switch (evt->getAction()) {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700220 case NetlinkEvent::Action::kAdd: {
221 for (const auto& source : mDiskSources) {
222 if (source->matches(eventPath)) {
223 // For now, assume that MMC and virtio-blk (the latter is
Alistair Delvaff1fc9b2020-05-14 16:35:03 -0700224 // specific to virtual platforms; see Utils.cpp for details)
225 // devices are SD, and that everything else is USB
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700226 int flags = source->getFlags();
Alistair Delvaff1fc9b2020-05-14 16:35:03 -0700227 if (major == kMajorBlockMmc || IsVirtioBlkDevice(major)) {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700228 flags |= android::vold::Disk::Flags::kSd;
229 } else {
230 flags |= android::vold::Disk::Flags::kUsb;
231 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700232
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700233 auto disk =
234 new android::vold::Disk(eventPath, device, source->getNickname(), flags);
235 handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
236 break;
237 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700238 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700239 break;
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700240 }
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700241 case NetlinkEvent::Action::kChange: {
Nikita Ioffeb881fc42021-07-28 02:58:57 +0100242 LOG(VERBOSE) << "Disk at " << major << ":" << minor << " changed";
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700243 handleDiskChanged(device);
244 break;
245 }
246 case NetlinkEvent::Action::kRemove: {
247 handleDiskRemoved(device);
248 break;
249 }
250 default: {
251 LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction();
252 break;
253 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700254 }
255}
256
Jeff Sharkey401b2602017-12-14 22:15:20 -0700257void VolumeManager::handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk) {
258 // For security reasons, if secure keyguard is showing, wait
259 // until the user unlocks the device to actually touch it
Martijn Coenencf5916f2020-01-03 14:36:45 +0100260 // Additionally, wait until user 0 is actually started, since we need
261 // the user to be up before we can mount a FUSE daemon to handle the disk.
262 bool userZeroStarted = mStartedUsers.find(0) != mStartedUsers.end();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700263 if (mSecureKeyguardShowing) {
264 LOG(INFO) << "Found disk at " << disk->getEventPath()
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700265 << " but delaying scan due to secure keyguard";
Jeff Sharkey401b2602017-12-14 22:15:20 -0700266 mPendingDisks.push_back(disk);
Martijn Coenencf5916f2020-01-03 14:36:45 +0100267 } else if (!userZeroStarted) {
268 LOG(INFO) << "Found disk at " << disk->getEventPath()
269 << " but delaying scan due to user zero not having started";
270 mPendingDisks.push_back(disk);
Jeff Sharkey401b2602017-12-14 22:15:20 -0700271 } else {
272 disk->create();
273 mDisks.push_back(disk);
274 }
275}
276
277void VolumeManager::handleDiskChanged(dev_t device) {
278 for (const auto& disk : mDisks) {
279 if (disk->getDevice() == device) {
280 disk->readMetadata();
281 disk->readPartitions();
282 }
283 }
284
285 // For security reasons, we ignore all pending disks, since
286 // we'll scan them once the device is unlocked
287}
288
289void VolumeManager::handleDiskRemoved(dev_t device) {
290 auto i = mDisks.begin();
291 while (i != mDisks.end()) {
292 if ((*i)->getDevice() == device) {
293 (*i)->destroy();
294 i = mDisks.erase(i);
295 } else {
296 ++i;
297 }
298 }
299 auto j = mPendingDisks.begin();
300 while (j != mPendingDisks.end()) {
301 if ((*j)->getDevice() == device) {
302 j = mPendingDisks.erase(j);
303 } else {
304 ++j;
305 }
306 }
307}
308
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700309void VolumeManager::addDiskSource(const std::shared_ptr<DiskSource>& diskSource) {
Wei Wang6b455c22017-01-20 11:52:33 -0800310 std::lock_guard<std::mutex> lock(mLock);
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700311 mDiskSources.push_back(diskSource);
312}
313
314std::shared_ptr<android::vold::Disk> VolumeManager::findDisk(const std::string& id) {
315 for (auto disk : mDisks) {
316 if (disk->getId() == id) {
317 return disk;
San Mehatf1b736b2009-10-10 17:22:08 -0700318 }
319 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700320 return nullptr;
321}
San Mehatf1b736b2009-10-10 17:22:08 -0700322
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700323std::shared_ptr<android::vold::VolumeBase> VolumeManager::findVolume(const std::string& id) {
Zima438b242019-09-25 14:37:38 +0100324 for (const auto& vol : mInternalEmulatedVolumes) {
325 if (vol->getId() == id) {
326 return vol;
327 }
San Mehatf1b736b2009-10-10 17:22:08 -0700328 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700329 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700330 auto vol = disk->findVolume(id);
331 if (vol != nullptr) {
332 return vol;
333 }
334 }
Jeff Sharkey11c2d382017-09-11 10:32:01 -0600335 for (const auto& vol : mObbVolumes) {
336 if (vol->getId() == id) {
337 return vol;
338 }
339 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700340 return nullptr;
341}
342
Greg Kaiser2bc201e2018-12-18 08:42:08 -0800343void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
344 std::list<std::string>& list) const {
Jeff Sharkeyc86ab6f2015-06-26 14:02:09 -0700345 list.clear();
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700346 for (const auto& disk : mDisks) {
Jeff Sharkeyc86ab6f2015-06-26 14:02:09 -0700347 disk->listVolumes(type, list);
348 }
349}
350
Jeff Sharkey3ce18252017-10-24 11:08:45 -0600351int VolumeManager::forgetPartition(const std::string& partGuid, const std::string& fsUuid) {
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700352 std::string normalizedGuid;
353 if (android::vold::NormalizeHex(partGuid, normalizedGuid)) {
354 LOG(WARNING) << "Invalid GUID " << partGuid;
355 return -1;
356 }
357
Paul Crowleyc6433a22017-10-24 14:54:43 -0700358 bool success = true;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700359 std::string keyPath = android::vold::BuildKeyPath(normalizedGuid);
360 if (unlink(keyPath.c_str()) != 0) {
361 LOG(ERROR) << "Failed to unlink " << keyPath;
Paul Crowleyc6433a22017-10-24 14:54:43 -0700362 success = false;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700363 }
Eric Biggersa6957c02022-06-15 18:52:18 +0000364 if (IsFbeEnabled()) {
Eric Biggersa701c452018-10-23 13:06:55 -0700365 if (!fscrypt_destroy_volume_keys(fsUuid)) {
Paul Crowleyc6433a22017-10-24 14:54:43 -0700366 success = false;
367 }
368 }
369 return success ? 0 : -1;
Jeff Sharkeybc40cc82015-06-18 14:25:08 -0700370}
371
Zima438b242019-09-25 14:37:38 +0100372void VolumeManager::destroyEmulatedVolumesForUser(userid_t userId) {
373 // Destroy and remove all unstacked EmulatedVolumes for the user
374 auto i = mInternalEmulatedVolumes.begin();
375 while (i != mInternalEmulatedVolumes.end()) {
376 auto vol = *i;
377 if (vol->getMountUserId() == userId) {
378 vol->destroy();
379 i = mInternalEmulatedVolumes.erase(i);
380 } else {
381 i++;
382 }
383 }
384
385 // Destroy and remove all stacked EmulatedVolumes for the user on each mounted private volume
386 std::list<std::string> private_vols;
387 listVolumes(VolumeBase::Type::kPrivate, private_vols);
388 for (const std::string& id : private_vols) {
389 PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get());
390 std::list<std::shared_ptr<VolumeBase>> vols_to_remove;
391 if (pvol->getState() == VolumeBase::State::kMounted) {
392 for (const auto& vol : pvol->getVolumes()) {
393 if (vol->getMountUserId() == userId) {
394 vols_to_remove.push_back(vol);
395 }
396 }
397 for (const auto& vol : vols_to_remove) {
398 vol->destroy();
399 pvol->removeVolume(vol);
400 }
401 } // else EmulatedVolumes will be destroyed on VolumeBase#unmount
402 }
403}
404
405void VolumeManager::createEmulatedVolumesForUser(userid_t userId) {
406 // Create unstacked EmulatedVolumes for the user
407 auto vol = std::shared_ptr<android::vold::VolumeBase>(
408 new android::vold::EmulatedVolume("/data/media", userId));
409 vol->setMountUserId(userId);
410 mInternalEmulatedVolumes.push_back(vol);
411 vol->create();
412
413 // Create stacked EmulatedVolumes for the user on each PrivateVolume
414 std::list<std::string> private_vols;
415 listVolumes(VolumeBase::Type::kPrivate, private_vols);
416 for (const std::string& id : private_vols) {
417 PrivateVolume* pvol = static_cast<PrivateVolume*>(findVolume(id).get());
418 if (pvol->getState() == VolumeBase::State::kMounted) {
419 auto evol =
420 std::shared_ptr<android::vold::VolumeBase>(new android::vold::EmulatedVolume(
421 pvol->getPath() + "/media", pvol->getRawDevice(), pvol->getFsUuid(),
422 userId));
423 evol->setMountUserId(userId);
424 pvol->addVolume(evol);
425 evol->create();
426 } // else EmulatedVolumes will be created per user when on PrivateVolume#doMount
427 }
428}
429
Martijn Coenen73e30102022-07-12 08:11:02 +0000430userid_t VolumeManager::getSharedStorageUser(userid_t userId) {
431 if (mSharedStorageUser.find(userId) == mSharedStorageUser.end()) {
432 return USER_UNKNOWN;
433 }
434 return mSharedStorageUser.at(userId);
435}
436
437int VolumeManager::onUserAdded(userid_t userId, int userSerialNumber,
438 userid_t sharesStorageWithUserId) {
Zima438b242019-09-25 14:37:38 +0100439 LOG(INFO) << "onUserAdded: " << userId;
440
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700441 mAddedUsers[userId] = userSerialNumber;
Martijn Coenen73e30102022-07-12 08:11:02 +0000442 if (sharesStorageWithUserId != USER_UNKNOWN) {
443 mSharedStorageUser[userId] = sharesStorageWithUserId;
444 }
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700445 return 0;
446}
447
448int VolumeManager::onUserRemoved(userid_t userId) {
Zima438b242019-09-25 14:37:38 +0100449 LOG(INFO) << "onUserRemoved: " << userId;
450
Zim2d45d9b2019-11-14 16:19:05 +0000451 onUserStopped(userId);
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700452 mAddedUsers.erase(userId);
Martijn Coenen73e30102022-07-12 08:11:02 +0000453 mSharedStorageUser.erase(userId);
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700454 return 0;
455}
456
Sudheer Shankaebce4cc2019-04-29 10:46:35 -0700457int VolumeManager::onUserStarted(userid_t userId) {
Zima438b242019-09-25 14:37:38 +0100458 LOG(INFO) << "onUserStarted: " << userId;
459
Zim2d45d9b2019-11-14 16:19:05 +0000460 if (mStartedUsers.find(userId) == mStartedUsers.end()) {
461 createEmulatedVolumesForUser(userId);
himanshuz0ad08622023-07-27 21:15:00 +0000462 std::list<std::string> public_vols;
463 listVolumes(VolumeBase::Type::kPublic, public_vols);
464 for (const std::string& id : public_vols) {
465 PublicVolume* pvol = static_cast<PublicVolume*>(findVolume(id).get());
466 if (pvol->getState() != VolumeBase::State::kMounted) {
467 continue;
468 }
469 if (pvol->isVisible() == 0) {
470 continue;
471 }
472 userid_t mountUserId = pvol->getMountUserId();
473 if (userId == mountUserId) {
474 // No need to bind mount for the user that owns the mount
475 continue;
476 }
477 if (mountUserId != VolumeManager::Instance()->getSharedStorageUser(userId)) {
478 // No need to bind if the user does not share storage with the mount owner
479 continue;
480 }
481 auto bindMountStatus = pvol->bindMountForUser(userId);
482 if (bindMountStatus != OK) {
483 LOG(ERROR) << "Bind Mounting Public Volume: " << pvol << " for user: " << userId
484 << "Failed. Error: " << bindMountStatus;
485 }
486 }
Zim2d45d9b2019-11-14 16:19:05 +0000487 }
488
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700489 mStartedUsers.insert(userId);
Martijn Coenencf5916f2020-01-03 14:36:45 +0100490
491 createPendingDisksIfNeeded();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700492 return 0;
493}
494
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700495int VolumeManager::onUserStopped(userid_t userId) {
Sudheer Shanka40ab6742018-09-18 13:07:45 -0700496 LOG(VERBOSE) << "onUserStopped: " << userId;
Zima438b242019-09-25 14:37:38 +0100497
Zim2d45d9b2019-11-14 16:19:05 +0000498 if (mStartedUsers.find(userId) != mStartedUsers.end()) {
Zima438b242019-09-25 14:37:38 +0100499 destroyEmulatedVolumesForUser(userId);
500 }
501
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700502 mStartedUsers.erase(userId);
Sudheer Shankafa6a1742018-10-04 16:26:22 -0700503 return 0;
504}
505
Martijn Coenencf5916f2020-01-03 14:36:45 +0100506void VolumeManager::createPendingDisksIfNeeded() {
507 bool userZeroStarted = mStartedUsers.find(0) != mStartedUsers.end();
508 if (!mSecureKeyguardShowing && userZeroStarted) {
509 // Now that secure keyguard has been dismissed and user 0 has
510 // started, process any pending disks
Jeff Sharkey401b2602017-12-14 22:15:20 -0700511 for (const auto& disk : mPendingDisks) {
512 disk->create();
513 mDisks.push_back(disk);
514 }
515 mPendingDisks.clear();
516 }
Martijn Coenencf5916f2020-01-03 14:36:45 +0100517}
518
519int VolumeManager::onSecureKeyguardStateChanged(bool isShowing) {
520 mSecureKeyguardShowing = isShowing;
521 createPendingDisksIfNeeded();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700522 return 0;
523}
524
Narayan Kamath02efdf52019-11-27 10:53:51 +0000525// This code is executed after a fork so it's very important that the set of
526// methods we call here is strictly limited.
527//
528// TODO: Get rid of this guesswork altogether and instead exec a process
529// immediately after fork to do our bindding for us.
530static bool childProcess(const char* storageSource, const char* userSource, int nsFd,
Ricky Wai07e64a42020-02-11 14:31:24 +0000531 const char* name) {
Narayan Kamath02efdf52019-11-27 10:53:51 +0000532 if (setns(nsFd, CLONE_NEWNS) != 0) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000533 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns for %s :%s", name,
Narayan Kamath02efdf52019-11-27 10:53:51 +0000534 strerror(errno));
535 return false;
536 }
537
538 // NOTE: Inlined from vold::UnmountTree here to avoid using PLOG methods and
539 // to also protect against future changes that may cause issues across a
540 // fork.
541 if (TEMP_FAILURE_RETRY(umount2("/storage/", MNT_DETACH)) < 0 && errno != EINVAL &&
542 errno != ENOENT) {
543 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to unmount /storage/ :%s",
544 strerror(errno));
545 return false;
546 }
547
548 if (TEMP_FAILURE_RETRY(mount(storageSource, "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) {
549 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s for %s :%s",
Ricky Wai07e64a42020-02-11 14:31:24 +0000550 storageSource, name, strerror(errno));
Narayan Kamath02efdf52019-11-27 10:53:51 +0000551 return false;
552 }
553
554 if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) {
555 async_safe_format_log(ANDROID_LOG_ERROR, "vold",
Ricky Wai07e64a42020-02-11 14:31:24 +0000556 "Failed to set MS_SLAVE to /storage for %s :%s", name,
Narayan Kamath02efdf52019-11-27 10:53:51 +0000557 strerror(errno));
558 return false;
559 }
560
561 if (TEMP_FAILURE_RETRY(mount(userSource, "/storage/self", NULL, MS_BIND, NULL)) == -1) {
562 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s for %s :%s",
Ricky Wai07e64a42020-02-11 14:31:24 +0000563 userSource, name, strerror(errno));
Narayan Kamath02efdf52019-11-27 10:53:51 +0000564 return false;
565 }
566
567 return true;
568}
569
Ricky Wai07e64a42020-02-11 14:31:24 +0000570// Fork the process and remount storage
571bool forkAndRemountChild(uid_t uid, pid_t pid, int nsFd, const char* name, void* params) {
572 int32_t mountMode = *static_cast<int32_t*>(params);
573 std::string userSource;
574 std::string storageSource;
575 pid_t child;
576 // Need to fix these paths to account for when sdcardfs is gone
Sudheer Shanka817b9112018-12-13 17:40:28 -0800577 switch (mountMode) {
578 case VoldNativeService::REMOUNT_MODE_NONE:
Ricky Wai07e64a42020-02-11 14:31:24 +0000579 return true;
Sudheer Shanka817b9112018-12-13 17:40:28 -0800580 case VoldNativeService::REMOUNT_MODE_DEFAULT:
Ricky Wai07e64a42020-02-11 14:31:24 +0000581 storageSource = "/mnt/runtime/default";
Sudheer Shanka817b9112018-12-13 17:40:28 -0800582 break;
Abhijeet Kaure715ec12021-02-24 12:33:25 +0000583 case VoldNativeService::REMOUNT_MODE_ANDROID_WRITABLE:
Sudheer Shankaa05ea742019-04-12 13:55:28 -0700584 case VoldNativeService::REMOUNT_MODE_INSTALLER:
Ricky Wai07e64a42020-02-11 14:31:24 +0000585 storageSource = "/mnt/runtime/write";
Sudheer Shanka817b9112018-12-13 17:40:28 -0800586 break;
Zim981222f2019-09-09 10:24:44 +0100587 case VoldNativeService::REMOUNT_MODE_PASS_THROUGH:
Ricky Wai07e64a42020-02-11 14:31:24 +0000588 return true;
Sudheer Shanka817b9112018-12-13 17:40:28 -0800589 default:
590 PLOG(ERROR) << "Unknown mode " << std::to_string(mountMode);
Ricky Wai07e64a42020-02-11 14:31:24 +0000591 return false;
Sudheer Shanka817b9112018-12-13 17:40:28 -0800592 }
Ricky Wai07e64a42020-02-11 14:31:24 +0000593 LOG(DEBUG) << "Remounting " << uid << " as " << storageSource;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700594
Ricky Wai07e64a42020-02-11 14:31:24 +0000595 // Fork a child to mount user-specific symlink helper into place
596 userSource = StringPrintf("/mnt/user/%d", multiuser_get_user_id(uid));
597 if (!(child = fork())) {
598 if (childProcess(storageSource.c_str(), userSource.c_str(), nsFd, name)) {
599 _exit(0);
600 } else {
601 _exit(1);
602 }
603 }
604
605 if (child == -1) {
606 PLOG(ERROR) << "Failed to fork";
607 return false;
608 } else {
609 TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0));
610 }
611 return true;
612}
613
614// Helper function to scan all processes in /proc and call the callback if:
615// 1). pid belongs to an app process
616// 2). If input uid is 0 or it matches the process uid
617// 3). If userId is not -1 or userId matches the process userId
618bool scanProcProcesses(uid_t uid, userid_t userId, ScanProcCallback callback, void* params) {
Jeff Sharkey66270a22015-06-24 11:49:24 -0700619 DIR* dir;
620 struct dirent* de;
Jeff Sharkey3472e522017-10-06 18:02:53 -0600621 std::string rootName;
622 std::string pidName;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700623 int pidFd;
624 int nsFd;
625 struct stat sb;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700626
Jiyong Park8d21c922019-01-04 13:35:25 +0900627 static bool apexUpdatable = android::sysprop::ApexProperties::updatable().value_or(false);
628
Jeff Sharkey66270a22015-06-24 11:49:24 -0700629 if (!(dir = opendir("/proc"))) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000630 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to opendir");
631 return false;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700632 }
633
634 // Figure out root namespace to compare against below
Jeff Sharkey3472e522017-10-06 18:02:53 -0600635 if (!android::vold::Readlinkat(dirfd(dir), "1/ns/mnt", &rootName)) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000636 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to read root namespace");
Jeff Sharkey66270a22015-06-24 11:49:24 -0700637 closedir(dir);
Ricky Wai07e64a42020-02-11 14:31:24 +0000638 return false;
Jeff Sharkey66270a22015-06-24 11:49:24 -0700639 }
640
Ricky Wai07e64a42020-02-11 14:31:24 +0000641 async_safe_format_log(ANDROID_LOG_INFO, "vold", "Start scanning all processes");
Jeff Sharkey66270a22015-06-24 11:49:24 -0700642 // Poke through all running PIDs look for apps running as UID
643 while ((de = readdir(dir))) {
Jeff Vander Stoep58890832017-10-23 17:12:31 -0700644 pid_t pid;
645 if (de->d_type != DT_DIR) continue;
646 if (!android::base::ParseInt(de->d_name, &pid)) continue;
647
Jeff Sharkey66270a22015-06-24 11:49:24 -0700648 pidFd = -1;
649 nsFd = -1;
650
651 pidFd = openat(dirfd(dir), de->d_name, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
652 if (pidFd < 0) {
653 goto next;
654 }
655 if (fstat(pidFd, &sb) != 0) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000656 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to stat %s", de->d_name);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700657 goto next;
658 }
Ricky Wai07e64a42020-02-11 14:31:24 +0000659 if (uid != 0 && sb.st_uid != uid) {
660 goto next;
661 }
662 if (userId != static_cast<userid_t>(-1) && multiuser_get_user_id(sb.st_uid) != userId) {
Jeff Sharkey66270a22015-06-24 11:49:24 -0700663 goto next;
664 }
665
666 // Matches so far, but refuse to touch if in root namespace
Jeff Sharkey3472e522017-10-06 18:02:53 -0600667 if (!android::vold::Readlinkat(pidFd, "ns/mnt", &pidName)) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000668 async_safe_format_log(ANDROID_LOG_ERROR, "vold",
669 "Failed to read namespacefor %s", de->d_name);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700670 goto next;
671 }
Jeff Sharkey3472e522017-10-06 18:02:53 -0600672 if (rootName == pidName) {
Jeff Sharkey66270a22015-06-24 11:49:24 -0700673 goto next;
674 }
675
Jiyong Park8d21c922019-01-04 13:35:25 +0900676 if (apexUpdatable) {
677 std::string exeName;
678 // When ro.apex.bionic_updatable is set to true,
679 // some early native processes have mount namespaces that are different
680 // from that of the init. Therefore, above check can't filter them out.
681 // Since the propagation type of / is 'shared', unmounting /storage
682 // for the early native processes affects other processes including
683 // init. Filter out such processes by skipping if a process is a
684 // non-Java process whose UID is < AID_APP_START. (The UID condition
685 // is required to not filter out child processes spawned by apps.)
686 if (!android::vold::Readlinkat(pidFd, "exe", &exeName)) {
Jiyong Park8d21c922019-01-04 13:35:25 +0900687 goto next;
688 }
689 if (!StartsWith(exeName, "/system/bin/app_process") && sb.st_uid < AID_APP_START) {
Jiyong Park8d21c922019-01-04 13:35:25 +0900690 goto next;
691 }
692 }
693
Jeff Sharkey66270a22015-06-24 11:49:24 -0700694 // We purposefully leave the namespace open across the fork
Nick Kraleviche7e89ac2019-03-29 16:03:51 -0700695 // NOLINTNEXTLINE(android-cloexec-open): Deliberately not O_CLOEXEC
696 nsFd = openat(pidFd, "ns/mnt", O_RDONLY);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700697 if (nsFd < 0) {
Ricky Wai07e64a42020-02-11 14:31:24 +0000698 async_safe_format_log(ANDROID_LOG_ERROR, "vold",
699 "Failed to open namespace for %s", de->d_name);
Jeff Sharkey66270a22015-06-24 11:49:24 -0700700 goto next;
701 }
702
Ricky Wai07e64a42020-02-11 14:31:24 +0000703 if (!callback(sb.st_uid, pid, nsFd, de->d_name, params)) {
704 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed in callback");
Jeff Sharkey66270a22015-06-24 11:49:24 -0700705 }
706
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700707 next:
Jeff Sharkey66270a22015-06-24 11:49:24 -0700708 close(nsFd);
709 close(pidFd);
710 }
711 closedir(dir);
Ricky Wai07e64a42020-02-11 14:31:24 +0000712 async_safe_format_log(ANDROID_LOG_INFO, "vold", "Finished scanning all processes");
713 return true;
714}
715
Ricky Waia2ca11e2021-01-15 14:03:23 +0000716// In each app's namespace, unmount obb and data dirs
717static bool umountStorageDirs(int nsFd, const char* android_data_dir, const char* android_obb_dir,
718 int uid, const char* targets[], int size) {
719 // This code is executed after a fork so it's very important that the set of
720 // methods we call here is strictly limited.
721 if (setns(nsFd, CLONE_NEWNS) != 0) {
722 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns %s", strerror(errno));
723 return false;
724 }
725
726 // Unmount of Android/data/foo needs to be done before Android/data below.
727 bool result = true;
728 for (int i = 0; i < size; i++) {
729 if (TEMP_FAILURE_RETRY(umount2(targets[i], MNT_DETACH)) < 0 && errno != EINVAL &&
730 errno != ENOENT) {
731 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s: %s",
732 targets[i], strerror(errno));
733 result = false;
734 }
735 }
736
737 // Mount tmpfs on Android/data and Android/obb
738 if (TEMP_FAILURE_RETRY(umount2(android_data_dir, MNT_DETACH)) < 0 && errno != EINVAL &&
739 errno != ENOENT) {
740 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s :%s",
741 android_data_dir, strerror(errno));
742 result = false;
743 }
744 if (TEMP_FAILURE_RETRY(umount2(android_obb_dir, MNT_DETACH)) < 0 && errno != EINVAL &&
745 errno != ENOENT) {
746 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to umount %s :%s",
747 android_obb_dir, strerror(errno));
748 result = false;
749 }
750 return result;
751}
752
Ricky Waie96b34f2020-05-07 16:01:33 +0100753// In each app's namespace, mount tmpfs on obb and data dir, and bind mount obb and data
754// package dirs.
755static bool remountStorageDirs(int nsFd, const char* android_data_dir, const char* android_obb_dir,
756 int uid, const char* sources[], const char* targets[], int size) {
Ricky Wai6b122572020-02-28 16:30:47 +0000757 // This code is executed after a fork so it's very important that the set of
758 // methods we call here is strictly limited.
Ricky Wai07e64a42020-02-11 14:31:24 +0000759 if (setns(nsFd, CLONE_NEWNS) != 0) {
760 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to setns %s", strerror(errno));
761 return false;
762 }
763
Ricky Waie96b34f2020-05-07 16:01:33 +0100764 // Mount tmpfs on Android/data and Android/obb
765 if (TEMP_FAILURE_RETRY(mount("tmpfs", android_data_dir, "tmpfs",
766 MS_NOSUID | MS_NODEV | MS_NOEXEC, "uid=0,gid=0,mode=0751")) == -1) {
767 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount tmpfs to %s :%s",
768 android_data_dir, strerror(errno));
769 return false;
770 }
771 if (TEMP_FAILURE_RETRY(mount("tmpfs", android_obb_dir, "tmpfs",
772 MS_NOSUID | MS_NODEV | MS_NOEXEC, "uid=0,gid=0,mode=0751")) == -1) {
773 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount tmpfs to %s :%s",
774 android_obb_dir, strerror(errno));
775 return false;
776 }
777
Ricky Wai6b122572020-02-28 16:30:47 +0000778 for (int i = 0; i < size; i++) {
Ricky Waie96b34f2020-05-07 16:01:33 +0100779 // Create package dir and bind mount it to the actual one.
780 if (TEMP_FAILURE_RETRY(mkdir(targets[i], 0700)) == -1) {
781 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mkdir %s %s",
782 targets[i], strerror(errno));
783 return false;
784 }
Ricky Wai6b122572020-02-28 16:30:47 +0000785 if (TEMP_FAILURE_RETRY(mount(sources[i], targets[i], NULL, MS_BIND | MS_REC, NULL)) == -1) {
786 async_safe_format_log(ANDROID_LOG_ERROR, "vold", "Failed to mount %s to %s :%s",
787 sources[i], targets[i], strerror(errno));
Ricky Wai07e64a42020-02-11 14:31:24 +0000788 return false;
789 }
Ricky Wai07e64a42020-02-11 14:31:24 +0000790 }
791 return true;
792}
793
Ricky Wai6b122572020-02-28 16:30:47 +0000794static std::string getStorageDirSrc(userid_t userId, const std::string& dirName,
795 const std::string& packageName) {
Daniel Rosenbergf36bddd2020-05-11 22:58:42 -0700796 if (IsSdcardfsUsed()) {
Ricky Wai6b122572020-02-28 16:30:47 +0000797 return StringPrintf("/mnt/runtime/default/emulated/%d/%s/%s",
798 userId, dirName.c_str(), packageName.c_str());
799 } else {
800 return StringPrintf("/mnt/pass_through/%d/emulated/%d/%s/%s",
801 userId, userId, dirName.c_str(), packageName.c_str());
Ricky Wai07e64a42020-02-11 14:31:24 +0000802 }
Ricky Wai6b122572020-02-28 16:30:47 +0000803}
804
805static std::string getStorageDirTarget(userid_t userId, std::string dirName,
806 std::string packageName) {
807 return StringPrintf("/storage/emulated/%d/%s/%s",
808 userId, dirName.c_str(), packageName.c_str());
809}
810
Ricky Waia2ca11e2021-01-15 14:03:23 +0000811// Fork the process and remount / unmount app data and obb dirs
812bool VolumeManager::forkAndRemountStorage(int uid, int pid, bool doUnmount,
Linus Tufvesson75973cb2020-03-23 11:59:43 +0000813 const std::vector<std::string>& packageNames) {
Ricky Wai6b122572020-02-28 16:30:47 +0000814 userid_t userId = multiuser_get_user_id(uid);
815 std::string mnt_path = StringPrintf("/proc/%d/ns/mnt", pid);
816 android::base::unique_fd nsFd(
817 TEMP_FAILURE_RETRY(open(mnt_path.c_str(), O_RDONLY | O_CLOEXEC)));
818 if (nsFd == -1) {
819 PLOG(ERROR) << "Unable to open " << mnt_path.c_str();
820 return false;
821 }
822 // Storing both Android/obb and Android/data paths.
823 int size = packageNames.size() * 2;
824
825 std::unique_ptr<std::string[]> sources(new std::string[size]);
826 std::unique_ptr<std::string[]> targets(new std::string[size]);
827 std::unique_ptr<const char*[]> sources_uptr(new const char*[size]);
828 std::unique_ptr<const char*[]> targets_uptr(new const char*[size]);
829 const char** sources_cstr = sources_uptr.get();
830 const char** targets_cstr = targets_uptr.get();
831
832 for (int i = 0; i < size; i += 2) {
833 std::string const& packageName = packageNames[i/2];
834 sources[i] = getStorageDirSrc(userId, "Android/data", packageName);
835 targets[i] = getStorageDirTarget(userId, "Android/data", packageName);
836 sources[i+1] = getStorageDirSrc(userId, "Android/obb", packageName);
837 targets[i+1] = getStorageDirTarget(userId, "Android/obb", packageName);
838
839 sources_cstr[i] = sources[i].c_str();
840 targets_cstr[i] = targets[i].c_str();
841 sources_cstr[i+1] = sources[i+1].c_str();
842 targets_cstr[i+1] = targets[i+1].c_str();
843 }
844
845 for (int i = 0; i < size; i++) {
Linus Tufvesson75973cb2020-03-23 11:59:43 +0000846 // Make sure /storage/emulated/... paths are setup correctly
Ricky Waif6da79c2021-01-19 11:27:36 +0000847 // This needs to be done before EnsureDirExists to ensure Android/ is created.
848 auto status = setupAppDir(targets_cstr[i], uid, false /* fixupExistingOnly */);
Ricky Wai6b122572020-02-28 16:30:47 +0000849 if (status != OK) {
850 PLOG(ERROR) << "Failed to create dir: " << targets_cstr[i];
851 return false;
852 }
Ricky Waif6da79c2021-01-19 11:27:36 +0000853 status = EnsureDirExists(sources_cstr[i], 0771, AID_MEDIA_RW, AID_MEDIA_RW);
854 if (status != OK) {
855 PLOG(ERROR) << "Failed to create dir: " << sources_cstr[i];
856 return false;
857 }
Ricky Wai6b122572020-02-28 16:30:47 +0000858 }
859
Ricky Waie96b34f2020-05-07 16:01:33 +0100860 char android_data_dir[PATH_MAX];
861 char android_obb_dir[PATH_MAX];
862 snprintf(android_data_dir, PATH_MAX, "/storage/emulated/%d/Android/data", userId);
863 snprintf(android_obb_dir, PATH_MAX, "/storage/emulated/%d/Android/obb", userId);
864
Ricky Wai6b122572020-02-28 16:30:47 +0000865 pid_t child;
866 // Fork a child to mount Android/obb android Android/data dirs, as we don't want it to affect
867 // original vold process mount namespace.
868 if (!(child = fork())) {
Ricky Waia2ca11e2021-01-15 14:03:23 +0000869 if (doUnmount) {
870 if (umountStorageDirs(nsFd, android_data_dir, android_obb_dir, uid,
871 targets_cstr, size)) {
872 _exit(0);
873 } else {
874 _exit(1);
875 }
Ricky Wai07e64a42020-02-11 14:31:24 +0000876 } else {
Ricky Waia2ca11e2021-01-15 14:03:23 +0000877 if (remountStorageDirs(nsFd, android_data_dir, android_obb_dir, uid,
878 sources_cstr, targets_cstr, size)) {
879 _exit(0);
880 } else {
881 _exit(1);
882 }
Ricky Wai07e64a42020-02-11 14:31:24 +0000883 }
884 }
Ricky Wai6b122572020-02-28 16:30:47 +0000885
Ricky Wai07e64a42020-02-11 14:31:24 +0000886 if (child == -1) {
887 PLOG(ERROR) << "Failed to fork";
Ricky Wai6b122572020-02-28 16:30:47 +0000888 return false;
889 } else {
890 int status;
891 if (TEMP_FAILURE_RETRY(waitpid(child, &status, 0)) == -1) {
892 PLOG(ERROR) << "Failed to waitpid: " << child;
893 return false;
894 }
895 if (!WIFEXITED(status)) {
896 PLOG(ERROR) << "Process did not exit normally, status: " << status;
897 return false;
898 }
899 if (WEXITSTATUS(status)) {
900 PLOG(ERROR) << "Process exited with code: " << WEXITSTATUS(status);
901 return false;
Ricky Wai07e64a42020-02-11 14:31:24 +0000902 }
903 }
Ricky Wai6b122572020-02-28 16:30:47 +0000904 return true;
905}
906
Ricky Waia2ca11e2021-01-15 14:03:23 +0000907int VolumeManager::handleAppStorageDirs(int uid, int pid,
908 bool doUnmount, const std::vector<std::string>& packageNames) {
Ricky Wai6b122572020-02-28 16:30:47 +0000909 // Only run the remount if fuse is mounted for that user.
910 userid_t userId = multiuser_get_user_id(uid);
911 bool fuseMounted = false;
912 for (auto& vol : mInternalEmulatedVolumes) {
913 if (vol->getMountUserId() == userId && vol->getState() == VolumeBase::State::kMounted) {
914 auto* emulatedVol = static_cast<android::vold::EmulatedVolume*>(vol.get());
915 if (emulatedVol) {
916 fuseMounted = emulatedVol->isFuseMounted();
917 }
918 break;
919 }
920 }
921 if (fuseMounted) {
Ricky Waia2ca11e2021-01-15 14:03:23 +0000922 forkAndRemountStorage(uid, pid, doUnmount, packageNames);
Ricky Wai6b122572020-02-28 16:30:47 +0000923 }
Jeff Sharkey66270a22015-06-24 11:49:24 -0700924 return 0;
925}
926
Martijn Coenen23c04452020-04-29 07:49:41 +0200927int VolumeManager::abortFuse() {
928 return android::vold::AbortFuseConnections();
929}
930
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700931int VolumeManager::reset() {
932 // Tear down all existing disks/volumes and start from a blank slate so
933 // newly connected framework hears all events.
Zima438b242019-09-25 14:37:38 +0100934 for (const auto& vol : mInternalEmulatedVolumes) {
935 vol->destroy();
Gao Xiangd263da82017-08-14 11:32:13 +0800936 }
Zima438b242019-09-25 14:37:38 +0100937 mInternalEmulatedVolumes.clear();
Zima438b242019-09-25 14:37:38 +0100938
Youkichi Hosoidfaff1d2021-11-25 16:24:35 +0900939 // Destroy and recreate all disks except that StubVolume disks are just
940 // destroyed and removed from both mDisks and mPendingDisks.
941 // StubVolumes are managed from outside Android (e.g. from Chrome OS) and
942 // their disk recreation on reset events should be handled from outside by
943 // calling createStubVolume() again.
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700944 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700945 disk->destroy();
Youkichi Hosoidfaff1d2021-11-25 16:24:35 +0900946 if (!disk->isStub()) {
947 disk->create();
948 }
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700949 }
Youkichi Hosoidfaff1d2021-11-25 16:24:35 +0900950 const auto isStub = [](const auto& disk) { return disk->isStub(); };
951 mDisks.remove_if(isStub);
952 mPendingDisks.remove_if(isStub);
953
Jeff Sharkeyfa1c6772017-03-25 22:49:13 -0600954 updateVirtualDisk();
Jeff Sharkeybd3038d2015-06-10 09:42:01 -0700955 mAddedUsers.clear();
Sudheer Shanka023b5392019-02-06 12:39:19 -0800956 mStartedUsers.clear();
Martijn Coenen73e30102022-07-12 08:11:02 +0000957 mSharedStorageUser.clear();
Zim817f2242022-05-19 16:53:22 +0100958
959 // Abort all FUSE connections to avoid deadlocks if the FUSE daemon was killed
960 // with FUSE fds open.
961 abortFuse();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700962 return 0;
963}
964
Keun-young Parka5bbb5e2017-03-13 18:02:50 -0700965// Can be called twice (sequentially) during shutdown. should be safe for that.
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700966int VolumeManager::shutdown() {
Zima438b242019-09-25 14:37:38 +0100967 if (mInternalEmulatedVolumes.empty()) {
Paul Crowleyedf7a4e2018-09-18 15:14:18 -0700968 return 0; // already shutdown
Keun-young Parka5bbb5e2017-03-13 18:02:50 -0700969 }
Paul Crowley56292ef2017-10-20 08:07:53 -0700970 android::vold::sSleepOnUnmount = false;
Zima438b242019-09-25 14:37:38 +0100971 for (const auto& vol : mInternalEmulatedVolumes) {
972 vol->destroy();
973 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700974 for (const auto& disk : mDisks) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700975 disk->destroy();
976 }
Zima438b242019-09-25 14:37:38 +0100977
978 mInternalEmulatedVolumes.clear();
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700979 mDisks.clear();
Jeff Sharkey401b2602017-12-14 22:15:20 -0700980 mPendingDisks.clear();
Paul Crowley56292ef2017-10-20 08:07:53 -0700981 android::vold::sSleepOnUnmount = true;
Martijn Coenen23c04452020-04-29 07:49:41 +0200982
Jeff Sharkey36801cc2015-03-13 16:09:20 -0700983 return 0;
San Mehatf1b736b2009-10-10 17:22:08 -0700984}
985
Jeff Sharkey9c484982015-03-31 10:35:33 -0700986int VolumeManager::unmountAll() {
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700987 std::lock_guard<std::mutex> lock(mLock);
Jeff Sharkey67b8c492017-09-21 17:08:43 -0600988 ATRACE_NAME("VolumeManager::unmountAll()");
Jeff Sharkeyc8e04c52015-04-21 12:14:17 -0700989
Jeff Sharkey9c484982015-03-31 10:35:33 -0700990 // First, try gracefully unmounting all known devices
Zima438b242019-09-25 14:37:38 +0100991 for (const auto& vol : mInternalEmulatedVolumes) {
992 vol->unmount();
Jeff Sharkey9c484982015-03-31 10:35:33 -0700993 }
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -0700994 for (const auto& disk : mDisks) {
Jeff Sharkey9c484982015-03-31 10:35:33 -0700995 disk->unmountAll();
996 }
997
998 // Worst case we might have some stale mounts lurking around, so
999 // force unmount those just to be safe.
LongPing.WEI4f046062018-11-23 19:27:35 +08001000 FILE* fp = setmntent("/proc/mounts", "re");
Jeff Sharkey9c484982015-03-31 10:35:33 -07001001 if (fp == NULL) {
Jeff Sharkey3472e522017-10-06 18:02:53 -06001002 PLOG(ERROR) << "Failed to open /proc/mounts";
Jeff Sharkey9c484982015-03-31 10:35:33 -07001003 return -errno;
1004 }
1005
1006 // Some volumes can be stacked on each other, so force unmount in
1007 // reverse order to give us the best chance of success.
1008 std::list<std::string> toUnmount;
1009 mntent* mentry;
1010 while ((mentry = getmntent(fp)) != NULL) {
Jeff Sharkey3472e522017-10-06 18:02:53 -06001011 auto test = std::string(mentry->mnt_dir);
Mark Salyzyn86e81e72018-09-20 10:09:27 -07001012 if ((StartsWith(test, "/mnt/") &&
1013#ifdef __ANDROID_DEBUGGABLE__
1014 !StartsWith(test, "/mnt/scratch") &&
1015#endif
Martijn Coenenb0e977a2020-01-11 19:24:26 +01001016 !StartsWith(test, "/mnt/vendor") && !StartsWith(test, "/mnt/product") &&
Ricky Waief639212020-04-07 13:43:20 +01001017 !StartsWith(test, "/mnt/installer") && !StartsWith(test, "/mnt/androidwritable")) ||
Mark Salyzyn86e81e72018-09-20 10:09:27 -07001018 StartsWith(test, "/storage/")) {
Jeff Sharkey3472e522017-10-06 18:02:53 -06001019 toUnmount.push_front(test);
Jeff Sharkey9c484982015-03-31 10:35:33 -07001020 }
1021 }
1022 endmntent(fp);
1023
Chih-Hung Hsieh11a2ce82016-07-27 14:11:02 -07001024 for (const auto& path : toUnmount) {
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001025 LOG(DEBUG) << "Tearing down stale mount " << path;
Jeff Sharkey9c484982015-03-31 10:35:33 -07001026 android::vold::ForceUnmount(path);
1027 }
1028
1029 return 0;
1030}
1031
Ricky Waibbfb6ea2020-12-03 15:32:52 +00001032int VolumeManager::ensureAppDirsCreated(const std::vector<std::string>& paths, int32_t appUid) {
Ricky Waibbfb6ea2020-12-03 15:32:52 +00001033 int size = paths.size();
1034 for (int i = 0; i < size; i++) {
1035 int result = setupAppDir(paths[i], appUid, false /* fixupExistingOnly */,
1036 true /* skipIfDirExists */);
1037 if (result != OK) {
1038 return result;
1039 }
1040 }
1041 return OK;
1042}
1043
1044int VolumeManager::setupAppDir(const std::string& path, int32_t appUid, bool fixupExistingOnly,
1045 bool skipIfDirExists) {
Jeff Sharkey36801cc2015-03-13 16:09:20 -07001046 // Only offer to create directories for paths managed by vold
Martijn Coenen13ff6682019-12-24 12:57:16 +01001047 if (!StartsWith(path, "/storage/")) {
Jeff Sharkey3472e522017-10-06 18:02:53 -06001048 LOG(ERROR) << "Failed to find mounted volume for " << path;
Jeff Sharkey71ebe152013-09-17 17:24:38 -07001049 return -EINVAL;
1050 }
Martijn Coenen13ff6682019-12-24 12:57:16 +01001051
Martijn Coenen0a7e9922020-01-24 16:17:32 +01001052 // Find the volume it belongs to
1053 auto filter_fn = [&](const VolumeBase& vol) {
1054 if (vol.getState() != VolumeBase::State::kMounted) {
1055 // The volume must be mounted
1056 return false;
1057 }
Youkichi Hosoi2991cbe2021-11-11 11:23:01 +09001058 if (!vol.isVisibleForWrite()) {
1059 // App dirs should only be created for writable volumes.
Martijn Coenen0a7e9922020-01-24 16:17:32 +01001060 return false;
1061 }
1062 if (vol.getInternalPath().empty()) {
1063 return false;
1064 }
1065 if (vol.getMountUserId() != USER_UNKNOWN &&
1066 vol.getMountUserId() != multiuser_get_user_id(appUid)) {
1067 // The app dir must be created on a volume with the same user-id
1068 return false;
1069 }
1070 if (!path.empty() && StartsWith(path, vol.getPath())) {
1071 return true;
1072 }
1073
1074 return false;
1075 };
1076 auto volume = findVolumeWithFilter(filter_fn);
1077 if (volume == nullptr) {
1078 LOG(ERROR) << "Failed to find mounted volume for " << path;
1079 return -EINVAL;
1080 }
Zimc59d7742020-01-06 21:48:16 +00001081 // Convert paths to lower filesystem paths to avoid making FUSE requests for these reasons:
1082 // 1. A FUSE request from vold puts vold at risk of hanging if the FUSE daemon is down
1083 // 2. The FUSE daemon prevents requests on /mnt/user/0/emulated/<userid != 0> and a request
1084 // on /storage/emulated/10 means /mnt/user/0/emulated/10
Martijn Coenen0a7e9922020-01-24 16:17:32 +01001085 const std::string lowerPath =
1086 volume->getInternalPath() + path.substr(volume->getPath().length());
Zimc59d7742020-01-06 21:48:16 +00001087
Martijn Coenen62a4b272020-01-31 15:23:09 +01001088 const std::string volumeRoot = volume->getRootPath(); // eg /data/media/0
1089
Ricky Waibbfb6ea2020-12-03 15:32:52 +00001090 const int access_result = access(lowerPath.c_str(), F_OK);
1091 if (fixupExistingOnly && access_result != 0) {
Martijn Coenen816f4d92020-02-18 15:06:37 +01001092 // Nothing to fixup
1093 return OK;
1094 }
1095
Ricky Waibbfb6ea2020-12-03 15:32:52 +00001096 if (skipIfDirExists && access_result == 0) {
1097 // It's safe to assume it's ok as it will be used for zygote to bind mount dir only,
1098 // which the dir doesn't need to have correct permission for now yet.
1099 return OK;
1100 }
1101
Martijn Coenenbf205ab2020-04-20 15:14:48 +02001102 if (volume->getType() == VolumeBase::Type::kPublic) {
1103 // On public volumes, we don't need to setup permissions, as everything goes through
1104 // FUSE; just create the dirs and be done with it.
1105 return fs_mkdirs(lowerPath.c_str(), 0700);
1106 }
1107
Martijn Coenenb5a31c92020-02-13 23:30:38 +01001108 // Create the app paths we need from the root
Martijn Coenen816f4d92020-02-18 15:06:37 +01001109 return PrepareAppDirFromRoot(lowerPath, volumeRoot, appUid, fixupExistingOnly);
1110}
1111
1112int VolumeManager::fixupAppDir(const std::string& path, int32_t appUid) {
Daniel Rosenbergf36bddd2020-05-11 22:58:42 -07001113 if (IsSdcardfsUsed()) {
Martijn Coenen816f4d92020-02-18 15:06:37 +01001114 //sdcardfs magically does this for us
1115 return OK;
1116 }
1117 return setupAppDir(path, appUid, true /* fixupExistingOnly */);
Jeff Sharkey71ebe152013-09-17 17:24:38 -07001118}
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001119
Eric Biggers7e79a432022-03-01 21:19:18 +00001120int VolumeManager::createObb(const std::string& sourcePath, int32_t ownerGid,
1121 std::string* outVolId) {
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001122 int id = mNextObbId++;
1123
Martijn Coenend6a612a2020-11-19 10:49:45 +01001124 std::string lowerSourcePath;
1125
1126 // Convert to lower filesystem path
1127 if (StartsWith(sourcePath, "/storage/")) {
1128 auto filter_fn = [&](const VolumeBase& vol) {
1129 if (vol.getState() != VolumeBase::State::kMounted) {
1130 // The volume must be mounted
1131 return false;
1132 }
Youkichi Hosoi2991cbe2021-11-11 11:23:01 +09001133 if (!vol.isVisibleForWrite()) {
1134 // Obb volume should only be created for writable volumes.
Martijn Coenend6a612a2020-11-19 10:49:45 +01001135 return false;
1136 }
1137 if (vol.getInternalPath().empty()) {
1138 return false;
1139 }
1140 if (!sourcePath.empty() && StartsWith(sourcePath, vol.getPath())) {
1141 return true;
1142 }
1143
1144 return false;
1145 };
1146 auto volume = findVolumeWithFilter(filter_fn);
1147 if (volume == nullptr) {
1148 LOG(ERROR) << "Failed to find mounted volume for " << sourcePath;
1149 return -EINVAL;
1150 } else {
1151 lowerSourcePath =
1152 volume->getInternalPath() + sourcePath.substr(volume->getPath().length());
1153 }
1154 } else {
1155 lowerSourcePath = sourcePath;
1156 }
1157
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001158 auto vol = std::shared_ptr<android::vold::VolumeBase>(
Eric Biggers7e79a432022-03-01 21:19:18 +00001159 new android::vold::ObbVolume(id, lowerSourcePath, ownerGid));
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001160 vol->create();
1161
1162 mObbVolumes.push_back(vol);
1163 *outVolId = vol->getId();
1164 return android::OK;
1165}
1166
1167int VolumeManager::destroyObb(const std::string& volId) {
1168 auto i = mObbVolumes.begin();
1169 while (i != mObbVolumes.end()) {
1170 if ((*i)->getId() == volId) {
1171 (*i)->destroy();
1172 i = mObbVolumes.erase(i);
1173 } else {
1174 ++i;
1175 }
1176 }
1177 return android::OK;
1178}
1179
Risan8c9f3322018-10-29 08:52:56 +09001180int VolumeManager::createStubVolume(const std::string& sourcePath, const std::string& mountPath,
1181 const std::string& fsType, const std::string& fsUuid,
Risan73a7a852020-02-07 18:03:44 +09001182 const std::string& fsLabel, int32_t flags,
Risan82e90de2020-02-04 16:07:21 +09001183 std::string* outVolId) {
1184 dev_t stubId = --mNextStubId;
1185 auto vol = std::shared_ptr<android::vold::StubVolume>(
1186 new android::vold::StubVolume(stubId, sourcePath, mountPath, fsType, fsUuid, fsLabel));
Risan8c9f3322018-10-29 08:52:56 +09001187
Youkichi Hosoidefc0452020-07-08 06:08:48 +09001188 int32_t passedFlags = 0;
Risan73a7a852020-02-07 18:03:44 +09001189 passedFlags |= (flags & android::vold::Disk::Flags::kUsb);
1190 passedFlags |= (flags & android::vold::Disk::Flags::kSd);
Youkichi Hosoidefc0452020-07-08 06:08:48 +09001191 if (flags & android::vold::Disk::Flags::kStubVisible) {
1192 passedFlags |= (flags & android::vold::Disk::Flags::kStubVisible);
1193 } else {
1194 passedFlags |= (flags & android::vold::Disk::Flags::kStubInvisible);
1195 }
Risan82e90de2020-02-04 16:07:21 +09001196 // StubDisk doesn't have device node corresponds to it. So, a fake device
Risan73a7a852020-02-07 18:03:44 +09001197 // number is used.
Risan82e90de2020-02-04 16:07:21 +09001198 auto disk = std::shared_ptr<android::vold::Disk>(
Risan73a7a852020-02-07 18:03:44 +09001199 new android::vold::Disk("stub", stubId, "stub", passedFlags));
Risan82e90de2020-02-04 16:07:21 +09001200 disk->initializePartition(vol);
1201 handleDiskAdded(disk);
Risan8c9f3322018-10-29 08:52:56 +09001202 *outVolId = vol->getId();
1203 return android::OK;
1204}
1205
1206int VolumeManager::destroyStubVolume(const std::string& volId) {
Risan82e90de2020-02-04 16:07:21 +09001207 auto tokens = android::base::Split(volId, ":");
1208 CHECK(tokens.size() == 2);
1209 dev_t stubId;
1210 CHECK(android::base::ParseUint(tokens[1], &stubId));
1211 handleDiskRemoved(stubId);
Risan8c9f3322018-10-29 08:52:56 +09001212 return android::OK;
1213}
1214
Risan8f6198d2018-10-26 20:56:45 -06001215int VolumeManager::mountAppFuse(uid_t uid, int mountId, unique_fd* device_fd) {
Risanac02a482018-10-31 21:59:47 -06001216 return android::vold::MountAppFuse(uid, mountId, device_fd);
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001217}
1218
Risan8f6198d2018-10-26 20:56:45 -06001219int VolumeManager::unmountAppFuse(uid_t uid, int mountId) {
Risanac02a482018-10-31 21:59:47 -06001220 return android::vold::UnmountAppFuse(uid, mountId);
Risan8f6198d2018-10-26 20:56:45 -06001221}
1222
1223int VolumeManager::openAppFuseFile(uid_t uid, int mountId, int fileId, int flags) {
Risanac02a482018-10-31 21:59:47 -06001224 return android::vold::OpenAppFuseFile(uid, mountId, fileId, flags);
Jeff Sharkey11c2d382017-09-11 10:32:01 -06001225}