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