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 | * |
| 30 | * Knows how to mount itself and then spawn a FUSE daemon to synthesize |
| 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 { |
| 41 | public: |
| 42 | explicit PublicVolume(dev_t device); |
| 43 | virtual ~PublicVolume(); |
| 44 | |
| 45 | status_t readMetadata(); |
| 46 | status_t initAsecStage(); |
| 47 | |
| 48 | void setPrimary(bool primary); |
| 49 | bool getPrimary() { return mPrimary; } |
| 50 | |
| 51 | const std::string& getFsUuid() { return mFsUuid; } |
| 52 | const std::string& getFsLabel() { return mFsLabel; } |
| 53 | |
| 54 | status_t bindUser(userid_t user); |
| 55 | status_t unbindUser(userid_t user); |
| 56 | |
| 57 | protected: |
| 58 | status_t doMount(); |
| 59 | status_t doUnmount(); |
| 60 | status_t doFormat(); |
| 61 | |
| 62 | status_t bindUserInternal(userid_t user, bool bind); |
| 63 | |
| 64 | private: |
| 65 | /* Kernel device representing partition */ |
| 66 | dev_t mDevice; |
| 67 | /* Block device path */ |
| 68 | std::string mDevPath; |
| 69 | /* Mount point of raw partition */ |
| 70 | std::string mRawPath; |
| 71 | /* Mount point of FUSE wrapper */ |
| 72 | std::string mFusePath; |
| 73 | /* PID of FUSE wrapper */ |
| 74 | pid_t mFusePid; |
| 75 | /* Flag indicating this is primary storage */ |
| 76 | bool mPrimary; |
| 77 | |
| 78 | /* Parsed UUID from filesystem */ |
| 79 | std::string mFsUuid; |
| 80 | /* User-visible label from filesystem */ |
| 81 | std::string mFsLabel; |
| 82 | |
| 83 | DISALLOW_COPY_AND_ASSIGN(PublicVolume); |
| 84 | }; |
| 85 | |
| 86 | } // namespace vold |
| 87 | } // namespace android |
| 88 | |
| 89 | #endif |