summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adb/usb_vendors.c6
-rwxr-xr-xinit/init.c18
-rw-r--r--libcutils/Android.mk4
-rw-r--r--libcutils/arch-mips/android_memset.c31
-rw-r--r--libsparse/output_file.c3
-rw-r--r--rootdir/init.rc2
-rw-r--r--toolbox/dmesg.c27
-rw-r--r--toolbox/ls.c80
8 files changed, 119 insertions, 52 deletions
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
index df9b1d1..604c461 100644
--- a/adb/usb_vendors.c
+++ b/adb/usb_vendors.c
@@ -137,6 +137,10 @@
#define VENDOR_ID_HARRIS 0x19A5
// OPPO's USB Vendor ID
#define VENDOR_ID_OPPO 0x22D9
+// Xiaomi's USB Vendor ID
+#define VENDOR_ID_XIAOMI 0x2717
+// BYD's USB Vendor ID
+#define VENDOR_ID_BYD 0x19D1
/** built-in vendor list */
@@ -192,6 +196,8 @@ int builtInVendorIds[] = {
VENDOR_ID_ANYDATA,
VENDOR_ID_HARRIS,
VENDOR_ID_OPPO,
+ VENDOR_ID_XIAOMI,
+ VENDOR_ID_BYD,
};
#define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0]))
diff --git a/init/init.c b/init/init.c
index 5c03dea..3e67192 100755
--- a/init/init.c
+++ b/init/init.c
@@ -90,7 +90,7 @@ void notify_service_state(const char *name, const char *state)
}
static int have_console;
-static char *console_name = "/dev/console";
+static char console_name[PROP_VALUE_MAX] = "/dev/console";
static time_t process_needs_restart;
static const char *ENV[32];
@@ -430,7 +430,7 @@ static void restart_processes()
static void msg_start(const char *name)
{
- struct service *svc;
+ struct service *svc = NULL;
char *tmp = NULL;
char *args = NULL;
@@ -438,11 +438,13 @@ static void msg_start(const char *name)
svc = service_find_by_name(name);
else {
tmp = strdup(name);
- args = strchr(tmp, ':');
- *args = '\0';
- args++;
+ if (tmp) {
+ args = strchr(tmp, ':');
+ *args = '\0';
+ args++;
- svc = service_find_by_name(tmp);
+ svc = service_find_by_name(tmp);
+ }
}
if (svc) {
@@ -547,11 +549,9 @@ static int keychord_init_action(int nargs, char **args)
static int console_init_action(int nargs, char **args)
{
int fd;
- char tmp[PROP_VALUE_MAX];
if (console[0]) {
- snprintf(tmp, sizeof(tmp), "/dev/%s", console);
- console_name = strdup(tmp);
+ snprintf(console_name, sizeof(console_name), "/dev/%s", console);
}
fd = open(console_name, O_RDWR);
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index 4056e8a..5037705 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -131,7 +131,11 @@ ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
LOCAL_CFLAGS += -DHAVE_MEMSET16 -DHAVE_MEMSET32
LOCAL_SRC_FILES += arch-x86/android_memset16.S arch-x86/android_memset32.S memory.c
else # !x86-atom
+ifeq ($(TARGET_ARCH),mips)
+LOCAL_SRC_FILES += arch-mips/android_memset.c
+else # !mips
LOCAL_SRC_FILES += memory.c
+endif # !mips
endif # !x86-atom
endif # !arm
diff --git a/libcutils/arch-mips/android_memset.c b/libcutils/arch-mips/android_memset.c
new file mode 100644
index 0000000..bbc99fe
--- /dev/null
+++ b/libcutils/arch-mips/android_memset.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 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 <cutils/memory.h>
+
+/* Use mips-assembler versions supplied by bionic/libc/arch-mips/string/memset.S: */
+void _memset16(uint16_t* dst, uint16_t value, size_t size);
+void _memset32(uint32_t* dst, uint32_t value, size_t size);
+
+void android_memset16(uint16_t* dst, uint16_t value, size_t size)
+{
+ _memset16(dst, value, size);
+}
+
+void android_memset32(uint32_t* dst, uint32_t value, size_t size)
+{
+ _memset32(dst, value, size);
+}
diff --git a/libsparse/output_file.c b/libsparse/output_file.c
index b5ae419..5014e4a 100644
--- a/libsparse/output_file.c
+++ b/libsparse/output_file.c
@@ -675,6 +675,9 @@ struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t
} else {
out = output_file_new_normal();
}
+ if (!out) {
+ return NULL;
+ }
out->ops->open(out, fd);
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 89ec18a..c3ef503 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -37,7 +37,7 @@ loglevel 3
export ANDROID_STORAGE /storage
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
- export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
+ export BOOTCLASSPATH /system/framework/core.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
# Backward compatibility
symlink /system/etc /etc
diff --git a/toolbox/dmesg.c b/toolbox/dmesg.c
index e57f607..9c73b00 100644
--- a/toolbox/dmesg.c
+++ b/toolbox/dmesg.c
@@ -5,15 +5,30 @@
#include <sys/klog.h>
#include <string.h>
-#define KLOG_BUF_SHIFT 17 /* CONFIG_LOG_BUF_SHIFT from our kernel */
-#define KLOG_BUF_LEN (1 << KLOG_BUF_SHIFT)
+#define FALLBACK_KLOG_BUF_SHIFT 17 /* CONFIG_LOG_BUF_SHIFT from our kernel */
+#define FALLBACK_KLOG_BUF_LEN (1 << FALLBACK_KLOG_BUF_SHIFT)
int dmesg_main(int argc, char **argv)
{
- char buffer[KLOG_BUF_LEN + 1];
- char *p = buffer;
+ char *buffer;
+ char *p;
ssize_t ret;
- int n, op;
+ int n, op, klog_buf_len;
+
+ klog_buf_len = klogctl(KLOG_SIZE_BUFFER, 0, 0);
+
+ if (klog_buf_len <= 0) {
+ klog_buf_len = FALLBACK_KLOG_BUF_LEN;
+ }
+
+ buffer = (char *)malloc(klog_buf_len + 1);
+
+ if (!buffer) {
+ perror("malloc");
+ return EXIT_FAILURE;
+ }
+
+ p = buffer;
if((argc == 2) && (!strcmp(argv[1],"-c"))) {
op = KLOG_READ_CLEAR;
@@ -21,7 +36,7 @@ int dmesg_main(int argc, char **argv)
op = KLOG_READ_ALL;
}
- n = klogctl(op, buffer, KLOG_BUF_LEN);
+ n = klogctl(op, buffer, klog_buf_len);
if (n < 0) {
perror("klogctl");
return EXIT_FAILURE;
diff --git a/toolbox/ls.c b/toolbox/ls.c
index e530521..5324511 100644
--- a/toolbox/ls.c
+++ b/toolbox/ls.c
@@ -28,6 +28,7 @@
#define LIST_LONG_NUMERIC (1 << 5)
#define LIST_CLASSIFY (1 << 6)
#define LIST_MACLABEL (1 << 7)
+#define LIST_INODE (1 << 8)
// fwd
static int listpath(const char *name, int flags);
@@ -127,22 +128,20 @@ static int show_total_size(const char *dirname, DIR *d, int flags)
return 0;
}
-static int listfile_size(const char *path, const char *filename, int flags)
+static int listfile_size(const char *path, const char *filename, struct stat *s,
+ int flags)
{
- struct stat s;
-
- if (lstat(path, &s) < 0) {
- fprintf(stderr, "lstat '%s' failed: %s\n", path, strerror(errno));
+ if(!s || !path) {
return -1;
}
/* blocks are 512 bytes, we want output to be KB */
if ((flags & LIST_SIZE) != 0) {
- printf("%lld ", s.st_blocks / 2);
+ printf("%lld ", s->st_blocks / 2);
}
if ((flags & LIST_CLASSIFY) != 0) {
- char filetype = mode2kind(s.st_mode);
+ char filetype = mode2kind(s->st_mode);
if (filetype != 'l') {
printf("%c ", filetype);
} else {
@@ -161,15 +160,18 @@ static int listfile_size(const char *path, const char *filename, int flags)
return 0;
}
-static int listfile_long(const char *path, int flags)
+static int listfile_long(const char *path, struct stat *s, int flags)
{
- struct stat s;
char date[32];
char mode[16];
char user[16];
char group[16];
const char *name;
+ if(!s || !path) {
+ return -1;
+ }
+
/* name is anything after the final '/', or the whole path if none*/
name = strrchr(path, '/');
if(name == 0) {
@@ -178,36 +180,32 @@ static int listfile_long(const char *path, int flags)
name++;
}
- if(lstat(path, &s) < 0) {
- return -1;
- }
-
- mode2str(s.st_mode, mode);
+ mode2str(s->st_mode, mode);
if (flags & LIST_LONG_NUMERIC) {
- sprintf(user, "%ld", s.st_uid);
- sprintf(group, "%ld", s.st_gid);
+ sprintf(user, "%ld", s->st_uid);
+ sprintf(group, "%ld", s->st_gid);
} else {
- user2str(s.st_uid, user);
- group2str(s.st_gid, group);
+ user2str(s->st_uid, user);
+ group2str(s->st_gid, group);
}
- strftime(date, 32, "%Y-%m-%d %H:%M", localtime((const time_t*)&s.st_mtime));
+ strftime(date, 32, "%Y-%m-%d %H:%M", localtime((const time_t*)&s->st_mtime));
date[31] = 0;
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
// MMMMMMMM UUUUUUUU GGGGGGGGG XXXXXXXX YYYY-MM-DD HH:MM NAME (->LINK)
- switch(s.st_mode & S_IFMT) {
+ switch(s->st_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
printf("%s %-8s %-8s %3d, %3d %s %s\n",
mode, user, group,
- (int) MAJOR(s.st_rdev), (int) MINOR(s.st_rdev),
+ (int) MAJOR(s->st_rdev), (int) MINOR(s->st_rdev),
date, name);
break;
case S_IFREG:
printf("%s %-8s %-8s %8lld %s %s\n",
- mode, user, group, s.st_size, date, name);
+ mode, user, group, s->st_size, date, name);
break;
case S_IFLNK: {
char linkto[256];
@@ -237,15 +235,18 @@ static int listfile_long(const char *path, int flags)
return 0;
}
-static int listfile_maclabel(const char *path, int flags)
+static int listfile_maclabel(const char *path, struct stat *s, int flags)
{
- struct stat s;
char mode[16];
char user[16];
char group[16];
char *maclabel = NULL;
const char *name;
+ if(!s || !path) {
+ return -1;
+ }
+
/* name is anything after the final '/', or the whole path if none*/
name = strrchr(path, '/');
if(name == 0) {
@@ -254,20 +255,16 @@ static int listfile_maclabel(const char *path, int flags)
name++;
}
- if(lstat(path, &s) < 0) {
- return -1;
- }
-
lgetfilecon(path, &maclabel);
if (!maclabel) {
return -1;
}
- mode2str(s.st_mode, mode);
- user2str(s.st_uid, user);
- group2str(s.st_gid, group);
+ mode2str(s->st_mode, mode);
+ user2str(s->st_uid, user);
+ group2str(s->st_gid, group);
- switch(s.st_mode & S_IFMT) {
+ switch(s->st_mode & S_IFMT) {
case S_IFLNK: {
char linkto[256];
ssize_t len;
@@ -301,7 +298,9 @@ static int listfile_maclabel(const char *path, int flags)
static int listfile(const char *dirname, const char *filename, int flags)
{
- if ((flags & (LIST_LONG | LIST_SIZE | LIST_CLASSIFY | LIST_MACLABEL)) == 0) {
+ struct stat s;
+
+ if ((flags & (LIST_LONG | LIST_SIZE | LIST_CLASSIFY | LIST_MACLABEL | LIST_INODE)) == 0) {
printf("%s\n", filename);
return 0;
}
@@ -316,12 +315,20 @@ static int listfile(const char *dirname, const char *filename, int flags)
pathname = filename;
}
+ if(lstat(pathname, &s) < 0) {
+ return -1;
+ }
+
+ if(flags & LIST_INODE) {
+ printf("%8llu ", s.st_ino);
+ }
+
if ((flags & LIST_MACLABEL) != 0) {
- return listfile_maclabel(pathname, flags);
+ return listfile_maclabel(pathname, &s, flags);
} else if ((flags & LIST_LONG) != 0) {
- return listfile_long(pathname, flags);
+ return listfile_long(pathname, &s, flags);
} else /*((flags & LIST_SIZE) != 0)*/ {
- return listfile_size(pathname, filename, flags);
+ return listfile_size(pathname, filename, &s, flags);
}
}
@@ -456,6 +463,7 @@ int ls_main(int argc, char **argv)
case 'Z': flags |= LIST_MACLABEL; break;
case 'a': flags |= LIST_ALL; break;
case 'F': flags |= LIST_CLASSIFY; break;
+ case 'i': flags |= LIST_INODE; break;
default:
fprintf(stderr, "%s: Unknown option '-%c'. Aborting.\n", "ls", arg[0]);
exit(1);