Tom Marshall | dd9b45d | 2019-01-04 14:37:31 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * Copyright (C) 2019 The LineageOS Project |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef ANDROID_VOLMGR_PUBLIC_VOLUME_H |
| 19 | #define ANDROID_VOLMGR_PUBLIC_VOLUME_H |
| 20 | |
| 21 | #include "VolumeBase.h" |
| 22 | |
| 23 | #include <cutils/multiuser.h> |
| 24 | |
| 25 | namespace android { |
| 26 | namespace volmgr { |
| 27 | |
| 28 | /* |
| 29 | * Shared storage provided by public (vfat) partition. |
| 30 | * |
| 31 | * Knows how to mount itself and then spawn a FUSE daemon to synthesize |
| 32 | * permissions. |
| 33 | * |
| 34 | * This volume is not inherently multi-user aware, so it has two possible |
| 35 | * modes of operation: |
| 36 | * 1. If primary storage for the device, it only binds itself to the |
| 37 | * owner user. |
| 38 | * 2. If secondary storage, it binds itself for all users, but masks |
| 39 | * away the Android directory for secondary users. |
| 40 | */ |
| 41 | class PublicVolume : public VolumeBase { |
| 42 | public: |
| 43 | PublicVolume(dev_t device, const std::string& nickname, const std::string& mntopts = "", |
| 44 | const std::string& fstype = ""); |
| 45 | virtual ~PublicVolume(); |
| 46 | |
| 47 | protected: |
| 48 | status_t doCreate() override; |
| 49 | status_t doDestroy() override; |
| 50 | status_t doMount() override; |
| 51 | status_t doUnmount(bool detach = false) override; |
| 52 | |
| 53 | status_t readMetadata(); |
| 54 | |
| 55 | private: |
| 56 | /* Kernel device representing partition */ |
| 57 | dev_t mDevice; |
| 58 | /* Block device path */ |
| 59 | std::string mDevPath; |
| 60 | |
| 61 | /* Filesystem type */ |
| 62 | std::string mFsType; |
| 63 | /* Filesystem UUID */ |
| 64 | std::string mFsUuid; |
| 65 | /* Mount options */ |
| 66 | std::string mMntOpts; |
| 67 | |
| 68 | DISALLOW_COPY_AND_ASSIGN(PublicVolume); |
| 69 | }; |
| 70 | |
| 71 | } // namespace volmgr |
| 72 | } // namespace android |
| 73 | |
| 74 | #endif |