blob: 972351c5832dd460582b7626c8ea0a2286d077e6 [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_EMULATED_VOLUME_H
18#define ANDROID_VOLD_EMULATED_VOLUME_H
19
20#include "VolumeBase.h"
21
22#include <cutils/multiuser.h>
23
24namespace android {
25namespace vold {
26
27/*
28 * Shared storage emulated on top of private storage.
29 *
30 * Knows how to spawn a FUSE daemon to synthesize permissions. ObbVolume
31 * can be stacked above it.
32 *
33 * This volume is always multi-user aware, but is only binds itself to
34 * users when its primary storage. This volume should never be presented
35 * as secondary storage, since we're strongly encouraging developers to
36 * store data local to their app.
37 */
38class EmulatedVolume : public VolumeBase {
39public:
40 EmulatedVolume(const std::string& rawPath, const std::string& nickname);
41 virtual ~EmulatedVolume();
42
43 void setPrimary(bool primary);
44 bool getPrimary() { return mPrimary; }
45
46 status_t bindUser(userid_t user);
47 status_t unbindUser(userid_t user);
48
49private:
50 /* Mount point of raw storage */
51 std::string mRawPath;
52 /* Mount point of FUSE wrapper */
53 std::string mFusePath;
54 /* PID of FUSE wrapper */
55 pid_t mFusePid;
56 /* Flag indicating this is primary storage */
57 bool mPrimary;
58
59protected:
60 status_t doMount();
61 status_t doUnmount();
62 status_t doFormat();
63
64 status_t bindUserInternal(userid_t user, bool bind);
65
66 DISALLOW_COPY_AND_ASSIGN(EmulatedVolume);
67};
68
69} // namespace vold
70} // namespace android
71
72#endif