blob: 5eff35e44855590292f765da326427d0651b5fe7 [file] [log] [blame]
Jeff Sharkeydeb24052015-03-02 21:01:40 -08001/*
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
24namespace android {
25namespace vold {
26
27/*
28 * Shared storage provided by public (vfat) partition.
29 *
Martijn Coenenadcc8452019-12-09 14:18:01 +010030 * Knows how to mount itself and then spawn a sdcardfs daemon to synthesize
Jeff Sharkeydeb24052015-03-02 21:01:40 -080031 * 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 */
40class PublicVolume : public VolumeBase {
Paul Crowley14c8c072018-09-18 13:30:21 -070041 public:
Jeff Sharkeydeb24052015-03-02 21:01:40 -080042 explicit PublicVolume(dev_t device);
43 virtual ~PublicVolume();
44
himanshuz0ad08622023-07-27 21:15:00 +000045 status_t bindMountForUser(userid_t user_id);
Omar Eissad9c4b232025-03-13 11:52:43 +000046 std::string getStableName();
himanshuz0ad08622023-07-27 21:15:00 +000047
Paul Crowley14c8c072018-09-18 13:30:21 -070048 protected:
Jeff Sharkey9c484982015-03-31 10:35:33 -070049 status_t doCreate() override;
50 status_t doDestroy() override;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070051 status_t doMount() override;
52 status_t doUnmount() override;
Jeff Sharkeyd0640f62015-05-21 22:35:42 -070053 status_t doFormat(const std::string& fsType) override;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070054
Jeff Sharkeydeb24052015-03-02 21:01:40 -080055 status_t readMetadata();
56 status_t initAsecStage();
57
Paul Crowley14c8c072018-09-18 13:30:21 -070058 private:
Jeff Sharkeydeb24052015-03-02 21:01:40 -080059 /* Kernel device representing partition */
60 dev_t mDevice;
61 /* Block device path */
62 std::string mDevPath;
63 /* Mount point of raw partition */
64 std::string mRawPath;
Jeff Sharkey66270a22015-06-24 11:49:24 -070065
Martijn Coenenadcc8452019-12-09 14:18:01 +010066 std::string mSdcardFsDefault;
67 std::string mSdcardFsRead;
68 std::string mSdcardFsWrite;
69 std::string mSdcardFsFull;
Jeff Sharkeydeb24052015-03-02 21:01:40 -080070
Martijn Coenen6f5802e2019-11-28 11:53:53 +010071 /* Whether we mounted FUSE for this volume */
72 bool mFuseMounted;
73
Martijn Coenen86f21a22020-01-06 09:48:14 +010074 /* Whether to use sdcardfs for this volume */
75 bool mUseSdcardFs;
76
Jeff Sharkey36801cc2015-03-13 16:09:20 -070077 /* Filesystem type */
78 std::string mFsType;
79 /* Filesystem UUID */
Jeff Sharkeydeb24052015-03-02 21:01:40 -080080 std::string mFsUuid;
Jeff Sharkey36801cc2015-03-13 16:09:20 -070081 /* User-visible filesystem label */
Jeff Sharkeydeb24052015-03-02 21:01:40 -080082 std::string mFsLabel;
83
84 DISALLOW_COPY_AND_ASSIGN(PublicVolume);
85};
86
87} // namespace vold
88} // namespace android
89
90#endif