Merge "rootfs: init.rc start logd parse error"
diff --git a/adb/Android.mk b/adb/Android.mk
index f0117d3..6951904 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -69,6 +69,8 @@
qemu_tracing.cpp \
usb_linux_client.cpp \
+LOCAL_SHARED_LIBRARIES := libbase
+
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -80,6 +82,8 @@
$(LIBADB_$(HOST_OS)_SRC_FILES) \
adb_auth_host.cpp \
+LOCAL_SHARED_LIBRARIES := libbase
+
# Even though we're building a static library (and thus there's no link step for
# this to take effect), this adds the SSL includes to our path.
LOCAL_STATIC_LIBRARIES := libcrypto_static
@@ -165,6 +169,16 @@
libcutils \
$(EXTRA_STATIC_LIBS) \
+# libc++ not available on windows yet
+ifneq ($(HOST_OS),windows)
+ LOCAL_CXX_STL := libc++_static
+endif
+
+# Don't add anything here, we don't want additional shared dependencies
+# on the host adb tool, and shared libraries that link against libc++
+# will violate ODR
+LOCAL_SHARED_LIBRARIES :=
+
include $(BUILD_HOST_EXECUTABLE)
$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
diff --git a/adb/adb.cpp b/adb/adb.cpp
index b09e853..de82cd4 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -32,6 +32,8 @@
#include <string>
+#include <base/stringprintf.h>
+
#include "adb_auth.h"
#include "adb_io.h"
#include "adb_listeners.h"
@@ -802,7 +804,6 @@
if (!strncmp(service, "forward:",8) ||
!strncmp(service, "killforward:",12)) {
char *local, *remote;
- int r;
atransport *transport;
int createForward = strncmp(service, "kill", 4);
@@ -845,12 +846,13 @@
return 1;
}
+ install_status_t r;
if (createForward) {
r = install_listener(local, remote, transport, no_rebind);
} else {
r = remove_listener(local, transport);
}
- if(r == 0) {
+ if (r == INSTALL_STATUS_OK) {
#if ADB_HOST
/* On the host: 1st OKAY is connect, 2nd OKAY is status */
WriteFdExactly(reply_fd, "OKAY", 4);
@@ -859,22 +861,19 @@
return 1;
}
- if (createForward) {
- const char* message;
- switch (r) {
- case INSTALL_STATUS_CANNOT_BIND:
- message = "cannot bind to socket";
- break;
- case INSTALL_STATUS_CANNOT_REBIND:
- message = "cannot rebind existing socket";
- break;
- default:
- message = "internal error";
- }
- sendfailmsg(reply_fd, message);
- } else {
- sendfailmsg(reply_fd, "cannot remove listener");
+ std::string message;
+ switch (r) {
+ case INSTALL_STATUS_OK: message = " "; break;
+ case INSTALL_STATUS_INTERNAL_ERROR: message = "internal error"; break;
+ case INSTALL_STATUS_CANNOT_BIND:
+ message = android::base::StringPrintf("cannot bind to socket: %s", strerror(errno));
+ break;
+ case INSTALL_STATUS_CANNOT_REBIND:
+ message = android::base::StringPrintf("cannot rebind existing socket: %s", strerror(errno));
+ break;
+ case INSTALL_STATUS_LISTENER_NOT_FOUND: message = "listener not found"; break;
}
+ sendfailmsg(reply_fd, message.c_str());
return 1;
}
return 0;
diff --git a/adb/adb_listeners.cpp b/adb/adb_listeners.cpp
index 84b9c64..a1a5ddb 100644
--- a/adb/adb_listeners.cpp
+++ b/adb/adb_listeners.cpp
@@ -190,17 +190,17 @@
return result;
}
-int remove_listener(const char *local_name, atransport* transport)
+install_status_t remove_listener(const char *local_name, atransport* transport)
{
alistener *l;
for (l = listener_list.next; l != &listener_list; l = l->next) {
if (!strcmp(local_name, l->local_name)) {
listener_disconnect(l, l->transport);
- return 0;
+ return INSTALL_STATUS_OK;
}
}
- return -1;
+ return INSTALL_STATUS_LISTENER_NOT_FOUND;
}
void remove_all_listeners(void)
@@ -268,10 +268,10 @@
listener->fd = local_name_to_fd(local_name);
if (listener->fd < 0) {
+ printf("cannot bind '%s': %s\n", local_name, strerror(errno));
free(listener->local_name);
free(listener->connect_to);
free(listener);
- printf("cannot bind '%s'\n", local_name);
return INSTALL_STATUS_CANNOT_BIND;
}
diff --git a/adb/adb_listeners.h b/adb/adb_listeners.h
index 6421df1..f55fdee 100644
--- a/adb/adb_listeners.h
+++ b/adb/adb_listeners.h
@@ -25,6 +25,7 @@
INSTALL_STATUS_INTERNAL_ERROR = -1,
INSTALL_STATUS_CANNOT_BIND = -2,
INSTALL_STATUS_CANNOT_REBIND = -3,
+ INSTALL_STATUS_LISTENER_NOT_FOUND = -4,
};
extern alistener listener_list;
@@ -40,7 +41,7 @@
int format_listeners(char* buf, size_t buflen);
-int remove_listener(const char *local_name, atransport* transport);
+install_status_t remove_listener(const char* local_name, atransport* transport);
void remove_all_listeners(void);
#endif /* __ADB_LISTENERS_H */
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index 710ef3c..f10c143 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -35,19 +35,18 @@
return lstat(path.c_str(), &sb) != -1 && S_ISDIR(sb.st_mode);
}
-static bool should_escape(const char c) {
- return (c == ' ' || c == '\'' || c == '"' || c == '\\' || c == '(' || c == ')');
-}
-
std::string escape_arg(const std::string& s) {
- // Preserve empty arguments.
- if (s.empty()) return "\"\"";
+ std::string result = s;
- std::string result(s);
+ // Insert a \ before any ' in the string.
for (auto it = result.begin(); it != result.end(); ++it) {
- if (should_escape(*it)) {
+ if (*it == '\'') {
it = result.insert(it, '\\') + 1;
}
}
+
+ // Prefix and suffix the whole string with '.
+ result.insert(result.begin(), '\'');
+ result.push_back('\'');
return result;
}
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp
index 95e28a8..a395079 100644
--- a/adb/adb_utils_test.cpp
+++ b/adb/adb_utils_test.cpp
@@ -25,28 +25,28 @@
}
TEST(adb_utils, escape_arg) {
- ASSERT_EQ(R"("")", escape_arg(""));
+ ASSERT_EQ(R"('')", escape_arg(""));
- ASSERT_EQ(R"(abc)", escape_arg("abc"));
+ ASSERT_EQ(R"('abc')", escape_arg("abc"));
- ASSERT_EQ(R"(\ abc)", escape_arg(" abc"));
- ASSERT_EQ(R"(\'abc)", escape_arg("'abc"));
- ASSERT_EQ(R"(\"abc)", escape_arg("\"abc"));
- ASSERT_EQ(R"(\\abc)", escape_arg("\\abc"));
- ASSERT_EQ(R"(\(abc)", escape_arg("(abc"));
- ASSERT_EQ(R"(\)abc)", escape_arg(")abc"));
+ ASSERT_EQ(R"(' abc')", escape_arg(" abc"));
+ ASSERT_EQ(R"('\'abc')", escape_arg("'abc"));
+ ASSERT_EQ(R"('"abc')", escape_arg("\"abc"));
+ ASSERT_EQ(R"('\abc')", escape_arg("\\abc"));
+ ASSERT_EQ(R"('(abc')", escape_arg("(abc"));
+ ASSERT_EQ(R"(')abc')", escape_arg(")abc"));
- ASSERT_EQ(R"(abc\ abc)", escape_arg("abc abc"));
- ASSERT_EQ(R"(abc\'abc)", escape_arg("abc'abc"));
- ASSERT_EQ(R"(abc\"abc)", escape_arg("abc\"abc"));
- ASSERT_EQ(R"(abc\\abc)", escape_arg("abc\\abc"));
- ASSERT_EQ(R"(abc\(abc)", escape_arg("abc(abc"));
- ASSERT_EQ(R"(abc\)abc)", escape_arg("abc)abc"));
+ ASSERT_EQ(R"('abc abc')", escape_arg("abc abc"));
+ ASSERT_EQ(R"('abc\'abc')", escape_arg("abc'abc"));
+ ASSERT_EQ(R"('abc"abc')", escape_arg("abc\"abc"));
+ ASSERT_EQ(R"('abc\abc')", escape_arg("abc\\abc"));
+ ASSERT_EQ(R"('abc(abc')", escape_arg("abc(abc"));
+ ASSERT_EQ(R"('abc)abc')", escape_arg("abc)abc"));
- ASSERT_EQ(R"(abc\ )", escape_arg("abc "));
- ASSERT_EQ(R"(abc\')", escape_arg("abc'"));
- ASSERT_EQ(R"(abc\")", escape_arg("abc\""));
- ASSERT_EQ(R"(abc\\)", escape_arg("abc\\"));
- ASSERT_EQ(R"(abc\()", escape_arg("abc("));
- ASSERT_EQ(R"(abc\))", escape_arg("abc)"));
+ ASSERT_EQ(R"('abc ')", escape_arg("abc "));
+ ASSERT_EQ(R"('abc\'')", escape_arg("abc'"));
+ ASSERT_EQ(R"('abc"')", escape_arg("abc\""));
+ ASSERT_EQ(R"('abc\')", escape_arg("abc\\"));
+ ASSERT_EQ(R"('abc(')", escape_arg("abc("));
+ ASSERT_EQ(R"('abc)')", escape_arg("abc)"));
}
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index f193d2f..e59a96a 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -312,6 +312,7 @@
static void copy_to_file(int inFd, int outFd) {
const size_t BUFSIZE = 32 * 1024;
char* buf = (char*) malloc(BUFSIZE);
+ if (buf == nullptr) fatal("couldn't allocate buffer for copy_to_file");
int len;
long total = 0;
@@ -419,6 +420,11 @@
fdi = 0; //dup(0);
int* fds = reinterpret_cast<int*>(malloc(sizeof(int) * 2));
+ if (fds == nullptr) {
+ fprintf(stderr, "couldn't allocate fds array: %s\n", strerror(errno));
+ return 1;
+ }
+
fds[0] = fd;
fds[1] = fdi;
@@ -764,8 +770,7 @@
cmd += " " + escape_arg(*argv++);
}
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static int mkdirs(const char *path)
@@ -1457,27 +1462,27 @@
return uninstall_app(ttype, serial, argc, argv);
}
else if (!strcmp(argv[0], "sync")) {
- std::string src_arg;
+ std::string src;
bool list_only = false;
if (argc < 2) {
// No local path was specified.
- src_arg = "";
+ src = "";
} else if (argc >= 2 && strcmp(argv[1], "-l") == 0) {
- list_only = 1;
+ list_only = true;
if (argc == 3) {
- src_arg = argv[2];
+ src = argv[2];
} else {
- src_arg = "";
+ src = "";
}
} else if (argc == 2) {
// A local path or "android"/"data" arg was specified.
- src_arg = argv[1];
+ src = argv[1];
} else {
return usage();
}
- if (src_arg != "" &&
- src_arg != "system" && src_arg != "data" && src_arg != "vendor" && src_arg != "oem") {
+ if (src != "" &&
+ src != "system" && src != "data" && src != "vendor" && src != "oem") {
return usage();
}
@@ -1485,25 +1490,19 @@
std::string data_src_path = product_file("data");
std::string vendor_src_path = product_file("vendor");
std::string oem_src_path = product_file("oem");
- if (!directory_exists(vendor_src_path)) {
- vendor_src_path = "";
- }
- if (!directory_exists(oem_src_path)) {
- oem_src_path = "";
- }
int rc = 0;
- if (rc == 0 && (src_arg.empty() || src_arg == "system")) {
- rc = do_sync_sync(system_src_path.c_str(), "/system", list_only);
+ if (rc == 0 && (src.empty() || src == "system")) {
+ rc = do_sync_sync(system_src_path, "/system", list_only);
}
- if (rc == 0 && (src_arg.empty() || src_arg == "vendor")) {
- rc = do_sync_sync(vendor_src_path.c_str(), "/vendor", list_only);
+ if (rc == 0 && (src.empty() || src == "vendor") && directory_exists(vendor_src_path)) {
+ rc = do_sync_sync(vendor_src_path, "/vendor", list_only);
}
- if(rc == 0 && (src_arg.empty() || src_arg == "oem")) {
- rc = do_sync_sync(oem_src_path.c_str(), "/oem", list_only);
+ if (rc == 0 && (src.empty() || src == "oem") && directory_exists(oem_src_path)) {
+ rc = do_sync_sync(oem_src_path, "/oem", list_only);
}
- if (rc == 0 && (src_arg.empty() || src_arg == "data")) {
- rc = do_sync_sync(data_src_path.c_str(), "/data", list_only);
+ if (rc == 0 && (src.empty() || src == "data")) {
+ rc = do_sync_sync(data_src_path, "/data", list_only);
}
return rc;
}
@@ -1609,8 +1608,7 @@
cmd += " " + escape_arg(*argv++);
}
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static int uninstall_app(transport_type transport, const char* serial, int argc,
@@ -1635,8 +1633,7 @@
static int delete_file(transport_type transport, const char* serial, char* filename)
{
std::string cmd = "shell:rm -f " + escape_arg(filename);
- send_shell_command(transport, serial, cmd);
- return 0;
+ return send_shell_command(transport, serial, cmd);
}
static const char* get_basename(const char* filename)
@@ -1697,7 +1694,7 @@
argv[last_apk] = apk_dest; /* destination name, not source location */
}
- pm_command(transport, serial, argc, argv);
+ err = pm_command(transport, serial, argc, argv);
cleanup_apk:
delete_file(transport, serial, apk_dest);
diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp
index 730a5e2..49d8783 100644
--- a/adb/file_sync_client.cpp
+++ b/adb/file_sync_client.cpp
@@ -1027,18 +1027,18 @@
}
}
-int do_sync_sync(const char *lpath, const char *rpath, int listonly)
+int do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only)
{
- fprintf(stderr,"syncing %s...\n",rpath);
+ fprintf(stderr, "syncing %s...\n", rpath.c_str());
int fd = adb_connect("sync:");
- if(fd < 0) {
- fprintf(stderr,"error: %s\n", adb_error());
+ if (fd < 0) {
+ fprintf(stderr, "error: %s\n", adb_error());
return 1;
}
BEGIN();
- if(copy_local_dir_remote(fd, lpath, rpath, 1, listonly)){
+ if (copy_local_dir_remote(fd, lpath.c_str(), rpath.c_str(), 1, list_only)) {
return 1;
} else {
END();
diff --git a/adb/file_sync_service.h b/adb/file_sync_service.h
index 6e1ccce..344eb98 100644
--- a/adb/file_sync_service.h
+++ b/adb/file_sync_service.h
@@ -17,6 +17,8 @@
#ifndef _FILE_SYNC_SERVICE_H_
#define _FILE_SYNC_SERVICE_H_
+#include <string>
+
#define htoll(x) (x)
#define ltohl(x) (x)
@@ -67,7 +69,7 @@
void file_sync_service(int fd, void *cookie);
int do_sync_ls(const char *path);
int do_sync_push(const char *lpath, const char *rpath, int show_progress);
-int do_sync_sync(const char *lpath, const char *rpath, int listonly);
+int do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only);
int do_sync_pull(const char *rpath, const char *lpath, int show_progress, int pullTime);
#define SYNC_DATA_MAX (64*1024)
diff --git a/adb/services.cpp b/adb/services.cpp
index ff13722..e6c84a4 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -689,6 +689,10 @@
return create_device_tracker();
} else if (!strncmp(name, "wait-for-", strlen("wait-for-"))) {
auto sinfo = reinterpret_cast<state_info*>(malloc(sizeof(state_info)));
+ if (sinfo == nullptr) {
+ fprintf(stderr, "couldn't allocate state_info: %s", strerror(errno));
+ return NULL;
+ }
if (serial)
sinfo->serial = strdup(serial);
diff --git a/adb/tests/test_adb.py b/adb/tests/test_adb.py
index f111b043..52d8056 100755
--- a/adb/tests/test_adb.py
+++ b/adb/tests/test_adb.py
@@ -267,6 +267,18 @@
adb.unroot()
adb.wait()
+ def test_argument_escaping(self):
+ """Make sure that argument escaping is somewhat sane."""
+ adb = AdbWrapper()
+
+ # http://b/19734868
+ result = adb.shell("sh -c 'echo hello; echo world'").splitlines()
+ self.assertEqual(["hello", "world"], result)
+
+ # http://b/15479704
+ self.assertEqual('t', adb.shell("'true && echo t'").strip())
+ self.assertEqual('t', adb.shell("sh -c 'true && echo t'").strip())
+
class AdbFile(unittest.TestCase):
SCRATCH_DIR = "/data/local/tmp"
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 37f9d7b..d395a80 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -493,10 +493,8 @@
asocket*
create_device_tracker(void)
{
- device_tracker* tracker = reinterpret_cast<device_tracker*>(
- calloc(1, sizeof(*tracker)));
-
- if(tracker == 0) fatal("cannot allocate device tracker");
+ device_tracker* tracker = reinterpret_cast<device_tracker*>(calloc(1, sizeof(*tracker)));
+ if (tracker == nullptr) fatal("cannot allocate device tracker");
D( "device tracker %p created\n", tracker);
@@ -1002,8 +1000,11 @@
int register_socket_transport(int s, const char *serial, int port, int local)
{
- atransport *t = reinterpret_cast<atransport*>(
- calloc(1, sizeof(atransport)));
+ atransport *t = reinterpret_cast<atransport*>(calloc(1, sizeof(atransport)));
+ if (t == nullptr) {
+ return -1;
+ }
+
atransport *n;
char buff[32];
@@ -1102,8 +1103,8 @@
void register_usb_transport(usb_handle *usb, const char *serial, const char *devpath, unsigned writeable)
{
- atransport *t = reinterpret_cast<atransport*>(
- calloc(1, sizeof(atransport)));
+ atransport *t = reinterpret_cast<atransport*>(calloc(1, sizeof(atransport)));
+ if (t == nullptr) fatal("cannot allocate USB atransport");
D("transport: %p init'ing for usb_handle %p (sn='%s')\n", t, usb,
serial ? serial : "");
init_usb_transport(t, usb, (writeable ? CS_OFFLINE : CS_NOPERM));
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index fe3c87f..30e6bf5 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -144,7 +144,7 @@
if(serverfd == -1) {
serverfd = socket_inaddr_any_server(port, SOCK_STREAM);
if(serverfd < 0) {
- D("server: cannot bind socket yet\n");
+ D("server: cannot bind socket yet: %s\n", strerror(errno));
adb_sleep_ms(1000);
continue;
}
diff --git a/adb/usb_linux.cpp b/adb/usb_linux.cpp
index 6fd2b40..9f23511 100644
--- a/adb/usb_linux.cpp
+++ b/adb/usb_linux.cpp
@@ -598,8 +598,8 @@
D("[ usb located new device %s (%d/%d/%d) ]\n",
dev_name, ep_in, ep_out, interface);
- usb_handle* usb = reinterpret_cast<usb_handle*>(
- calloc(1, sizeof(usb_handle)));
+ usb_handle* usb = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (usb == nullptr) fatal("couldn't allocate usb_handle");
strcpy(usb->fname, dev_name);
usb->ep_in = ep_in;
usb->ep_out = ep_out;
diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp
index 343f20c..18289e2 100644
--- a/adb/usb_linux_client.cpp
+++ b/adb/usb_linux_client.cpp
@@ -18,6 +18,7 @@
#include "sysdeps.h"
+#include <cutils/properties.h>
#include <dirent.h>
#include <errno.h>
#include <linux/usb/ch9.h>
@@ -240,6 +241,8 @@
static void usb_adb_init()
{
usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (h == nullptr) fatal("couldn't allocate usb_handle");
+
h->write = usb_adb_write;
h->read = usb_adb_read;
h->kick = usb_adb_kick;
@@ -362,6 +365,7 @@
adb_sleep_ms(1000);
}
+ property_set("sys.usb.ffs.ready", "1");
D("[ usb_thread - registering device ]\n");
register_usb_transport(usb, 0, 0, 1);
@@ -466,6 +470,8 @@
D("[ usb_init - using FunctionFS ]\n");
usb_handle* h = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (h == nullptr) fatal("couldn't allocate usb_handle");
+
h->write = usb_ffs_write;
h->read = usb_ffs_read;
h->kick = usb_ffs_kick;
diff --git a/adb/usb_osx.cpp b/adb/usb_osx.cpp
index 303ae45..a795ce3 100644
--- a/adb/usb_osx.cpp
+++ b/adb/usb_osx.cpp
@@ -336,6 +336,7 @@
goto err_bad_adb_interface;
handle = reinterpret_cast<usb_handle*>(calloc(1, sizeof(usb_handle)));
+ if (handle == nullptr) goto err_bad_adb_interface;
//* Iterate over the endpoints for this interface and find the first
//* bulk in/out pipes available. These will be our read/write pipes.
diff --git a/fastboot/Android.mk b/fastboot/Android.mk
index b9e957f..7b2975b 100644
--- a/fastboot/Android.mk
+++ b/fastboot/Android.mk
@@ -74,6 +74,16 @@
LOCAL_STATIC_LIBRARIES += libf2fs_utils_host libf2fs_ioutils_host libf2fs_dlutils_host
endif
+# libc++ not available on windows yet
+ifneq ($(HOST_OS),windows)
+ LOCAL_CXX_STL := libc++_static
+endif
+
+# Don't add anything here, we don't want additional shared dependencies
+# on the host fastboot tool, and shared libraries that link against libc++
+# will violate ODR
+LOCAL_SHARED_LIBRARIES :=
+
include $(BUILD_HOST_EXECUTABLE)
my_dist_files := $(LOCAL_BUILT_MODULE)
diff --git a/include/cutils/dir_hash.h b/include/cutils/dir_hash.h
deleted file mode 100644
index fbb4d02..0000000
--- a/include/cutils/dir_hash.h
+++ /dev/null
@@ -1,26 +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.
- */
-
-typedef enum {
- SHA_1,
-} HashAlgorithm;
-
-int get_file_hash(HashAlgorithm algorithm, const char *path,
- char *output_string, size_t max_output_string);
-
-int get_recursive_hash_manifest(HashAlgorithm algorithm,
- const char *directory_path,
- char **output_string);
diff --git a/include/cutils/partition_utils.h b/include/cutils/partition_utils.h
index 597df92..72ca80d 100644
--- a/include/cutils/partition_utils.h
+++ b/include/cutils/partition_utils.h
@@ -20,7 +20,6 @@
__BEGIN_DECLS
int partition_wiped(char *source);
-void erase_footer(const char *dev_path, long long size);
__END_DECLS
diff --git a/include/memtrack/memtrack.h b/include/memtrack/memtrack.h
index 0f1f85e..3917300 100644
--- a/include/memtrack/memtrack.h
+++ b/include/memtrack/memtrack.h
@@ -121,7 +121,7 @@
ssize_t memtrack_proc_gl_pss(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_total
+ * memtrack_proc_other_total
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
@@ -131,7 +131,7 @@
ssize_t memtrack_proc_other_total(struct memtrack_proc *p);
/**
- * memtrack_proc_gl_pss
+ * memtrack_proc_other_pss
*
* Same as memtrack_proc_graphics_total, but counts miscellaneous memory
* not tracked by gl or graphics calls above.
diff --git a/include/utils/Timers.h b/include/utils/Timers.h
index d015421..54ec474 100644
--- a/include/utils/Timers.h
+++ b/include/utils/Timers.h
@@ -24,6 +24,8 @@
#include <sys/types.h>
#include <sys/time.h>
+#include <utils/Compat.h>
+
// ------------------------------------------------------------------
// C API
@@ -33,46 +35,46 @@
typedef int64_t nsecs_t; // nano-seconds
-static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000000000;
}
-static inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000000;
}
-static inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs)
{
return secs*1000;
}
-static inline nsecs_t nanoseconds_to_seconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs)
{
return secs/1000000000;
}
-static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
{
return secs/1000000;
}
-static inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs)
+static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs)
{
return secs/1000;
}
-static inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);}
-static inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);}
-static inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);}
-static inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);}
-static inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);}
-static inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);}
+static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);}
+static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);}
+static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);}
+static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);}
-static inline nsecs_t seconds(nsecs_t v) { return s2ns(v); }
-static inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); }
-static inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); }
+static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); }
+static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); }
+static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); }
enum {
SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock
diff --git a/libcutils/dir_hash.c b/libcutils/dir_hash.c
deleted file mode 100644
index 098b5db..0000000
--- a/libcutils/dir_hash.c
+++ /dev/null
@@ -1,335 +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.
- */
-
-#include <dirent.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sha1.h>
-#include <unistd.h>
-#include <limits.h>
-
-#include <sys/stat.h>
-
-#include <netinet/in.h>
-#include <resolv.h>
-
-#include <cutils/dir_hash.h>
-
-/**
- * Copies, if it fits within max_output_string bytes, into output_string
- * a hash of the contents, size, permissions, uid, and gid of the file
- * specified by path, using the specified algorithm. Returns the length
- * of the output string, or a negative number if the buffer is too short.
- */
-int get_file_hash(HashAlgorithm algorithm, const char *path,
- char *output_string, size_t max_output_string) {
- SHA1_CTX context;
- struct stat sb;
- unsigned char md[SHA1_DIGEST_LENGTH];
- int used;
- size_t n;
-
- if (algorithm != SHA_1) {
- errno = EINVAL;
- return -1;
- }
-
- if (stat(path, &sb) != 0) {
- return -1;
- }
-
- if (S_ISLNK(sb.st_mode)) {
- char buf[PATH_MAX];
- int len;
-
- len = readlink(path, buf, sizeof(buf));
- if (len < 0) {
- return -1;
- }
-
- SHA1Init(&context);
- SHA1Update(&context, (unsigned char *) buf, len);
- SHA1Final(md, &context);
- } else if (S_ISREG(sb.st_mode)) {
- char buf[10000];
- FILE *f = fopen(path, "rb");
- int len;
-
- if (f == NULL) {
- return -1;
- }
-
- SHA1Init(&context);
-
- while ((len = fread(buf, 1, sizeof(buf), f)) > 0) {
- SHA1Update(&context, (unsigned char *) buf, len);
- }
-
- if (ferror(f)) {
- fclose(f);
- return -1;
- }
-
- fclose(f);
- SHA1Final(md, &context);
- }
-
- if (S_ISLNK(sb.st_mode) || S_ISREG(sb.st_mode)) {
- used = b64_ntop(md, SHA1_DIGEST_LENGTH,
- output_string, max_output_string);
- if (used < 0) {
- errno = ENOSPC;
- return -1;
- }
-
- n = snprintf(output_string + used, max_output_string - used,
- " %d 0%o %d %d", (int) sb.st_size, sb.st_mode,
- (int) sb.st_uid, (int) sb.st_gid);
- } else {
- n = snprintf(output_string, max_output_string,
- "- - 0%o %d %d", sb.st_mode,
- (int) sb.st_uid, (int) sb.st_gid);
- }
-
- if (n >= max_output_string - used) {
- errno = ENOSPC;
- return -(used + n);
- }
-
- return used + n;
-}
-
-struct list {
- char *name;
- struct list *next;
-};
-
-static int cmp(const void *a, const void *b) {
- struct list *const *ra = a;
- struct list *const *rb = b;
-
- return strcmp((*ra)->name, (*rb)->name);
-}
-
-static int recurse(HashAlgorithm algorithm, const char *directory_path,
- struct list **out) {
- struct list *list = NULL;
- struct list *f;
-
- struct dirent *de;
- DIR *d = opendir(directory_path);
-
- if (d == NULL) {
- return -1;
- }
-
- while ((de = readdir(d)) != NULL) {
- if (strcmp(de->d_name, ".") == 0) {
- continue;
- }
- if (strcmp(de->d_name, "..") == 0) {
- continue;
- }
-
- char *name = malloc(strlen(de->d_name) + 1);
- struct list *node = malloc(sizeof(struct list));
-
- if (name == NULL || node == NULL) {
- struct list *next;
- for (f = list; f != NULL; f = next) {
- next = f->next;
- free(f->name);
- free(f);
- }
-
- free(name);
- free(node);
- closedir(d);
- return -1;
- }
-
- strcpy(name, de->d_name);
-
- node->name = name;
- node->next = list;
- list = node;
- }
-
- closedir(d);
-
- for (f = list; f != NULL; f = f->next) {
- struct stat sb;
- char *name;
- char outstr[NAME_MAX + 100];
- char *keep;
- struct list *res;
-
- name = malloc(strlen(f->name) + strlen(directory_path) + 2);
- if (name == NULL) {
- struct list *next;
- for (f = list; f != NULL; f = f->next) {
- next = f->next;
- free(f->name);
- free(f);
- }
- for (f = *out; f != NULL; f = f->next) {
- next = f->next;
- free(f->name);
- free(f);
- }
- *out = NULL;
- return -1;
- }
-
- sprintf(name, "%s/%s", directory_path, f->name);
-
- int len = get_file_hash(algorithm, name,
- outstr, sizeof(outstr));
- if (len < 0) {
- // should not happen
- return -1;
- }
-
- keep = malloc(len + strlen(name) + 3);
- res = malloc(sizeof(struct list));
-
- if (keep == NULL || res == NULL) {
- struct list *next;
- for (f = list; f != NULL; f = f->next) {
- next = f->next;
- free(f->name);
- free(f);
- }
- for (f = *out; f != NULL; f = f->next) {
- next = f->next;
- free(f->name);
- free(f);
- }
- *out = NULL;
-
- free(keep);
- free(res);
- return -1;
- }
-
- sprintf(keep, "%s %s\n", name, outstr);
-
- res->name = keep;
- res->next = *out;
- *out = res;
-
- if ((stat(name, &sb) == 0) && S_ISDIR(sb.st_mode)) {
- if (recurse(algorithm, name, out) < 0) {
- struct list *next;
- for (f = list; f != NULL; f = next) {
- next = f->next;
- free(f->name);
- free(f);
- }
-
- return -1;
- }
- }
- }
-
- struct list *next;
- for (f = list; f != NULL; f = next) {
- next = f->next;
-
- free(f->name);
- free(f);
- }
-}
-
-/**
- * Allocates a string containing the names and hashes of all files recursively
- * reached under the specified directory_path, using the specified algorithm.
- * The string is returned as *output_string; the return value is the length
- * of the string, or a negative number if there was a failure.
- */
-int get_recursive_hash_manifest(HashAlgorithm algorithm,
- const char *directory_path,
- char **output_string) {
- struct list *out = NULL;
- struct list *r;
- struct list **list;
- int count = 0;
- int len = 0;
- int retlen = 0;
- int i;
- char *buf;
-
- if (recurse(algorithm, directory_path, &out) < 0) {
- return -1;
- }
-
- for (r = out; r != NULL; r = r->next) {
- count++;
- len += strlen(r->name);
- }
-
- list = malloc(count * sizeof(struct list *));
- if (list == NULL) {
- struct list *next;
- for (r = out; r != NULL; r = next) {
- next = r->next;
- free(r->name);
- free(r);
- }
- return -1;
- }
-
- count = 0;
- for (r = out; r != NULL; r = r->next) {
- list[count++] = r;
- }
-
- qsort(list, count, sizeof(struct list *), cmp);
-
- buf = malloc(len + 1);
- if (buf == NULL) {
- struct list *next;
- for (r = out; r != NULL; r = next) {
- next = r->next;
- free(r->name);
- free(r);
- }
- free(list);
- return -1;
- }
-
- for (i = 0; i < count; i++) {
- int n = strlen(list[i]->name);
-
- strcpy(buf + retlen, list[i]->name);
- retlen += n;
- }
-
- free(list);
-
- struct list *next;
- for (r = out; r != NULL; r = next) {
- next = r->next;
-
- free(r->name);
- free(r);
- }
-
- *output_string = buf;
- return retlen;
-}
diff --git a/liblog/log_is_loggable.c b/liblog/log_is_loggable.c
index df67123..2e09192 100644
--- a/liblog/log_is_loggable.c
+++ b/liblog/log_is_loggable.c
@@ -28,7 +28,7 @@
return def;
}
{
- static const char log_namespace[] = "log.tag.";
+ static const char log_namespace[] = "persist.log.tag.";
char key[sizeof(log_namespace) + strlen(tag)];
strcpy(key, log_namespace);
@@ -37,6 +37,9 @@
if (__system_property_get(key + 8, buf) <= 0) {
buf[0] = '\0';
}
+ if (!buf[0] && __system_property_get(key, buf) <= 0) {
+ buf[0] = '\0';
+ }
}
switch (toupper(buf[0])) {
case 'V': return ANDROID_LOG_VERBOSE;
@@ -53,17 +56,6 @@
int __android_log_is_loggable(int prio, const char *tag, int def)
{
- static char user;
- int logLevel;
-
- if (user == 0) {
- char buf[PROP_VALUE_MAX];
- if (__system_property_get("ro.build.type", buf) <= 0) {
- buf[0] = '\0';
- }
- user = strcmp(buf, "user") ? -1 : 1;
- }
-
- logLevel = (user == 1) ? def : __android_log_level(tag, def);
+ int logLevel = __android_log_level(tag, def);
return logLevel >= 0 && prio >= logLevel;
}
diff --git a/libnetutils/Android.mk b/libnetutils/Android.mk
index 1f61511..2060df4 100644
--- a/libnetutils/Android.mk
+++ b/libnetutils/Android.mk
@@ -17,3 +17,10 @@
LOCAL_CFLAGS := -Werror
include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := dhcptool.c
+LOCAL_SHARED_LIBRARIES := libnetutils
+LOCAL_MODULE := dhcptool
+LOCAL_MODULE_TAGS := debug
+include $(BUILD_EXECUTABLE)
diff --git a/libnetutils/dhcptool.c b/libnetutils/dhcptool.c
new file mode 100644
index 0000000..352ac5e
--- /dev/null
+++ b/libnetutils/dhcptool.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015, 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.
+ */
+
+#include <errno.h>
+#include <error.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+#include <netutils/dhcp.h>
+#include <netutils/ifc.h>
+
+int main(int argc, char* argv[]) {
+ if (argc != 2) {
+ error(EXIT_FAILURE, 0, "usage: %s INTERFACE", argv[0]);
+ }
+
+ char* interface = argv[1];
+ if (ifc_init()) {
+ error(EXIT_FAILURE, errno, "dhcptool %s: ifc_init failed", interface);
+ }
+
+ int rc = do_dhcp(interface);
+ if (rc) {
+ error(0, errno, "dhcptool %s: do_dhcp failed", interface);
+ }
+
+ ifc_close();
+
+ return rc ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index a0436ef..1dced11 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -226,6 +226,84 @@
return it;
}
+// Define a temporary mechanism to report the last LogBufferElement pointer
+// for the specified uid, pid and tid. Used below to help merge-sort when
+// pruning for worst UID.
+class LogBufferElementKey {
+ const union {
+ struct {
+ uint16_t uid;
+ uint16_t pid;
+ uint16_t tid;
+ uint16_t padding;
+ } __packed;
+ uint64_t value;
+ } __packed;
+
+public:
+ LogBufferElementKey(uid_t u, pid_t p, pid_t t):uid(u),pid(p),tid(t),padding(0) { }
+ LogBufferElementKey(uint64_t k):value(k) { }
+
+ uint64_t getKey() { return value; }
+};
+
+class LogBufferElementEntry {
+ const uint64_t key;
+ LogBufferElement *last;
+
+public:
+ LogBufferElementEntry(const uint64_t &k, LogBufferElement *e):key(k),last(e) { }
+
+ const uint64_t&getKey() const { return key; }
+
+ LogBufferElement *getLast() { return last; }
+};
+
+class LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBufferElementEntry> {
+
+public:
+ bool merge(LogBufferElement *e, unsigned short dropped) {
+ LogBufferElementKey key(e->getUid(), e->getPid(), e->getTid());
+ android::hash_t hash = android::hash_type(key.getKey());
+ ssize_t index = find(-1, hash, key.getKey());
+ if (index != -1) {
+ LogBufferElementEntry &entry = editEntryAt(index);
+ LogBufferElement *l = entry.getLast();
+ unsigned short d = l->getDropped();
+ if ((dropped + d) > USHRT_MAX) {
+ removeAt(index);
+ } else {
+ l->setDropped(dropped + d);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ size_t add(LogBufferElement *e) {
+ LogBufferElementKey key(e->getUid(), e->getPid(), e->getTid());
+ android::hash_t hash = android::hash_type(key.getKey());
+ return android::BasicHashtable<uint64_t, LogBufferElementEntry>::
+ add(hash, LogBufferElementEntry(key.getKey(), e));
+ }
+
+ inline void clear() {
+ android::BasicHashtable<uint64_t, LogBufferElementEntry>::clear();
+ }
+
+ void clear(LogBufferElement *e) {
+ uint64_t current = e->getRealTime().nsec() - NS_PER_SEC;
+ ssize_t index = -1;
+ while((index = next(index)) >= 0) {
+ if (current > editEntryAt(index).getLast()->getRealTime().nsec()) {
+ removeAt(index);
+ index = -1;
+ }
+ }
+ }
+
+};
+
// prune "pruneRows" of type "id" from the buffer.
//
// mLogElementsLock must be held when this function is called.
@@ -287,9 +365,16 @@
if (sorted.get()) {
if (sorted[0] && sorted[1]) {
- worst = sorted[0]->getKey();
worst_sizes = sorted[0]->getSizes();
- second_worst_sizes = sorted[1]->getSizes();
+ // Calculate threshold as 12.5% of available storage
+ size_t threshold = log_buffer_size(id) / 8;
+ if (worst_sizes > threshold) {
+ worst = sorted[0]->getKey();
+ second_worst_sizes = sorted[1]->getSizes();
+ if (second_worst_sizes < threshold) {
+ second_worst_sizes = threshold;
+ }
+ }
}
}
}
@@ -301,7 +386,7 @@
bool kick = false;
bool leading = true;
- LogBufferElement *last = NULL;
+ LogBufferElementLast last;
for(it = mLogElements.begin(); it != mLogElements.end();) {
LogBufferElement *e = *it;
@@ -322,24 +407,18 @@
continue;
}
- pid_t pid = e->getPid();
-
// merge any drops
- if (last && dropped
- && ((dropped + last->getDropped()) < USHRT_MAX)
- && (last->getPid() == pid)
- && (last->getTid() == e->getTid())) {
+ if (dropped && last.merge(e, dropped)) {
it = mLogElements.erase(it);
stats.erase(e);
delete e;
- last->setDropped(dropped + last->getDropped());
continue;
}
leading = false;
if (hasBlacklist && mPrune.naughty(e)) {
- last = NULL;
+ last.clear(e);
it = erase(it);
if (dropped) {
continue;
@@ -361,13 +440,13 @@
}
if (dropped) {
- last = e;
+ last.add(e);
++it;
continue;
}
if (e->getUid() != worst) {
- last = NULL;
+ last.clear(e);
++it;
continue;
}
@@ -382,17 +461,12 @@
unsigned short len = e->getMsgLen();
stats.drop(e);
e->setDropped(1);
- // merge any drops
- if (last
- && (last->getDropped() < (USHRT_MAX - 1))
- && (last->getPid() == pid)
- && (last->getTid() == e->getTid())) {
+ if (last.merge(e, 1)) {
it = mLogElements.erase(it);
stats.erase(e);
delete e;
- last->setDropped(last->getDropped() + 1);
} else {
- last = e;
+ last.add(e);
++it;
}
if (worst_sizes < second_worst_sizes) {
@@ -400,6 +474,7 @@
}
worst_sizes -= len;
}
+ last.clear();
if (!kick || !mPrune.worstUidEnabled()) {
break; // the following loop will ask bad clients to skip/drop
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index 0801fe8..eadc4dd 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -328,22 +328,32 @@
}
if (!headerPrinted) {
+ output.appendFormat("\n\n");
+ android::String8 name("");
if (uid == AID_ROOT) {
- output.appendFormat(
- "\n\nChattiest UIDs in %s:\n",
+ name.appendFormat(
+ "Chattiest UIDs in %s log buffer:",
android_log_id_to_name(id));
} else {
- output.appendFormat(
- "\n\nLogging for your UID in %s:\n",
+ name.appendFormat(
+ "Logging for your UID in %s log buffer:",
android_log_id_to_name(id));
}
- android::String8 name("UID");
android::String8 size("Size");
android::String8 pruned("Pruned");
if (!worstUidEnabledForLogid(id)) {
pruned.setTo("");
}
format_line(output, name, size, pruned);
+
+ name.setTo("UID PACKAGE");
+ size.setTo("BYTES");
+ pruned.setTo("LINES");
+ if (!worstUidEnabledForLogid(id)) {
+ pruned.setTo("");
+ }
+ format_line(output, name, size, pruned);
+
headerPrinted = true;
}
@@ -380,15 +390,22 @@
}
if (!headerPrinted) {
+ output.appendFormat("\n\n");
+ android::String8 name("");
if (uid == AID_ROOT) {
- output.appendFormat("\n\nChattiest PIDs:\n");
+ name.appendFormat("Chattiest PIDs:");
} else {
- output.appendFormat("\n\nLogging for this PID:\n");
+ name.appendFormat("Logging for this PID:");
}
- android::String8 name(" PID/UID");
android::String8 size("Size");
android::String8 pruned("Pruned");
format_line(output, name, size, pruned);
+
+ name.setTo(" PID/UID COMMAND LINE");
+ size.setTo("BYTES");
+ pruned.setTo("LINES");
+ format_line(output, name, size, pruned);
+
headerPrinted = true;
}
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 903c706..d3c562f 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -249,6 +249,7 @@
mkdir /data/misc/bluedroid 0770 bluetooth net_bt_stack
mkdir /data/misc/bluetooth 0770 system system
mkdir /data/misc/keystore 0700 keystore keystore
+ mkdir /data/misc/gatekeeper 0700 system system
mkdir /data/misc/keychain 0771 system system
mkdir /data/misc/net 0750 root shell
mkdir /data/misc/radio 0770 system radio