blob: 0e0904ee6e765dc6983544c4bd05505b3be0b0c4 [file] [log] [blame]
Jeff Sharkeydeb24052015-03-02 21:01:40 -08001/*
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 ANDROID_VOLD_UTILS_H
18#define ANDROID_VOLD_UTILS_H
19
20#include <utils/Errors.h>
21
Jeff Sharkey9c484982015-03-31 10:35:33 -070022#include <vector>
Jeff Sharkeydeb24052015-03-02 21:01:40 -080023#include <string>
24
25// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. It goes in the private:
26// declarations in a class.
27#if !defined(DISALLOW_COPY_AND_ASSIGN)
28#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
29 TypeName(const TypeName&) = delete; \
30 void operator=(const TypeName&) = delete
31#endif
32
33namespace android {
34namespace vold {
35
36status_t CreateDeviceNode(const std::string& path, dev_t dev);
37status_t DestroyDeviceNode(const std::string& path);
38
39/* Really unmounts the path, killing active processes along the way */
40status_t ForceUnmount(const std::string& path);
41
Jeff Sharkey36801cc2015-03-13 16:09:20 -070042/* Creates bind mount from source to target */
43status_t BindMount(const std::string& source, const std::string& target);
44
Jeff Sharkey9c484982015-03-31 10:35:33 -070045/* Reads filesystem metadata from device at path */
46status_t ReadMetadata(const std::string& path, std::string& fsType,
47 std::string& fsUuid, std::string& fsLabel);
48
49status_t ForkExecvp(const std::vector<std::string>& args, int* status,
50 bool ignore_int_quit, bool logwrap);
51
52status_t ReadRandomBytes(size_t bytes, std::string& out);
53
54status_t HexToStr(const std::string& hex, std::string& str);
55status_t StrToHex(const std::string& str, std::string& hex);
56
Jeff Sharkeydeb24052015-03-02 21:01:40 -080057} // namespace vold
58} // namespace android
59
60#endif