blob: 2f7704d273adfcc6095a8cda28f4af8684510c83 [file] [log] [blame]
Felipe Lemef0292972016-11-22 13:57:05 -08001/*
2 * Copyright (C) 2016 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#ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_
17#define FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_
18
19#include <cstdint>
20#include <string>
21
22// TODO: rename macros to DUMPSTATE_LOGXXX
23#ifndef MYLOGD
24#define MYLOGD(...) \
25 fprintf(stderr, __VA_ARGS__); \
26 ALOGD(__VA_ARGS__);
27#endif
28
29#ifndef MYLOGI
30#define MYLOGI(...) \
31 fprintf(stderr, __VA_ARGS__); \
32 ALOGI(__VA_ARGS__);
33#endif
34
35#ifndef MYLOGE
36#define MYLOGE(...) \
37 fprintf(stderr, __VA_ARGS__); \
38 ALOGE(__VA_ARGS__);
39#endif
40
41// Internal functions used by .cpp files on multiple build targets.
42// TODO: move to android::os::dumpstate::internal namespace
43
44// TODO: use functions from <chrono> instead
45const uint64_t NANOS_PER_SEC = 1000000000;
46uint64_t Nanotime();
47
48// Switches to non-root user and group.
49bool DropRootUser();
50
51// TODO: move to .cpp as static once is not used by utils.cpp anymore.
52int DumpFileFromFdToFd(const std::string& title, const std::string& path_string, int fd, int out_fd,
53 bool dry_run = false);
54
55#endif // FRAMEWORK_NATIVE_CMD_DUMPSTATE_INTERNAL_H_