19c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey/* 29c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * Copyright (C) 2015 The Android Open Source Project 39c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * 49c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License"); 59c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * you may not use this file except in compliance with the License. 69c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * You may obtain a copy of the License at 79c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * 89c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * http://www.apache.org/licenses/LICENSE-2.0 99c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * 109c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * Unless required by applicable law or agreed to in writing, software 119c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS, 129c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * See the License for the specific language governing permissions and 149c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * limitations under the License. 159c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey */ 169c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 179c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey#ifndef ANDROID_VOLD_PRIVATE_VOLUME_H 189c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey#define ANDROID_VOLD_PRIVATE_VOLUME_H 199c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 209c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey#include "VolumeBase.h" 219c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 229c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey#include <cutils/multiuser.h> 239c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 249c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeynamespace android { 259c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeynamespace vold { 269c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 279c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey/* 289c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * Private storage provided by an encrypted partition. 299c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * 309c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * Given a raw block device, it knows how to wrap it in dm-crypt and 319c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * format as ext4/f2fs. EmulatedVolume can be stacked above it. 329c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * 339c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * This volume is designed to behave much like the internal /data 349c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * partition, both in layout and function. For example, apps and 359c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * private app data can be safely stored on this volume because the 369c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey * keys are tightly tied to this device. 379c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey */ 389c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeyclass PrivateVolume : public VolumeBase { 399c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeypublic: 409c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey PrivateVolume(dev_t device, const std::string& keyRaw); 419c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey virtual ~PrivateVolume(); 429c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 439c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeyprotected: 449c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey status_t doCreate() override; 459c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey status_t doDestroy() override; 469c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey status_t doMount() override; 479c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey status_t doUnmount() override; 48d0640f6358041f7e2657167560b357078db73526Jeff Sharkey status_t doFormat(const std::string& fsType) override; 499c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 509c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey status_t readMetadata(); 519c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 529c48498f4529f623650c56d03e63324c8d813032Jeff Sharkeyprivate: 539c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Kernel device of raw, encrypted partition */ 549c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey dev_t mRawDevice; 559c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Path to raw, encrypted block device */ 569c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mRawDevPath; 579c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Path to decrypted block device */ 589c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mDmDevPath; 599c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Path where decrypted device is mounted */ 609c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mPath; 619c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 629c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Encryption key as raw bytes */ 639c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mKeyRaw; 649c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 659c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Filesystem type */ 669c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mFsType; 679c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* Filesystem UUID */ 689c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mFsUuid; 699c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey /* User-visible filesystem label */ 709c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey std::string mFsLabel; 719c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 729c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey DISALLOW_COPY_AND_ASSIGN(PrivateVolume); 739c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey}; 749c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 759c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey} // namespace vold 769c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey} // namespace android 779c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey 789c48498f4529f623650c56d03e63324c8d813032Jeff Sharkey#endif 79