Ethan Yonker | bd7492d | 2016-12-07 13:55:01 -0600 | [diff] [blame] | 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 TWRP_VOLD_UTILS_H |
| 18 | #define TWRP_VOLD_UTILS_H |
| 19 | |
| 20 | #include <utils/Errors.h> |
| 21 | #include <cutils/multiuser.h> |
| 22 | #include <selinux/selinux.h> |
| 23 | |
| 24 | #include <vector> |
| 25 | #include <string> |
| 26 | |
Ethan Yonker | fefe591 | 2017-09-30 22:22:13 -0500 | [diff] [blame] | 27 | // DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. It goes in the private: |
| 28 | // declarations in a class. |
| 29 | #if !defined(DISALLOW_COPY_AND_ASSIGN) |
| 30 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 31 | TypeName(const TypeName&) = delete; \ |
| 32 | void operator=(const TypeName&) = delete |
| 33 | #endif |
| 34 | |
Ethan Yonker | bd7492d | 2016-12-07 13:55:01 -0600 | [diff] [blame] | 35 | namespace android { |
| 36 | namespace vold { |
| 37 | |
| 38 | /* Returns either WEXITSTATUS() status, or a negative errno */ |
| 39 | status_t ForkExecvp(const std::vector<std::string>& args); |
| 40 | status_t ForkExecvp(const std::vector<std::string>& args, security_context_t context); |
| 41 | |
| 42 | status_t ForkExecvp(const std::vector<std::string>& args, |
| 43 | std::vector<std::string>& output); |
| 44 | status_t ForkExecvp(const std::vector<std::string>& args, |
| 45 | std::vector<std::string>& output, security_context_t context); |
| 46 | |
| 47 | pid_t ForkExecvpAsync(const std::vector<std::string>& args); |
| 48 | |
| 49 | status_t ReadRandomBytes(size_t bytes, std::string& out); |
| 50 | |
| 51 | /* Converts hex string to raw bytes, ignoring [ :-] */ |
| 52 | status_t HexToStr(const std::string& hex, std::string& str); |
| 53 | |
| 54 | std::string BuildKeyPath(const std::string& partGuid); |
| 55 | |
| 56 | std::string BuildDataSystemLegacyPath(userid_t userid); |
| 57 | std::string BuildDataSystemCePath(userid_t userid); |
| 58 | std::string BuildDataSystemDePath(userid_t userid); |
| 59 | std::string BuildDataMiscLegacyPath(userid_t userid); |
| 60 | std::string BuildDataMiscCePath(userid_t userid); |
| 61 | std::string BuildDataMiscDePath(userid_t userid); |
| 62 | std::string BuildDataProfilesDePath(userid_t userid); |
| 63 | std::string BuildDataProfilesForeignDexDePath(userid_t userid); |
| 64 | |
| 65 | std::string BuildDataPath(const char* volumeUuid); |
| 66 | std::string BuildDataMediaCePath(const char* volumeUuid, userid_t userid); |
| 67 | std::string BuildDataUserCePath(const char* volumeUuid, userid_t userid); |
| 68 | std::string BuildDataUserDePath(const char* volumeUuid, userid_t userid); |
| 69 | |
| 70 | } // namespace vold |
| 71 | } // namespace android |
| 72 | |
| 73 | #endif |