Merge "Change "chown" to coreutils syntax."
diff --git a/include/cutils/logprint.h b/include/cutils/logprint.h
index 769c8a7..2b1e1c5 100644
--- a/include/cutils/logprint.h
+++ b/include/cutils/logprint.h
@@ -44,8 +44,8 @@
     time_t tv_sec;
     long tv_nsec;
     android_LogPriority priority;
-    pid_t pid;
-    pthread_t tid;
+    int32_t pid;
+    int32_t tid;
     const char * tag;
     size_t messageLen;
     const char * message;
diff --git a/include/system/audio_policy.h b/include/system/audio_policy.h
index 1e0af7d..d45758a 100644
--- a/include/system/audio_policy.h
+++ b/include/system/audio_policy.h
@@ -34,7 +34,7 @@
  * sharing an output with other AudioTracks)
  */
 typedef enum {
-    AUDIO_POLICY_OUTPUT_FLAG_INDIRECT = 0x0,
+    AUDIO_POLICY_OUTPUT_FLAG_NONE = 0x0,
     AUDIO_POLICY_OUTPUT_FLAG_DIRECT = 0x1
 } audio_policy_output_flags_t;
 
diff --git a/init/init.c b/init/init.c
index 71c28b5..1ee88a7 100755
--- a/init/init.c
+++ b/init/init.c
@@ -940,7 +940,7 @@
     }
 
         /* run all property triggers based on current state of the properties */
-    queue_builtin_action(queue_property_triggers_action, "queue_propety_triggers");
+    queue_builtin_action(queue_property_triggers_action, "queue_property_triggers");
 
 
 #if BOOTCHART
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index f8b7254..df43299 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -398,7 +398,7 @@
         break;
     case FORMAT_THREAD:
         prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%c(%5d:%p) ", priChar, pid, (void*)tid);
+            "%c(%5d:%5d) ", priChar, pid, tid);
         strcpy(suffixBuf, "\n"); suffixLen = 1;
         break;
     case FORMAT_RAW:
@@ -417,8 +417,8 @@
         break;
     case FORMAT_LONG:
         prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "[ %s %5d:%p %c/%-8s ]\n",
-            timeBuf, pid, (void*)tid, priChar, tag);
+            "[ %s %5d:%5d %c/%-8s ]\n",
+            timeBuf, pid, tid, priChar, tag);
         strcpy(suffixBuf, "\n\n"); suffixLen = 2;
         break;
     default:
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 8366c94..6fac84b 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -673,7 +673,7 @@
 
     if (inCount != 0) {
         fprintf(stderr,
-            "Warning: leftover binary log data (%d bytes)\n", inCount);
+            "Warning: leftover binary log data (%zu bytes)\n", inCount);
     }
 
     /*
@@ -753,7 +753,7 @@
             break;
         case FORMAT_THREAD:
             prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-                "%c(%5d:%p) ", priChar, entry->pid, (void*)entry->tid);
+                "%c(%5d:%5d) ", priChar, entry->pid, entry->tid);
             strcpy(suffixBuf, "\n");
             suffixLen = 1;
             break;
@@ -773,15 +773,15 @@
         case FORMAT_THREADTIME:
             prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
                 "%s.%03ld %5d %5d %c %-8s: ", timeBuf, entry->tv_nsec / 1000000,
-                (int)entry->pid, (int)entry->tid, priChar, entry->tag);
+                entry->pid, entry->tid, priChar, entry->tag);
             strcpy(suffixBuf, "\n");
             suffixLen = 1;
             break;
         case FORMAT_LONG:
             prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-                "[ %s.%03ld %5d:%p %c/%-8s ]\n",
+                "[ %s.%03ld %5d:%5d %c/%-8s ]\n",
                 timeBuf, entry->tv_nsec / 1000000, entry->pid,
-                (void*)entry->tid, priChar, entry->tag);
+                entry->tid, priChar, entry->tag);
             strcpy(suffixBuf, "\n\n");
             suffixLen = 2;
             prefixSuffixIsHeaderFooter = 1;
diff --git a/logwrapper/logwrapper.c b/logwrapper/logwrapper.c
index 6a80560..dd777c0 100644
--- a/logwrapper/logwrapper.c
+++ b/logwrapper/logwrapper.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <libgen.h>
 
 #include "private/android_filesystem_config.h"
 #include "cutils/log.h"
@@ -34,13 +35,13 @@
 
 void usage() {
     fatal(
-        "Usage: logwrapper [-x] BINARY [ARGS ...]\n"
+        "Usage: logwrapper [-d] BINARY [ARGS ...]\n"
         "\n"
         "Forks and executes BINARY ARGS, redirecting stdout and stderr to\n"
         "the Android logging system. Tag is set to BINARY, priority is\n"
         "always LOG_INFO.\n"
         "\n"
-        "-x: Causes logwrapper to SIGSEGV when BINARY terminates\n"
+        "-d: Causes logwrapper to SIGSEGV when BINARY terminates\n"
         "    fault address is set to the status of wait()\n");
 }
 
@@ -51,6 +52,10 @@
     int a = 0;  // start index of unprocessed data
     int b = 0;  // end index of unprocessed data
     int sz;
+
+    char *btag = basename(tag);
+    if (!btag) btag = (char*) tag;
+
     while ((sz = read(parent_read, &buffer[b], sizeof(buffer) - 1 - b)) > 0) {
 
         sz += b;
@@ -60,7 +65,7 @@
                 buffer[b] = '\0';
             } else if (buffer[b] == '\n') {
                 buffer[b] = '\0';
-                ALOG(LOG_INFO, tag, "%s", &buffer[a]);
+                ALOG(LOG_INFO, btag, "%s", &buffer[a]);
                 a = b + 1;
             }
         }
@@ -68,7 +73,7 @@
         if (a == 0 && b == sizeof(buffer) - 1) {
             // buffer is full, flush
             buffer[b] = '\0';
-            ALOG(LOG_INFO, tag, "%s", &buffer[a]);
+            ALOG(LOG_INFO, btag, "%s", &buffer[a]);
             b = 0;
         } else if (a != b) {
             // Keep left-overs
@@ -84,11 +89,11 @@
     // Flush remaining data
     if (a != b) {
         buffer[b] = '\0';
-        ALOG(LOG_INFO, tag, "%s", &buffer[a]);
+        ALOG(LOG_INFO, btag, "%s", &buffer[a]);
     }
     status = 0xAAAA;
     if (wait(&status) != -1) {  // Wait for child
-        if (WIFEXITED(status))
+        if (WIFEXITED(status) && WEXITSTATUS(status))
             ALOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
                     WEXITSTATUS(status));
         else if (WIFSIGNALED(status))
diff --git a/toolbox/chown.c b/toolbox/chown.c
index 576c904..92efee6 100644
--- a/toolbox/chown.c
+++ b/toolbox/chown.c
@@ -64,7 +64,7 @@
 
     for (i = 2; i < argc; i++) {
         if (chown(argv[i], uid, gid) < 0) {
-            fprintf(stderr, "Unable to chmod %s: %s\n", argv[i], strerror(errno));
+            fprintf(stderr, "Unable to chown %s: %s\n", argv[i], strerror(errno));
             return 10;
         }
     }