OSDN Git Service

Merge "add vold to "shutdown critical"" am: da85cb71b3 am: 228b95fa15
[android-x86/system-vold.git] / PrivateVolume.h
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_PRIVATE_VOLUME_H
18 #define ANDROID_VOLD_PRIVATE_VOLUME_H
19
20 #include "VolumeBase.h"
21
22 #include <cutils/multiuser.h>
23
24 namespace android {
25 namespace vold {
26
27 /*
28  * Private storage provided by an encrypted partition.
29  *
30  * Given a raw block device, it knows how to wrap it in dm-crypt and
31  * format as ext4/f2fs.  EmulatedVolume can be stacked above it.
32  *
33  * This volume is designed to behave much like the internal /data
34  * partition, both in layout and function.  For example, apps and
35  * private app data can be safely stored on this volume because the
36  * keys are tightly tied to this device.
37  */
38 class PrivateVolume : public VolumeBase {
39 public:
40     PrivateVolume(dev_t device, const std::string& keyRaw);
41     virtual ~PrivateVolume();
42
43 protected:
44     status_t doCreate() override;
45     status_t doDestroy() override;
46     status_t doMount() override;
47     status_t doUnmount() override;
48     status_t doFormat(const std::string& fsType) override;
49
50     status_t readMetadata();
51
52 private:
53     /* Kernel device of raw, encrypted partition */
54     dev_t mRawDevice;
55     /* Path to raw, encrypted block device */
56     std::string mRawDevPath;
57     /* Path to decrypted block device */
58     std::string mDmDevPath;
59     /* Path where decrypted device is mounted */
60     std::string mPath;
61
62     /* Encryption key as raw bytes */
63     std::string mKeyRaw;
64
65     /* Filesystem type */
66     std::string mFsType;
67     /* Filesystem UUID */
68     std::string mFsUuid;
69     /* User-visible filesystem label */
70     std::string mFsLabel;
71
72     DISALLOW_COPY_AND_ASSIGN(PrivateVolume);
73 };
74
75 }  // namespace vold
76 }  // namespace android
77
78 #endif