Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [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 ANDROID_VOLD_UTILS_H |
| 18 | #define ANDROID_VOLD_UTILS_H |
| 19 | |
| 20 | #include <utils/Errors.h> |
| 21 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame^] | 22 | #include <vector> |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 23 | #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 | |
| 33 | namespace android { |
| 34 | namespace vold { |
| 35 | |
| 36 | status_t CreateDeviceNode(const std::string& path, dev_t dev); |
| 37 | status_t DestroyDeviceNode(const std::string& path); |
| 38 | |
| 39 | /* Really unmounts the path, killing active processes along the way */ |
| 40 | status_t ForceUnmount(const std::string& path); |
| 41 | |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 42 | /* Creates bind mount from source to target */ |
| 43 | status_t BindMount(const std::string& source, const std::string& target); |
| 44 | |
Jeff Sharkey | 9c48498 | 2015-03-31 10:35:33 -0700 | [diff] [blame^] | 45 | /* Reads filesystem metadata from device at path */ |
| 46 | status_t ReadMetadata(const std::string& path, std::string& fsType, |
| 47 | std::string& fsUuid, std::string& fsLabel); |
| 48 | |
| 49 | status_t ForkExecvp(const std::vector<std::string>& args, int* status, |
| 50 | bool ignore_int_quit, bool logwrap); |
| 51 | |
| 52 | status_t ReadRandomBytes(size_t bytes, std::string& out); |
| 53 | |
| 54 | status_t HexToStr(const std::string& hex, std::string& str); |
| 55 | status_t StrToHex(const std::string& str, std::string& hex); |
| 56 | |
Jeff Sharkey | deb2405 | 2015-03-02 21:01:40 -0800 | [diff] [blame] | 57 | } // namespace vold |
| 58 | } // namespace android |
| 59 | |
| 60 | #endif |