blob: 253541cf56fc6690f2d27bf73d70b1249da15231 [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);
Ethan Yonkere9afc3d2018-08-30 15:16:27 -050050status_t ReadRandomBytes(size_t bytes, char* buffer);
Ethan Yonkerbd7492d2016-12-07 13:55:01 -060051
52/* Converts hex string to raw bytes, ignoring [ :-] */
53status_t HexToStr(const std::string& hex, std::string& str);
54
55std::string BuildKeyPath(const std::string& partGuid);
56
57std::string BuildDataSystemLegacyPath(userid_t userid);
58std::string BuildDataSystemCePath(userid_t userid);
59std::string BuildDataSystemDePath(userid_t userid);
60std::string BuildDataMiscLegacyPath(userid_t userid);
61std::string BuildDataMiscCePath(userid_t userid);
62std::string BuildDataMiscDePath(userid_t userid);
63std::string BuildDataProfilesDePath(userid_t userid);
64std::string BuildDataProfilesForeignDexDePath(userid_t userid);
Ethan Yonkere9afc3d2018-08-30 15:16:27 -050065std::string BuildDataVendorCePath(userid_t userid);
66std::string BuildDataVendorDePath(userid_t userid);
Ethan Yonkerbd7492d2016-12-07 13:55:01 -060067
68std::string BuildDataPath(const char* volumeUuid);
69std::string BuildDataMediaCePath(const char* volumeUuid, userid_t userid);
70std::string BuildDataUserCePath(const char* volumeUuid, userid_t userid);
71std::string BuildDataUserDePath(const char* volumeUuid, userid_t userid);
72
73} // namespace vold
74} // namespace android
75
76#endif