Merge changes I70ab37d5,I716f89c0,I34c96adf,I77650923,I35b0d1ee, ...
* changes:
libsysutils: SocketListener export release
libsysutils: Add iovec/runOnEachSocket
liblog: support struct logger_event_v2 format
liblog: update timestamp on NOTICE file
libcutils: resolve warning in iosched_policy.c
liblog: Add const pedantics
logcat: Add -T flag (-t w/o assumption of -d)
logcat: Add logcat test suite
liblog: Add cpu utilization test
liblog: Add liblog test suite
debuggerd: Support newline split in log messages
liblog: deprecate export LOGGER ioctl definitions
liblog: deprecate export of LOGGER_LOG_* defines
liblog: Add README
liblog: resolve build warning messages
liblog: high CPU usage from logcat
liblog: fix build again
liblog: drop use of sys/cdefs.h
liblog: git_master@964770 build problem
logcat: Incorporate liblog reading API
debuggerd: Incorporate liblog reading API
liblog: Interface to support abstracting log read
adb: deprecate legacy log service interface
adb: regression from Move list.c to inlines
liblog: whitespace cleanup
libcutils: bug str_parms.c:str_parms_get_float().
libcutils: UNUSED argument warnings
libsysutils: Get rid of warnings
libcutils: Move list.c to inlines on list.h
diff --git a/adb/adb_client.c b/adb/adb_client.c
index f7823a8..586cd7b 100644
--- a/adb/adb_client.c
+++ b/adb/adb_client.c
@@ -241,7 +241,7 @@
} else {
// if server was running, check its version to make sure it is not out of date
char buf[100];
- int n;
+ size_t n;
int version = ADB_SERVER_VERSION - 1;
// if we have a file descriptor, then parse version result
@@ -250,7 +250,7 @@
buf[4] = 0;
n = strtoul(buf, 0, 16);
- if(n > (int)sizeof(buf)) goto error;
+ if(n > sizeof(buf)) goto error;
if(readx(fd, buf, n)) goto error;
adb_close(fd);
diff --git a/adb/usb_linux_client.c b/adb/usb_linux_client.c
index 69d8062..8426e0e 100644
--- a/adb/usb_linux_client.c
+++ b/adb/usb_linux_client.c
@@ -264,23 +264,25 @@
{
ssize_t ret;
- D("OPENING %s\n", USB_FFS_ADB_EP0);
- h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR);
- if (h->control < 0) {
- D("[ %s: cannot open control endpoint: errno=%d]\n", USB_FFS_ADB_EP0, errno);
- goto err;
- }
+ if (h->control < 0) { // might have already done this before
+ D("OPENING %s\n", USB_FFS_ADB_EP0);
+ h->control = adb_open(USB_FFS_ADB_EP0, O_RDWR);
+ if (h->control < 0) {
+ D("[ %s: cannot open control endpoint: errno=%d]\n", USB_FFS_ADB_EP0, errno);
+ goto err;
+ }
- ret = adb_write(h->control, &descriptors, sizeof(descriptors));
- if (ret < 0) {
- D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno);
- goto err;
- }
+ ret = adb_write(h->control, &descriptors, sizeof(descriptors));
+ if (ret < 0) {
+ D("[ %s: write descriptors failed: errno=%d ]\n", USB_FFS_ADB_EP0, errno);
+ goto err;
+ }
- ret = adb_write(h->control, &strings, sizeof(strings));
- if (ret < 0) {
- D("[ %s: writing strings failed: errno=%d]\n", USB_FFS_ADB_EP0, errno);
- goto err;
+ ret = adb_write(h->control, &strings, sizeof(strings));
+ if (ret < 0) {
+ D("[ %s: writing strings failed: errno=%d]\n", USB_FFS_ADB_EP0, errno);
+ goto err;
+ }
}
h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR);
@@ -320,14 +322,14 @@
while (1) {
// wait until the USB device needs opening
adb_mutex_lock(&usb->lock);
- while (usb->control != -1)
+ while (usb->control != -1 && usb->bulk_in != -1 && usb->bulk_out != -1)
adb_cond_wait(&usb->notify, &usb->lock);
adb_mutex_unlock(&usb->lock);
while (1) {
init_functionfs(usb);
- if (usb->control >= 0)
+ if (usb->control >= 0 && usb->bulk_in >= 0 && usb->bulk_out >= 0)
break;
adb_sleep_ms(1000);
@@ -424,10 +426,13 @@
D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno);
adb_mutex_lock(&h->lock);
- adb_close(h->control);
+
+ // don't close ep0 here, since we may not need to reinitialize it with
+ // the same descriptors again. if however ep1/ep2 fail to re-open in
+ // init_functionfs, only then would we close and open ep0 again.
adb_close(h->bulk_out);
adb_close(h->bulk_in);
- h->control = h->bulk_out = h->bulk_in = -1;
+ h->bulk_out = h->bulk_in = -1;
// notify usb_ffs_open_thread that we are disconnected
adb_cond_signal(&h->notify);
diff --git a/init/init.c b/init/init.c
index 4266a73..0250e97 100644
--- a/init/init.c
+++ b/init/init.c
@@ -868,6 +868,7 @@
void selinux_init_all_handles(void)
{
sehandle = selinux_android_file_context_handle();
+ selinux_android_set_sehandle(sehandle);
sehandle_prop = selinux_android_prop_context_handle();
}
diff --git a/init/util.c b/init/util.c
index 5efd5be..e772342 100644
--- a/init/util.c
+++ b/init/util.c
@@ -25,6 +25,7 @@
#include <ftw.h>
#include <selinux/label.h>
+#include <selinux/android.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -524,60 +525,12 @@
return rc;
}
-static int restorecon_sb(const char *pathname, const struct stat *sb)
+int restorecon(const char* pathname)
{
- char *secontext = NULL;
- char *oldsecontext = NULL;
- int i;
-
- if (selabel_lookup(sehandle, &secontext, pathname, sb->st_mode) < 0)
- return -errno;
-
- if (lgetfilecon(pathname, &oldsecontext) < 0) {
- freecon(secontext);
- return -errno;
- }
-
- if (strcmp(oldsecontext, secontext) != 0) {
- if (lsetfilecon(pathname, secontext) < 0) {
- freecon(oldsecontext);
- freecon(secontext);
- return -errno;
- }
- }
- freecon(oldsecontext);
- freecon(secontext);
- return 0;
-}
-
-int restorecon(const char *pathname)
-{
- struct stat sb;
-
- if (is_selinux_enabled() <= 0 || !sehandle)
- return 0;
-
- if (lstat(pathname, &sb) < 0)
- return -errno;
-
- return restorecon_sb(pathname, &sb);
-}
-
-static int nftw_restorecon(const char* filename, const struct stat* statptr,
- int fileflags __attribute__((unused)),
- struct FTW* pftw __attribute__((unused)))
-{
- restorecon_sb(filename, statptr);
- return 0;
+ return selinux_android_restorecon(pathname);
}
int restorecon_recursive(const char* pathname)
{
- int fd_limit = 20;
- int flags = FTW_DEPTH | FTW_MOUNT | FTW_PHYS;
-
- if (is_selinux_enabled() <= 0 || !sehandle)
- return 0;
-
- return nftw(pathname, nftw_restorecon, fd_limit, flags);
+ return selinux_android_restorecon_recursive(pathname);
}
diff --git a/libbacktrace/Android.mk b/libbacktrace/Android.mk
index 9c52ad7..f23eefd 100644
--- a/libbacktrace/Android.mk
+++ b/libbacktrace/Android.mk
@@ -23,8 +23,7 @@
liblog \
# To enable using libunwind on each arch, add it to this list.
-libunwind_architectures :=
-#libunwind_architectures := arm
+libunwind_architectures := arm64
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),$(libunwind_architectures)))
diff --git a/libbacktrace/UnwindCurrent.cpp b/libbacktrace/UnwindCurrent.cpp
index 747eb21..d1195ee 100644
--- a/libbacktrace/UnwindCurrent.cpp
+++ b/libbacktrace/UnwindCurrent.cpp
@@ -43,7 +43,7 @@
#include <asm/sigcontext.h>
#include <asm/ucontext.h>
typedef struct ucontext ucontext_t;
-#elif !defined(__mips__)
+#elif !defined(__mips__) && !defined(__aarch64__)
#error Unsupported architecture.
#endif
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 8d31060..da83a85 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -19,6 +19,8 @@
* passed on to the underlying (fake) log device. When not in the
* simulator, messages are printed to stderr.
*/
+#include "fake_log_device.h"
+
#include <log/logd.h>
#include <stdlib.h>
diff --git a/liblog/fake_log_device.h b/liblog/fake_log_device.h
new file mode 100644
index 0000000..9d168cd
--- /dev/null
+++ b/liblog/fake_log_device.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef _LIBLOG_FAKE_LOG_DEVICE_H
+#define _LIBLOG_FAKE_LOG_DEVICE_H
+
+#include <sys/types.h>
+
+struct iovec;
+
+int fakeLogOpen(const char *pathName, int flags);
+int fakeLogClose(int fd);
+ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count);
+
+#endif // _LIBLOG_FAKE_LOG_DEVICE_H
diff --git a/liblog/logd_write.c b/liblog/logd_write.c
index f3054af..6b35a0f 100644
--- a/liblog/logd_write.c
+++ b/liblog/logd_write.c
@@ -40,6 +40,7 @@
#if FAKE_LOG_DEVICE
// This will be defined when building for the host.
+#include "fake_log_device.h"
#define log_open(pathname, flags) fakeLogOpen(pathname, flags)
#define log_writev(filedes, vector, count) fakeLogWritev(filedes, vector, count)
#define log_close(filedes) fakeLogClose(filedes)
@@ -55,6 +56,8 @@
static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
+#define UNUSED __attribute__((__unused__))
+
static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 };
/*
@@ -77,7 +80,8 @@
return (g_log_status == kLogAvailable);
}
-static int __write_to_log_null(log_id_t log_fd, struct iovec *vec, size_t nr)
+static int __write_to_log_null(UNUSED log_id_t log_fd, UNUSED struct iovec *vec,
+ UNUSED size_t nr)
{
return -1;
}