Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace android { |
| 25 | namespace vold { |
| 26 | |
| 27 | /* |
| 28 | * Shared storage emulated on top of private storage. |
| 29 | * |
Martijn Coenen | adcc845 | 2019-12-09 14:18:01 +0100 | [diff] [blame] | 30 | * Knows how to spawn a sdcardfs daemon to synthesize permissions. ObbVolume |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 31 | * 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 | */ |
| 38 | class EmulatedVolume : public VolumeBase { |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 39 | public: |
Zim | a438b24 | 2019-09-25 14:37:38 +0100 | [diff] [blame] | 40 | explicit EmulatedVolume(const std::string& rawPath, int userId); |
| 41 | EmulatedVolume(const std::string& rawPath, dev_t device, const std::string& fsUuid, int userId); |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 42 | virtual ~EmulatedVolume(); |
Martijn Coenen | 62a4b27 | 2020-01-31 15:23:09 +0100 | [diff] [blame] | 43 | std::string getRootPath() const override; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 44 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 45 | protected: |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 46 | status_t doMount() override; |
| 47 | status_t doUnmount() override; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 48 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 49 | private: |
Martijn Coenen | 86f21a2 | 2020-01-06 09:48:14 +0100 | [diff] [blame] | 50 | status_t mountFuseBindMounts(); |
| 51 | status_t unmountFuseBindMounts(); |
| 52 | |
Martijn Coenen | 6f5802e | 2019-11-28 11:53:53 +0100 | [diff] [blame] | 53 | std::string getLabel(); |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 54 | std::string mRawPath; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 55 | std::string mLabel; |
| 56 | |
Martijn Coenen | adcc845 | 2019-12-09 14:18:01 +0100 | [diff] [blame] | 57 | std::string mSdcardFsDefault; |
| 58 | std::string mSdcardFsRead; |
| 59 | std::string mSdcardFsWrite; |
| 60 | std::string mSdcardFsFull; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 61 | |
Martijn Coenen | 6f5802e | 2019-11-28 11:53:53 +0100 | [diff] [blame] | 62 | /* Whether we mounted FUSE for this volume */ |
| 63 | bool mFuseMounted; |
| 64 | |
Martijn Coenen | 86f21a2 | 2020-01-06 09:48:14 +0100 | [diff] [blame] | 65 | /* Whether to use sdcardfs for this volume */ |
| 66 | bool mUseSdcardFs; |
| 67 | |
Ricky Wai | 07e64a4 | 2020-02-11 14:31:24 +0000 | [diff] [blame^] | 68 | /* Whether to use app data isolation is enabled tor this volume */ |
| 69 | bool mAppDataIsolationEnabled; |
| 70 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 71 | DISALLOW_COPY_AND_ASSIGN(EmulatedVolume); |
| 72 | }; |
| 73 | |
| 74 | } // namespace vold |
| 75 | } // namespace android |
| 76 | |
| 77 | #endif |