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_PUBLIC_VOLUME_H |
| 18 | #define ANDROID_VOLD_PUBLIC_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 provided by public (vfat) partition. |
| 29 | * |
Martijn Coenen | adcc845 | 2019-12-09 14:18:01 +0100 | [diff] [blame] | 30 | * Knows how to mount itself and then spawn a sdcardfs daemon to synthesize |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 31 | * permissions. AsecVolume and ObbVolume can be stacked above it. |
| 32 | * |
| 33 | * This volume is not inherently multi-user aware, so it has two possible |
| 34 | * modes of operation: |
| 35 | * 1. If primary storage for the device, it only binds itself to the |
| 36 | * owner user. |
| 37 | * 2. If secondary storage, it binds itself for all users, but masks |
| 38 | * away the Android directory for secondary users. |
| 39 | */ |
| 40 | class PublicVolume : public VolumeBase { |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 41 | public: |
Alexander Martinz | 7226888 | 2023-09-28 14:43:16 +0200 | [diff] [blame] | 42 | explicit PublicVolume(dev_t device); |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 43 | virtual ~PublicVolume(); |
| 44 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 45 | protected: |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame] | 46 | status_t doCreate() override; |
| 47 | status_t doDestroy() override; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 48 | status_t doMount() override; |
| 49 | status_t doUnmount() override; |
Jeff Sharkey | d0640f6 | 2015-05-21 22:35:42 -0700 | [diff] [blame] | 50 | status_t doFormat(const std::string& fsType) override; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 51 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 52 | status_t readMetadata(); |
| 53 | status_t initAsecStage(); |
| 54 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 55 | private: |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 56 | /* Kernel device representing partition */ |
| 57 | dev_t mDevice; |
| 58 | /* Block device path */ |
| 59 | std::string mDevPath; |
| 60 | /* Mount point of raw partition */ |
| 61 | std::string mRawPath; |
Jeff Sharkey | 66270a2 | 2015-06-24 11:49:24 -0700 | [diff] [blame] | 62 | |
Martijn Coenen | adcc845 | 2019-12-09 14:18:01 +0100 | [diff] [blame] | 63 | std::string mSdcardFsDefault; |
| 64 | std::string mSdcardFsRead; |
| 65 | std::string mSdcardFsWrite; |
| 66 | std::string mSdcardFsFull; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 67 | |
Martijn Coenen | 6f5802e | 2019-11-28 11:53:53 +0100 | [diff] [blame] | 68 | /* Whether we mounted FUSE for this volume */ |
| 69 | bool mFuseMounted; |
| 70 | |
Martijn Coenen | 86f21a2 | 2020-01-06 09:48:14 +0100 | [diff] [blame] | 71 | /* Whether to use sdcardfs for this volume */ |
| 72 | bool mUseSdcardFs; |
| 73 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 74 | /* Filesystem type */ |
| 75 | std::string mFsType; |
| 76 | /* Filesystem UUID */ |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 77 | std::string mFsUuid; |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 78 | /* User-visible filesystem label */ |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 79 | std::string mFsLabel; |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 80 | |
| 81 | DISALLOW_COPY_AND_ASSIGN(PublicVolume); |
| 82 | }; |
| 83 | |
| 84 | } // namespace vold |
| 85 | } // namespace android |
| 86 | |
| 87 | #endif |