Merge "mkbootfs: Fix the default st_mode for root directory."
diff --git a/base/include/android-base/parseint.h b/base/include/android-base/parseint.h
index ed75e2d..7415409 100644
--- a/base/include/android-base/parseint.h
+++ b/base/include/android-base/parseint.h
@@ -31,7 +31,7 @@
template <typename T>
bool ParseUint(const char* s, T* out,
T max = std::numeric_limits<T>::max()) {
- int base = (s[0] == '0' && s[1] == 'x') ? 16 : 10;
+ int base = (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10;
errno = 0;
char* end;
unsigned long long int result = strtoull(s, &end, base);
@@ -53,7 +53,7 @@
bool ParseInt(const char* s, T* out,
T min = std::numeric_limits<T>::min(),
T max = std::numeric_limits<T>::max()) {
- int base = (s[0] == '0' && s[1] == 'x') ? 16 : 10;
+ int base = (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10;
errno = 0;
char* end;
long long int result = strtoll(s, &end, base);
diff --git a/include/cutils/native_handle.h b/include/cutils/native_handle.h
index 31695cb..813dadc 100644
--- a/include/cutils/native_handle.h
+++ b/include/cutils/native_handle.h
@@ -57,6 +57,15 @@
native_handle_t* native_handle_create(int numFds, int numInts);
/*
+ * native_handle_clone
+ *
+ * creates a native_handle_t and initializes it from another native_handle_t.
+ * Must be destroyed with native_handle_delete().
+ *
+ */
+native_handle_t* native_handle_clone(const native_handle_t* handle);
+
+/*
* native_handle_delete
*
* frees a native_handle_t allocated with native_handle_create().
diff --git a/libcutils/Android.bp b/libcutils/Android.bp
index 8624d13..955c0ec 100644
--- a/libcutils/Android.bp
+++ b/libcutils/Android.bp
@@ -87,12 +87,6 @@
"uevent.c",
],
- // TODO: remove liblog as whole static library, once we don't have prebuilt that requires
- // liblog symbols present in libcutils.
- whole_static_libs: [
- "liblog",
- ],
-
static_libs: ["libdebuggerd_client"],
export_static_lib_headers: ["libdebuggerd_client"],
diff --git a/libcutils/native_handle.c b/libcutils/native_handle.c
index 7f3479d..cae146d 100644
--- a/libcutils/native_handle.c
+++ b/libcutils/native_handle.c
@@ -44,6 +44,27 @@
return h;
}
+native_handle_t* native_handle_clone(const native_handle_t* handle)
+{
+ native_handle_t* clone = native_handle_create(handle->numFds, handle->numInts);
+ int i;
+
+ for (i = 0; i < handle->numFds; i++) {
+ clone->data[i] = dup(handle->data[i]);
+ if (clone->data[i] < 0) {
+ clone->numFds = i;
+ native_handle_close(clone);
+ native_handle_delete(clone);
+ return NULL;
+ }
+ }
+
+ memcpy(&clone->data[handle->numFds], &handle->data[handle->numFds],
+ sizeof(int) * handle->numInts);
+
+ return clone;
+}
+
int native_handle_delete(native_handle_t* h)
{
if (h) {