summaryrefslogtreecommitdiff
authorTanguy Pruvot <tanguy.pruvot@gmail.com>2014-07-03 09:34:01 (GMT)
committer Tanguy Pruvot <tanguy.pruvot@gmail.com>2014-07-04 13:28:14 (GMT)
commit6a06a1090c5f8c0cefd0f7cf6b266ea42be99c01 (patch)
treeb7b45e4eb8993b520f12f670c08f6c56355ff7a3
parentc847cb88c46a9fc18f92cee02b2c0055f8174394 (diff)
downloadbusybox-6a06a1090c5f8c0cefd0f7cf6b266ea42be99c01.zip
busybox-6a06a1090c5f8c0cefd0f7cf6b266ea42be99c01.tar.gz
busybox-6a06a1090c5f8c0cefd0f7cf6b266ea42be99c01.tar.bz2
android: add a switch to handle Android L
restore support of wait3() librpc: inet_makeaddr() is now in bionic nslookup modified (_res is now hidden in libc dns) tested on kitkat and built on l-preview Note: With static version built on l-preview, nslookup doesnt work on kitkat due to a new socket flag named SOCK_CLOEXEC (0x80000), bacon kernel could be incompatible with this socket option (to check) or dnsproxyd could be not compatible. To be tested on a real Android 5.0 build later... Change-Id: I109bcb6764e84c14c7fc890a6014326238fdf26f Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Diffstat
-rw-r--r--Android.mk14
-rw-r--r--android/librpc/pmap_rmt.c2
-rw-r--r--include/android.h5
-rw-r--r--libbb/android.c2
-rw-r--r--networking/interface.c2
-rw-r--r--networking/nslookup.c61
6 files changed, 66 insertions, 20 deletions
diff --git a/Android.mk b/Android.mk
index b6cf167..201c370 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,9 +1,9 @@
LOCAL_PATH := $(call my-dir)
BB_PATH := $(LOCAL_PATH)
-# Bionic Branches Switches (CM7/AOSP/ICS)
+# Bionic Branches Switches (GB/ICS/L)
BIONIC_ICS := true
-
+BIONIC_L := false
# Make a static library for regex.
include $(CLEAR_VARS)
@@ -19,6 +19,9 @@ LOCAL_SRC_FILES := $(shell cat $(BB_PATH)/android/librpc.sources)
LOCAL_C_INCLUDES := $(BB_PATH)/android/librpc
LOCAL_MODULE := libuclibcrpc
LOCAL_CFLAGS += -fno-strict-aliasing
+ifeq ($(BIONIC_L),true)
+LOCAL_CFLAGS += -DBIONIC_L
+endif
include $(BUILD_STATIC_LIBRARY)
@@ -111,6 +114,7 @@ BUSYBOX_C_INCLUDES = \
$(BB_PATH)/include $(BB_PATH)/libbb \
bionic/libc/private \
bionic/libm/include \
+ bionic/libc \
bionic/libm \
libc/kernel/common \
external/libselinux/include \
@@ -128,11 +132,15 @@ BUSYBOX_CFLAGS = \
-D'CONFIG_DEFAULT_MODULES_DIR="$(KERNEL_MODULES_DIR)"' \
-D'BB_VER="$(strip $(shell $(SUBMAKE) kernelversion)) $(BUSYBOX_SUFFIX)"' -DBB_BT=AUTOCONF_TIMESTAMP
-# to handle differences in ICS (ipv6)
+# to handle differences in ICS/JB (ipv6)
ifeq ($(BIONIC_ICS),true)
BUSYBOX_CFLAGS += -DBIONIC_ICS
endif
+ifeq ($(BIONIC_L),true)
+BUSYBOX_CFLAGS += -DBIONIC_L
+endif
+
# Build the static lib for the recovery tool
diff --git a/android/librpc/pmap_rmt.c b/android/librpc/pmap_rmt.c
index 68089ae..e4dbd44 100644
--- a/android/librpc/pmap_rmt.c
+++ b/android/librpc/pmap_rmt.c
@@ -59,7 +59,7 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
#include <arpa/inet.h>
#define MAX_BROADCAST_SIZE 1400
-#ifdef ANDROID
+#if defined(ANDROID) && !defined(BIONIC_L)
static struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host)
{
struct in_addr a;
diff --git a/include/android.h b/include/android.h
index c3a3282..a96605a 100644
--- a/include/android.h
+++ b/include/android.h
@@ -75,4 +75,9 @@ const char *hasmntopt(const struct mntent *, const char *);
#define _SOCKLEN_T_DECLARED
typedef int socklen_t;
+/* wait3 was removed in android L */
+#ifdef BIONIC_L
+#define wait3(status, options, rusage) wait4(-1, status, options, rusage)
+#endif
+
#endif
diff --git a/libbb/android.c b/libbb/android.c
index 8f2c3c4..f4b8df3 100644
--- a/libbb/android.c
+++ b/libbb/android.c
@@ -70,7 +70,7 @@ struct mntent *getmntent(FILE *fp)
}
/* not used anyway */
-int addmntent(FILE *fp, const struct mntent *mnt)
+int addmntent(FILE *fp UNUSED_PARAM, const struct mntent *mnt UNUSED_PARAM)
{
errno = ENOENT;
return 1;
diff --git a/networking/interface.c b/networking/interface.c
index bf7d2b1..8e95d94 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -54,7 +54,7 @@
#define _PATH_PROCNET_DEV "/proc/net/dev"
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
-#ifdef HAVE_AFINET6
+#if defined(HAVE_AFINET6) && !defined(BIONIC_L)
# ifndef _LINUX_IN6_H
/*
* This is from linux/include/net/ipv6.h
diff --git a/networking/nslookup.c b/networking/nslookup.c
index 77337cf..202356b 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -28,18 +28,31 @@
#include <resolv.h>
#include "libbb.h"
-#ifdef __BIONIC__
+#ifdef ANDROID
# include <netinet/in.h>
-# ifdef ENABLE_FEATURE_IPV6
+# if ENABLE_FEATURE_IPV6
# include <netinet/in6.h>
# endif
-# include <arpa_nameser.h>
-# include <resolv_private.h>
-# include <resolv.h>
-# undef _res
-# define _res (*__res_get_state())
+# define ANDROID_CHANGES
+# ifdef BIONIC_L
+# include <arpa/nameser.h>
+# include <dns/include/resolv_private.h>
+# include <dns/resolv/res_private.h>
+# else
+# include <arpa_nameser.h>
+# include <private/resolv_private.h>
+# include <netbsd/resolv/res_private.h>
+# endif
+
+static struct __res_state res_st;
+struct __res_state * __res_state(void)
+{
+ return &res_st;
+}
#endif
+#define EXT(res) ((&res)->_u._ext)
+
/*
* I'm only implementing non-interactive mode;
* I totally forgot nslookup even had an interactive mode.
@@ -129,13 +142,19 @@ static int print_host(const char *hostname, const char *header)
static void server_print(void)
{
char *server;
- struct sockaddr *sa=NULL;
+ struct sockaddr *sa = NULL;
+
+#if ENABLE_FEATURE_IPV6
+# ifdef ANDROID
+ if (EXT(_res).ext)
+ sa = (struct sockaddr*) &EXT(_res).ext->nsaddrs[0];
+# else
+ sa = (struct sockaddr*)_res._u._ext.nsaddrs[0];
+# endif
-#if ENABLE_FEATURE_IPV6 && !defined(__BIONIC__)
- sa = (struct sockaddr*)_res._u._ext.nsaddrs[0];
if (!sa)
#endif
- sa = (struct sockaddr*)&_res.nsaddr_list[0];
+ sa = (struct sockaddr*) &_res.nsaddr_list[0];
server = xmalloc_sockaddr2dotted_noport(sa);
print_host(server, "Server:");
@@ -153,7 +172,7 @@ static void set_default_dns(const char *server)
if (!server)
return;
- /* NB: this works even with, say, "[::1]:5353"! :) */
+ /* NB: this works even with, say, "[::1]:53"! :) */
lsa = xhost2sockaddr(server, 53);
if (lsa->u.sa.sa_family == AF_INET) {
@@ -161,7 +180,8 @@ static void set_default_dns(const char *server)
/* struct copy */
_res.nsaddr_list[0] = lsa->u.sin;
}
-#if ENABLE_FEATURE_IPV6 && !defined(__BIONIC__)
+
+#if ENABLE_FEATURE_IPV6
/* Hoped libc can cope with IPv4 address there too.
* No such luck, glibc 2.4 segfaults even with IPv6,
* maybe I misunderstand how to make glibc use IPv6 addr?
@@ -170,10 +190,18 @@ static void set_default_dns(const char *server)
// glibc neither SEGVs nor sends any dgrams with this
// (strace shows no socket ops):
//_res.nscount = 0;
- _res._u._ext.nscount = 1;
+ #ifdef ANDROID
+ if (EXT(_res).ext) {
+ EXT(_res).nscount = 1;
+ memcpy(&EXT(_res).ext->nsaddrs[0].sin6, &lsa->u.sin6,
+ sizeof(struct sockaddr_in6));
+ }
+ #else
/* store a pointer to part of malloc'ed lsa */
+ _res._u._ext.nscount = 1;
_res._u._ext.nsaddrs[0] = &lsa->u.sin6;
/* must not free(lsa)! */
+ #endif
}
#endif
}
@@ -192,6 +220,11 @@ int nslookup_main(int argc, char **argv)
/* initialize DNS structure _res used in printing the default
* name server and in the explicit name server option feature. */
res_init();
+
+#ifdef ANDROID
+ res_ninit(&_res);
+#endif
+
/* rfc2133 says this enables IPv6 lookups */
/* (but it also says "may be enabled in /etc/resolv.conf") */
/*_res.options |= RES_USE_INET6;*/