blob: 8d0445d897708cdbdce4b1a93036a035b6aa8032 [file] [log] [blame]
Ethan Yonkerbd7492d2016-12-07 13:55:01 -06001/*
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
27namespace android {
28namespace vold {
29
30/* Returns either WEXITSTATUS() status, or a negative errno */
31status_t ForkExecvp(const std::vector<std::string>& args);
32status_t ForkExecvp(const std::vector<std::string>& args, security_context_t context);
33
34status_t ForkExecvp(const std::vector<std::string>& args,
35 std::vector<std::string>& output);
36status_t ForkExecvp(const std::vector<std::string>& args,
37 std::vector<std::string>& output, security_context_t context);
38
39pid_t ForkExecvpAsync(const std::vector<std::string>& args);
40
41status_t ReadRandomBytes(size_t bytes, std::string& out);
42
43/* Converts hex string to raw bytes, ignoring [ :-] */
44status_t HexToStr(const std::string& hex, std::string& str);
45
46std::string BuildKeyPath(const std::string& partGuid);
47
48std::string BuildDataSystemLegacyPath(userid_t userid);
49std::string BuildDataSystemCePath(userid_t userid);
50std::string BuildDataSystemDePath(userid_t userid);
51std::string BuildDataMiscLegacyPath(userid_t userid);
52std::string BuildDataMiscCePath(userid_t userid);
53std::string BuildDataMiscDePath(userid_t userid);
54std::string BuildDataProfilesDePath(userid_t userid);
55std::string BuildDataProfilesForeignDexDePath(userid_t userid);
56
57std::string BuildDataPath(const char* volumeUuid);
58std::string BuildDataMediaCePath(const char* volumeUuid, userid_t userid);
59std::string BuildDataUserCePath(const char* volumeUuid, userid_t userid);
60std::string BuildDataUserDePath(const char* volumeUuid, userid_t userid);
61
62} // namespace vold
63} // namespace android
64
65#endif