Browse Source
EXPERIMENTAL STATUS! To try things out: Define TERMUX_UNIFIED_HEADERS=1 and build to use the new unified headers. This causes ndk_patches_unified/ to be used to patch the NDK header files instead of ndk_patches/.android-5
Fredrik Fornwall
8 years ago
23 changed files with 4979 additions and 2 deletions
@ -0,0 +1,111 @@ |
|||
Add <arpa/ftp.h> for some ftp defines which some packages needs. |
|||
|
|||
diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h ./usr/include/arpa/ftp.h
|
|||
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/arpa/ftp.h 1970-01-01 01:00:00.000000000 +0100
|
|||
+++ ./usr/include/arpa/ftp.h 2014-02-07 02:07:52.000000000 +0100
|
|||
@@ -0,0 +1,105 @@
|
|||
+/*
|
|||
+ * Copyright (c) 1983, 1989, 1993
|
|||
+ * The Regents of the University of California. All rights reserved.
|
|||
+ *
|
|||
+ * Redistribution and use in source and binary forms, with or without
|
|||
+ * modification, are permitted provided that the following conditions
|
|||
+ * are met:
|
|||
+ * 1. Redistributions of source code must retain the above copyright
|
|||
+ * notice, this list of conditions and the following disclaimer.
|
|||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|||
+ * notice, this list of conditions and the following disclaimer in the
|
|||
+ * documentation and/or other materials provided with the distribution.
|
|||
+ * 4. Neither the name of the University nor the names of its contributors
|
|||
+ * may be used to endorse or promote products derived from this software
|
|||
+ * without specific prior written permission.
|
|||
+ *
|
|||
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|||
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|||
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|||
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|||
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|||
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|||
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|||
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|||
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|||
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|||
+ * SUCH DAMAGE.
|
|||
+ *
|
|||
+ * @(#)ftp.h 8.1 (Berkeley) 6/2/93
|
|||
+ */
|
|||
+
|
|||
+#ifndef _ARPA_FTP_H
|
|||
+#define _ARPA_FTP_H 1
|
|||
+
|
|||
+/* Definitions for FTP; see RFC-765. */
|
|||
+
|
|||
+/*
|
|||
+ * Reply codes.
|
|||
+ */
|
|||
+#define PRELIM 1 /* positive preliminary */
|
|||
+#define COMPLETE 2 /* positive completion */
|
|||
+#define CONTINUE 3 /* positive intermediate */
|
|||
+#define TRANSIENT 4 /* transient negative completion */
|
|||
+#define ERROR 5 /* permanent negative completion */
|
|||
+
|
|||
+/*
|
|||
+ * Type codes
|
|||
+ */
|
|||
+#define TYPE_A 1 /* ASCII */
|
|||
+#define TYPE_E 2 /* EBCDIC */
|
|||
+#define TYPE_I 3 /* image */
|
|||
+#define TYPE_L 4 /* local byte size */
|
|||
+
|
|||
+#ifdef FTP_NAMES
|
|||
+char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
|
|||
+#endif
|
|||
+
|
|||
+/*
|
|||
+ * Form codes
|
|||
+ */
|
|||
+#define FORM_N 1 /* non-print */
|
|||
+#define FORM_T 2 /* telnet format effectors */
|
|||
+#define FORM_C 3 /* carriage control (ASA) */
|
|||
+#ifdef FTP_NAMES
|
|||
+char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
|
|||
+#endif
|
|||
+
|
|||
+/*
|
|||
+ * Structure codes
|
|||
+ */
|
|||
+#define STRU_F 1 /* file (no record structure) */
|
|||
+#define STRU_R 2 /* record structure */
|
|||
+#define STRU_P 3 /* page structure */
|
|||
+#ifdef FTP_NAMES
|
|||
+char *strunames[] = {"0", "File", "Record", "Page" };
|
|||
+#endif
|
|||
+
|
|||
+/*
|
|||
+ * Mode types
|
|||
+ */
|
|||
+#define MODE_S 1 /* stream */
|
|||
+#define MODE_B 2 /* block */
|
|||
+#define MODE_C 3 /* compressed */
|
|||
+#ifdef FTP_NAMES
|
|||
+char *modenames[] = {"0", "Stream", "Block", "Compressed" };
|
|||
+#endif
|
|||
+
|
|||
+/*
|
|||
+ * Record Tokens
|
|||
+ */
|
|||
+#define REC_ESC '\377' /* Record-mode Escape */
|
|||
+#define REC_EOR '\001' /* Record-mode End-of-Record */
|
|||
+#define REC_EOF '\002' /* Record-mode End-of-File */
|
|||
+
|
|||
+/*
|
|||
+ * Block Header
|
|||
+ */
|
|||
+#define BLK_EOR 0x80 /* Block is End-of-Record */
|
|||
+#define BLK_EOF 0x40 /* Block is End-of-File */
|
|||
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
|
|||
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
|
|||
+
|
|||
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
|
|||
+
|
|||
+#endif /* arpa/ftp.h */
|
@ -0,0 +1,88 @@ |
|||
The <arpa/tftp.h> header is needed by inetutils. |
|||
|
|||
diff -N -a -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/arpa/tftp.h ./usr/include/arpa/tftp.h
|
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/arpa/tftp.h 1969-12-31 19:00:00.000000000 -0500
|
|||
+++ ./usr/include/arpa/tftp.h 2015-05-12 15:40:31.648145474 -0400
|
|||
@@ -0,0 +1,82 @@
|
|||
+/*
|
|||
+ * Copyright (c) 1983, 1993
|
|||
+ * The Regents of the University of California. All rights reserved.
|
|||
+ *
|
|||
+ * Redistribution and use in source and binary forms, with or without
|
|||
+ * modification, are permitted provided that the following conditions
|
|||
+ * are met:
|
|||
+ * 1. Redistributions of source code must retain the above copyright
|
|||
+ * notice, this list of conditions and the following disclaimer.
|
|||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|||
+ * notice, this list of conditions and the following disclaimer in the
|
|||
+ * documentation and/or other materials provided with the distribution.
|
|||
+ * 4. Neither the name of the University nor the names of its contributors
|
|||
+ * may be used to endorse or promote products derived from this software
|
|||
+ * without specific prior written permission.
|
|||
+ *
|
|||
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|||
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|||
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|||
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|||
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|||
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|||
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|||
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|||
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|||
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|||
+ * SUCH DAMAGE.
|
|||
+ *
|
|||
+ * @(#)tftp.h 8.1 (Berkeley) 6/2/93
|
|||
+ */
|
|||
+
|
|||
+#ifndef _ARPA_TFTP_H
|
|||
+#define _ARPA_TFTP_H 1
|
|||
+
|
|||
+/*
|
|||
+ * Trivial File Transfer Protocol (IEN-133)
|
|||
+ */
|
|||
+#define SEGSIZE 512 /* data segment size */
|
|||
+
|
|||
+/*
|
|||
+ * Packet types.
|
|||
+ */
|
|||
+#define RRQ 01 /* read request */
|
|||
+#define WRQ 02 /* write request */
|
|||
+#define DATA 03 /* data packet */
|
|||
+#define ACK 04 /* acknowledgement */
|
|||
+#define ERROR 05 /* error code */
|
|||
+
|
|||
+struct tftphdr {
|
|||
+ short th_opcode; /* packet type */
|
|||
+ union {
|
|||
+ char tu_padding[3]; /* sizeof() compat */
|
|||
+ struct {
|
|||
+ union {
|
|||
+ unsigned short tu_block; /* block # */
|
|||
+ short tu_code; /* error code */
|
|||
+ } __attribute__ ((__packed__)) th_u3;
|
|||
+ char tu_data[0]; /* data or error string */
|
|||
+ } __attribute__ ((__packed__)) th_u2;
|
|||
+ char tu_stuff[0]; /* request packet stuff */
|
|||
+ } __attribute__ ((__packed__)) th_u1;
|
|||
+} __attribute__ ((__packed__));
|
|||
+
|
|||
+#define th_block th_u1.th_u2.th_u3.tu_block
|
|||
+#define th_code th_u1.th_u2.th_u3.tu_code
|
|||
+#define th_stuff th_u1.tu_stuff
|
|||
+#define th_data th_u1.th_u2.tu_data
|
|||
+#define th_msg th_u1.th_u2.tu_data
|
|||
+
|
|||
+/*
|
|||
+ * Error codes.
|
|||
+ */
|
|||
+#define EUNDEF 0 /* not defined */
|
|||
+#define ENOTFOUND 1 /* file not found */
|
|||
+#define EACCESS 2 /* access violation */
|
|||
+#define ENOSPACE 3 /* disk full or allocation exceeded */
|
|||
+#define EBADOP 4 /* illegal TFTP operation */
|
|||
+#define EBADID 5 /* unknown transfer ID */
|
|||
+#define EEXISTS 6 /* file already exists */
|
|||
+#define ENOUSER 7 /* no such user */
|
|||
+
|
|||
+#endif /* arpa/tftp.h */
|
@ -0,0 +1,37 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/dlfcn.h ./usr/include/dlfcn.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/dlfcn.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/dlfcn.h 2017-06-18 01:32:23.881672767 +0200
|
|||
@@ -61,23 +61,23 @@
|
|||
|
|||
int dladdr(const void* addr, Dl_info* _Nonnull info); |
|||
|
|||
-enum {
|
|||
+/* Termux modification: Use #define for these instead of an enum
|
|||
+ to improve compatibility with ifdef checks. */
|
|||
#if defined(__LP64__) |
|||
- RTLD_NOW = 2,
|
|||
+# define RTLD_NOW 2
|
|||
#else |
|||
- RTLD_NOW = 0,
|
|||
+# define RTLD_NOW 0
|
|||
#endif |
|||
- RTLD_LAZY = 1,
|
|||
+# define RTLD_LAZY 1
|
|||
|
|||
- RTLD_LOCAL = 0,
|
|||
+# define RTLD_LOCAL 0
|
|||
#if defined(__LP64__) |
|||
- RTLD_GLOBAL = 0x00100,
|
|||
+# define RTLD_GLOBAL 0x00100
|
|||
#else |
|||
- RTLD_GLOBAL = 2,
|
|||
+# define RTLD_GLOBAL 2
|
|||
#endif |
|||
- RTLD_NOLOAD = 4,
|
|||
- RTLD_NODELETE = 0x01000,
|
|||
-};
|
|||
+# define RTLD_NOLOAD 4
|
|||
+# define RTLD_NODELETE 0x01000
|
|||
|
|||
#if defined (__LP64__) |
|||
#define RTLD_DEFAULT __BIONIC_CAST(reinterpret_cast, void*, 0) |
File diff suppressed because it is too large
@ -0,0 +1,17 @@ |
|||
Avoid defining constants which causes at least dpkg build to think that |
|||
sync_file_range(2) is available - which it is not. |
|||
|
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/fcntl.h ./usr/include/fcntl.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/fcntl.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/fcntl.h 2017-06-18 02:03:25.533276409 +0200
|
|||
@@ -61,10 +61,6 @@
|
|||
#define SPLICE_F_MORE 4 |
|||
#define SPLICE_F_GIFT 8 |
|||
|
|||
-#define SYNC_FILE_RANGE_WAIT_BEFORE 1
|
|||
-#define SYNC_FILE_RANGE_WRITE 2
|
|||
-#define SYNC_FILE_RANGE_WAIT_AFTER 4
|
|||
-
|
|||
int creat(const char*, mode_t); |
|||
|
|||
#if __ANDROID_API__ >= 21 |
@ -0,0 +1,27 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/grp.h ./usr/include/grp.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/grp.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/grp.h 2017-06-18 01:40:08.452570901 +0200
|
|||
@@ -52,18 +52,11 @@
|
|||
|
|||
/* Note: Android has thousands and thousands of ids to iterate through. */ |
|||
|
|||
-#if __ANDROID_API__ >= 26
|
|||
-struct group* getgrent(void) __INTRODUCED_IN(26);
|
|||
-
|
|||
-void setgrent(void) __INTRODUCED_IN(26);
|
|||
-void endgrent(void) __INTRODUCED_IN(26);
|
|||
-#endif /* __ANDROID_API__ >= 26 */
|
|||
-
|
|||
-
|
|||
-#if __ANDROID_API__ >= 24
|
|||
-int getgrgid_r(gid_t, struct group*, char*, size_t, struct group**) __INTRODUCED_IN(24);
|
|||
-int getgrnam_r(const char*, struct group*, char*, size_t, struct group**) __INTRODUCED_IN(24);
|
|||
-#endif /* __ANDROID_API__ >= 24 */
|
|||
+static struct group* getgrent(void) { return 0; }
|
|||
+static void setgrent(void) {}
|
|||
+static void endgrent(void) {}
|
|||
+static int getgrgid_r(gid_t gid, struct group * grp, char * buf, size_t buflen, struct group ** result) { *result = 0; return 0; }
|
|||
+static int getgrnam_r(const char * name, struct group * grp, char * buf, size_t buflen, struct group ** result) { *result = 0; return 0; }
|
|||
|
|||
int getgrouplist (const char*, gid_t, gid_t*, int*); |
|||
int initgroups (const char*, gid_t); |
@ -0,0 +1,607 @@ |
|||
/*
|
|||
* Copyright (c) 1995, 1999 |
|||
* Berkeley Software Design, Inc. All rights reserved. |
|||
* |
|||
* Redistribution and use in source and binary forms, with or without |
|||
* modification, are permitted provided that the following conditions |
|||
* are met: |
|||
* 1. Redistributions of source code must retain the above copyright |
|||
* notice, this list of conditions and the following disclaimer. |
|||
* |
|||
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND |
|||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|||
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE |
|||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|||
* SUCH DAMAGE. |
|||
* |
|||
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp |
|||
*/ |
|||
/*
|
|||
Copyright (c) 2013, Kenneth MacKay |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without modification, |
|||
are permitted provided that the following conditions are met: |
|||
* Redistributions of source code must retain the above copyright notice, this |
|||
list of conditions and the following disclaimer. |
|||
* Redistributions in binary form must reproduce the above copyright notice, |
|||
this list of conditions and the following disclaimer in the documentation |
|||
and/or other materials provided with the distribution. |
|||
|
|||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
|||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|||
*/ |
|||
|
|||
#ifndef _IFADDRS_H_ |
|||
#define _IFADDRS_H_ |
|||
|
|||
struct ifaddrs { |
|||
struct ifaddrs *ifa_next; |
|||
char *ifa_name; |
|||
unsigned int ifa_flags; |
|||
struct sockaddr *ifa_addr; |
|||
struct sockaddr *ifa_netmask; |
|||
struct sockaddr *ifa_dstaddr; |
|||
void *ifa_data; |
|||
}; |
|||
|
|||
/*
|
|||
* This may have been defined in <net/if.h>. Note that if <net/if.h> is |
|||
* to be included it must be included before this header file. |
|||
*/ |
|||
#ifndef ifa_broadaddr |
|||
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ |
|||
#endif |
|||
|
|||
#include <sys/cdefs.h> |
|||
|
|||
__BEGIN_DECLS |
|||
static int getifaddrs(struct ifaddrs **ifap); |
|||
static void freeifaddrs(struct ifaddrs *ifa); |
|||
__END_DECLS |
|||
|
|||
#endif |
|||
|
|||
|
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <stddef.h> |
|||
#include <errno.h> |
|||
#include <unistd.h> |
|||
#include <sys/socket.h> |
|||
#include <netpacket/packet.h> |
|||
#include <net/if_arp.h> |
|||
#include <netinet/in.h> |
|||
#include <linux/netlink.h> |
|||
#include <linux/rtnetlink.h> |
|||
|
|||
typedef struct NetlinkList { |
|||
struct NetlinkList *m_next; |
|||
struct nlmsghdr *m_data; |
|||
unsigned int m_size; |
|||
} NetlinkList; |
|||
|
|||
static int netlink_socket(void) |
|||
{ |
|||
int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); |
|||
if (l_socket < 0) return -1; |
|||
|
|||
struct sockaddr_nl l_addr; |
|||
memset(&l_addr, 0, sizeof(l_addr)); |
|||
l_addr.nl_family = AF_NETLINK; |
|||
if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0) { |
|||
close(l_socket); |
|||
return -1; |
|||
} |
|||
|
|||
return l_socket; |
|||
} |
|||
|
|||
static int netlink_send(int p_socket, int p_request) |
|||
{ |
|||
struct { |
|||
struct nlmsghdr m_hdr; |
|||
struct rtgenmsg m_msg; |
|||
} l_data; |
|||
|
|||
memset(&l_data, 0, sizeof(l_data)); |
|||
|
|||
l_data.m_hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); |
|||
l_data.m_hdr.nlmsg_type = p_request; |
|||
l_data.m_hdr.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST; |
|||
l_data.m_hdr.nlmsg_pid = 0; |
|||
l_data.m_hdr.nlmsg_seq = p_socket; |
|||
l_data.m_msg.rtgen_family = AF_UNSPEC; |
|||
|
|||
struct sockaddr_nl l_addr; |
|||
memset(&l_addr, 0, sizeof(l_addr)); |
|||
l_addr.nl_family = AF_NETLINK; |
|||
return (sendto(p_socket, &l_data.m_hdr, l_data.m_hdr.nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr))); |
|||
} |
|||
|
|||
static int netlink_recv(int p_socket, void *p_buffer, size_t p_len) |
|||
{ |
|||
struct msghdr l_msg; |
|||
struct iovec l_iov = { p_buffer, p_len }; |
|||
struct sockaddr_nl l_addr; |
|||
|
|||
for (;;) { |
|||
l_msg.msg_name = (void *)&l_addr; |
|||
l_msg.msg_namelen = sizeof(l_addr); |
|||
l_msg.msg_iov = &l_iov; |
|||
l_msg.msg_iovlen = 1; |
|||
l_msg.msg_control = NULL; |
|||
l_msg.msg_controllen = 0; |
|||
l_msg.msg_flags = 0; |
|||
int l_result = recvmsg(p_socket, &l_msg, 0); |
|||
|
|||
if (l_result < 0) { |
|||
if (errno == EINTR) { |
|||
continue; |
|||
} |
|||
return -2; |
|||
} |
|||
|
|||
if (l_msg.msg_flags & MSG_TRUNC) { |
|||
/* Buffer was too small. */ |
|||
return -1; |
|||
} |
|||
return l_result; |
|||
} |
|||
} |
|||
|
|||
static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done) |
|||
{ |
|||
size_t l_size = 4096; |
|||
void *l_buffer = NULL; |
|||
|
|||
for(;;) { |
|||
free(l_buffer); |
|||
l_buffer = malloc(l_size); |
|||
if (l_buffer == NULL) return NULL; |
|||
|
|||
int l_read = netlink_recv(p_socket, l_buffer, l_size); |
|||
*p_size = l_read; |
|||
if (l_read == -2) { |
|||
free(l_buffer); |
|||
return NULL; |
|||
} |
|||
if (l_read >= 0) { |
|||
pid_t l_pid = getpid(); |
|||
struct nlmsghdr *l_hdr; |
|||
for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read)) { |
|||
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) continue; |
|||
|
|||
if(l_hdr->nlmsg_type == NLMSG_DONE) { |
|||
*p_done = 1; |
|||
break; |
|||
} |
|||
|
|||
if(l_hdr->nlmsg_type == NLMSG_ERROR) { |
|||
free(l_buffer); |
|||
return NULL; |
|||
} |
|||
} |
|||
return (struct nlmsghdr*)l_buffer; |
|||
} |
|||
|
|||
l_size *= 2; |
|||
} |
|||
} |
|||
|
|||
static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size) |
|||
{ |
|||
NetlinkList *l_item = (NetlinkList*)malloc(sizeof(NetlinkList)); |
|||
if (l_item == NULL) return NULL; |
|||
|
|||
l_item->m_next = NULL; |
|||
l_item->m_data = p_data; |
|||
l_item->m_size = p_size; |
|||
return l_item; |
|||
} |
|||
|
|||
static void freeResultList(NetlinkList *p_list) |
|||
{ |
|||
NetlinkList *l_cur; |
|||
while (p_list) { |
|||
l_cur = p_list; |
|||
p_list = p_list->m_next; |
|||
free(l_cur->m_data); |
|||
free(l_cur); |
|||
} |
|||
} |
|||
|
|||
static NetlinkList *getResultList(int p_socket, int p_request) |
|||
{ |
|||
if (netlink_send(p_socket, p_request) < 0) return NULL; |
|||
|
|||
NetlinkList *l_list = NULL; |
|||
NetlinkList *l_end = NULL; |
|||
int l_size; |
|||
int l_done = 0; |
|||
while (!l_done) { |
|||
struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done); |
|||
if (!l_hdr) { |
|||
freeResultList(l_list); |
|||
return NULL; |
|||
} |
|||
|
|||
NetlinkList *l_item = newListItem(l_hdr, l_size); |
|||
if (!l_item) { |
|||
freeResultList(l_list); |
|||
return NULL; |
|||
} |
|||
if (!l_list) { |
|||
l_list = l_item; |
|||
} else { |
|||
l_end->m_next = l_item; |
|||
} |
|||
l_end = l_item; |
|||
} |
|||
return l_list; |
|||
} |
|||
|
|||
static size_t maxSize(size_t a, size_t b) |
|||
{ |
|||
return (a > b ? a : b); |
|||
} |
|||
|
|||
static size_t calcAddrLen(sa_family_t p_family, int p_dataSize) |
|||
{ |
|||
switch (p_family) { |
|||
case AF_INET: |
|||
return sizeof(struct sockaddr_in); |
|||
case AF_INET6: |
|||
return sizeof(struct sockaddr_in6); |
|||
case AF_PACKET: |
|||
return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize); |
|||
default: |
|||
return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize); |
|||
} |
|||
} |
|||
|
|||
static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size) |
|||
{ |
|||
switch (p_family) { |
|||
case AF_INET: |
|||
memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size); |
|||
break; |
|||
case AF_INET6: |
|||
memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size); |
|||
break; |
|||
case AF_PACKET: |
|||
memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size); |
|||
((struct sockaddr_ll*)p_dest)->sll_halen = p_size; |
|||
break; |
|||
default: |
|||
memcpy(p_dest->sa_data, p_data, p_size); |
|||
break; |
|||
} |
|||
p_dest->sa_family = p_family; |
|||
} |
|||
|
|||
static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry) |
|||
{ |
|||
if (!*p_resultList) { |
|||
*p_resultList = p_entry; |
|||
} else { |
|||
struct ifaddrs *l_cur = *p_resultList; |
|||
while(l_cur->ifa_next) { |
|||
l_cur = l_cur->ifa_next; |
|||
} |
|||
l_cur->ifa_next = p_entry; |
|||
} |
|||
} |
|||
|
|||
static int interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList) |
|||
{ |
|||
struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr); |
|||
|
|||
size_t l_nameSize = 0; |
|||
size_t l_addrSize = 0; |
|||
size_t l_dataSize = 0; |
|||
|
|||
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); |
|||
struct rtattr *l_rta; |
|||
for (l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { |
|||
void *l_rtaData = RTA_DATA(l_rta); |
|||
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); |
|||
switch (l_rta->rta_type) { |
|||
case IFLA_ADDRESS: |
|||
case IFLA_BROADCAST: |
|||
l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize)); |
|||
break; |
|||
case IFLA_IFNAME: |
|||
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); |
|||
break; |
|||
case IFLA_STATS: |
|||
l_dataSize += NLMSG_ALIGN(l_rtaSize); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
struct ifaddrs *l_entry = (struct ifaddrs*)malloc(sizeof(struct ifaddrs) + sizeof(int) + l_nameSize + l_addrSize + l_dataSize); |
|||
if (l_entry == NULL) return -1; |
|||
memset(l_entry, 0, sizeof(struct ifaddrs)); |
|||
l_entry->ifa_name = (char*)""; |
|||
|
|||
char *l_index = ((char *)l_entry) + sizeof(struct ifaddrs); |
|||
char *l_name = l_index + sizeof(int); |
|||
char *l_addr = l_name + l_nameSize; |
|||
char *l_data = l_addr + l_addrSize; |
|||
|
|||
/* Save the interface index so we can look it up when handling the addresses. */ |
|||
memcpy(l_index, &l_info->ifi_index, sizeof(int)); |
|||
|
|||
l_entry->ifa_flags = l_info->ifi_flags; |
|||
|
|||
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); |
|||
for (l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { |
|||
void *l_rtaData = RTA_DATA(l_rta); |
|||
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); |
|||
switch (l_rta->rta_type) { |
|||
case IFLA_ADDRESS: |
|||
case IFLA_BROADCAST: |
|||
{ |
|||
size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize); |
|||
makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); |
|||
((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index; |
|||
((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type; |
|||
if (l_rta->rta_type == IFLA_ADDRESS) { |
|||
l_entry->ifa_addr = (struct sockaddr *)l_addr; |
|||
} else { |
|||
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; |
|||
} |
|||
l_addr += NLMSG_ALIGN(l_addrLen); |
|||
break; |
|||
} |
|||
case IFLA_IFNAME: |
|||
strncpy(l_name, (char*)l_rtaData, l_rtaDataSize); |
|||
l_name[l_rtaDataSize] = '\0'; |
|||
l_entry->ifa_name = l_name; |
|||
break; |
|||
case IFLA_STATS: |
|||
memcpy(l_data, l_rtaData, l_rtaDataSize); |
|||
l_entry->ifa_data = l_data; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
addToEnd(p_resultList, l_entry); |
|||
return 0; |
|||
} |
|||
|
|||
static struct ifaddrs *findInterface(int p_index, struct ifaddrs **p_links, int p_numLinks) |
|||
{ |
|||
int l_num = 0; |
|||
struct ifaddrs *l_cur = *p_links; |
|||
while (l_cur && l_num < p_numLinks) { |
|||
char *l_indexPtr = ((char *)l_cur) + sizeof(struct ifaddrs); |
|||
int l_index; |
|||
memcpy(&l_index, l_indexPtr, sizeof(int)); |
|||
if(l_index == p_index) return l_cur; |
|||
|
|||
l_cur = l_cur->ifa_next; |
|||
++l_num; |
|||
} |
|||
return NULL; |
|||
} |
|||
|
|||
static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, int p_numLinks) |
|||
{ |
|||
struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr); |
|||
struct ifaddrs *l_interface = findInterface(l_info->ifa_index, p_resultList, p_numLinks); |
|||
|
|||
if (l_info->ifa_family == AF_PACKET) return 0; |
|||
|
|||
size_t l_nameSize = 0; |
|||
size_t l_addrSize = 0; |
|||
int l_addedNetmask = 0; |
|||
|
|||
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); |
|||
struct rtattr *l_rta; |
|||
for (l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { |
|||
void *l_rtaData = RTA_DATA(l_rta); |
|||
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); |
|||
|
|||
switch (l_rta->rta_type) { |
|||
case IFA_ADDRESS: |
|||
case IFA_LOCAL: |
|||
if ((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask) { |
|||
/* Make room for netmask. */ |
|||
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); |
|||
l_addedNetmask = 1; |
|||
} |
|||
case IFA_BROADCAST: |
|||
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); |
|||
break; |
|||
case IFA_LABEL: |
|||
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
struct ifaddrs *l_entry = (struct ifaddrs*)malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize); |
|||
if (l_entry == NULL) return -1; |
|||
memset(l_entry, 0, sizeof(struct ifaddrs)); |
|||
l_entry->ifa_name = (l_interface ? l_interface->ifa_name : (char*)""); |
|||
|
|||
char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs); |
|||
char *l_addr = l_name + l_nameSize; |
|||
|
|||
l_entry->ifa_flags = l_info->ifa_flags; |
|||
if (l_interface) { |
|||
l_entry->ifa_flags |= l_interface->ifa_flags; |
|||
} |
|||
|
|||
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); |
|||
for (l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize)) { |
|||
void *l_rtaData = RTA_DATA(l_rta); |
|||
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); |
|||
switch (l_rta->rta_type) { |
|||
case IFA_ADDRESS: |
|||
case IFA_BROADCAST: |
|||
case IFA_LOCAL: |
|||
{ |
|||
size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize); |
|||
makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); |
|||
if (l_info->ifa_family == AF_INET6) { |
|||
if (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData)) { |
|||
((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index; |
|||
} |
|||
} |
|||
|
|||
if (l_rta->rta_type == IFA_ADDRESS) { |
|||
/* Apparently in a point-to-point network IFA_ADDRESS contains
|
|||
the dest address and IFA_LOCAL contains the local address. */ |
|||
if(l_entry->ifa_addr) { |
|||
l_entry->ifa_dstaddr = (struct sockaddr *)l_addr; |
|||
} else { |
|||
l_entry->ifa_addr = (struct sockaddr *)l_addr; |
|||
} |
|||
} else if (l_rta->rta_type == IFA_LOCAL) { |
|||
if(l_entry->ifa_addr) { |
|||
l_entry->ifa_dstaddr = l_entry->ifa_addr; |
|||
} |
|||
l_entry->ifa_addr = (struct sockaddr *)l_addr; |
|||
} else { |
|||
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; |
|||
} |
|||
l_addr += NLMSG_ALIGN(l_addrLen); |
|||
break; |
|||
} |
|||
case IFA_LABEL: |
|||
strncpy(l_name, (char*)l_rtaData, l_rtaDataSize); |
|||
l_name[l_rtaDataSize] = '\0'; |
|||
l_entry->ifa_name = l_name; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6)) { |
|||
unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128); |
|||
unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen); |
|||
char l_mask[16] = {0}; |
|||
unsigned i; |
|||
for (i=0; i<(l_prefix/8); ++i) { |
|||
l_mask[i] = 0xff; |
|||
} |
|||
if (l_prefix % 8) { |
|||
l_mask[i] = 0xff << (8 - (l_prefix % 8)); |
|||
} |
|||
|
|||
makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8); |
|||
l_entry->ifa_netmask = (struct sockaddr *)l_addr; |
|||
} |
|||
|
|||
addToEnd(p_resultList, l_entry); |
|||
return 0; |
|||
} |
|||
|
|||
static int interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList) |
|||
{ |
|||
int l_numLinks = 0; |
|||
pid_t l_pid = getpid(); |
|||
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) { |
|||
unsigned int l_nlsize = p_netlinkList->m_size; |
|||
struct nlmsghdr *l_hdr; |
|||
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) |
|||
{ |
|||
if ((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) continue; |
|||
|
|||
if (l_hdr->nlmsg_type == NLMSG_DONE) break; |
|||
|
|||
if (l_hdr->nlmsg_type == RTM_NEWLINK) { |
|||
if(interpretLink(l_hdr, p_resultList) == -1) return -1; |
|||
++l_numLinks; |
|||
} |
|||
} |
|||
} |
|||
return l_numLinks; |
|||
} |
|||
|
|||
static int interpretAddrs(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks) |
|||
{ |
|||
pid_t l_pid = getpid(); |
|||
for (; p_netlinkList; p_netlinkList = p_netlinkList->m_next) { |
|||
unsigned int l_nlsize = p_netlinkList->m_size; |
|||
struct nlmsghdr *l_hdr; |
|||
for (l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) { |
|||
if ((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) continue; |
|||
|
|||
if (l_hdr->nlmsg_type == NLMSG_DONE) break; |
|||
|
|||
if (l_hdr->nlmsg_type == RTM_NEWADDR) { |
|||
if (interpretAddr(l_hdr, p_resultList, p_numLinks) == -1) return -1; |
|||
} |
|||
} |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
static int getifaddrs(struct ifaddrs **ifap) |
|||
{ |
|||
if (!ifap) return -1; |
|||
*ifap = NULL; |
|||
|
|||
int l_socket = netlink_socket(); |
|||
if (l_socket < 0) { |
|||
return -1; |
|||
} |
|||
|
|||
NetlinkList *l_linkResults = getResultList(l_socket, RTM_GETLINK); |
|||
if (!l_linkResults) { |
|||
close(l_socket); |
|||
return -1; |
|||
} |
|||
|
|||
NetlinkList *l_addrResults = getResultList(l_socket, RTM_GETADDR); |
|||
if (!l_addrResults) { |
|||
close(l_socket); |
|||
freeResultList(l_linkResults); |
|||
return -1; |
|||
} |
|||
|
|||
int l_result = 0; |
|||
int l_numLinks = interpretLinks(l_socket, l_linkResults, ifap); |
|||
if (l_numLinks == -1 || interpretAddrs(l_socket, l_addrResults, ifap, l_numLinks) == -1) { |
|||
l_result = -1; |
|||
} |
|||
|
|||
freeResultList(l_linkResults); |
|||
freeResultList(l_addrResults); |
|||
close(l_socket); |
|||
return l_result; |
|||
} |
|||
|
|||
static void freeifaddrs(struct ifaddrs *ifa) |
|||
{ |
|||
struct ifaddrs *l_cur; |
|||
while (ifa) { |
|||
l_cur = ifa; |
|||
ifa = ifa->ifa_next; |
|||
free(l_cur); |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/limits.h ./usr/include/limits.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/limits.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/limits.h 2017-06-18 02:05:17.404056395 +0200
|
|||
@@ -139,7 +139,7 @@
|
|||
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX |
|||
|
|||
#define _POSIX_VERSION 200809L /* Posix C language bindings version */ |
|||
-#define _POSIX2_VERSION -1 /* we don't support Posix command-line tools */
|
|||
+#define _POSIX2_VERSION 200809 /* Termux change to avoid coreutils obsolete breakage */
|
|||
#define _XOPEN_VERSION 700 /* by Posix definition */ |
|||
|
|||
/* >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS */ |
@ -0,0 +1,18 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/linux/fcntl.h ./usr/include/linux/fcntl.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/linux/fcntl.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/linux/fcntl.h 2017-06-18 01:44:54.697429382 +0200
|
|||
@@ -46,6 +46,14 @@
|
|||
#define DN_MULTISHOT 0x80000000 |
|||
#define AT_FDCWD - 100 |
|||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ |
|||
+
|
|||
+/* Termux patch: This flag is not supported on Android 6.0+, and should not
|
|||
+ be needed since there are not setuid binaries. Define AT_EACCESS to 0 to
|
|||
+ avoid packages defining their own AT_EACCESS (which e.g. coreutil does)
|
|||
+ since that will only result in errors. See:
|
|||
+ https://android.googlesource.com/platform/bionic/+/3577825%5E!/ */
|
|||
+#define AT_EACCESS 0
|
|||
+
|
|||
#define AT_SYMLINK_NOFOLLOW 0x100 |
|||
#define AT_REMOVEDIR 0x200 |
|||
#define AT_SYMLINK_FOLLOW 0x400 |
@ -0,0 +1,25 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/paths.h ./usr/include/paths.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/paths.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/paths.h 2017-06-18 01:49:55.374140031 +0200
|
|||
@@ -34,13 +34,19 @@
|
|||
|
|||
#include <sys/cdefs.h> |
|||
|
|||
-#define _PATH_BSHELL "/system/bin/sh"
|
|||
+#define _PATH_BSHELL "@TERMUX_PREFIX@/bin/sh"
|
|||
#define _PATH_CONSOLE "/dev/console" |
|||
-#define _PATH_DEFPATH "/sbin:/system/sbin:/system/bin:/system/xbin:/vendor/bin:/vendor/xbin"
|
|||
+#define _PATH_DEFPATH "@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets"
|
|||
#define _PATH_DEV "/dev/" |
|||
#define _PATH_DEVNULL "/dev/null" |
|||
#define _PATH_KLOG "/proc/kmsg" |
|||
#define _PATH_MOUNTED "/proc/mounts" |
|||
#define _PATH_TTY "/dev/tty" |
|||
|
|||
+#define _PATH_STDPATH _PATH_DEFPATH
|
|||
+#define _PATH_TMP "@TERMUX_PREFIX@/tmp/"
|
|||
+#define _PATH_VARDB "@TERMUX_PREFIX@/var/db/"
|
|||
+#define _PATH_VARRUN "@TERMUX_PREFIX@/var/run/"
|
|||
+#define _PATH_VARTMP "@TERMUX_PREFIX@/var/tmp/"
|
|||
+
|
|||
#endif /* !_PATHS_H_ */ |
@ -0,0 +1,64 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/pwd.h ./usr/include/pwd.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/pwd.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/pwd.h 2017-06-18 01:54:51.654897945 +0200
|
|||
@@ -89,7 +89,6 @@
|
|||
struct passwd* getpwent(void) __INTRODUCED_IN(26); |
|||
|
|||
void setpwent(void) __INTRODUCED_IN(26); |
|||
-void endpwent(void) __INTRODUCED_IN(26);
|
|||
#endif /* __ANDROID_API__ >= 26 */ |
|||
|
|||
|
|||
@@ -99,6 +98,52 @@
|
|||
int getpwuid_r(uid_t, struct passwd*, char*, size_t, struct passwd**) __INTRODUCED_IN(12); |
|||
#endif /* __ANDROID_API__ >= 12 */ |
|||
|
|||
+static void android_setup_pwd(struct passwd* pw) {
|
|||
+ static char realpath_buffer[4096/*PATH_MAX*/];
|
|||
+ char* result = realpath("@TERMUX_HOME@/.termux/shell", realpath_buffer);
|
|||
+ if (result == NULL || access(realpath_buffer, X_OK) == -1) {
|
|||
+ char const* bash_path = "@TERMUX_PREFIX@/bin/bash";
|
|||
+ if (access(bash_path, X_OK) != -1) pw->pw_shell = (char*) bash_path;
|
|||
+ else pw->pw_shell = "@TERMUX_PREFIX@/bin/sh";
|
|||
+ } else {
|
|||
+ pw->pw_shell = realpath_buffer;
|
|||
+ }
|
|||
+ pw->pw_dir = "@TERMUX_HOME@";
|
|||
+ pw->pw_passwd = "*";
|
|||
+#ifdef __LP64__
|
|||
+ pw->pw_gecos = ""; /* Avoid NULL field. */
|
|||
+#endif
|
|||
+}
|
|||
+
|
|||
+static struct passwd* android_polyfill_getpwuid(uid_t t) {
|
|||
+ struct passwd* pw = getpwuid(t);
|
|||
+ if (pw == NULL) return NULL;
|
|||
+ android_setup_pwd(pw);
|
|||
+ return pw;
|
|||
+}
|
|||
+
|
|||
+static struct passwd* android_polyfill_getpwnam(const char* name) {
|
|||
+ struct passwd* pw = getpwnam(name);
|
|||
+ if (pw == NULL) return NULL;
|
|||
+ android_setup_pwd(pw);
|
|||
+ return pw;
|
|||
+}
|
|||
+
|
|||
+static int android_polyfill_getpwuid_r(uid_t uid,
|
|||
+ struct passwd *pwd,
|
|||
+ char *buffer,
|
|||
+ size_t bufsize,
|
|||
+ struct passwd **result) {
|
|||
+ int ret = getpwuid_r(uid, pwd, buffer, bufsize, result);
|
|||
+ if (ret != 0) return ret;
|
|||
+ android_setup_pwd(pwd);
|
|||
+ return 0;
|
|||
+}
|
|||
+
|
|||
+#define getpwnam android_polyfill_getpwnam
|
|||
+#define getpwuid android_polyfill_getpwuid
|
|||
+#define getpwuid_r android_polyfill_getpwuid_r
|
|||
+static void endpwent(void) { /* Do nothing. */ }
|
|||
|
|||
__END_DECLS |
|||
|
@ -0,0 +1,13 @@ |
|||
Fix problem where <linux/route.h> needed <sys/socket.h> to compile. |
|||
|
|||
diff -u -r /Users/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/linux/route.h ./usr/include/linux/route.h
|
|||
--- /Users/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/linux/route.h 2014-10-15 04:53:49.000000000 +0200
|
|||
+++ ./usr/include/linux/route.h 2014-12-14 20:10:13.000000000 +0100
|
|||
@@ -18,6 +18,7 @@
|
|||
****************************************************************************/ |
|||
#ifndef _LINUX_ROUTE_H |
|||
#define _LINUX_ROUTE_H |
|||
+#include <sys/socket.h> /* for struct sockaddr */
|
|||
#include <linux/if.h> |
|||
#include <linux/compiler.h> |
|||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ |
@ -0,0 +1,82 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/include/stdio.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/stdio.h 2017-06-18 01:59:17.835984565 +0200
|
|||
@@ -44,6 +44,9 @@
|
|||
#include <stdarg.h> |
|||
#include <stddef.h> |
|||
|
|||
+#include <string.h> /* For strcpy(3) used by ctermid() */
|
|||
+#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */
|
|||
+
|
|||
#define __need_NULL |
|||
#include <stddef.h> |
|||
|
|||
@@ -174,7 +178,7 @@
|
|||
__warnattr_strict("vsprintf is often misused; please use vsnprintf"); |
|||
char* tmpnam(char*) |
|||
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead"); |
|||
-#define P_tmpdir "/tmp/" /* deprecated */
|
|||
+#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */
|
|||
char* tempnam(const char*, const char*) |
|||
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead"); |
|||
|
|||
@@ -239,8 +243,6 @@
|
|||
__INTRODUCED_IN(24); |
|||
#endif /* __ANDROID_API__ >= 24 */ |
|||
|
|||
-FILE* tmpfile(void);
|
|||
-
|
|||
#if __ANDROID_API__ >= 24 |
|||
FILE* tmpfile64(void) __INTRODUCED_IN(24); |
|||
#endif /* __ANDROID_API__ >= 24 */ |
|||
@@ -256,10 +258,15 @@
|
|||
|
|||
#define L_ctermid 1024 /* size for ctermid() */ |
|||
|
|||
-#if __ANDROID_API__ >= 26
|
|||
-char* ctermid(char*) __INTRODUCED_IN(26);
|
|||
-#endif /* __ANDROID_API__ >= 26 */
|
|||
+/* Needed by gnulibs freading() */
|
|||
+#define __sferror(p) (((p)->_flags & __SERR) != 0)
|
|||
|
|||
+/* Used by perl, fish, and others */
|
|||
+static __inline__ char* ctermid(char* s) {
|
|||
+ if (s == 0) return (char*) "/dev/tty";
|
|||
+ strcpy(s, "/dev/tty");
|
|||
+ return s;
|
|||
+}
|
|||
|
|||
FILE* fdopen(int, const char*); |
|||
int fileno(FILE*); |
|||
@@ -577,4 +584,31 @@
|
|||
|
|||
__END_DECLS |
|||
|
|||
+__BEGIN_DECLS
|
|||
+
|
|||
+int open(const char*, int, ...) __overloadable __RENAME_CLANG(open);
|
|||
+extern pid_t getpid();
|
|||
+extern int unlink(const char*);
|
|||
+void free(void* p);
|
|||
+uint32_t arc4random(void);
|
|||
+static __inline__ FILE* tmpfile() {
|
|||
+ int p = getpid();
|
|||
+ char* path;
|
|||
+ int i;
|
|||
+ for (i = 0; i < 100; i++) {
|
|||
+ unsigned int r = arc4random();
|
|||
+ if (asprintf(&path, "/data/data/com.termux/files/usr/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
|
|||
+ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
|
|||
+ free(path);
|
|||
+ if (fd >= 0) {
|
|||
+ FILE* result = fdopen(fd, "w+");
|
|||
+ unlink(path);
|
|||
+ return result;
|
|||
+ }
|
|||
+ }
|
|||
+ return NULL;
|
|||
+}
|
|||
+
|
|||
+__END_DECLS
|
|||
+
|
|||
#endif /* _STDIO_H_ */ |
@ -0,0 +1,18 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/string.h ./usr/include/string.h
|
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/string.h 2014-12-02 22:38:31.000000000 -0500
|
|||
+++ ./usr/include/string.h 2015-05-08 23:00:18.591924680 -0400
|
|||
@@ -289,6 +289,14 @@
|
|||
|
|||
#endif /* defined(__BIONIC_FORTIFY) */ |
|||
|
|||
+/* Termux: Patched support for GNU extension function mempcpy(3): */
|
|||
+#if defined(_GNU_SOURCE) && defined(TERMUX_EXPOSE_MEMPCPY)
|
|||
+static void* mempcpy(void* dest, void const* src, size_t n)
|
|||
+{
|
|||
+ return memcpy(dest, src, n) + n;
|
|||
+}
|
|||
+#endif
|
|||
+
|
|||
__END_DECLS |
|||
|
|||
#endif /* _STRING_H_ */ |
@ -0,0 +1,22 @@ |
|||
Mosh needs fd_set to be const*. And native code used by the nio4r gem (used by Rails 5) needs fd_mask. |
|||
|
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/sys/select.h ./usr/include/sys/select.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/sys/select.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/sys/select.h 2017-06-18 02:06:53.359009782 +0200
|
|||
@@ -38,6 +38,7 @@
|
|||
__BEGIN_DECLS |
|||
|
|||
#define FD_SETSIZE 1024 |
|||
+typedef unsigned long fd_mask;
|
|||
#define NFDBITS (8 * sizeof(unsigned long)) |
|||
#define __FDSET_LONGS (FD_SETSIZE/NFDBITS) |
|||
|
|||
@@ -62,7 +63,7 @@
|
|||
#if __ANDROID_API__ >= 21 |
|||
void __FD_CLR_chk(int, fd_set*, size_t) __INTRODUCED_IN(21); |
|||
void __FD_SET_chk(int, fd_set*, size_t) __INTRODUCED_IN(21); |
|||
-int __FD_ISSET_chk(int, fd_set*, size_t) __INTRODUCED_IN(21);
|
|||
+int __FD_ISSET_chk(int, fd_set const*, size_t) __INTRODUCED_IN(21);
|
|||
#endif /* __ANDROID_API__ >= 21 */ |
|||
|
|||
|
@ -0,0 +1,14 @@ |
|||
Needed by util-linux. |
|||
|
|||
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/sys/ttydefaults.h ./usr/include/sys/ttydefaults.h
|
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/sys/ttydefaults.h 2016-06-01 12:53:26.000000000 -0400
|
|||
+++ ./usr/include/sys/ttydefaults.h 2016-06-22 06:29:26.247578626 -0400
|
|||
@@ -46,7 +46,7 @@
|
|||
* Defaults on "first" open. |
|||
*/ |
|||
#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY) |
|||
-#define TTYDEF_OFLAG (OPOST | ONLCR | OXTABS)
|
|||
+#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
|
|||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) |
|||
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL) |
|||
#define TTYDEF_SPEED (B9600) |
@ -0,0 +1,17 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/user.h ./usr/include/sys/user.h
|
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/user.h 2014-12-08 21:59:41.000000000 -0500
|
|||
+++ ./usr/include/sys/user.h 2016-01-08 20:08:08.327228220 -0500
|
|||
@@ -99,6 +99,13 @@
|
|||
int u_debugreg[8]; |
|||
}; |
|||
|
|||
+/* Needed by binutils on x86 */
|
|||
+/* http://osxr.org/android/source/bionic/libc/kernel/arch-x86/asm/user_32.h#0089 */
|
|||
+#define NBPG PAGE_SIZE
|
|||
+#define UPAGES 1
|
|||
+#define HOST_TEXT_START_ADDR (u.start_code)
|
|||
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
|
|||
+
|
|||
#elif defined(__x86_64__) |
|||
|
|||
struct user_fpregs_struct { |
@ -0,0 +1,13 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/sys/wait.h ./usr/include/sys/wait.h
|
|||
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/sys/wait.h 2017-06-07 01:07:52.000000000 +0200
|
|||
+++ ./usr/include/sys/wait.h 2017-06-18 02:11:22.268075841 +0200
|
|||
@@ -57,6 +57,9 @@
|
|||
// Implemented as a static inline before 18. |
|||
#endif |
|||
|
|||
+/* Termux addition: Add wait3() declaration used by busybox. Available in libc for 32-bit only. */
|
|||
+static pid_t wait3(int* status, int options, struct rusage* rusage) { return wait4(-1, status, options, rusage); }
|
|||
+
|
|||
/* Posix states that idtype_t should be an enumeration type, but |
|||
* the kernel headers define P_ALL, P_PID and P_PGID as constant macros |
|||
* instead. |
@ -0,0 +1,4 @@ |
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/syscall.h 2016-12-03 21:40:40.033159200 +0530
|
|||
+++ ./usr/include/syscall.h 2016-12-03 19:52:16.226951188 +0530
|
|||
@@ -0,0 +1 @@
|
|||
+#include <sys/syscall.h>
|
@ -0,0 +1,114 @@ |
|||
/*
|
|||
* Copyright (c) 1987, 1993 |
|||
* The Regents of the University of California. All rights reserved. |
|||
* |
|||
* Redistribution and use in source and binary forms, with or without |
|||
* modification, are permitted provided that the following conditions |
|||
* are met: |
|||
* 1. Redistributions of source code must retain the above copyright |
|||
* notice, this list of conditions and the following disclaimer. |
|||
* 2. Redistributions in binary form must reproduce the above copyright |
|||
* notice, this list of conditions and the following disclaimer in the |
|||
* documentation and/or other materials provided with the distribution. |
|||
* 4. Neither the name of the University nor the names of its contributors |
|||
* may be used to endorse or promote products derived from this software |
|||
* without specific prior written permission. |
|||
* |
|||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|||
* SUCH DAMAGE. |
|||
* |
|||
* @(#)sysexits.h 8.1 (Berkeley) 6/2/93 |
|||
*/ |
|||
|
|||
#ifndef _SYSEXITS_H |
|||
#define _SYSEXITS_H 1 |
|||
|
|||
/*
|
|||
* SYSEXITS.H -- Exit status codes for system programs. |
|||
* |
|||
* This include file attempts to categorize possible error |
|||
* exit statuses for system programs, notably delivermail |
|||
* and the Berkeley network. |
|||
* |
|||
* Error numbers begin at EX__BASE to reduce the possibility of |
|||
* clashing with other exit statuses that random programs may |
|||
* already return. The meaning of the codes is approximately |
|||
* as follows: |
|||
* |
|||
* EX_USAGE -- The command was used incorrectly, e.g., with |
|||
* the wrong number of arguments, a bad flag, a bad |
|||
* syntax in a parameter, or whatever. |
|||
* EX_DATAERR -- The input data was incorrect in some way. |
|||
* This should only be used for user's data & not |
|||
* system files. |
|||
* EX_NOINPUT -- An input file (not a system file) did not |
|||
* exist or was not readable. This could also include |
|||
* errors like "No message" to a mailer (if it cared |
|||
* to catch it). |
|||
* EX_NOUSER -- The user specified did not exist. This might |
|||
* be used for mail addresses or remote logins. |
|||
* EX_NOHOST -- The host specified did not exist. This is used |
|||
* in mail addresses or network requests. |
|||
* EX_UNAVAILABLE -- A service is unavailable. This can occur |
|||
* if a support program or file does not exist. This |
|||
* can also be used as a catchall message when something |
|||
* you wanted to do doesn't work, but you don't know |
|||
* why. |
|||
* EX_SOFTWARE -- An internal software error has been detected. |
|||
* This should be limited to non-operating system related |
|||
* errors as possible. |
|||
* EX_OSERR -- An operating system error has been detected. |
|||
* This is intended to be used for such things as "cannot |
|||
* fork", "cannot create pipe", or the like. It includes |
|||
* things like getuid returning a user that does not |
|||
* exist in the passwd file. |
|||
* EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, |
|||
* etc.) does not exist, cannot be opened, or has some |
|||
* sort of error (e.g., syntax error). |
|||
* EX_CANTCREAT -- A (user specified) output file cannot be |
|||
* created. |
|||
* EX_IOERR -- An error occurred while doing I/O on some file. |
|||
* EX_TEMPFAIL -- temporary failure, indicating something that |
|||
* is not really an error. In sendmail, this means |
|||
* that a mailer (e.g.) could not create a connection, |
|||
* and the request should be reattempted later. |
|||
* EX_PROTOCOL -- the remote system returned something that |
|||
* was "not possible" during a protocol exchange. |
|||
* EX_NOPERM -- You did not have sufficient permission to |
|||
* perform the operation. This is not intended for |
|||
* file system problems, which should use NOINPUT or |
|||
* CANTCREAT, but rather for higher level permissions. |
|||
*/ |
|||
|
|||
#define EX_OK 0 /* successful termination */ |
|||
|
|||
#define EX__BASE 64 /* base value for error messages */ |
|||
|
|||
#define EX_USAGE 64 /* command line usage error */ |
|||
#define EX_DATAERR 65 /* data format error */ |
|||
#define EX_NOINPUT 66 /* cannot open input */ |
|||
#define EX_NOUSER 67 /* addressee unknown */ |
|||
#define EX_NOHOST 68 /* host name unknown */ |
|||
#define EX_UNAVAILABLE 69 /* service unavailable */ |
|||
#define EX_SOFTWARE 70 /* internal software error */ |
|||
#define EX_OSERR 71 /* system error (e.g., can't fork) */ |
|||
#define EX_OSFILE 72 /* critical OS file missing */ |
|||
#define EX_CANTCREAT 73 /* can't create (user) output file */ |
|||
#define EX_IOERR 74 /* input/output error */ |
|||
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ |
|||
#define EX_PROTOCOL 76 /* remote error in protocol */ |
|||
#define EX_NOPERM 77 /* permission denied */ |
|||
#define EX_CONFIG 78 /* configuration error */ |
|||
|
|||
#define EX__MAX 78 /* maximum listed value */ |
|||
|
|||
#endif /* sysexits.h */ |
@ -0,0 +1,77 @@ |
|||
diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h ./usr/include/syslog.h
|
|||
--- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h 2012-08-21 07:23:12.000000000 +0200
|
|||
+++ ./usr/include/syslog.h 2014-01-29 17:51:55.000000000 +0100
|
|||
@@ -31,6 +31,8 @@
|
|||
#include <stdio.h> |
|||
#include <sys/cdefs.h> |
|||
#include <stdarg.h> |
|||
+#include <android/log.h> /* for __android_log_vprint() */
|
|||
+#include <unistd.h> /* for getpid() */
|
|||
|
|||
__BEGIN_DECLS |
|||
|
|||
@@ -111,6 +112,64 @@
|
|||
extern void syslog_r(int, struct syslog_data *, const char *, ...); |
|||
extern void vsyslog_r(int, struct syslog_data *, const char *, va_list); |
|||
|
|||
+extern /*const*/ char* __progname;
|
|||
+static __inline__ void android_polyfill_openlog(const char* a, int b, int c) {
|
|||
+ (void) a;
|
|||
+ (void) b;
|
|||
+ (void) c;
|
|||
+}
|
|||
+static __inline__ void android_polyfill_closelog() {}
|
|||
+
|
|||
+static __inline__ void android_polyfill_vsyslog(int syslog_priority, char const* format, va_list ap)
|
|||
+{
|
|||
+ android_LogPriority a = ANDROID_LOG_ERROR;
|
|||
+ switch (syslog_priority) {
|
|||
+ case LOG_WARNING: a = ANDROID_LOG_WARN; break;
|
|||
+ case LOG_NOTICE : a = ANDROID_LOG_INFO; break;
|
|||
+ case LOG_INFO: a = ANDROID_LOG_INFO; break;
|
|||
+ case LOG_DEBUG: a = ANDROID_LOG_DEBUG; break;
|
|||
+ }
|
|||
+ char* syslog_text;
|
|||
+ if (vasprintf(&syslog_text, format, ap) == -1) {
|
|||
+ __android_log_vprint(a, "syslog", format, ap);
|
|||
+ return;
|
|||
+ }
|
|||
+ __android_log_print(a, "syslog", "%s - %s", __progname, syslog_text);
|
|||
+ free(syslog_text);
|
|||
+}
|
|||
+
|
|||
+static __inline__ void android_polyfill_syslog(int priority, const char* format, ...)
|
|||
+{
|
|||
+ va_list myargs;
|
|||
+ va_start(myargs, format);
|
|||
+ android_polyfill_vsyslog(priority, format, myargs);
|
|||
+ va_end(myargs);
|
|||
+}
|
|||
+
|
|||
+static __inline__ void android_polyfill_syslog_r(int syslog_priority, void* d, const char* format, ...)
|
|||
+{
|
|||
+ (void) d;
|
|||
+ va_list myargs;
|
|||
+ va_start(myargs, format);
|
|||
+ android_polyfill_vsyslog(syslog_priority, format, myargs);
|
|||
+ va_end(myargs);
|
|||
+}
|
|||
+
|
|||
+static __inline__ void android_polyfill_vsyslog_r(int syslog_priority, void* d, const char* fmt, va_list ap)
|
|||
+{
|
|||
+ (void) d;
|
|||
+ android_polyfill_vsyslog(syslog_priority, fmt, ap);
|
|||
+}
|
|||
+
|
|||
+#define openlog android_polyfill_openlog
|
|||
+#define closelog android_polyfill_closelog
|
|||
+
|
|||
+#define syslog android_polyfill_syslog
|
|||
+#define syslog_r android_polyfill_syslog_r
|
|||
+
|
|||
+#define vsyslog android_polyfill_vsyslog
|
|||
+#define vsyslog_r android_polyfill_vsyslog_r
|
|||
+
|
|||
__END_DECLS |
|||
|
|||
#endif /* _SYSLOG_H */ |
@ -0,0 +1,12 @@ |
|||
diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/termios.h ./usr/include/termios.h
|
|||
--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/termios.h 2014-10-14 22:53:49.000000000 -0400
|
|||
+++ ./usr/include/termios.h 2015-05-15 18:23:49.264331535 -0400
|
|||
@@ -49,6 +49,8 @@
|
|||
int tcsendbreak(int, int); |
|||
int tcsetattr(int, int, const struct termios*); |
|||
|
|||
+#define _POSIX_VDISABLE 0
|
|||
+
|
|||
__END_DECLS |
|||
|
|||
#endif /* _TERMIOS_H_ */ |
Loading…
Reference in new issue