blob: b196a4df2d5d0b94d4c339406848042d784b2d25
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 droidvold { |
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(const std::string& physicalDevName, const bool isPhysical); |
43 | virtual ~PublicVolume(); |
44 | |
45 | protected: |
46 | status_t doCreate() override; |
47 | status_t doDestroy() override; |
48 | status_t doMount() override; |
49 | status_t doUnmount() override; |
50 | status_t doFormat(const std::string& fsType) override; |
51 | bool isSrdiskMounted() { return mSrMounted;} |
52 | |
53 | status_t readMetadata(); |
54 | status_t initAsecStage(); |
55 | status_t prepareDir(const std::string& path, mode_t mode, uid_t uid, gid_t gid); |
56 | |
57 | private: |
58 | /* Kernel device representing partition */ |
59 | dev_t mDevice; |
60 | /* Block device path */ |
61 | std::string mDevPath; |
62 | /* Mount point of raw partition */ |
63 | std::string mRawPath; |
64 | |
65 | std::string mFuseDefault; |
66 | std::string mFuseRead; |
67 | std::string mFuseWrite; |
68 | |
69 | /* Filesystem type */ |
70 | std::string mFsType; |
71 | /* Filesystem UUID */ |
72 | std::string mFsUuid; |
73 | /* User-visible filesystem label */ |
74 | std::string mFsLabel; |
75 | |
76 | bool mSrMounted; |
77 | |
78 | /* Just sd/udisk physical devices are used */ |
79 | bool mJustPhysicalDev; |
80 | |
81 | DISALLOW_COPY_AND_ASSIGN(PublicVolume); |
82 | }; |
83 | |
84 | } // namespace vold |
85 | } // namespace android |
86 | |
87 | #endif |
88 |