blob: 0389ea7f377d49b7951f31c00287079318d2eb05 [file] [log] [blame]
Jeff Sharkeydeb24052015-03-02 21:01:40 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_VOLD_EMULATED_VOLUME_H
18#define ANDROID_VOLD_EMULATED_VOLUME_H
19
20#include "VolumeBase.h"
21
22#include <cutils/multiuser.h>
23
24namespace android {
25namespace vold {
26
27/*
28 * Shared storage emulated on top of private storage.
29 *
Martijn Coenenadcc8452019-12-09 14:18:01 +010030 * Knows how to spawn a sdcardfs daemon to synthesize permissions. ObbVolume
Jeff Sharkeydeb24052015-03-02 21:01:40 -080031 * can be stacked above it.
32 *
33 * This volume is always multi-user aware, but is only binds itself to
34 * users when its primary storage. This volume should never be presented
35 * as secondary storage, since we're strongly encouraging developers to
36 * store data local to their app.
37 */
38class EmulatedVolume : public VolumeBase {
Paul Crowley14c8c072018-09-18 13:30:21 -070039 public:
Zima438b242019-09-25 14:37:38 +010040 explicit EmulatedVolume(const std::string& rawPath, int userId);
41 EmulatedVolume(const std::string& rawPath, dev_t device, const std::string& fsUuid, int userId);
Jeff Sharkeydeb24052015-03-02 21:01:40 -080042 virtual ~EmulatedVolume();
Martijn Coenen62a4b272020-01-31 15:23:09 +010043 std::string getRootPath() const override;
Ricky Wai6b122572020-02-28 16:30:47 +000044 bool isFuseMounted() const { return mFuseMounted; }
Jeff Sharkeydeb24052015-03-02 21:01:40 -080045
Paul Crowley14c8c072018-09-18 13:30:21 -070046 protected:
Jeff Sharkey36801cc2015-03-13 16:09:20 -070047 status_t doMount() override;
48 status_t doUnmount() override;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080049
Paul Crowley14c8c072018-09-18 13:30:21 -070050 private:
Martijn Coenen449a7d82020-03-16 14:37:33 +010051 status_t unmountSdcardFs();
Martijn Coenen86f21a22020-01-06 09:48:14 +010052 status_t mountFuseBindMounts();
53 status_t unmountFuseBindMounts();
54
Martijn Coenen73e30102022-07-12 08:11:02 +000055 status_t bindMountVolume(const EmulatedVolume& vol, std::list<std::string>& pathsToUnmount);
56
57 std::string getLabel() const;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080058 std::string mRawPath;
Jeff Sharkey66270a22015-06-24 11:49:24 -070059 std::string mLabel;
60
Martijn Coenenadcc8452019-12-09 14:18:01 +010061 std::string mSdcardFsDefault;
62 std::string mSdcardFsRead;
63 std::string mSdcardFsWrite;
64 std::string mSdcardFsFull;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080065
Martijn Coenen6f5802e2019-11-28 11:53:53 +010066 /* Whether we mounted FUSE for this volume */
67 bool mFuseMounted;
68
Martijn Coenen86f21a22020-01-06 09:48:14 +010069 /* Whether to use sdcardfs for this volume */
70 bool mUseSdcardFs;
71
Ricky Wai07e64a42020-02-11 14:31:24 +000072 /* Whether to use app data isolation is enabled tor this volume */
73 bool mAppDataIsolationEnabled;
74
Martijn Coenen73e30102022-07-12 08:11:02 +000075 /* Location of bind mount for another profile that shares storage with us */
76 std::string mSharedStorageMountPath = "";
77
Jeff Sharkeydeb24052015-03-02 21:01:40 -080078 DISALLOW_COPY_AND_ASSIGN(EmulatedVolume);
79};
80
81} // namespace vold
82} // namespace android
83
84#endif