Merge "remove emergency shutdown and improve init's reboot logic"
diff --git a/include/private/android_filesystem_capability.h b/include/private/android_filesystem_capability.h
new file mode 120000
index 0000000..f310b35
--- /dev/null
+++ b/include/private/android_filesystem_capability.h
@@ -0,0 +1 @@
+../../libcutils/include/private/android_filesystem_capability.h
\ No newline at end of file
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
deleted file mode 100644
index d200070..0000000
--- a/include/private/android_filesystem_config.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* This file is used to define the properties of the filesystem
-** images generated by build tools (mkbootfs and mkyaffs2image) and
-** by the device side of adb.
-*/
-
-/*
- * This file is consumed by build/tools/fs_config and is used
- * for generating various files. Anything #define AID_<name>
- * becomes the mapping for getpwnam/getpwuid, etc. The <name>
- * field is lowercased.
- * For example:
- * #define AID_FOO_BAR 6666 becomes a friendly name of "foo_bar"
- *
- * The above holds true with the exception of:
- * mediacodec
- * mediaex
- * mediadrm
- * Whose friendly names do not match the #define statements.
- *
- * Additionally, AID_OEM_RESERVED_START and AID_OEM_RESERVED_END
- * can be used to define reserved OEM ranges used for sanity checks
- * during the build process. The rules are, they must end with START/END
- * The proper convention is incrementing a number like so:
- * AID_OEM_RESERVED_START
- * AID_OEM_RESERVED_1_START
- * AID_OEM_RESERVED_2_START
- * ...
- * The same applies to the END.
- * They are not required to be in order, but must not overlap each other and
- * must define a START and END'ing range. START must be smaller than END.
- */
-
-#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
-#define _ANDROID_FILESYSTEM_CONFIG_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <stdint.h>
-
-#if defined(__ANDROID__)
-#include <linux/capability.h>
-#else
-#include "android_filesystem_capability.h"
-#endif
-
-#define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
-
-/* This is the master Users and Groups config for the platform.
- * DO NOT EVER RENUMBER
- */
-
-#define AID_ROOT 0 /* traditional unix root user */
-
-#define AID_SYSTEM 1000 /* system server */
-
-#define AID_RADIO 1001 /* telephony subsystem, RIL */
-#define AID_BLUETOOTH 1002 /* bluetooth subsystem */
-#define AID_GRAPHICS 1003 /* graphics devices */
-#define AID_INPUT 1004 /* input devices */
-#define AID_AUDIO 1005 /* audio devices */
-#define AID_CAMERA 1006 /* camera devices */
-#define AID_LOG 1007 /* log devices */
-#define AID_COMPASS 1008 /* compass device */
-#define AID_MOUNT 1009 /* mountd socket */
-#define AID_WIFI 1010 /* wifi subsystem */
-#define AID_ADB 1011 /* android debug bridge (adbd) */
-#define AID_INSTALL 1012 /* group for installing packages */
-#define AID_MEDIA 1013 /* mediaserver process */
-#define AID_DHCP 1014 /* dhcp client */
-#define AID_SDCARD_RW 1015 /* external storage write access */
-#define AID_VPN 1016 /* vpn system */
-#define AID_KEYSTORE 1017 /* keystore subsystem */
-#define AID_USB 1018 /* USB devices */
-#define AID_DRM 1019 /* DRM server */
-#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */
-#define AID_GPS 1021 /* GPS daemon */
-#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */
-#define AID_MEDIA_RW 1023 /* internal media storage write access */
-#define AID_MTP 1024 /* MTP USB driver access */
-#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */
-#define AID_DRMRPC 1026 /* group for drm rpc */
-#define AID_NFC 1027 /* nfc subsystem */
-#define AID_SDCARD_R 1028 /* external storage read access */
-#define AID_CLAT 1029 /* clat part of nat464 */
-#define AID_LOOP_RADIO 1030 /* loop radio devices */
-#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */
-#define AID_PACKAGE_INFO 1032 /* access to installed package details */
-#define AID_SDCARD_PICS 1033 /* external storage photos access */
-#define AID_SDCARD_AV 1034 /* external storage audio/video access */
-#define AID_SDCARD_ALL 1035 /* access all users external storage */
-#define AID_LOGD 1036 /* log daemon */
-#define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */
-#define AID_DBUS 1038 /* dbus-daemon IPC broker process */
-#define AID_TLSDATE 1039 /* tlsdate unprivileged user */
-#define AID_MEDIA_EX 1040 /* mediaextractor process */
-#define AID_AUDIOSERVER 1041 /* audioserver process */
-#define AID_METRICS_COLL 1042 /* metrics_collector process */
-#define AID_METRICSD 1043 /* metricsd process */
-#define AID_WEBSERV 1044 /* webservd process */
-#define AID_DEBUGGERD 1045 /* debuggerd unprivileged user */
-#define AID_MEDIA_CODEC 1046 /* mediacodec process */
-#define AID_CAMERASERVER 1047 /* cameraserver process */
-#define AID_FIREWALL 1048 /* firewalld process */
-#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */
-#define AID_NVRAM 1050 /* Access-controlled NVRAM */
-#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */
-#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */
-#define AID_WEBVIEW_ZYGOTE 1053 /* WebView zygote process */
-#define AID_VEHICLE_NETWORK 1054 /* Vehicle network service */
-#define AID_MEDIA_AUDIO 1055 /* GID for audio files on internal media storage */
-#define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */
-#define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */
-#define AID_TOMBSTONED 1058 /* tombstoned user */
-#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */
-#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */
-#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */
-/* Changes to this file must be made in AOSP, *not* in internal branches. */
-
-#define AID_SHELL 2000 /* adb and debug shell user */
-#define AID_CACHE 2001 /* cache access */
-#define AID_DIAG 2002 /* access to diagnostic resources */
-
-/* The range 2900-2999 is reserved for OEM, and must never be
- * used here */
-#define AID_OEM_RESERVED_START 2900
-#define AID_OEM_RESERVED_END 2999
-
-/* The 3000 series are intended for use as supplemental group id's only.
- * They indicate special Android capabilities that the kernel is aware of. */
-#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
-#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
-#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
-#define AID_NET_RAW 3004 /* can create raw INET sockets */
-#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
-#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */
-#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */
-#define AID_READPROC 3009 /* Allow /proc read access */
-#define AID_WAKELOCK 3010 /* Allow system wakelock read/write access */
-
-/* The range 5000-5999 is also reserved for OEM, and must never be used here. */
-#define AID_OEM_RESERVED_2_START 5000
-#define AID_OEM_RESERVED_2_END 5999
-
-#define AID_EVERYBODY 9997 /* shared between all apps in the same profile */
-#define AID_MISC 9998 /* access to misc storage */
-#define AID_NOBODY 9999
-
-#define AID_APP 10000 /* TODO: switch users over to AID_APP_START */
-#define AID_APP_START 10000 /* first app user */
-#define AID_APP_END 19999 /* last app user */
-
-#define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */
-#define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */
-
-#define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */
-#define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */
-
-#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
-#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */
-
-#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */
-#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */
-
-#define AID_USER 100000 /* TODO: switch users over to AID_USER_OFFSET */
-#define AID_USER_OFFSET 100000 /* offset for uid ranges for each user */
-
-/*
- * android_ids has moved to pwd/grp functionality.
- * If you need to add one, the structure is now
- * auto-generated based on the AID_ constraints
- * documented at the top of this header file.
- * Also see build/tools/fs_config for more details.
- */
-
-#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
-
-struct fs_path_config {
- unsigned mode;
- unsigned uid;
- unsigned gid;
- uint64_t capabilities;
- const char *prefix;
-};
-
-/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
-
-__BEGIN_DECLS
-
-/*
- * Used in:
- * build/tools/fs_config/fs_config.c
- * build/tools/fs_get_stats/fs_get_stats.c
- * system/extras/ext4_utils/make_ext4fs_main.c
- * external/squashfs-tools/squashfs-tools/android.c
- * system/core/cpio/mkbootfs.c
- * system/core/adb/file_sync_service.cpp
- * system/extras/ext4_utils/canned_fs_config.c
- */
-void fs_config(const char *path, int dir, const char *target_out_path,
- unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities);
-
-ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc);
-
-__END_DECLS
-
-#endif
-#endif
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
new file mode 120000
index 0000000..f28a564
--- /dev/null
+++ b/include/private/android_filesystem_config.h
@@ -0,0 +1 @@
+../../libcutils/include/private/android_filesystem_config.h
\ No newline at end of file
diff --git a/include/private/canned_fs_config.h b/include/private/canned_fs_config.h
new file mode 120000
index 0000000..8f92b2d
--- /dev/null
+++ b/include/private/canned_fs_config.h
@@ -0,0 +1 @@
+../../libcutils/include/private/canned_fs_config.h
\ No newline at end of file
diff --git a/libbacktrace/BacktraceCurrent.h b/libbacktrace/BacktraceCurrent.h
index 8aad36d..072ffd2 100644
--- a/libbacktrace/BacktraceCurrent.h
+++ b/libbacktrace/BacktraceCurrent.h
@@ -36,7 +36,7 @@
class BacktraceMap;
class BacktraceCurrent : public Backtrace {
-public:
+ public:
BacktraceCurrent(pid_t pid, pid_t tid, BacktraceMap* map) : Backtrace(pid, tid, map) {}
virtual ~BacktraceCurrent() {}
@@ -46,10 +46,10 @@
bool Unwind(size_t num_ignore_frames, ucontext_t* ucontext) override;
-protected:
+ protected:
bool DiscardFrame(const backtrace_frame_data_t& frame);
-private:
+ private:
bool UnwindThread(size_t num_ignore_frames);
virtual bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) = 0;
diff --git a/libbacktrace/BacktracePtrace.h b/libbacktrace/BacktracePtrace.h
index 1d49811..760817b 100644
--- a/libbacktrace/BacktracePtrace.h
+++ b/libbacktrace/BacktracePtrace.h
@@ -25,7 +25,7 @@
class BacktraceMap;
class BacktracePtrace : public Backtrace {
-public:
+ public:
BacktracePtrace(pid_t pid, pid_t tid, BacktraceMap* map) : Backtrace(pid, tid, map) {}
virtual ~BacktracePtrace() {}
diff --git a/libbacktrace/ThreadEntry.h b/libbacktrace/ThreadEntry.h
index 11924a3..caa5497 100644
--- a/libbacktrace/ThreadEntry.h
+++ b/libbacktrace/ThreadEntry.h
@@ -22,7 +22,7 @@
#include <ucontext.h>
class ThreadEntry {
-public:
+ public:
static ThreadEntry* Get(pid_t pid, pid_t tid, bool create = true);
static void Remove(ThreadEntry* entry);
@@ -47,7 +47,7 @@
inline ucontext_t* GetUcontext() { return &ucontext_; }
-private:
+ private:
ThreadEntry(pid_t pid, pid_t tid);
~ThreadEntry();
diff --git a/libbacktrace/UnwindCurrent.cpp b/libbacktrace/UnwindCurrent.cpp
index 666c481..4862d9d 100644
--- a/libbacktrace/UnwindCurrent.cpp
+++ b/libbacktrace/UnwindCurrent.cpp
@@ -23,12 +23,23 @@
#define UNW_LOCAL_ONLY
#include <libunwind.h>
+#include <android-base/logging.h>
#include <backtrace/Backtrace.h>
#include "BacktraceLog.h"
#include "UnwindCurrent.h"
std::string UnwindCurrent::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) {
+ if (!initialized_) {
+ // If init local is not called, then trying to get a function name will
+ // fail, so try to initialize first.
+ std::unique_ptr<unw_cursor_t> cursor(new unw_cursor_t);
+ if (unw_init_local(cursor.get(), &context_) < 0) {
+ return "";
+ }
+ initialized_ = true;
+ }
+
*offset = 0;
char buf[512];
unw_word_t value;
@@ -85,6 +96,7 @@
error_ = BACKTRACE_UNWIND_ERROR_SETUP_FAILED;
return false;
}
+ initialized_ = true;
size_t num_frames = 0;
do {
@@ -124,6 +136,11 @@
num_frames++;
} else {
num_ignore_frames--;
+ // Set the number of frames to zero to remove the frame added
+ // above. By definition, if we still have frames to ignore
+ // there should only be one frame in the vector.
+ CHECK(num_frames == 0);
+ frames_.resize(0);
}
}
ret = unw_step (cursor.get());
diff --git a/libbacktrace/UnwindCurrent.h b/libbacktrace/UnwindCurrent.h
index 3023996..3656104 100644
--- a/libbacktrace/UnwindCurrent.h
+++ b/libbacktrace/UnwindCurrent.h
@@ -32,18 +32,20 @@
#include <libunwind.h>
class UnwindCurrent : public BacktraceCurrent {
-public:
+ public:
UnwindCurrent(pid_t pid, pid_t tid, BacktraceMap* map) : BacktraceCurrent(pid, tid, map) {}
virtual ~UnwindCurrent() {}
std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override;
-private:
+ private:
void GetUnwContextFromUcontext(const ucontext_t* ucontext);
bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) override;
unw_context_t context_;
+
+ bool initialized_ = false;
};
#endif // _LIBBACKTRACE_UNWIND_CURRENT_H
diff --git a/libbacktrace/UnwindMap.h b/libbacktrace/UnwindMap.h
index d5bec06..6ffdafd 100644
--- a/libbacktrace/UnwindMap.h
+++ b/libbacktrace/UnwindMap.h
@@ -28,28 +28,28 @@
// libunwind.h first then this header.
class UnwindMap : public BacktraceMap {
-public:
+ public:
explicit UnwindMap(pid_t pid);
unw_map_cursor_t* GetMapCursor() { return &map_cursor_; }
-protected:
+ protected:
unw_map_cursor_t map_cursor_;
};
class UnwindMapRemote : public UnwindMap {
-public:
+ public:
explicit UnwindMapRemote(pid_t pid);
virtual ~UnwindMapRemote();
bool Build() override;
-private:
+ private:
bool GenerateMap();
};
class UnwindMapLocal : public UnwindMap {
-public:
+ public:
UnwindMapLocal();
virtual ~UnwindMapLocal();
@@ -60,7 +60,7 @@
void LockIterator() override { pthread_rwlock_rdlock(&map_lock_); }
void UnlockIterator() override { pthread_rwlock_unlock(&map_lock_); }
-private:
+ private:
bool GenerateMap();
bool map_created_;
diff --git a/libbacktrace/UnwindPtrace.cpp b/libbacktrace/UnwindPtrace.cpp
index 306d2ac..5c73bd6 100644
--- a/libbacktrace/UnwindPtrace.cpp
+++ b/libbacktrace/UnwindPtrace.cpp
@@ -37,6 +37,7 @@
_UPT_destroy(upt_info_);
upt_info_ = nullptr;
}
+
if (addr_space_) {
// Remove the map from the address space before destroying it.
// It will be freed in the UnwindMap destructor.
@@ -47,18 +48,14 @@
}
}
-bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) {
- if (GetMap() == nullptr) {
- // Without a map object, we can't do anything.
- error_ = BACKTRACE_UNWIND_ERROR_MAP_MISSING;
- return false;
+bool UnwindPtrace::Init() {
+ if (upt_info_) {
+ return true;
}
- error_ = BACKTRACE_UNWIND_NO_ERROR;
-
- if (ucontext) {
- BACK_LOGW("Unwinding from a specified context not supported yet.");
- error_ = BACKTRACE_UNWIND_ERROR_UNSUPPORTED_OPERATION;
+ if (addr_space_) {
+ // If somehow the addr_space_ gets initialized but upt_info_ doesn't,
+ // then that indicates there is some kind of failure.
return false;
}
@@ -79,6 +76,28 @@
return false;
}
+ return true;
+}
+
+bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) {
+ if (GetMap() == nullptr) {
+ // Without a map object, we can't do anything.
+ error_ = BACKTRACE_UNWIND_ERROR_MAP_MISSING;
+ return false;
+ }
+
+ error_ = BACKTRACE_UNWIND_NO_ERROR;
+
+ if (ucontext) {
+ BACK_LOGW("Unwinding from a specified context not supported yet.");
+ error_ = BACKTRACE_UNWIND_ERROR_UNSUPPORTED_OPERATION;
+ return false;
+ }
+
+ if (!Init()) {
+ return false;
+ }
+
unw_cursor_t cursor;
int ret = unw_init_remote(&cursor, addr_space_, upt_info_);
if (ret < 0) {
@@ -115,10 +134,10 @@
prev->stack_size = frame->sp - prev->sp;
}
- frame->func_name = GetFunctionName(frame->pc, &frame->func_offset);
-
FillInMap(frame->pc, &frame->map);
+ frame->func_name = GetFunctionName(frame->pc, &frame->func_offset);
+
num_frames++;
} else {
num_ignore_frames--;
@@ -130,6 +149,10 @@
}
std::string UnwindPtrace::GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) {
+ if (!Init()) {
+ return "";
+ }
+
*offset = 0;
char buf[512];
unw_word_t value;
diff --git a/libbacktrace/UnwindPtrace.h b/libbacktrace/UnwindPtrace.h
index ab04abf..4688110 100644
--- a/libbacktrace/UnwindPtrace.h
+++ b/libbacktrace/UnwindPtrace.h
@@ -30,7 +30,7 @@
#include "BacktracePtrace.h"
class UnwindPtrace : public BacktracePtrace {
-public:
+ public:
UnwindPtrace(pid_t pid, pid_t tid, BacktraceMap* map);
virtual ~UnwindPtrace();
@@ -38,7 +38,9 @@
std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override;
-private:
+ private:
+ bool Init();
+
unw_addr_space_t addr_space_;
struct UPT_info* upt_info_;
};
diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp
index e25c8e9..9ca373a 100644
--- a/libbacktrace/backtrace_test.cpp
+++ b/libbacktrace/backtrace_test.cpp
@@ -43,6 +43,7 @@
#include <backtrace/BacktraceMap.h>
#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
#include <cutils/atomic.h>
#include <cutils/threads.h>
@@ -85,13 +86,13 @@
int test_recursive_call(int, void (*)(void*), void*);
}
-uint64_t NanoTime() {
+static uint64_t NanoTime() {
struct timespec t = { 0, 0 };
clock_gettime(CLOCK_MONOTONIC, &t);
return static_cast<uint64_t>(t.tv_sec * NS_PER_SEC + t.tv_nsec);
}
-std::string DumpFrames(Backtrace* backtrace) {
+static std::string DumpFrames(Backtrace* backtrace) {
if (backtrace->NumFrames() == 0) {
return " No frames to dump.\n";
}
@@ -103,7 +104,7 @@
return frame;
}
-void WaitForStop(pid_t pid) {
+static void WaitForStop(pid_t pid) {
uint64_t start = NanoTime();
siginfo_t si;
@@ -116,7 +117,28 @@
}
}
-bool ReadyLevelBacktrace(Backtrace* backtrace) {
+static void CreateRemoteProcess(pid_t* pid) {
+ if ((*pid = fork()) == 0) {
+ while (true)
+ ;
+ _exit(0);
+ }
+ ASSERT_NE(-1, *pid);
+
+ ASSERT_TRUE(ptrace(PTRACE_ATTACH, *pid, 0, 0) == 0);
+
+ // Wait for the process to get to a stopping point.
+ WaitForStop(*pid);
+}
+
+static void FinishRemoteProcess(pid_t pid) {
+ ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
+
+ kill(pid, SIGKILL);
+ ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
+}
+
+static bool ReadyLevelBacktrace(Backtrace* backtrace) {
// See if test_level_four is in the backtrace.
bool found = false;
for (Backtrace::const_iterator it = backtrace->begin(); it != backtrace->end(); ++it) {
@@ -129,7 +151,7 @@
return found;
}
-void VerifyLevelDump(Backtrace* backtrace) {
+static void VerifyLevelDump(Backtrace* backtrace) {
ASSERT_GT(backtrace->NumFrames(), static_cast<size_t>(0))
<< DumpFrames(backtrace);
ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES))
@@ -157,7 +179,7 @@
<< DumpFrames(backtrace);
}
-void VerifyLevelBacktrace(void*) {
+static void VerifyLevelBacktrace(void*) {
std::unique_ptr<Backtrace> backtrace(
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
ASSERT_TRUE(backtrace.get() != nullptr);
@@ -167,11 +189,11 @@
VerifyLevelDump(backtrace.get());
}
-bool ReadyMaxBacktrace(Backtrace* backtrace) {
+static bool ReadyMaxBacktrace(Backtrace* backtrace) {
return (backtrace->NumFrames() == MAX_BACKTRACE_FRAMES);
}
-void VerifyMaxDump(Backtrace* backtrace) {
+static void VerifyMaxDump(Backtrace* backtrace) {
ASSERT_EQ(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES))
<< DumpFrames(backtrace);
// Verify that the last frame is our recursive call.
@@ -179,7 +201,7 @@
<< DumpFrames(backtrace);
}
-void VerifyMaxBacktrace(void*) {
+static void VerifyMaxBacktrace(void*) {
std::unique_ptr<Backtrace> backtrace(
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
ASSERT_TRUE(backtrace.get() != nullptr);
@@ -189,7 +211,7 @@
VerifyMaxDump(backtrace.get());
}
-void ThreadSetState(void* data) {
+static void ThreadSetState(void* data) {
thread_t* thread = reinterpret_cast<thread_t*>(data);
android_atomic_acquire_store(1, &thread->state);
volatile int i = 0;
@@ -198,16 +220,7 @@
}
}
-void VerifyThreadTest(pid_t tid, void (*VerifyFunc)(Backtrace*)) {
- std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), tid));
- ASSERT_TRUE(backtrace.get() != nullptr);
- ASSERT_TRUE(backtrace->Unwind(0));
- ASSERT_EQ(BACKTRACE_UNWIND_NO_ERROR, backtrace->GetError());
-
- VerifyFunc(backtrace.get());
-}
-
-bool WaitForNonZero(int32_t* value, uint64_t seconds) {
+static bool WaitForNonZero(int32_t* value, uint64_t seconds) {
uint64_t start = NanoTime();
do {
if (android_atomic_acquire_load(value)) {
@@ -240,9 +253,8 @@
ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelBacktrace, nullptr), 0);
}
-void VerifyIgnoreFrames(
- Backtrace* bt_all, Backtrace* bt_ign1,
- Backtrace* bt_ign2, const char* cur_proc) {
+static void VerifyIgnoreFrames(Backtrace* bt_all, Backtrace* bt_ign1, Backtrace* bt_ign2,
+ const char* cur_proc) {
EXPECT_EQ(bt_all->NumFrames(), bt_ign1->NumFrames() + 1)
<< "All backtrace:\n" << DumpFrames(bt_all) << "Ignore 1 backtrace:\n" << DumpFrames(bt_ign1);
EXPECT_EQ(bt_all->NumFrames(), bt_ign2->NumFrames() + 2)
@@ -266,7 +278,7 @@
}
}
-void VerifyLevelIgnoreFrames(void*) {
+static void VerifyLevelIgnoreFrames(void*) {
std::unique_ptr<Backtrace> all(
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
ASSERT_TRUE(all.get() != nullptr);
@@ -296,9 +308,8 @@
ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, VerifyMaxBacktrace, nullptr), 0);
}
-void VerifyProcTest(pid_t pid, pid_t tid, bool share_map,
- bool (*ReadyFunc)(Backtrace*),
- void (*VerifyFunc)(Backtrace*)) {
+static void VerifyProcTest(pid_t pid, pid_t tid, bool share_map, bool (*ReadyFunc)(Backtrace*),
+ void (*VerifyFunc)(Backtrace*)) {
pid_t ptrace_tid;
if (tid < 0) {
ptrace_tid = pid;
@@ -376,7 +387,7 @@
ASSERT_EQ(waitpid(pid, &status, 0), pid);
}
-void VerifyProcessIgnoreFrames(Backtrace* bt_all) {
+static void VerifyProcessIgnoreFrames(Backtrace* bt_all) {
std::unique_ptr<Backtrace> ign1(Backtrace::Create(bt_all->Pid(), BACKTRACE_CURRENT_THREAD));
ASSERT_TRUE(ign1.get() != nullptr);
ASSERT_TRUE(ign1->Unwind(1));
@@ -404,12 +415,12 @@
}
// Create a process with multiple threads and dump all of the threads.
-void* PtraceThreadLevelRun(void*) {
+static void* PtraceThreadLevelRun(void*) {
EXPECT_NE(test_level_one(1, 2, 3, 4, nullptr, nullptr), 0);
return nullptr;
}
-void GetThreads(pid_t pid, std::vector<pid_t>* threads) {
+static void GetThreads(pid_t pid, std::vector<pid_t>* threads) {
// Get the list of tasks.
char task_path[128];
snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid);
@@ -461,11 +472,8 @@
}
VerifyProcTest(pid, *it, false, ReadyLevelBacktrace, VerifyLevelDump);
}
- ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
- kill(pid, SIGKILL);
- int status;
- ASSERT_EQ(waitpid(pid, &status, 0), pid);
+ FinishRemoteProcess(pid);
}
void VerifyLevelThread(void*) {
@@ -481,7 +489,7 @@
ASSERT_NE(test_level_one(1, 2, 3, 4, VerifyLevelThread, nullptr), 0);
}
-void VerifyMaxThread(void*) {
+static void VerifyMaxThread(void*) {
std::unique_ptr<Backtrace> backtrace(Backtrace::Create(getpid(), gettid()));
ASSERT_TRUE(backtrace.get() != nullptr);
ASSERT_TRUE(backtrace->Unwind(0));
@@ -494,7 +502,7 @@
ASSERT_NE(test_recursive_call(MAX_BACKTRACE_FRAMES+10, VerifyMaxThread, nullptr), 0);
}
-void* ThreadLevelRun(void* data) {
+static void* ThreadLevelRun(void* data) {
thread_t* thread = reinterpret_cast<thread_t*>(data);
thread->tid = gettid();
@@ -585,7 +593,7 @@
android_atomic_acquire_store(0, &thread_data.state);
}
-void* ThreadMaxRun(void* data) {
+static void* ThreadMaxRun(void* data) {
thread_t* thread = reinterpret_cast<thread_t*>(data);
thread->tid = gettid();
@@ -616,7 +624,7 @@
android_atomic_acquire_store(0, &thread_data.state);
}
-void* ThreadDump(void* data) {
+static void* ThreadDump(void* data) {
dump_thread_t* dump = reinterpret_cast<dump_thread_t*>(data);
while (true) {
if (android_atomic_acquire_load(dump->now)) {
@@ -873,11 +881,9 @@
uintptr_t end;
};
-bool map_sort(map_test_t i, map_test_t j) {
- return i.start < j.start;
-}
+static bool map_sort(map_test_t i, map_test_t j) { return i.start < j.start; }
-void VerifyMap(pid_t pid) {
+static void VerifyMap(pid_t pid) {
char buffer[4096];
snprintf(buffer, sizeof(buffer), "/proc/%d/maps", pid);
@@ -908,29 +914,15 @@
TEST(libbacktrace, verify_map_remote) {
pid_t pid;
-
- if ((pid = fork()) == 0) {
- while (true) {
- }
- _exit(0);
- }
- ASSERT_LT(0, pid);
-
- ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
-
- // Wait for the process to get to a stopping point.
- WaitForStop(pid);
+ CreateRemoteProcess(&pid);
// The maps should match exactly since the forked process has been paused.
VerifyMap(pid);
- ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
-
- kill(pid, SIGKILL);
- ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
+ FinishRemoteProcess(pid);
}
-void InitMemory(uint8_t* memory, size_t bytes) {
+static void InitMemory(uint8_t* memory, size_t bytes) {
for (size_t i = 0; i < bytes; i++) {
memory[i] = i;
if (memory[i] == '\0') {
@@ -941,7 +933,7 @@
}
}
-void* ThreadReadTest(void* data) {
+static void* ThreadReadTest(void* data) {
thread_t* thread_data = reinterpret_cast<thread_t*>(data);
thread_data->tid = gettid();
@@ -982,7 +974,7 @@
return nullptr;
}
-void RunReadTest(Backtrace* backtrace, uintptr_t read_addr) {
+static void RunReadTest(Backtrace* backtrace, uintptr_t read_addr) {
size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
// Create a page of data to use to do quick compares.
@@ -1043,7 +1035,7 @@
volatile uintptr_t g_ready = 0;
volatile uintptr_t g_addr = 0;
-void ForkedReadTest() {
+static void ForkedReadTest() {
// Create two map pages.
size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
uint8_t* memory;
@@ -1117,7 +1109,7 @@
ASSERT_TRUE(test_executed);
}
-void VerifyFunctionsFound(const std::vector<std::string>& found_functions) {
+static void VerifyFunctionsFound(const std::vector<std::string>& found_functions) {
// We expect to find these functions in libbacktrace_test. If we don't
// find them, that's a bug in the memory read handling code in libunwind.
std::list<std::string> expected_functions;
@@ -1137,7 +1129,7 @@
ASSERT_TRUE(expected_functions.empty()) << "Not all functions found in shared library.";
}
-const char* CopySharedLibrary() {
+static const char* CopySharedLibrary() {
#if defined(__LP64__)
const char* lib_name = "lib64";
#else
@@ -1293,7 +1285,7 @@
VerifyFunctionsFound(found_functions);
}
-bool FindFuncFrameInBacktrace(Backtrace* backtrace, uintptr_t test_func, size_t* frame_num) {
+static bool FindFuncFrameInBacktrace(Backtrace* backtrace, uintptr_t test_func, size_t* frame_num) {
backtrace_map_t map;
backtrace->FillInMap(test_func, &map);
if (!BacktraceMap::IsValid(map)) {
@@ -1312,7 +1304,7 @@
return false;
}
-void VerifyUnreadableElfFrame(Backtrace* backtrace, uintptr_t test_func, size_t frame_num) {
+static void VerifyUnreadableElfFrame(Backtrace* backtrace, uintptr_t test_func, size_t frame_num) {
ASSERT_LT(backtrace->NumFrames(), static_cast<size_t>(MAX_BACKTRACE_FRAMES))
<< DumpFrames(backtrace);
@@ -1324,7 +1316,7 @@
ASSERT_LT(diff, 200U) << DumpFrames(backtrace);
}
-void VerifyUnreadableElfBacktrace(uintptr_t test_func) {
+static void VerifyUnreadableElfBacktrace(uintptr_t test_func) {
std::unique_ptr<Backtrace> backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS,
BACKTRACE_CURRENT_THREAD));
ASSERT_TRUE(backtrace.get() != nullptr);
@@ -1418,12 +1410,38 @@
ASSERT_EQ(BACKTRACE_UNWIND_ERROR_THREAD_DOESNT_EXIST, backtrace->GetError());
}
+TEST(libbacktrace, local_get_function_name_before_unwind) {
+ std::unique_ptr<Backtrace> backtrace(
+ Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
+ ASSERT_TRUE(backtrace.get() != nullptr);
+
+ // Verify that trying to get a function name before doing an unwind works.
+ uintptr_t cur_func_offset = reinterpret_cast<uintptr_t>(&test_level_one) + 1;
+ size_t offset;
+ ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset));
+}
+
+TEST(libbacktrace, remote_get_function_name_before_unwind) {
+ pid_t pid;
+ CreateRemoteProcess(&pid);
+
+ // Now create an unwind object.
+ std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, pid));
+
+ // Verify that trying to get a function name before doing an unwind works.
+ uintptr_t cur_func_offset = reinterpret_cast<uintptr_t>(&test_level_one) + 1;
+ size_t offset;
+ ASSERT_NE(std::string(""), backtrace->GetFunctionName(cur_func_offset, &offset));
+
+ FinishRemoteProcess(pid);
+}
+
#if defined(ENABLE_PSS_TESTS)
#include "GetPss.h"
#define MAX_LEAK_BYTES (32*1024UL)
-void CheckForLeak(pid_t pid, pid_t tid) {
+static void CheckForLeak(pid_t pid, pid_t tid) {
// Do a few runs to get the PSS stable.
for (size_t i = 0; i < 100; i++) {
Backtrace* backtrace = Backtrace::Create(pid, tid);
@@ -1472,24 +1490,10 @@
TEST(libbacktrace, check_for_leak_remote) {
pid_t pid;
-
- if ((pid = fork()) == 0) {
- while (true) {
- }
- _exit(0);
- }
- ASSERT_LT(0, pid);
-
- ASSERT_TRUE(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
-
- // Wait for the process to get to a stopping point.
- WaitForStop(pid);
+ CreateRemoteProcess(&pid);
CheckForLeak(pid, BACKTRACE_CURRENT_THREAD);
- ASSERT_TRUE(ptrace(PTRACE_DETACH, pid, 0, 0) == 0);
-
- kill(pid, SIGKILL);
- ASSERT_EQ(waitpid(pid, nullptr, 0), pid);
+ FinishRemoteProcess(pid);
}
#endif
diff --git a/include/private/android_filesystem_capability.h b/libcutils/include/private/android_filesystem_capability.h
similarity index 86%
rename from include/private/android_filesystem_capability.h
rename to libcutils/include/private/android_filesystem_capability.h
index b92d3db..0227b1d 100644
--- a/include/private/android_filesystem_capability.h
+++ b/libcutils/include/private/android_filesystem_capability.h
@@ -35,15 +35,15 @@
#define _LINUX_CAPABILITY_U32S_3 2
typedef struct __user_cap_header_struct {
- __u32 version;
- int pid;
-} __user *cap_user_header_t;
+ __u32 version;
+ int pid;
+} __user* cap_user_header_t;
typedef struct __user_cap_data_struct {
- __u32 effective;
- __u32 permitted;
- __u32 inheritable;
-} __user *cap_user_data_t;
+ __u32 effective;
+ __u32 permitted;
+ __u32 inheritable;
+} __user* cap_user_data_t;
#define VFS_CAP_REVISION_MASK 0xFF000000
#define VFS_CAP_REVISION_SHIFT 24
@@ -51,20 +51,20 @@
#define VFS_CAP_FLAGS_EFFECTIVE 0x000001
#define VFS_CAP_REVISION_1 0x01000000
#define VFS_CAP_U32_1 1
-#define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1))
+#define XATTR_CAPS_SZ_1 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_1))
#define VFS_CAP_REVISION_2 0x02000000
#define VFS_CAP_U32_2 2
-#define XATTR_CAPS_SZ_2 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2))
+#define XATTR_CAPS_SZ_2 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_2))
#define XATTR_CAPS_SZ XATTR_CAPS_SZ_2
#define VFS_CAP_U32 VFS_CAP_U32_2
#define VFS_CAP_REVISION VFS_CAP_REVISION_2
struct vfs_cap_data {
- __le32 magic_etc;
- struct {
- __le32 permitted;
- __le32 inheritable;
- } data[VFS_CAP_U32];
+ __le32 magic_etc;
+ struct {
+ __le32 permitted;
+ __le32 inheritable;
+ } data[VFS_CAP_U32];
};
#define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
@@ -110,7 +110,7 @@
#define CAP_LAST_CAP CAP_AUDIT_READ
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
#define CAP_TO_INDEX(x) ((x) >> 5)
-#define CAP_TO_MASK(x) (1 << ((x) & 31))
+#define CAP_TO_MASK(x) (1 << ((x)&31))
#undef __user
#undef __u32
diff --git a/libcutils/include/private/android_filesystem_config.h b/libcutils/include/private/android_filesystem_config.h
new file mode 100644
index 0000000..0037f15
--- /dev/null
+++ b/libcutils/include/private/android_filesystem_config.h
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* This file is used to define the properties of the filesystem
+** images generated by build tools (mkbootfs and mkyaffs2image) and
+** by the device side of adb.
+*/
+
+/*
+ * This file is consumed by build/tools/fs_config and is used
+ * for generating various files. Anything #define AID_<name>
+ * becomes the mapping for getpwnam/getpwuid, etc. The <name>
+ * field is lowercased.
+ * For example:
+ * #define AID_FOO_BAR 6666 becomes a friendly name of "foo_bar"
+ *
+ * The above holds true with the exception of:
+ * mediacodec
+ * mediaex
+ * mediadrm
+ * Whose friendly names do not match the #define statements.
+ *
+ * Additionally, AID_OEM_RESERVED_START and AID_OEM_RESERVED_END
+ * can be used to define reserved OEM ranges used for sanity checks
+ * during the build process. The rules are, they must end with START/END
+ * The proper convention is incrementing a number like so:
+ * AID_OEM_RESERVED_START
+ * AID_OEM_RESERVED_1_START
+ * AID_OEM_RESERVED_2_START
+ * ...
+ * The same applies to the END.
+ * They are not required to be in order, but must not overlap each other and
+ * must define a START and END'ing range. START must be smaller than END.
+ */
+
+#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
+#define _ANDROID_FILESYSTEM_CONFIG_H_
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#if defined(__ANDROID__)
+#include <linux/capability.h>
+#else
+#include "android_filesystem_capability.h"
+#endif
+
+#define CAP_MASK_LONG(cap_name) (1ULL << (cap_name))
+
+/* This is the master Users and Groups config for the platform.
+ * DO NOT EVER RENUMBER
+ */
+
+#define AID_ROOT 0 /* traditional unix root user */
+
+#define AID_SYSTEM 1000 /* system server */
+
+#define AID_RADIO 1001 /* telephony subsystem, RIL */
+#define AID_BLUETOOTH 1002 /* bluetooth subsystem */
+#define AID_GRAPHICS 1003 /* graphics devices */
+#define AID_INPUT 1004 /* input devices */
+#define AID_AUDIO 1005 /* audio devices */
+#define AID_CAMERA 1006 /* camera devices */
+#define AID_LOG 1007 /* log devices */
+#define AID_COMPASS 1008 /* compass device */
+#define AID_MOUNT 1009 /* mountd socket */
+#define AID_WIFI 1010 /* wifi subsystem */
+#define AID_ADB 1011 /* android debug bridge (adbd) */
+#define AID_INSTALL 1012 /* group for installing packages */
+#define AID_MEDIA 1013 /* mediaserver process */
+#define AID_DHCP 1014 /* dhcp client */
+#define AID_SDCARD_RW 1015 /* external storage write access */
+#define AID_VPN 1016 /* vpn system */
+#define AID_KEYSTORE 1017 /* keystore subsystem */
+#define AID_USB 1018 /* USB devices */
+#define AID_DRM 1019 /* DRM server */
+#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */
+#define AID_GPS 1021 /* GPS daemon */
+#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */
+#define AID_MEDIA_RW 1023 /* internal media storage write access */
+#define AID_MTP 1024 /* MTP USB driver access */
+#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */
+#define AID_DRMRPC 1026 /* group for drm rpc */
+#define AID_NFC 1027 /* nfc subsystem */
+#define AID_SDCARD_R 1028 /* external storage read access */
+#define AID_CLAT 1029 /* clat part of nat464 */
+#define AID_LOOP_RADIO 1030 /* loop radio devices */
+#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */
+#define AID_PACKAGE_INFO 1032 /* access to installed package details */
+#define AID_SDCARD_PICS 1033 /* external storage photos access */
+#define AID_SDCARD_AV 1034 /* external storage audio/video access */
+#define AID_SDCARD_ALL 1035 /* access all users external storage */
+#define AID_LOGD 1036 /* log daemon */
+#define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */
+#define AID_DBUS 1038 /* dbus-daemon IPC broker process */
+#define AID_TLSDATE 1039 /* tlsdate unprivileged user */
+#define AID_MEDIA_EX 1040 /* mediaextractor process */
+#define AID_AUDIOSERVER 1041 /* audioserver process */
+#define AID_METRICS_COLL 1042 /* metrics_collector process */
+#define AID_METRICSD 1043 /* metricsd process */
+#define AID_WEBSERV 1044 /* webservd process */
+#define AID_DEBUGGERD 1045 /* debuggerd unprivileged user */
+#define AID_MEDIA_CODEC 1046 /* mediacodec process */
+#define AID_CAMERASERVER 1047 /* cameraserver process */
+#define AID_FIREWALL 1048 /* firewalld process */
+#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */
+#define AID_NVRAM 1050 /* Access-controlled NVRAM */
+#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */
+#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */
+#define AID_WEBVIEW_ZYGOTE 1053 /* WebView zygote process */
+#define AID_VEHICLE_NETWORK 1054 /* Vehicle network service */
+#define AID_MEDIA_AUDIO 1055 /* GID for audio files on internal media storage */
+#define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */
+#define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */
+#define AID_TOMBSTONED 1058 /* tombstoned user */
+#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */
+#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */
+#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */
+/* Changes to this file must be made in AOSP, *not* in internal branches. */
+
+#define AID_SHELL 2000 /* adb and debug shell user */
+#define AID_CACHE 2001 /* cache access */
+#define AID_DIAG 2002 /* access to diagnostic resources */
+
+/* The range 2900-2999 is reserved for OEM, and must never be
+ * used here */
+#define AID_OEM_RESERVED_START 2900
+#define AID_OEM_RESERVED_END 2999
+
+/* The 3000 series are intended for use as supplemental group id's only.
+ * They indicate special Android capabilities that the kernel is aware of. */
+#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
+#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
+#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
+#define AID_NET_RAW 3004 /* can create raw INET sockets */
+#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
+#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */
+#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */
+#define AID_READPROC 3009 /* Allow /proc read access */
+#define AID_WAKELOCK 3010 /* Allow system wakelock read/write access */
+
+/* The range 5000-5999 is also reserved for OEM, and must never be used here. */
+#define AID_OEM_RESERVED_2_START 5000
+#define AID_OEM_RESERVED_2_END 5999
+
+#define AID_EVERYBODY 9997 /* shared between all apps in the same profile */
+#define AID_MISC 9998 /* access to misc storage */
+#define AID_NOBODY 9999
+
+#define AID_APP 10000 /* TODO: switch users over to AID_APP_START */
+#define AID_APP_START 10000 /* first app user */
+#define AID_APP_END 19999 /* last app user */
+
+#define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */
+#define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */
+
+#define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */
+#define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */
+
+#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
+#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */
+
+#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */
+#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */
+
+#define AID_USER 100000 /* TODO: switch users over to AID_USER_OFFSET */
+#define AID_USER_OFFSET 100000 /* offset for uid ranges for each user */
+
+/*
+ * android_ids has moved to pwd/grp functionality.
+ * If you need to add one, the structure is now
+ * auto-generated based on the AID_ constraints
+ * documented at the top of this header file.
+ * Also see build/tools/fs_config for more details.
+ */
+
+#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
+
+struct fs_path_config {
+ unsigned mode;
+ unsigned uid;
+ unsigned gid;
+ uint64_t capabilities;
+ const char* prefix;
+};
+
+/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
+
+__BEGIN_DECLS
+
+/*
+ * Used in:
+ * build/tools/fs_config/fs_config.c
+ * build/tools/fs_get_stats/fs_get_stats.c
+ * system/extras/ext4_utils/make_ext4fs_main.c
+ * external/squashfs-tools/squashfs-tools/android.c
+ * system/core/cpio/mkbootfs.c
+ * system/core/adb/file_sync_service.cpp
+ * system/extras/ext4_utils/canned_fs_config.c
+ */
+void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,
+ unsigned* mode, uint64_t* capabilities);
+
+ssize_t fs_config_generate(char* buffer, size_t length, const struct fs_path_config* pc);
+
+__END_DECLS
+
+#endif
+#endif
diff --git a/include/private/canned_fs_config.h b/libcutils/include/private/canned_fs_config.h
similarity index 88%
rename from include/private/canned_fs_config.h
rename to libcutils/include/private/canned_fs_config.h
index d9f51ca..71e1537 100644
--- a/include/private/canned_fs_config.h
+++ b/libcutils/include/private/canned_fs_config.h
@@ -20,7 +20,7 @@
#include <inttypes.h>
int load_canned_fs_config(const char* fn);
-void canned_fs_config(const char* path, int dir, const char* target_out_path,
- unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities);
+void canned_fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid,
+ unsigned* gid, unsigned* mode, uint64_t* capabilities);
#endif
diff --git a/libcutils/include_vndk/private b/libcutils/include_vndk/private
new file mode 120000
index 0000000..2245a85
--- /dev/null
+++ b/libcutils/include_vndk/private
@@ -0,0 +1 @@
+../include/private
\ No newline at end of file