mirror of
https://github.com/topjohnwu/ndk-box-kitchen.git
synced 2024-11-23 11:29:45 +00:00
Update patches and config
This commit is contained in:
parent
bdd5eb470b
commit
effd7dbd35
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.36.1
|
||||
# Tue May 23 17:20:45 2023
|
||||
# Mon Jul 15 18:16:39 2024
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@ -94,8 +94,8 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SMALL=1
|
||||
CONFIG_SHA1_SMALL=3
|
||||
CONFIG_SHA1_HWACCEL=1
|
||||
CONFIG_SHA256_HWACCEL=1
|
||||
# CONFIG_SHA1_HWACCEL is not set
|
||||
# CONFIG_SHA256_HWACCEL is not set
|
||||
CONFIG_SHA3_SMALL=1
|
||||
# CONFIG_FEATURE_NON_POSIX_CP is not set
|
||||
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
|
||||
@ -298,7 +298,7 @@ CONFIG_MV=y
|
||||
CONFIG_NICE=y
|
||||
CONFIG_NL=y
|
||||
CONFIG_NOHUP=y
|
||||
# CONFIG_NPROC is not set
|
||||
CONFIG_NPROC=y
|
||||
CONFIG_OD=y
|
||||
CONFIG_PASTE=y
|
||||
CONFIG_PRINTENV=y
|
||||
@ -325,7 +325,7 @@ CONFIG_FEATURE_STAT_FILESYSTEM=y
|
||||
CONFIG_STTY=y
|
||||
CONFIG_SUM=y
|
||||
CONFIG_SYNC=y
|
||||
# CONFIG_FEATURE_SYNC_FANCY is not set
|
||||
CONFIG_FEATURE_SYNC_FANCY=y
|
||||
CONFIG_FSYNC=y
|
||||
CONFIG_TAC=y
|
||||
CONFIG_TAIL=y
|
||||
@ -481,7 +481,7 @@ CONFIG_FEATURE_FIND_DELETE=y
|
||||
CONFIG_FEATURE_FIND_EMPTY=y
|
||||
CONFIG_FEATURE_FIND_PATH=y
|
||||
CONFIG_FEATURE_FIND_REGEX=y
|
||||
# CONFIG_FEATURE_FIND_CONTEXT is not set
|
||||
CONFIG_FEATURE_FIND_CONTEXT=y
|
||||
CONFIG_FEATURE_FIND_LINKS=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_EGREP=y
|
||||
@ -503,9 +503,9 @@ CONFIG_FEATURE_XARGS_SUPPORT_ARGS_FILE=y
|
||||
# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set
|
||||
# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set
|
||||
# CONFIG_HALT is not set
|
||||
CONFIG_POWEROFF=y
|
||||
CONFIG_REBOOT=y
|
||||
CONFIG_FEATURE_WAIT_FOR_INIT=y
|
||||
# CONFIG_POWEROFF is not set
|
||||
# CONFIG_REBOOT is not set
|
||||
# CONFIG_FEATURE_WAIT_FOR_INIT is not set
|
||||
# CONFIG_FEATURE_CALL_TELINIT is not set
|
||||
CONFIG_TELINIT_PATH=""
|
||||
# CONFIG_INIT is not set
|
||||
@ -613,7 +613,7 @@ CONFIG_DMESG=y
|
||||
CONFIG_FEATURE_DMESG_PRETTY=y
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_FEATURE_EJECT_SCSI=y
|
||||
# CONFIG_FALLOCATE is not set
|
||||
CONFIG_FALLOCATE=y
|
||||
CONFIG_FATATTR=y
|
||||
CONFIG_FBSET=y
|
||||
CONFIG_FEATURE_FBSET_FANCY=y
|
||||
@ -661,11 +661,11 @@ CONFIG_MESG=y
|
||||
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
|
||||
CONFIG_MKE2FS=y
|
||||
CONFIG_MKFS_EXT2=y
|
||||
CONFIG_MKFS_MINIX=y
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
CONFIG_MKFS_REISER=y
|
||||
CONFIG_MKDOSFS=y
|
||||
CONFIG_MKFS_VFAT=y
|
||||
# CONFIG_MKFS_MINIX is not set
|
||||
# CONFIG_FEATURE_MINIX2 is not set
|
||||
# CONFIG_MKFS_REISER is not set
|
||||
# CONFIG_MKDOSFS is not set
|
||||
# CONFIG_MKFS_VFAT is not set
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_UUID=y
|
||||
CONFIG_MORE=y
|
||||
@ -968,8 +968,8 @@ CONFIG_PSCAN=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_SLATTACH=y
|
||||
CONFIG_SSL_CLIENT=y
|
||||
# CONFIG_TC is not set
|
||||
# CONFIG_FEATURE_TC_INGRESS is not set
|
||||
CONFIG_TC=y
|
||||
CONFIG_FEATURE_TC_INGRESS=y
|
||||
CONFIG_TCPSVD=y
|
||||
CONFIG_UDPSVD=y
|
||||
CONFIG_TELNET=y
|
||||
@ -1208,7 +1208,7 @@ CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
# CONFIG_FEATURE_SH_STANDALONE is not set
|
||||
# CONFIG_FEATURE_SH_NOFORK is not set
|
||||
CONFIG_FEATURE_SH_READ_FRAC=y
|
||||
CONFIG_FEATURE_SH_HISTFILESIZE=y
|
||||
# CONFIG_FEATURE_SH_HISTFILESIZE is not set
|
||||
CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS=y
|
||||
|
||||
#
|
||||
|
@ -5,11 +5,9 @@ include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := busybox
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_STATIC_LIBRARIES := libselinux
|
||||
LOCAL_DISABLE_FORMAT_STRING_CHECKS := true
|
||||
LOCAL_LDFLAGS := -static -Wl,--wrap=realpath -Wl,--wrap=rename -Wl,--wrap=renameat
|
||||
LOCAL_CFLAGS := \
|
||||
-w -include include/autoconf.h -D__USE_BSD -D__USE_GNU \
|
||||
-DBB_VER=\"$(BB_VER)\" -DBB_BT=AUTOCONF_TIMESTAMP \
|
||||
-Wno-implicit-function-declaration
|
||||
-DBB_VER=\"$(BB_VER)\" -DBB_BT=AUTOCONF_TIMESTAMP
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
|
106
patches/0001-Fix-incorrect-assumptions-about-NDK.patch
Normal file
106
patches/0001-Fix-incorrect-assumptions-about-NDK.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From 4d264bc921b1a74381d356167b4c15673c819456 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sat, 13 Jul 2024 18:26:16 -0700
|
||||
Subject: [PATCH 01/17] Fix incorrect assumptions about NDK
|
||||
|
||||
---
|
||||
include/platform.h | 5 ++++-
|
||||
libbb/missing_syscalls.c | 22 ----------------------
|
||||
miscutils/adjtimex.c | 6 +-----
|
||||
util-linux/swaponoff.c | 4 +---
|
||||
4 files changed, 6 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/include/platform.h b/include/platform.h
|
||||
index ea0512f36..e5bb07799 100644
|
||||
--- a/include/platform.h
|
||||
+++ b/include/platform.h
|
||||
@@ -545,12 +545,15 @@ typedef unsigned smalluint;
|
||||
# if __ANDROID_API__ >= 21
|
||||
# undef HAVE_WAIT3
|
||||
# endif
|
||||
+# if __ANDROID_API__ < 24
|
||||
+# undef HAVE_STRCHRNUL
|
||||
+# endif
|
||||
# undef HAVE_MEMPCPY
|
||||
-# undef HAVE_STRCHRNUL
|
||||
# undef HAVE_STRVERSCMP
|
||||
# undef HAVE_UNLOCKED_LINE_OPS
|
||||
# undef HAVE_NET_ETHERNET_H
|
||||
# undef HAVE_PRINTF_PERCENTM
|
||||
+# undef HAVE_SETBIT
|
||||
#endif
|
||||
|
||||
/*
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index dc40d9155..92b44b388 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -8,33 +8,11 @@
|
||||
#include "libbb.h"
|
||||
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
-/*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
|
||||
# include <sys/syscall.h>
|
||||
-pid_t getsid(pid_t pid)
|
||||
-{
|
||||
- return syscall(__NR_getsid, pid);
|
||||
-}
|
||||
-
|
||||
-int sethostname(const char *name, size_t len)
|
||||
-{
|
||||
- return syscall(__NR_sethostname, name, len);
|
||||
-}
|
||||
-
|
||||
-struct timex;
|
||||
-int adjtimex(struct timex *buf)
|
||||
-{
|
||||
- return syscall(__NR_adjtimex, buf);
|
||||
-}
|
||||
|
||||
int pivot_root(const char *new_root, const char *put_old)
|
||||
{
|
||||
return syscall(__NR_pivot_root, new_root, put_old);
|
||||
}
|
||||
|
||||
-# if __ANDROID_API__ < 21
|
||||
-int tcdrain(int fd)
|
||||
-{
|
||||
- return ioctl(fd, TCSBRK, 1);
|
||||
-}
|
||||
-# endif
|
||||
#endif
|
||||
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
|
||||
index 209d1d560..06ee8e903 100644
|
||||
--- a/miscutils/adjtimex.c
|
||||
+++ b/miscutils/adjtimex.c
|
||||
@@ -33,11 +33,7 @@
|
||||
//usage: "\n -p TCONST"
|
||||
|
||||
#include "libbb.h"
|
||||
-#ifdef __BIONIC__
|
||||
-# include <linux/timex.h>
|
||||
-#else
|
||||
-# include <sys/timex.h>
|
||||
-#endif
|
||||
+#include <sys/timex.h>
|
||||
|
||||
static const uint16_t statlist_bit[] ALIGN2 = {
|
||||
STA_PLL,
|
||||
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
|
||||
index e2ff4b5cc..67c384db6 100644
|
||||
--- a/util-linux/swaponoff.c
|
||||
+++ b/util-linux/swaponoff.c
|
||||
@@ -75,9 +75,7 @@
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include <mntent.h>
|
||||
-#ifndef __BIONIC__
|
||||
-# include <sys/swap.h>
|
||||
-#endif
|
||||
+#include <sys/swap.h>
|
||||
|
||||
#if ENABLE_FEATURE_SWAPONOFF_LABEL
|
||||
# include "volume_id.h"
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 534ef9f1b0676c20c9a821127e6cdf8107fb6cc7 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Fri, 27 Nov 2015 11:40:52 -0400
|
||||
Subject: [PATCH 01/35] Fix mconf/lkc host "warning statement with no effect"
|
||||
|
||||
---
|
||||
scripts/kconfig/lkc.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
|
||||
index 527f60c99..1972cb9a0 100644
|
||||
--- a/scripts/kconfig/lkc.h
|
||||
+++ b/scripts/kconfig/lkc.h
|
||||
@@ -12,8 +12,8 @@
|
||||
# include <libintl.h>
|
||||
#else
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
-# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
+# define textdomain(Domainname)
|
||||
+# define bindtextdomain(Domainname, Dirname)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 048f41aea9fbaa920166369e4cf89fe1cc31693e Mon Sep 17 00:00:00 2001
|
||||
From 62dc3c2191e35983b619fc750f9f731c4a84a232 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Thu, 3 Dec 2015 01:29:35 -0400
|
||||
Subject: [PATCH 07/35] loadfont/setfont/conspy: add missing header
|
||||
Subject: [PATCH 02/17] loadfont/setfont/conspy: add missing header
|
||||
|
||||
Imported from dorimanx's combined ported header toolchain:
|
||||
https://github.com/dorimanx/android-busybox-ndk
|
@ -1,325 +0,0 @@
|
||||
From 00804b71ea96cdba92b33727e9c1b19ef14ff0bd Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Tue, 4 May 2021 00:56:55 -0300
|
||||
Subject: [PATCH 03/35] android: fix 'mount', 'umount', 'fsck', 'df'
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>, based on 'Bionic Patch V1.0' by Vitaly Greck
|
||||
https://code.google.com/p/busybox-android/downloads/detail?name=patch
|
||||
Rebased for busybox 1.33.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
libbb/Kbuild.src | 3 +
|
||||
libbb/mntent_r.c | 288 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 291 insertions(+)
|
||||
create mode 100644 libbb/mntent_r.c
|
||||
|
||||
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
|
||||
index 653025e56..33c33b6be 100644
|
||||
--- a/libbb/Kbuild.src
|
||||
+++ b/libbb/Kbuild.src
|
||||
@@ -118,6 +118,9 @@ lib-y += xgethostbyname.o
|
||||
lib-y += xreadlink.o
|
||||
lib-y += xrealloc_vector.o
|
||||
|
||||
+# for android-busybox-ndk
|
||||
+lib-y += mntent_r.o
|
||||
+
|
||||
lib-$(CONFIG_MOUNT) += match_fstype.o
|
||||
lib-$(CONFIG_UMOUNT) += match_fstype.o
|
||||
|
||||
diff --git a/libbb/mntent_r.c b/libbb/mntent_r.c
|
||||
new file mode 100644
|
||||
index 000000000..107748740
|
||||
--- /dev/null
|
||||
+++ b/libbb/mntent_r.c
|
||||
@@ -0,0 +1,288 @@
|
||||
+/* Utilities for reading/writing fstab, mtab, etc.
|
||||
+ Copyright (C) 1995-2000, 2001, 2002, 2003, 2006, 2010, 2011
|
||||
+ Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+// file extracted from patch 'Bionic Patch V1.0 (Vitaly Greck)':
|
||||
+// https://busybox-android.googlecode.com/files/patch
|
||||
+//
|
||||
+// looks like its based on misc/mntent_r.c from glibc,
|
||||
+// contains all fixes in current master (2012-03-19),
|
||||
+// but is not source identical (mostly stuff removed)
|
||||
+// using the upstream one fails to build
|
||||
+
|
||||
+
|
||||
+#include <alloca.h>
|
||||
+#include <mntent.h>
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+
|
||||
+/* Prepare to begin reading and/or writing mount table entries from the
|
||||
+ beginning of FILE. MODE is as for `fopen'. */
|
||||
+FILE *setmntent (const char *file, const char *mode)
|
||||
+{
|
||||
+ /* Extend the mode parameter with "c" to disable cancellation in the
|
||||
+ I/O functions and "e" to set FD_CLOEXEC. */
|
||||
+ size_t modelen = strlen (mode);
|
||||
+ char newmode[modelen + 3];
|
||||
+ memcpy (newmode, mode, modelen);
|
||||
+ memcpy (newmode + modelen, "ce", 3);
|
||||
+ FILE *result = fopen (file, newmode);
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Close a stream opened with `setmntent'. */
|
||||
+int endmntent (FILE *stream)
|
||||
+{
|
||||
+ if (stream) /* SunOS 4.x allows for NULL stream */
|
||||
+ fclose (stream);
|
||||
+ return 1; /* SunOS 4.x says to always return 1 */
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Since the values in a line are separated by spaces, a name cannot
|
||||
+ contain a space. Therefore some programs encode spaces in names
|
||||
+ by the strings "\040". We undo the encoding when reading an entry.
|
||||
+ The decoding happens in place. */
|
||||
+static char *
|
||||
+decode_name (char *buf)
|
||||
+{
|
||||
+ char *rp = buf;
|
||||
+ char *wp = buf;
|
||||
+
|
||||
+ do
|
||||
+ if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '4' && rp[3] == '0')
|
||||
+ {
|
||||
+ /* \040 is a SPACE. */
|
||||
+ *wp++ = ' ';
|
||||
+ rp += 3;
|
||||
+ }
|
||||
+ else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '1')
|
||||
+ {
|
||||
+ /* \011 is a TAB. */
|
||||
+ *wp++ = '\t';
|
||||
+ rp += 3;
|
||||
+ }
|
||||
+ else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2')
|
||||
+ {
|
||||
+ /* \012 is a NEWLINE. */
|
||||
+ *wp++ = '\n';
|
||||
+ rp += 3;
|
||||
+ }
|
||||
+ else if (rp[0] == '\\' && rp[1] == '\\')
|
||||
+ {
|
||||
+ /* We have to escape \\ to be able to represent all characters. */
|
||||
+ *wp++ = '\\';
|
||||
+ rp += 1;
|
||||
+ }
|
||||
+ else if (rp[0] == '\\' && rp[1] == '1' && rp[2] == '3' && rp[3] == '4')
|
||||
+ {
|
||||
+ /* \134 is also \\. */
|
||||
+ *wp++ = '\\';
|
||||
+ rp += 3;
|
||||
+ }
|
||||
+ else
|
||||
+ *wp++ = *rp;
|
||||
+ while (*rp++ != '\0');
|
||||
+
|
||||
+ return buf;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Read one mount table entry from STREAM. Returns a pointer to storage
|
||||
+ reused on the next call, or null for EOF or error (use feof/ferror to
|
||||
+ check). */
|
||||
+struct mntent *getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
|
||||
+{
|
||||
+ char *cp;
|
||||
+ char *head;
|
||||
+
|
||||
+ do
|
||||
+ {
|
||||
+ char *end_ptr;
|
||||
+
|
||||
+ if (fgets (buffer, bufsiz, stream) == NULL)
|
||||
+ {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ end_ptr = strchr (buffer, '\n');
|
||||
+ if (end_ptr != NULL) /* chop newline */
|
||||
+ *end_ptr = '\0';
|
||||
+ else
|
||||
+ {
|
||||
+ /* Not the whole line was read. Do it now but forget it. */
|
||||
+ char tmp[1024];
|
||||
+ while (fgets (tmp, sizeof tmp, stream) != NULL)
|
||||
+ if (strchr (tmp, '\n') != NULL)
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ head = buffer + strspn (buffer, " \t");
|
||||
+ /* skip empty lines and comment lines: */
|
||||
+ }
|
||||
+ while (head[0] == '\0' || head[0] == '#');
|
||||
+
|
||||
+ cp = strsep (&head, " \t");
|
||||
+ mp->mnt_fsname = cp != NULL ? decode_name (cp) : (char *) "";
|
||||
+ if (head)
|
||||
+ head += strspn (head, " \t");
|
||||
+ cp = strsep (&head, " \t");
|
||||
+ mp->mnt_dir = cp != NULL ? decode_name (cp) : (char *) "";
|
||||
+ if (head)
|
||||
+ head += strspn (head, " \t");
|
||||
+ cp = strsep (&head, " \t");
|
||||
+ mp->mnt_type = cp != NULL ? decode_name (cp) : (char *) "";
|
||||
+ if (head)
|
||||
+ head += strspn (head, " \t");
|
||||
+ cp = strsep (&head, " \t");
|
||||
+ mp->mnt_opts = cp != NULL ? decode_name (cp) : (char *) "";
|
||||
+ switch (head ? sscanf (head, " %d %d ", &mp->mnt_freq, &mp->mnt_passno) : 0)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ mp->mnt_freq = 0;
|
||||
+ case 1:
|
||||
+ mp->mnt_passno = 0;
|
||||
+ case 2:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return mp;
|
||||
+}
|
||||
+
|
||||
+struct mntent *getmntent (FILE *stream)
|
||||
+{
|
||||
+ static struct mntent m;
|
||||
+ static char *getmntent_buffer;
|
||||
+
|
||||
+ #define BUFFER_SIZE 4096
|
||||
+ if (getmntent_buffer == NULL) {
|
||||
+ getmntent_buffer = (char *) malloc (BUFFER_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ return getmntent_r (stream, &m, getmntent_buffer, BUFFER_SIZE);
|
||||
+ #undef BUFFER_SIZE
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* We have to use an encoding for names if they contain spaces or tabs.
|
||||
+ To be able to represent all characters we also have to escape the
|
||||
+ backslash itself. This "function" must be a macro since we use
|
||||
+ `alloca'. */
|
||||
+#define encode_name(name) \
|
||||
+ do { \
|
||||
+ const char *rp = name; \
|
||||
+ \
|
||||
+ while (*rp != '\0') \
|
||||
+ if (*rp == ' ' || *rp == '\t' || *rp == '\n' || *rp == '\\') \
|
||||
+ break; \
|
||||
+ else \
|
||||
+ ++rp; \
|
||||
+ \
|
||||
+ if (*rp != '\0') \
|
||||
+ { \
|
||||
+ /* In the worst case the length of the string can increase to \
|
||||
+ four times the current length. */ \
|
||||
+ char *wp; \
|
||||
+ \
|
||||
+ rp = name; \
|
||||
+ name = wp = (char *) alloca (strlen (name) * 4 + 1); \
|
||||
+ \
|
||||
+ do \
|
||||
+ if (*rp == ' ') \
|
||||
+ { \
|
||||
+ *wp++ = '\\'; \
|
||||
+ *wp++ = '0'; \
|
||||
+ *wp++ = '4'; \
|
||||
+ *wp++ = '0'; \
|
||||
+ } \
|
||||
+ else if (*rp == '\t') \
|
||||
+ { \
|
||||
+ *wp++ = '\\'; \
|
||||
+ *wp++ = '0'; \
|
||||
+ *wp++ = '1'; \
|
||||
+ *wp++ = '1'; \
|
||||
+ } \
|
||||
+ else if (*rp == '\n') \
|
||||
+ { \
|
||||
+ *wp++ = '\\'; \
|
||||
+ *wp++ = '0'; \
|
||||
+ *wp++ = '1'; \
|
||||
+ *wp++ = '2'; \
|
||||
+ } \
|
||||
+ else if (*rp == '\\') \
|
||||
+ { \
|
||||
+ *wp++ = '\\'; \
|
||||
+ *wp++ = '\\'; \
|
||||
+ } \
|
||||
+ else \
|
||||
+ *wp++ = *rp; \
|
||||
+ while (*rp++ != '\0'); \
|
||||
+ } \
|
||||
+ } while (0)
|
||||
+
|
||||
+
|
||||
+/* Write the mount table entry described by MNT to STREAM.
|
||||
+ Return zero on success, nonzero on failure. */
|
||||
+int addmntent (FILE *stream, const struct mntent *mnt)
|
||||
+{
|
||||
+ struct mntent mntcopy = *mnt;
|
||||
+ if (fseek (stream, 0, SEEK_END))
|
||||
+ return 1;
|
||||
+
|
||||
+ /* Encode spaces and tabs in the names. */
|
||||
+ encode_name (mntcopy.mnt_fsname);
|
||||
+ encode_name (mntcopy.mnt_dir);
|
||||
+ encode_name (mntcopy.mnt_type);
|
||||
+ encode_name (mntcopy.mnt_opts);
|
||||
+
|
||||
+ return (fprintf (stream, "%s %s %s %s %d %d\n",
|
||||
+ mntcopy.mnt_fsname,
|
||||
+ mntcopy.mnt_dir,
|
||||
+ mntcopy.mnt_type,
|
||||
+ mntcopy.mnt_opts,
|
||||
+ mntcopy.mnt_freq,
|
||||
+ mntcopy.mnt_passno) < 0
|
||||
+ || fflush (stream) != 0);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* Search MNT->mnt_opts for an option matching OPT.
|
||||
+ Returns the address of the substring, or null if none found. */
|
||||
+char *hasmntopt (const struct mntent *mnt, const char *opt)
|
||||
+{
|
||||
+ const size_t optlen = strlen (opt);
|
||||
+ char *rest = mnt->mnt_opts, *p;
|
||||
+
|
||||
+ while ((p = strstr (rest, opt)) != NULL)
|
||||
+ {
|
||||
+ if ((p == rest || p[-1] == ',')
|
||||
+ && (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ','))
|
||||
+ return p;
|
||||
+
|
||||
+ rest = strchr (p, ',');
|
||||
+ if (rest == NULL)
|
||||
+ break;
|
||||
+ ++rest;
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 187cfa9753417e5033aa8893ca4e0299c934ebac Mon Sep 17 00:00:00 2001
|
||||
From 9cf0fa6cd156d864a738c21d34ee273392c56dfc Mon Sep 17 00:00:00 2001
|
||||
From: Tias Guns <tias@ulyssis.org>
|
||||
Date: Tue, 20 Mar 2012 21:26:07 +0000
|
||||
Subject: [PATCH 13/35] fix ipcs, ipcrm no sys/sem-shm-msg, etc
|
||||
Subject: [PATCH 03/17] fix ipcs, ipcrm no sys/sem-shm-msg, etc
|
||||
|
||||
patch from 'no-sys-shm,msg,sem' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
25
patches/0004-Bionic-does-not-have-ether_hostton.patch
Normal file
25
patches/0004-Bionic-does-not-have-ether_hostton.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 41a741b2213a0f127c239e163d1f8f894f5390f6 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sat, 13 Jul 2024 18:35:56 -0700
|
||||
Subject: [PATCH 04/17] Bionic does not have ether_hostton
|
||||
|
||||
---
|
||||
networking/ether-wake.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
|
||||
index 36e90acfb..0bbf2057f 100644
|
||||
--- a/networking/ether-wake.c
|
||||
+++ b/networking/ether-wake.c
|
||||
@@ -130,7 +130,7 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
|
||||
eap = ether_aton_r(hostid, eaddr);
|
||||
if (eap) {
|
||||
bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap));
|
||||
-#if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
|
||||
+#if !defined(__BIONIC__) && (!defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30))
|
||||
} else if (ether_hostton(hostid, eaddr) == 0) {
|
||||
bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr));
|
||||
#endif
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,530 +0,0 @@
|
||||
From f753b7bd2c777ff5b31c5faba49537c7095e1614 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Thu, 3 Dec 2015 17:01:57 -0400
|
||||
Subject: [PATCH 04/35] eject: add missing headers
|
||||
|
||||
Imported from dorimanx's combined ported header toolchain:
|
||||
https://github.com/dorimanx/android-busybox-ndk
|
||||
---
|
||||
include/scsi/scsi.h | 225 ++++++++++++++++++++++++++++++++++++
|
||||
include/scsi/sg.h | 276 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 501 insertions(+)
|
||||
create mode 100644 include/scsi/scsi.h
|
||||
create mode 100644 include/scsi/sg.h
|
||||
|
||||
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
|
||||
new file mode 100644
|
||||
index 000000000..06377ab00
|
||||
--- /dev/null
|
||||
+++ b/include/scsi/scsi.h
|
||||
@@ -0,0 +1,225 @@
|
||||
+/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/*
|
||||
+ * This header file contains public constants and structures used by
|
||||
+ * the scsi code for linux.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _SCSI_SCSI_H
|
||||
+#define _SCSI_SCSI_H 1
|
||||
+
|
||||
+#include <features.h>
|
||||
+
|
||||
+/*
|
||||
+ * SCSI opcodes
|
||||
+ */
|
||||
+
|
||||
+#define TEST_UNIT_READY 0x00
|
||||
+#define REZERO_UNIT 0x01
|
||||
+#define REQUEST_SENSE 0x03
|
||||
+#define FORMAT_UNIT 0x04
|
||||
+#define READ_BLOCK_LIMITS 0x05
|
||||
+#define REASSIGN_BLOCKS 0x07
|
||||
+#define READ_6 0x08
|
||||
+#define WRITE_6 0x0a
|
||||
+#define SEEK_6 0x0b
|
||||
+#define READ_REVERSE 0x0f
|
||||
+#define WRITE_FILEMARKS 0x10
|
||||
+#define SPACE 0x11
|
||||
+#define INQUIRY 0x12
|
||||
+#define RECOVER_BUFFERED_DATA 0x14
|
||||
+#define MODE_SELECT 0x15
|
||||
+#define RESERVE 0x16
|
||||
+#define RELEASE 0x17
|
||||
+#define COPY 0x18
|
||||
+#define ERASE 0x19
|
||||
+#define MODE_SENSE 0x1a
|
||||
+#define START_STOP 0x1b
|
||||
+#define RECEIVE_DIAGNOSTIC 0x1c
|
||||
+#define SEND_DIAGNOSTIC 0x1d
|
||||
+#define ALLOW_MEDIUM_REMOVAL 0x1e
|
||||
+
|
||||
+#define SET_WINDOW 0x24
|
||||
+#define READ_CAPACITY 0x25
|
||||
+#define READ_10 0x28
|
||||
+#define WRITE_10 0x2a
|
||||
+#define SEEK_10 0x2b
|
||||
+#define WRITE_VERIFY 0x2e
|
||||
+#define VERIFY 0x2f
|
||||
+#define SEARCH_HIGH 0x30
|
||||
+#define SEARCH_EQUAL 0x31
|
||||
+#define SEARCH_LOW 0x32
|
||||
+#define SET_LIMITS 0x33
|
||||
+#define PRE_FETCH 0x34
|
||||
+#define READ_POSITION 0x34
|
||||
+#define SYNCHRONIZE_CACHE 0x35
|
||||
+#define LOCK_UNLOCK_CACHE 0x36
|
||||
+#define READ_DEFECT_DATA 0x37
|
||||
+#define MEDIUM_SCAN 0x38
|
||||
+#define COMPARE 0x39
|
||||
+#define COPY_VERIFY 0x3a
|
||||
+#define WRITE_BUFFER 0x3b
|
||||
+#define READ_BUFFER 0x3c
|
||||
+#define UPDATE_BLOCK 0x3d
|
||||
+#define READ_LONG 0x3e
|
||||
+#define WRITE_LONG 0x3f
|
||||
+#define CHANGE_DEFINITION 0x40
|
||||
+#define WRITE_SAME 0x41
|
||||
+#define READ_TOC 0x43
|
||||
+#define LOG_SELECT 0x4c
|
||||
+#define LOG_SENSE 0x4d
|
||||
+#define MODE_SELECT_10 0x55
|
||||
+#define RESERVE_10 0x56
|
||||
+#define RELEASE_10 0x57
|
||||
+#define MODE_SENSE_10 0x5a
|
||||
+#define PERSISTENT_RESERVE_IN 0x5e
|
||||
+#define PERSISTENT_RESERVE_OUT 0x5f
|
||||
+#define MOVE_MEDIUM 0xa5
|
||||
+#define READ_12 0xa8
|
||||
+#define WRITE_12 0xaa
|
||||
+#define WRITE_VERIFY_12 0xae
|
||||
+#define SEARCH_HIGH_12 0xb0
|
||||
+#define SEARCH_EQUAL_12 0xb1
|
||||
+#define SEARCH_LOW_12 0xb2
|
||||
+#define READ_ELEMENT_STATUS 0xb8
|
||||
+#define SEND_VOLUME_TAG 0xb6
|
||||
+#define WRITE_LONG_2 0xea
|
||||
+
|
||||
+/*
|
||||
+ * Status codes
|
||||
+ */
|
||||
+
|
||||
+#define GOOD 0x00
|
||||
+#define CHECK_CONDITION 0x01
|
||||
+#define CONDITION_GOOD 0x02
|
||||
+#define BUSY 0x04
|
||||
+#define INTERMEDIATE_GOOD 0x08
|
||||
+#define INTERMEDIATE_C_GOOD 0x0a
|
||||
+#define RESERVATION_CONFLICT 0x0c
|
||||
+#define COMMAND_TERMINATED 0x11
|
||||
+#define QUEUE_FULL 0x14
|
||||
+
|
||||
+#define STATUS_MASK 0x3e
|
||||
+
|
||||
+/*
|
||||
+ * SENSE KEYS
|
||||
+ */
|
||||
+
|
||||
+#define NO_SENSE 0x00
|
||||
+#define RECOVERED_ERROR 0x01
|
||||
+#define NOT_READY 0x02
|
||||
+#define MEDIUM_ERROR 0x03
|
||||
+#define HARDWARE_ERROR 0x04
|
||||
+#define ILLEGAL_REQUEST 0x05
|
||||
+#define UNIT_ATTENTION 0x06
|
||||
+#define DATA_PROTECT 0x07
|
||||
+#define BLANK_CHECK 0x08
|
||||
+#define COPY_ABORTED 0x0a
|
||||
+#define ABORTED_COMMAND 0x0b
|
||||
+#define VOLUME_OVERFLOW 0x0d
|
||||
+#define MISCOMPARE 0x0e
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * DEVICE TYPES
|
||||
+ */
|
||||
+
|
||||
+#define TYPE_DISK 0x00
|
||||
+#define TYPE_TAPE 0x01
|
||||
+#define TYPE_PROCESSOR 0x03 /* HP scanners use this */
|
||||
+#define TYPE_WORM 0x04 /* Treated as ROM by our system */
|
||||
+#define TYPE_ROM 0x05
|
||||
+#define TYPE_SCANNER 0x06
|
||||
+#define TYPE_MOD 0x07 /* Magneto-optical disk -
|
||||
+ * - treated as TYPE_DISK */
|
||||
+#define TYPE_MEDIUM_CHANGER 0x08
|
||||
+#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */
|
||||
+#define TYPE_NO_LUN 0x7f
|
||||
+
|
||||
+/*
|
||||
+ * standard mode-select header prepended to all mode-select commands
|
||||
+ *
|
||||
+ * moved here from cdrom.h -- kraxel
|
||||
+ */
|
||||
+
|
||||
+struct ccs_modesel_head
|
||||
+ {
|
||||
+ unsigned char _r1; /* reserved. */
|
||||
+ unsigned char medium; /* device-specific medium type. */
|
||||
+ unsigned char _r2; /* reserved. */
|
||||
+ unsigned char block_desc_length; /* block descriptor length. */
|
||||
+ unsigned char density; /* device-specific density code. */
|
||||
+ unsigned char number_blocks_hi; /* number of blocks in this block
|
||||
+ desc. */
|
||||
+ unsigned char number_blocks_med;
|
||||
+ unsigned char number_blocks_lo;
|
||||
+ unsigned char _r3;
|
||||
+ unsigned char block_length_hi; /* block length for blocks in this
|
||||
+ desc. */
|
||||
+ unsigned char block_length_med;
|
||||
+ unsigned char block_length_lo;
|
||||
+ };
|
||||
+
|
||||
+/*
|
||||
+ * MESSAGE CODES
|
||||
+ */
|
||||
+
|
||||
+#define COMMAND_COMPLETE 0x00
|
||||
+#define EXTENDED_MESSAGE 0x01
|
||||
+#define EXTENDED_MODIFY_DATA_POINTER 0x00
|
||||
+#define EXTENDED_SDTR 0x01
|
||||
+#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */
|
||||
+#define EXTENDED_WDTR 0x03
|
||||
+#define SAVE_POINTERS 0x02
|
||||
+#define RESTORE_POINTERS 0x03
|
||||
+#define DISCONNECT 0x04
|
||||
+#define INITIATOR_ERROR 0x05
|
||||
+#define ABORT 0x06
|
||||
+#define MESSAGE_REJECT 0x07
|
||||
+#define NOP 0x08
|
||||
+#define MSG_PARITY_ERROR 0x09
|
||||
+#define LINKED_CMD_COMPLETE 0x0a
|
||||
+#define LINKED_FLG_CMD_COMPLETE 0x0b
|
||||
+#define BUS_DEVICE_RESET 0x0c
|
||||
+
|
||||
+#define INITIATE_RECOVERY 0x0f /* SCSI-II only */
|
||||
+#define RELEASE_RECOVERY 0x10 /* SCSI-II only */
|
||||
+
|
||||
+#define SIMPLE_QUEUE_TAG 0x20
|
||||
+#define HEAD_OF_QUEUE_TAG 0x21
|
||||
+#define ORDERED_QUEUE_TAG 0x22
|
||||
+
|
||||
+/*
|
||||
+ * Here are some scsi specific ioctl commands which are sometimes useful.
|
||||
+ */
|
||||
+/* These are a few other constants only used by scsi devices. */
|
||||
+
|
||||
+#define SCSI_IOCTL_GET_IDLUN 0x5382
|
||||
+
|
||||
+/* Used to turn on and off tagged queuing for scsi devices. */
|
||||
+
|
||||
+#define SCSI_IOCTL_TAGGED_ENABLE 0x5383
|
||||
+#define SCSI_IOCTL_TAGGED_DISABLE 0x5384
|
||||
+
|
||||
+/* Used to obtain the host number of a device. */
|
||||
+#define SCSI_IOCTL_PROBE_HOST 0x5385
|
||||
+
|
||||
+/* Used to get the bus number for a device. */
|
||||
+#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
|
||||
+
|
||||
+#endif /* scsi/scsi.h */
|
||||
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
|
||||
new file mode 100644
|
||||
index 000000000..767945236
|
||||
--- /dev/null
|
||||
+++ b/include/scsi/sg.h
|
||||
@@ -0,0 +1,276 @@
|
||||
+/* Copyright (C) 1997-2015 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/*
|
||||
+ History:
|
||||
+ Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user
|
||||
+ process control of SCSI devices.
|
||||
+ Development Sponsored by Killy Corp. NY NY
|
||||
+*/
|
||||
+
|
||||
+#ifndef _SCSI_SG_H
|
||||
+#define _SCSI_SG_H 1
|
||||
+
|
||||
+#include <features.h>
|
||||
+#define __need_size_t
|
||||
+#include <stddef.h>
|
||||
+
|
||||
+
|
||||
+/* New interface introduced in the 3.x SG drivers follows */
|
||||
+
|
||||
+/* Same structure as used by readv() Linux system call. It defines one
|
||||
+ scatter-gather element. */
|
||||
+typedef struct sg_iovec
|
||||
+{
|
||||
+ void * iov_base; /* Starting address */
|
||||
+ size_t iov_len; /* Length in bytes */
|
||||
+} sg_iovec_t;
|
||||
+
|
||||
+
|
||||
+typedef struct sg_io_hdr
|
||||
+{
|
||||
+ int interface_id; /* [i] 'S' for SCSI generic (required) */
|
||||
+ int dxfer_direction; /* [i] data transfer direction */
|
||||
+ unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
|
||||
+ unsigned char mx_sb_len; /* [i] max length to write to sbp */
|
||||
+ unsigned short int iovec_count; /* [i] 0 implies no scatter gather */
|
||||
+ unsigned int dxfer_len; /* [i] byte count of data transfer */
|
||||
+ void * dxferp; /* [i], [*io] points to data transfer memory
|
||||
+ or scatter gather list */
|
||||
+ unsigned char * cmdp; /* [i], [*i] points to command to perform */
|
||||
+ unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */
|
||||
+ unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
|
||||
+ unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
|
||||
+ int pack_id; /* [i->o] unused internally (normally) */
|
||||
+ void * usr_ptr; /* [i->o] unused internally */
|
||||
+ unsigned char status; /* [o] scsi status */
|
||||
+ unsigned char masked_status;/* [o] shifted, masked scsi status */
|
||||
+ unsigned char msg_status; /* [o] messaging level data (optional) */
|
||||
+ unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
|
||||
+ unsigned short int host_status; /* [o] errors from host adapter */
|
||||
+ unsigned short int driver_status;/* [o] errors from software driver */
|
||||
+ int resid; /* [o] dxfer_len - actual_transferred */
|
||||
+ unsigned int duration; /* [o] time taken by cmd (unit: millisec) */
|
||||
+ unsigned int info; /* [o] auxiliary information */
|
||||
+} sg_io_hdr_t;
|
||||
+
|
||||
+
|
||||
+/* Use negative values to flag difference from original sg_header structure. */
|
||||
+#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */
|
||||
+#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */
|
||||
+#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */
|
||||
+#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
|
||||
+ additional property than during indirect
|
||||
+ IO the user buffer is copied into the
|
||||
+ kernel buffers before the transfer */
|
||||
+
|
||||
+
|
||||
+/* following flag values can be "or"-ed together */
|
||||
+#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */
|
||||
+#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */
|
||||
+ /* the 2nd byte of SCSI command */
|
||||
+#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */
|
||||
+ /* user space (debug indirect IO) */
|
||||
+
|
||||
+/* The following 'info' values are "or"-ed together. */
|
||||
+#define SG_INFO_OK_MASK 0x1
|
||||
+#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */
|
||||
+#define SG_INFO_CHECK 0x1 /* something abnormal happened */
|
||||
+
|
||||
+#define SG_INFO_DIRECT_IO_MASK 0x6
|
||||
+#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */
|
||||
+#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */
|
||||
+#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */
|
||||
+
|
||||
+
|
||||
+/* Request information about a specific SG device, used by
|
||||
+ SG_GET_SCSI_ID ioctl (). */
|
||||
+struct sg_scsi_id {
|
||||
+ /* Host number as in "scsi<n>" where 'n' is one of 0, 1, 2 etc. */
|
||||
+ int host_no;
|
||||
+ int channel;
|
||||
+ /* SCSI id of target device. */
|
||||
+ int scsi_id;
|
||||
+ int lun;
|
||||
+ /* TYPE_... defined in <scsi/scsi.h>. */
|
||||
+ int scsi_type;
|
||||
+ /* Host (adapter) maximum commands per lun. */
|
||||
+ short int h_cmd_per_lun;
|
||||
+ /* Device (or adapter) maximum queue length. */
|
||||
+ short int d_queue_depth;
|
||||
+ /* Unused, set to 0 for now. */
|
||||
+ int unused[2];
|
||||
+};
|
||||
+
|
||||
+/* Used by SG_GET_REQUEST_TABLE ioctl(). */
|
||||
+typedef struct sg_req_info {
|
||||
+ char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */
|
||||
+ char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */
|
||||
+ char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */
|
||||
+ char problem; /* 0 -> no problem detected, 1 -> error to report */
|
||||
+ int pack_id; /* pack_id associated with request */
|
||||
+ void * usr_ptr; /* user provided pointer (in new interface) */
|
||||
+ unsigned int duration; /* millisecs elapsed since written (req_state==1)
|
||||
+ or request duration (req_state==2) */
|
||||
+ int unused;
|
||||
+} sg_req_info_t;
|
||||
+
|
||||
+
|
||||
+/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow.
|
||||
+ [Those that only apply to the SG 2.x drivers are at the end of the file.]
|
||||
+ (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */
|
||||
+
|
||||
+#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
|
||||
+
|
||||
+/* Used to configure SCSI command transformation layer for ATAPI devices */
|
||||
+/* Only supported by the ide-scsi driver */
|
||||
+#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */
|
||||
+ /* 3rd arg = 0 to disable transform, 1 to enable it */
|
||||
+#define SG_GET_TRANSFORM 0x2205
|
||||
+
|
||||
+#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */
|
||||
+#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */
|
||||
+
|
||||
+/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */
|
||||
+#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */
|
||||
+/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */
|
||||
+
|
||||
+/* Override host setting and always DMA using low memory ( <16MB on i386) */
|
||||
+#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */
|
||||
+#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */
|
||||
+
|
||||
+/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which
|
||||
+ tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN.
|
||||
+ If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0
|
||||
+ then pack_id ignored by read() and oldest readable fetched. */
|
||||
+#define SG_SET_FORCE_PACK_ID 0x227b
|
||||
+#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */
|
||||
+
|
||||
+#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */
|
||||
+
|
||||
+/* Yields max scatter gather tablesize allowed by current host adapter */
|
||||
+#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */
|
||||
+
|
||||
+#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
|
||||
+
|
||||
+/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */
|
||||
+#define SG_SCSI_RESET 0x2284
|
||||
+/* Associated values that can be given to SG_SCSI_RESET follow */
|
||||
+#define SG_SCSI_RESET_NOTHING 0
|
||||
+#define SG_SCSI_RESET_DEVICE 1
|
||||
+#define SG_SCSI_RESET_BUS 2
|
||||
+#define SG_SCSI_RESET_HOST 3
|
||||
+
|
||||
+/* synchronous SCSI command ioctl, (only in version 3 interface) */
|
||||
+#define SG_IO 0x2285 /* similar effect as write() followed by read() */
|
||||
+
|
||||
+#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */
|
||||
+
|
||||
+/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */
|
||||
+#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */
|
||||
+#define SG_GET_KEEP_ORPHAN 0x2288
|
||||
+
|
||||
+
|
||||
+#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */
|
||||
+/* Largest size (in bytes) a single scatter-gather list element can have.
|
||||
+ The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on
|
||||
+ i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported
|
||||
+ by adapter then this value is the largest data block that can be
|
||||
+ read/written by a single scsi command. The user can find the value of
|
||||
+ PAGE_SIZE by calling getpagesize() defined in unistd.h . */
|
||||
+
|
||||
+#define SG_DEFAULT_RETRIES 1
|
||||
+
|
||||
+/* Defaults, commented if they differ from original sg driver */
|
||||
+#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */
|
||||
+#define SG_DEF_FORCE_PACK_ID 0
|
||||
+#define SG_DEF_KEEP_ORPHAN 0
|
||||
+#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */
|
||||
+
|
||||
+/* maximum outstanding requests, write() yields EDOM if exceeded */
|
||||
+#define SG_MAX_QUEUE 16
|
||||
+
|
||||
+#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */
|
||||
+
|
||||
+/* Alternate style type names, "..._t" variants preferred */
|
||||
+typedef struct sg_io_hdr Sg_io_hdr;
|
||||
+typedef struct sg_io_vec Sg_io_vec;
|
||||
+typedef struct sg_scsi_id Sg_scsi_id;
|
||||
+typedef struct sg_req_info Sg_req_info;
|
||||
+
|
||||
+
|
||||
+/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
|
||||
+/* The older SG interface based on the 'sg_header' structure follows. */
|
||||
+/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
|
||||
+
|
||||
+#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */
|
||||
+
|
||||
+struct sg_header
|
||||
+ {
|
||||
+ /* Length of incoming packet (including header). */
|
||||
+ int pack_len;
|
||||
+ /* Maximal length of expected reply. */
|
||||
+ int reply_len;
|
||||
+ /* Id number of packet. */
|
||||
+ int pack_id;
|
||||
+ /* 0==ok, otherwise error number. */
|
||||
+ int result;
|
||||
+ /* Force 12 byte command length for group 6 & 7 commands. */
|
||||
+ unsigned int twelve_byte:1;
|
||||
+ /* SCSI status from target. */
|
||||
+ unsigned int target_status:5;
|
||||
+ /* Host status (see "DID" codes). */
|
||||
+ unsigned int host_status:8;
|
||||
+ /* Driver status+suggestion. */
|
||||
+ unsigned int driver_status:8;
|
||||
+ /* Unused. */
|
||||
+ unsigned int other_flags:10;
|
||||
+ /* Output in 3 cases:
|
||||
+ when target_status is CHECK_CONDITION or
|
||||
+ when target_status is COMMAND_TERMINATED or
|
||||
+ when (driver_status & DRIVER_SENSE) is true. */
|
||||
+ unsigned char sense_buffer[SG_MAX_SENSE];
|
||||
+ };
|
||||
+
|
||||
+
|
||||
+/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t
|
||||
+ interface is used. They are kept for backward compatibility with
|
||||
+ the original and version 2 drivers. */
|
||||
+
|
||||
+#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */
|
||||
+#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */
|
||||
+
|
||||
+/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */
|
||||
+#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */
|
||||
+#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */
|
||||
+
|
||||
+/* Turn on error sense trace (1..8), dump this device to log/console (9)
|
||||
+ or dump all sg device states ( >9 ) to log/console. */
|
||||
+#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */
|
||||
+
|
||||
+#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given
|
||||
+ number on the next write() on this file
|
||||
+ descriptor. */
|
||||
+
|
||||
+/* Defaults, commented if they differ from original sg driver */
|
||||
+#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */
|
||||
+#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when
|
||||
+ the new interface is used */
|
||||
+#define SG_DEF_UNDERRUN_FLAG 0
|
||||
+
|
||||
+
|
||||
+#endif /* scsi/sg.h */
|
||||
--
|
||||
2.45.2
|
||||
|
45
patches/0005-Prevent-duplicate-in6_ifreq-definition.patch
Normal file
45
patches/0005-Prevent-duplicate-in6_ifreq-definition.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 79bdb8978e9ffcfc4799ed00206602d5e57b5844 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sun, 14 Jul 2024 16:54:36 -0700
|
||||
Subject: [PATCH 05/17] Prevent duplicate in6_ifreq definition
|
||||
|
||||
---
|
||||
networking/ifconfig.c | 8 --------
|
||||
networking/interface.c | 2 +-
|
||||
2 files changed, 1 insertion(+), 9 deletions(-)
|
||||
|
||||
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
|
||||
index 9ee232a66..06898b6d2 100644
|
||||
--- a/networking/ifconfig.c
|
||||
+++ b/networking/ifconfig.c
|
||||
@@ -127,14 +127,6 @@
|
||||
# define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */
|
||||
#endif
|
||||
|
||||
-#if ENABLE_FEATURE_IPV6
|
||||
-struct in6_ifreq {
|
||||
- struct in6_addr ifr6_addr;
|
||||
- uint32_t ifr6_prefixlen;
|
||||
- int ifr6_ifindex;
|
||||
-};
|
||||
-#endif
|
||||
-
|
||||
/*
|
||||
* Here are the bit masks for the "flags" member of struct options below.
|
||||
* N_ signifies no arg prefix; M_ signifies arg prefixed by '-'.
|
||||
diff --git a/networking/interface.c b/networking/interface.c
|
||||
index 6b6c0944a..cf48733da 100644
|
||||
--- a/networking/interface.c
|
||||
+++ b/networking/interface.c
|
||||
@@ -54,7 +54,7 @@
|
||||
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
|
||||
|
||||
#ifdef HAVE_AFINET6
|
||||
-# ifndef _LINUX_IN6_H
|
||||
+# ifndef _UAPI_IPV6_H
|
||||
/*
|
||||
* This is from linux/include/net/ipv6.h
|
||||
*/
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,253 +0,0 @@
|
||||
From b454f643056e7b0e7799f202370e0a2ec3893665 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Tue, 10 Jan 2017 10:24:29 -0400
|
||||
Subject: [PATCH 05/35] fix udhcpd and nameif, add ether_ntoa_r and
|
||||
ether_aton_r from glibc
|
||||
|
||||
this patch also fixes part of arping and ether-wake, but not sufficiently yet
|
||||
|
||||
Patch modified by Tias Guns <tias@ulyssis.org> from 'ether_XtoY-from-glibc' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
Rebased for busybox 1.26.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
networking/arping.c | 1 +
|
||||
networking/ether-wake.c | 6 ++--
|
||||
networking/ether_aton_r.c | 63 +++++++++++++++++++++++++++++++++++++
|
||||
networking/ether_ntoa_r.c | 33 +++++++++++++++++++
|
||||
networking/ether_port.h | 29 +++++++++++++++++
|
||||
networking/nameif.c | 1 +
|
||||
networking/udhcp/Kbuild.src | 1 +
|
||||
networking/udhcp/dhcpd.c | 4 +++
|
||||
8 files changed, 136 insertions(+), 2 deletions(-)
|
||||
create mode 100644 networking/ether_aton_r.c
|
||||
create mode 100644 networking/ether_ntoa_r.c
|
||||
create mode 100644 networking/ether_port.h
|
||||
|
||||
diff --git a/networking/arping.c b/networking/arping.c
|
||||
index 86f0221ed..6a1b8bae1 100644
|
||||
--- a/networking/arping.c
|
||||
+++ b/networking/arping.c
|
||||
@@ -14,6 +14,7 @@
|
||||
//applet:IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_ARPING) += arping.o
|
||||
+//kbuild:lib-$(CONFIG_ARPING) += ether_ntoa_r.o
|
||||
|
||||
//usage:#define arping_trivial_usage
|
||||
//usage: "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP"
|
||||
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
|
||||
index 36e90acfb..809c0d9f0 100644
|
||||
--- a/networking/ether-wake.c
|
||||
+++ b/networking/ether-wake.c
|
||||
@@ -72,6 +72,7 @@
|
||||
//applet:IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake))
|
||||
|
||||
//kbuild:lib-$(CONFIG_ETHER_WAKE) += ether-wake.o
|
||||
+//kbuild:lib-$(CONFIG_ETHER_WAKE) += ether_aton_r.o ether_ntoa_r.o
|
||||
|
||||
//usage:#define ether_wake_trivial_usage
|
||||
//usage: "[-b] [-i IFACE] [-p aa:bb:cc:dd[:ee:ff]/a.b.c.d] MAC"
|
||||
@@ -126,13 +127,14 @@ void bb_debug_dump_packet(unsigned char *outpack, int pktsize)
|
||||
static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
|
||||
{
|
||||
struct ether_addr *eap;
|
||||
+ char ether_buf[20];
|
||||
|
||||
eap = ether_aton_r(hostid, eaddr);
|
||||
if (eap) {
|
||||
- bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap));
|
||||
+ bb_debug_msg("The target station address is %s\n\n", ether_ntoa_r(eap, ether_buf));
|
||||
#if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
|
||||
} else if (ether_hostton(hostid, eaddr) == 0) {
|
||||
- bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr));
|
||||
+ bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa_r(eaddr, ether_buf));
|
||||
#endif
|
||||
} else {
|
||||
bb_show_usage();
|
||||
diff --git a/networking/ether_aton_r.c b/networking/ether_aton_r.c
|
||||
new file mode 100644
|
||||
index 000000000..0215f16d4
|
||||
--- /dev/null
|
||||
+++ b/networking/ether_aton_r.c
|
||||
@@ -0,0 +1,63 @@
|
||||
+/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, write to the Free
|
||||
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
+ 02111-1307 USA. */
|
||||
+
|
||||
+#include <ctype.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <netinet/ether.h>
|
||||
+#include <netinet/if_ether.h>
|
||||
+
|
||||
+
|
||||
+struct ether_addr *
|
||||
+ether_aton_r (const char *asc, struct ether_addr *addr)
|
||||
+{
|
||||
+ size_t cnt;
|
||||
+
|
||||
+ for (cnt = 0; cnt < 6; ++cnt)
|
||||
+ {
|
||||
+ unsigned int number;
|
||||
+ char ch;
|
||||
+
|
||||
+ ch = tolower (*asc++);
|
||||
+ if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
|
||||
+ return NULL;
|
||||
+ number = isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
|
||||
+
|
||||
+ ch = tolower (*asc);
|
||||
+ if ((cnt < 5 && ch != ':') || (cnt == 5 && ch != '\0' && !isspace (ch)))
|
||||
+ {
|
||||
+ ++asc;
|
||||
+ if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
|
||||
+ return NULL;
|
||||
+ number <<= 4;
|
||||
+ number += isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
|
||||
+
|
||||
+ ch = *asc;
|
||||
+ if (cnt < 5 && ch != ':')
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /* Store result. */
|
||||
+ addr->ether_addr_octet[cnt] = (unsigned char) number;
|
||||
+
|
||||
+ /* Skip ':'. */
|
||||
+ ++asc;
|
||||
+ }
|
||||
+
|
||||
+ return addr;
|
||||
+}
|
||||
diff --git a/networking/ether_ntoa_r.c b/networking/ether_ntoa_r.c
|
||||
new file mode 100644
|
||||
index 000000000..cd5061434
|
||||
--- /dev/null
|
||||
+++ b/networking/ether_ntoa_r.c
|
||||
@@ -0,0 +1,33 @@
|
||||
+/* Copyright (C) 1996,97,2002 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, write to the Free
|
||||
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
+ 02111-1307 USA. */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <netinet/ether.h>
|
||||
+#include <netinet/if_ether.h>
|
||||
+
|
||||
+
|
||||
+char *
|
||||
+ether_ntoa_r (const struct ether_addr *addr, char *buf)
|
||||
+{
|
||||
+ sprintf (buf, "%x:%x:%x:%x:%x:%x",
|
||||
+ addr->ether_addr_octet[0], addr->ether_addr_octet[1],
|
||||
+ addr->ether_addr_octet[2], addr->ether_addr_octet[3],
|
||||
+ addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
|
||||
+ return buf;
|
||||
+}
|
||||
diff --git a/networking/ether_port.h b/networking/ether_port.h
|
||||
new file mode 100644
|
||||
index 000000000..5e0146b29
|
||||
--- /dev/null
|
||||
+++ b/networking/ether_port.h
|
||||
@@ -0,0 +1,29 @@
|
||||
+/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, write to the Free
|
||||
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
+ 02111-1307 USA. */
|
||||
+
|
||||
+#ifndef ETHER_PORT_H
|
||||
+#define ETHER_PORT_H 1
|
||||
+
|
||||
+#include <netinet/ether.h>
|
||||
+#include <netinet/if_ether.h>
|
||||
+
|
||||
+struct ether_addr * ether_aton_r (const char *asc, struct ether_addr *addr);
|
||||
+char * ether_ntoa_r (const struct ether_addr *addr, char *buf);
|
||||
+
|
||||
+#endif /* ETHER_PORT_H */
|
||||
diff --git a/networking/nameif.c b/networking/nameif.c
|
||||
index 66e042688..15a7b9c94 100644
|
||||
--- a/networking/nameif.c
|
||||
+++ b/networking/nameif.c
|
||||
@@ -41,6 +41,7 @@
|
||||
//applet:IF_NAMEIF(APPLET_NOEXEC(nameif, nameif, BB_DIR_SBIN, BB_SUID_DROP, nameif))
|
||||
|
||||
//kbuild:lib-$(CONFIG_NAMEIF) += nameif.o
|
||||
+//kbuild:lib-$(CONFIG_NAMEIF) += ether_aton_r.o
|
||||
|
||||
//usage:#define nameif_trivial_usage
|
||||
//usage: IF_NOT_FEATURE_NAMEIF_EXTENDED(
|
||||
diff --git a/networking/udhcp/Kbuild.src b/networking/udhcp/Kbuild.src
|
||||
index fcb725fbc..2d5739c7e 100644
|
||||
--- a/networking/udhcp/Kbuild.src
|
||||
+++ b/networking/udhcp/Kbuild.src
|
||||
@@ -14,6 +14,7 @@ lib-$(CONFIG_UDHCPD) += common.o packet.o signalpipe.o socket.o
|
||||
|
||||
lib-$(CONFIG_UDHCPC) += dhcpc.o
|
||||
lib-$(CONFIG_UDHCPD) += dhcpd.o arpping.o
|
||||
+lib-$(CONFIG_UDHCPD) += ../ether_aton_r.o ../ether_ntoa_r.o
|
||||
lib-$(CONFIG_DUMPLEASES) += dumpleases.o
|
||||
lib-$(CONFIG_DHCPRELAY) += dhcprelay.o common.o socket.o packet.o
|
||||
|
||||
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
|
||||
index 66750e2e6..aeebb12f3 100644
|
||||
--- a/networking/udhcp/dhcpd.c
|
||||
+++ b/networking/udhcp/dhcpd.c
|
||||
@@ -40,8 +40,12 @@
|
||||
//usage: "\nSignals:"
|
||||
//usage: "\n USR1 Update lease file"
|
||||
|
||||
+#include <sys/types.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <syslog.h>
|
||||
+
|
||||
+#include "../ether_port.h"
|
||||
+
|
||||
#include "common.h"
|
||||
#include "dhcpc.h"
|
||||
#include "dhcpd.h"
|
||||
--
|
||||
2.45.2
|
||||
|
32
patches/0006-Add-missing-sigisemptyset-implementation.patch
Normal file
32
patches/0006-Add-missing-sigisemptyset-implementation.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 1b95c833d8cda62bf79f0ec8da7cca8f3ea1e4d8 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sun, 14 Jul 2024 16:55:01 -0700
|
||||
Subject: [PATCH 06/17] Add missing sigisemptyset implementation
|
||||
|
||||
---
|
||||
shell/hush.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/shell/hush.c b/shell/hush.c
|
||||
index d111f0cc5..5fbceaae3 100644
|
||||
--- a/shell/hush.c
|
||||
+++ b/shell/hush.c
|
||||
@@ -1942,6 +1942,15 @@ enum {
|
||||
,
|
||||
};
|
||||
|
||||
+#ifdef __BIONIC__
|
||||
+static int sigisemptyset(const sigset_t *set)
|
||||
+{
|
||||
+ sigset_t empty;
|
||||
+ sigemptyset(&empty);
|
||||
+ return memcmp(&empty, set, sizeof(sigset_t)) == 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void record_pending_signo(int sig)
|
||||
{
|
||||
sigaddset(&G.pending_set, sig);
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,38 +0,0 @@
|
||||
From fa9b786d8c34bcaf61a3dfdd20138c6172e02755 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Wed, 2 Dec 2015 23:44:06 -0400
|
||||
Subject: [PATCH 06/35] fix ether-wake, avoid ether_hostton and include
|
||||
if_ether
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>, based on 'no-ether_hostton' by Dan Drown
|
||||
"there is no /etc/ethers or ether_hostton on bionic"
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
Rebased for busybox 1.24.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
networking/ether-wake.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
|
||||
index 809c0d9f0..920f0c4a0 100644
|
||||
--- a/networking/ether-wake.c
|
||||
+++ b/networking/ether-wake.c
|
||||
@@ -87,6 +87,7 @@
|
||||
#include "libbb.h"
|
||||
#include <netpacket/packet.h>
|
||||
#include <netinet/ether.h>
|
||||
+#include <netinet/if_ether.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
/* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to
|
||||
@@ -132,7 +133,7 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr)
|
||||
eap = ether_aton_r(hostid, eaddr);
|
||||
if (eap) {
|
||||
bb_debug_msg("The target station address is %s\n\n", ether_ntoa_r(eap, ether_buf));
|
||||
-#if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
|
||||
+#if !defined(__BIONIC__) && (!defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30))
|
||||
} else if (ether_hostton(hostid, eaddr) == 0) {
|
||||
bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa_r(eaddr, ether_buf));
|
||||
#endif
|
||||
--
|
||||
2.45.2
|
||||
|
34
patches/0007-Prevent-compiling-mtab-related-features.patch
Normal file
34
patches/0007-Prevent-compiling-mtab-related-features.patch
Normal file
@ -0,0 +1,34 @@
|
||||
From f258400ac6119a369865606883245ecf176005ae Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sun, 14 Jul 2024 21:26:56 -0700
|
||||
Subject: [PATCH 07/17] Prevent compiling mtab related features
|
||||
|
||||
---
|
||||
util-linux/mount.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util-linux/mount.c b/util-linux/mount.c
|
||||
index 4e65b6b46..08058db49 100644
|
||||
--- a/util-linux/mount.c
|
||||
+++ b/util-linux/mount.c
|
||||
@@ -768,7 +768,8 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
|
||||
// If the mount was successful, and we're maintaining an old-style
|
||||
// mtab file by hand, add the new entry to it now.
|
||||
mtab:
|
||||
- if (USE_MTAB && !rc && !(vfsflags & MS_REMOUNT)) {
|
||||
+ #if USE_MTAB
|
||||
+ if (!rc && !(vfsflags & MS_REMOUNT)) {
|
||||
char *fsname;
|
||||
FILE *mountTable = setmntent(bb_path_mtab_file, "a+");
|
||||
const char *option_str = mount_option_str;
|
||||
@@ -814,6 +815,7 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
|
||||
free(fsname);
|
||||
}
|
||||
}
|
||||
+#endif // USE_MTAB
|
||||
ret:
|
||||
return rc;
|
||||
}
|
||||
--
|
||||
2.45.2
|
||||
|
64
patches/0008-Remove-CBQ-support-from-tc.patch
Normal file
64
patches/0008-Remove-CBQ-support-from-tc.patch
Normal file
@ -0,0 +1,64 @@
|
||||
From 12334c3e19a1e902a90b7d4898f61b08301de94d Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Mon, 15 Jul 2024 18:50:57 -0700
|
||||
Subject: [PATCH 08/17] Remove CBQ support from tc
|
||||
|
||||
CBQ support is removed from Linux.
|
||||
More info: https://bugs.busybox.net/show_bug.cgi?id=15931
|
||||
---
|
||||
networking/tc.c | 11 +++++++----
|
||||
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/networking/tc.c b/networking/tc.c
|
||||
index 43187f7ee..92601d6e3 100644
|
||||
--- a/networking/tc.c
|
||||
+++ b/networking/tc.c
|
||||
@@ -31,7 +31,7 @@
|
||||
//usage: "qdisc [handle QHANDLE] [root|"IF_FEATURE_TC_INGRESS("ingress|")"parent CLASSID]\n"
|
||||
/* //usage: "[estimator INTERVAL TIME_CONSTANT]\n" */
|
||||
//usage: " [[QDISC_KIND] [help|OPTIONS]]\n"
|
||||
-//usage: " QDISC_KIND := [p|b]fifo|tbf|prio|cbq|red|etc.\n"
|
||||
+//usage: " QDISC_KIND := [p|b]fifo|tbf|prio|red|etc.\n"
|
||||
//usage: "qdisc show [dev STRING]"IF_FEATURE_TC_INGRESS(" [ingress]")"\n"
|
||||
//usage: "class [classid CLASSID] [root|parent CLASSID]\n"
|
||||
//usage: " [[QDISC_KIND] [help|OPTIONS] ]\n"
|
||||
@@ -230,7 +230,7 @@ static int cbq_parse_opt(int argc, char **argv, struct nlmsghdr *n)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
-#endif
|
||||
+
|
||||
static int cbq_print_opt(struct rtattr *opt)
|
||||
{
|
||||
struct rtattr *tb[TCA_CBQ_MAX+1];
|
||||
@@ -322,6 +322,7 @@ static int cbq_print_opt(struct rtattr *opt)
|
||||
done:
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static FAST_FUNC int print_qdisc(
|
||||
const struct sockaddr_nl *who UNUSED_PARAM,
|
||||
@@ -373,7 +374,8 @@ static FAST_FUNC int print_qdisc(
|
||||
if (qqq == 0) { /* pfifo_fast aka prio */
|
||||
prio_print_opt(tb[TCA_OPTIONS]);
|
||||
} else if (qqq == 1) { /* class based queuing */
|
||||
- cbq_print_opt(tb[TCA_OPTIONS]);
|
||||
+ /* cbq_print_opt(tb[TCA_OPTIONS]); */
|
||||
+ printf("cbq not supported");
|
||||
} else {
|
||||
/* don't know how to print options for this qdisc */
|
||||
printf("(options for %s)", name);
|
||||
@@ -444,7 +446,8 @@ static FAST_FUNC int print_class(
|
||||
/* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/
|
||||
} else if (qqq == 1) { /* class based queuing */
|
||||
/* cbq_print_copt() is identical to cbq_print_opt(). */
|
||||
- cbq_print_opt(tb[TCA_OPTIONS]);
|
||||
+ /* cbq_print_opt(tb[TCA_OPTIONS]); */
|
||||
+ printf("cbq not supported");
|
||||
} else {
|
||||
/* don't know how to print options for this class */
|
||||
printf("(options for %s)", name);
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,41 +0,0 @@
|
||||
From 9f36b941ea4c5a8f30549cc429fcf12f4462676c Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 12 Sep 2016 14:45:35 -0300
|
||||
Subject: [PATCH 08/35] android syscalls: shmget/msgget/semget
|
||||
|
||||
Patch modified by Tias Guns <tias@ulyssis.org> from 'no-sys-shm,msg,sem' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
libbb/missing_syscalls.c | 15 +++++++++++++++
|
||||
1 file changed, 15 insertions(+)
|
||||
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index dc40d9155..82b600ced 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -31,6 +31,21 @@ int pivot_root(const char *new_root, const char *put_old)
|
||||
return syscall(__NR_pivot_root, new_root, put_old);
|
||||
}
|
||||
|
||||
+int shmget(key_t key, size_t size, int shmflg)
|
||||
+{
|
||||
+ return syscall(__NR_shmget, key, size, shmflg);
|
||||
+}
|
||||
+
|
||||
+int msgget(key_t key, int msgflg)
|
||||
+{
|
||||
+ return syscall(__NR_msgget, key, msgflg);
|
||||
+}
|
||||
+
|
||||
+int semget(key_t key, int nsems, int semflg)
|
||||
+{
|
||||
+ return syscall(__NR_semget, key, nsems, semflg);
|
||||
+}
|
||||
+
|
||||
# if __ANDROID_API__ < 21
|
||||
int tcdrain(int fd)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
203
patches/0009-Use-bionic-libresolv-for-nslookup.patch
Normal file
203
patches/0009-Use-bionic-libresolv-for-nslookup.patch
Normal file
@ -0,0 +1,203 @@
|
||||
From 2eb6acaf13508003e26d51cbce7bc42b49634e3c Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Mon, 15 Jul 2024 17:20:17 -0700
|
||||
Subject: [PATCH 09/17] Use bionic libresolv for nslookup
|
||||
|
||||
---
|
||||
networking/bionic_resolv.h | 112 +++++++++++++++++++++++++++++++++++++
|
||||
networking/nslookup.c | 27 ++++-----
|
||||
2 files changed, 124 insertions(+), 15 deletions(-)
|
||||
create mode 100644 networking/bionic_resolv.h
|
||||
|
||||
diff --git a/networking/bionic_resolv.h b/networking/bionic_resolv.h
|
||||
new file mode 100644
|
||||
index 000000000..a15cb587b
|
||||
--- /dev/null
|
||||
+++ b/networking/bionic_resolv.h
|
||||
@@ -0,0 +1,112 @@
|
||||
+#pragma once
|
||||
+
|
||||
+// Struct/function definitions copied from headers in bionic/libc/dns
|
||||
+
|
||||
+#include <resolv.h>
|
||||
+#include <net/if.h>
|
||||
+
|
||||
+/* Hard-coded defines */
|
||||
+#define MAXNS 4 /* max # name servers we'll track */
|
||||
+#define MAXDNSRCH 6 /* max # domains in search path */
|
||||
+#define MAXDNSRCHPATH 256 /* max length of domain search paths */
|
||||
+#define MAXNSSAMPLES 64 /* max # samples to store per server */
|
||||
+#define MAXRESOLVSORT 10 /* number of net to sort on */
|
||||
+#define MAXALIASES 35
|
||||
+#define MAXADDRS 35
|
||||
+
|
||||
+// These are function pointers
|
||||
+typedef void* res_send_rhook;
|
||||
+typedef void* res_send_qhook;
|
||||
+
|
||||
+struct res_static {
|
||||
+ char* h_addr_ptrs[MAXADDRS + 1];
|
||||
+ char* host_aliases[MAXALIASES];
|
||||
+ char hostbuf[8 * 1024];
|
||||
+ u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
|
||||
+ FILE* hostf;
|
||||
+ int stayopen;
|
||||
+ const char* servent_ptr;
|
||||
+ struct servent servent;
|
||||
+ struct hostent host;
|
||||
+};
|
||||
+
|
||||
+union res_sockaddr_union {
|
||||
+ struct sockaddr_in sin;
|
||||
+#ifdef IN6ADDR_ANY_INIT
|
||||
+ struct sockaddr_in6 sin6;
|
||||
+#endif
|
||||
+#ifdef ISC_ALIGN64
|
||||
+ int64_t __align64; /* 64bit alignment */
|
||||
+#else
|
||||
+ int32_t __align32; /* 32bit alignment */
|
||||
+#endif
|
||||
+ char __space[128]; /* max size */
|
||||
+};
|
||||
+
|
||||
+struct __res_state_ext {
|
||||
+ union res_sockaddr_union nsaddrs[MAXNS];
|
||||
+ struct sort_list {
|
||||
+ int af;
|
||||
+ union {
|
||||
+ struct in_addr ina;
|
||||
+ struct in6_addr in6a;
|
||||
+ } addr, mask;
|
||||
+ } sort_list[MAXRESOLVSORT];
|
||||
+ char nsuffix[64];
|
||||
+ char nsuffix2[64];
|
||||
+};
|
||||
+
|
||||
+struct __res_state {
|
||||
+ unsigned netid; /* NetId: cache key and socket mark */
|
||||
+ int retrans; /* retransmission time interval */
|
||||
+ int retry; /* number of times to retransmit */
|
||||
+#ifdef sun
|
||||
+ u_int options; /* option flags - see below. */
|
||||
+#else
|
||||
+ u_long options; /* option flags - see below. */
|
||||
+#endif
|
||||
+ int nscount; /* number of name servers */
|
||||
+ struct sockaddr_in
|
||||
+ nsaddr_list[MAXNS]; /* address of name server */
|
||||
+#define nsaddr nsaddr_list[0] /* for backward compatibility */
|
||||
+ u_short id; /* current message id */
|
||||
+ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
|
||||
+ char defdname[256]; /* default domain (deprecated) */
|
||||
+#ifdef sun
|
||||
+ u_int pfcode; /* RES_PRF_ flags - see below. */
|
||||
+#else
|
||||
+ u_long pfcode; /* RES_PRF_ flags - see below. */
|
||||
+#endif
|
||||
+ unsigned ndots:4; /* threshold for initial abs. query */
|
||||
+ unsigned nsort:4; /* number of elements in sort_list[] */
|
||||
+ char unused[3];
|
||||
+ struct {
|
||||
+ struct in_addr addr;
|
||||
+ uint32_t mask;
|
||||
+ } sort_list[MAXRESOLVSORT];
|
||||
+#ifdef __OLD_RES_STATE
|
||||
+ char lookups[4];
|
||||
+#else
|
||||
+ res_send_qhook qhook; /* query hook */
|
||||
+ res_send_rhook rhook; /* response hook */
|
||||
+ int res_h_errno; /* last one set for this context */
|
||||
+ unsigned _mark; /* If non-0 SET_MARK to _mark on all request sockets */
|
||||
+ int _vcsock; /* PRIVATE: for res_send VC i/o */
|
||||
+ u_int _flags; /* PRIVATE: see below */
|
||||
+ u_int _pad; /* make _u 64 bit aligned */
|
||||
+ union {
|
||||
+ /* On an 32-bit arch this means 512b total. */
|
||||
+ char pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
|
||||
+ struct {
|
||||
+ uint16_t nscount;
|
||||
+ uint16_t nstimes[MAXNS]; /* ms. */
|
||||
+ int nssocks[MAXNS];
|
||||
+ struct __res_state_ext *ext; /* extention for IPv6 */
|
||||
+ } _ext;
|
||||
+ } _u;
|
||||
+#endif
|
||||
+ struct res_static rstatic[1];
|
||||
+};
|
||||
+
|
||||
+extern struct __res_state *__res_get_state(void);
|
||||
+#define _res (*__res_get_state())
|
||||
diff --git a/networking/nslookup.c b/networking/nslookup.c
|
||||
index 6da97baf4..0441ab116 100644
|
||||
--- a/networking/nslookup.c
|
||||
+++ b/networking/nslookup.c
|
||||
@@ -40,6 +40,9 @@
|
||||
//#include <netdb.h>
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
+#ifdef __BIONIC__
|
||||
+#include "bionic_resolv.h"
|
||||
+#endif
|
||||
|
||||
|
||||
#if !ENABLE_FEATURE_NSLOOKUP_BIG
|
||||
@@ -148,7 +151,8 @@ static void server_print(void)
|
||||
struct sockaddr *sa;
|
||||
|
||||
#if ENABLE_FEATURE_IPV6
|
||||
- sa = (struct sockaddr*)_res._u._ext.nsaddrs[0];
|
||||
+ if (_res._u._ext.nscount)
|
||||
+ sa = (struct sockaddr*)&_res._u._ext.ext->nsaddrs[0].sin6;
|
||||
if (!sa)
|
||||
#endif
|
||||
sa = (struct sockaddr*)&_res.nsaddr_list[0];
|
||||
@@ -166,8 +170,9 @@ static void set_default_dns(const char *server)
|
||||
{
|
||||
len_and_sockaddr *lsa;
|
||||
|
||||
+ // Set a fallback DNS server
|
||||
if (!server)
|
||||
- return;
|
||||
+ server = "8.8.8.8";
|
||||
|
||||
/* NB: this works even with, say, "[::1]:5353"! :) */
|
||||
lsa = xhost2sockaddr(server, 53);
|
||||
@@ -178,20 +183,15 @@ static void set_default_dns(const char *server)
|
||||
_res.nsaddr_list[0] = lsa->u.sin;
|
||||
}
|
||||
#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?
|
||||
- * (uclibc 0.9.31+ should work) */
|
||||
if (lsa->u.sa.sa_family == AF_INET6) {
|
||||
- // glibc neither SEGVs nor sends any dgrams with this
|
||||
- // (strace shows no socket ops):
|
||||
- //_res.nscount = 0;
|
||||
+ _res.nscount = 1;
|
||||
_res._u._ext.nscount = 1;
|
||||
- /* store a pointer to part of malloc'ed lsa */
|
||||
- _res._u._ext.nsaddrs[0] = &lsa->u.sin6;
|
||||
- /* must not free(lsa)! */
|
||||
+ /* struct copy */
|
||||
+ _res._u._ext.ext->nsaddrs[0].sin6 = lsa->u.sin6;
|
||||
+ _res.nsaddr_list[0].sin_family = 0;
|
||||
}
|
||||
#endif
|
||||
+ free(lsa);
|
||||
}
|
||||
|
||||
int nslookup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@@ -205,9 +205,6 @@ int nslookup_main(int argc, char **argv)
|
||||
if (!argv[1] || argv[1][0] == '-' || argc > 3)
|
||||
bb_show_usage();
|
||||
|
||||
- /* initialize DNS structure _res used in printing the default
|
||||
- * name server and in the explicit name server option feature. */
|
||||
- res_init();
|
||||
/* rfc2133 says this enables IPv6 lookups */
|
||||
/* (but it also says "may be enabled in /etc/resolv.conf") */
|
||||
/*_res.options |= RES_USE_INET6;*/
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,38 +0,0 @@
|
||||
From 8ba5becb43f65b01c1f4c3c858ea5557fadf057a Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 12 Sep 2016 14:46:40 -0300
|
||||
Subject: [PATCH 09/35] android syscalls: msgctl shmctl
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>
|
||||
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
libbb/missing_syscalls.c | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index 82b600ced..018f72d62 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -46,6 +46,19 @@ int semget(key_t key, int nsems, int semflg)
|
||||
return syscall(__NR_semget, key, nsems, semflg);
|
||||
}
|
||||
|
||||
+struct msqid_ds; /* #include <linux/msg.h> */
|
||||
+int msgctl(int msqid, int cmd, struct msqid_ds *buf)
|
||||
+{
|
||||
+ return syscall(__NR_msgctl, msqid, cmd, buf);
|
||||
+}
|
||||
+
|
||||
+struct shmid_ds; /* #include <linux/shm.h> */
|
||||
+// NOTE: IPC_INFO takes a struct shminfo64
|
||||
+int shmctl(int shmid, int cmd, struct shmid_ds *buf)
|
||||
+{
|
||||
+ return syscall(__NR_shmctl, shmid, cmd, buf);
|
||||
+}
|
||||
+
|
||||
# if __ANDROID_API__ < 21
|
||||
int tcdrain(int fd)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,8 +1,7 @@
|
||||
From a84db18ef75d4d5afe8ff1090297bd9329b75c3a Mon Sep 17 00:00:00 2001
|
||||
From 9cb8d202d99a8126413283d50dbe83e457387689 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Wed, 24 May 2023 14:15:00 -0300
|
||||
Subject: [PATCH 02/35] Fix direct mount .img (auto loopback) and losetup for
|
||||
Android /dev/block/loop
|
||||
Subject: [PATCH 10/17] Fix direct mount auto loopback and losetup for Android
|
||||
|
||||
---
|
||||
include/libbb.h | 12 +++++++++---
|
@ -1,48 +0,0 @@
|
||||
From 8f4de5081b22de50f52a70fc79d9696646914fb9 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 12 Sep 2016 14:48:30 -0300
|
||||
Subject: [PATCH 10/35] android syscalls: shmdt shmat sembuf
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>
|
||||
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
libbb/missing_syscalls.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index 018f72d62..b5ea2612e 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -36,6 +36,16 @@ int shmget(key_t key, size_t size, int shmflg)
|
||||
return syscall(__NR_shmget, key, size, shmflg);
|
||||
}
|
||||
|
||||
+int shmdt(const void *shmaddr)
|
||||
+{
|
||||
+ return syscall(__NR_shmdt, shmaddr);
|
||||
+}
|
||||
+
|
||||
+void *shmat(int shmid, const void *shmaddr, int shmflg)
|
||||
+{
|
||||
+ return (void *)syscall(__NR_shmat, shmid, shmaddr, shmflg);
|
||||
+}
|
||||
+
|
||||
int msgget(key_t key, int msgflg)
|
||||
{
|
||||
return syscall(__NR_msgget, key, msgflg);
|
||||
@@ -59,6 +69,12 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf)
|
||||
return syscall(__NR_shmctl, shmid, cmd, buf);
|
||||
}
|
||||
|
||||
+struct sembuf; /* #include <linux/sem.h> */
|
||||
+int semop(int semid, struct sembuf *sops, unsigned nsops)
|
||||
+{
|
||||
+ return syscall(__NR_semop, semid, sops, nsops);
|
||||
+}
|
||||
+
|
||||
# if __ANDROID_API__ < 21
|
||||
int tcdrain(int fd)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,19 +1,14 @@
|
||||
From 4e1b8164fb241cba15f4a41871d44f1aecfa2c26 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Tue, 23 May 2023 18:30:43 -0300
|
||||
Subject: [PATCH 27/35] ash history
|
||||
From 7d82ae116d7c3a3aa6d9048574fdf0564d513378 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Mon, 15 Jul 2024 17:44:50 -0700
|
||||
Subject: [PATCH 11/17] Update shell paths to Android specific values
|
||||
|
||||
allows ash history to work on Android
|
||||
|
||||
Patch modified by Tias Guns <tias@ulyssis.org> from 'busybox-android.patch' by Alexandre Courbot
|
||||
https://github.com/Gnurou/busybox-android
|
||||
Rebased for busybox 1.36.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
include/libbb.h | 4 ++--
|
||||
init/init.c | 2 +-
|
||||
libbb/get_shell_name.c | 4 ++++
|
||||
shell/ash.c | 8 ++++++--
|
||||
4 files changed, 13 insertions(+), 5 deletions(-)
|
||||
shell/ash.c | 4 ++--
|
||||
4 files changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/libbb.h b/include/libbb.h
|
||||
index 87dd74e48..112e45197 100644
|
||||
@ -63,7 +58,7 @@ index 5aebe9cdc..5af53bdda 100644
|
||||
if (pw && pw->pw_shell && pw->pw_shell[0])
|
||||
return pw->pw_shell;
|
||||
diff --git a/shell/ash.c b/shell/ash.c
|
||||
index 9344e4de1..5dd7f80f1 100644
|
||||
index 9344e4de1..19eed5451 100644
|
||||
--- a/shell/ash.c
|
||||
+++ b/shell/ash.c
|
||||
@@ -14537,7 +14537,7 @@ procargs(char **argv)
|
||||
@ -84,24 +79,6 @@ index 9344e4de1..5dd7f80f1 100644
|
||||
state1:
|
||||
state = 2;
|
||||
hp = lookupvar("HOME");
|
||||
@@ -14758,6 +14758,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (line_input_state) {
|
||||
const char *hp = lookupvar("HISTFILE");
|
||||
if (!hp) {
|
||||
+#ifdef __ANDROID__
|
||||
+ setvar("HISTFILE", "/mnt/sdcard/ash_history", 0);
|
||||
+#else
|
||||
hp = lookupvar("HOME");
|
||||
if (hp) {
|
||||
INT_OFF;
|
||||
@@ -14767,6 +14770,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
|
||||
INT_ON;
|
||||
hp = lookupvar("HISTFILE");
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
if (hp)
|
||||
line_input_state->hist_file = xstrdup(hp);
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,84 +0,0 @@
|
||||
From f8f14deeffacdb3d3e4df817b87ccb260e6b4c38 Mon Sep 17 00:00:00 2001
|
||||
From: Tias Guns <tias@ulyssis.org>
|
||||
Date: Sun, 5 Aug 2012 15:25:34 +0200
|
||||
Subject: [PATCH 11/35] android syscall (non-trivial): semctl
|
||||
|
||||
needed by ipcs and ipcrm, also needed (but not sufficient) for syslogd and logread
|
||||
|
||||
semctl from glibc
|
||||
patch from 'no-sys-shm,msg,sem' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
|
||||
Signed-off-by: Tias Guns <tias@ulyssis.org>
|
||||
---
|
||||
libbb/semctl.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 58 insertions(+)
|
||||
create mode 100644 libbb/semctl.c
|
||||
|
||||
diff --git a/libbb/semctl.c b/libbb/semctl.c
|
||||
new file mode 100644
|
||||
index 000000000..2c600e4f0
|
||||
--- /dev/null
|
||||
+++ b/libbb/semctl.c
|
||||
@@ -0,0 +1,58 @@
|
||||
+/* Copyright (C) 1995,1997,1998,2000,2003,2004,2006
|
||||
+ Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, write to the Free
|
||||
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
+ 02111-1307 USA. */
|
||||
+/* originally from glibc-2.14/sysdeps/unix/sysv/linux/semctl.c, modified */
|
||||
+
|
||||
+// syscall used by syslogd, ipcrm, ipcs
|
||||
+//kbuild:lib-y += semctl.o
|
||||
+
|
||||
+#include <sys/syscall.h> /* For __NR_xxx definitions */
|
||||
+#include <stdarg.h>
|
||||
+#include <sys/sem.h>
|
||||
+#include "libbb.h"
|
||||
+
|
||||
+/* code from GLIBC */
|
||||
+int semctl(int semid, int semnum, int cmd, ...) {
|
||||
+ union semun arg;
|
||||
+ va_list ap;
|
||||
+
|
||||
+ va_start (ap, cmd);
|
||||
+
|
||||
+ /* Get the argument only if required. */
|
||||
+ arg.buf = NULL;
|
||||
+ switch (cmd)
|
||||
+ {
|
||||
+ case SETVAL: /* arg.val */
|
||||
+ case GETALL: /* arg.array */
|
||||
+ case SETALL:
|
||||
+ case IPC_STAT: /* arg.buf */
|
||||
+ case IPC_SET:
|
||||
+ case SEM_STAT:
|
||||
+ case IPC_INFO: /* arg.__buf */
|
||||
+ case SEM_INFO:
|
||||
+ va_start (ap, cmd);
|
||||
+ arg = va_arg (ap, union semun);
|
||||
+ va_end (ap);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ va_end (ap);
|
||||
+
|
||||
+ return syscall(__NR_semctl, semid, semnum, cmd, arg);
|
||||
+}
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 6de85bca13186f6056c78afe264cad7efa5f8eb3 Mon Sep 17 00:00:00 2001
|
||||
From 4732054018b9f22edeb2b47153352a1399c5bc5a Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sat, 2 May 2020 01:48:30 -0700
|
||||
Subject: [PATCH 33/35] Disable SELinux features for install
|
||||
Subject: [PATCH 12/17] Disable SELinux features for install
|
||||
|
||||
matchpathcon is not usable on Android
|
||||
---
|
@ -1,85 +0,0 @@
|
||||
From 24a899b5756eb827998ce2aaf589933128998439 Mon Sep 17 00:00:00 2001
|
||||
From: Umakanthan Chandran <cumakt@gmail.com>
|
||||
Date: Fri, 3 Mar 2017 07:32:22 +0530
|
||||
Subject: [PATCH 12/35] missing_syscalls/semctl: fix missing definitions on x86
|
||||
and MIPS NDK cross-compiles
|
||||
|
||||
Signed-off-by: Umakanthan Chandran <cumakt@gmail.com>
|
||||
---
|
||||
libbb/missing_syscalls.c | 44 ++++++++++++++++++++++++++++++++++++++++
|
||||
libbb/semctl.c | 4 ++++
|
||||
2 files changed, 48 insertions(+)
|
||||
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index b5ea2612e..f02e8d14c 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -7,6 +7,50 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
+#ifndef __NR_shmget
|
||||
+#define __NR_shmget 29
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_shmat
|
||||
+#define __NR_shmat 30
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_shmctl
|
||||
+#define __NR_shmctl 31
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_semget
|
||||
+#define __NR_semget 64
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_semop
|
||||
+#define __NR_semop 65
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_semctl
|
||||
+#define __NR_semctl 66
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_shmdt
|
||||
+#define __NR_shmdt 67
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_msgget
|
||||
+#define __NR_msgget 68
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_msgsnd
|
||||
+#define __NR_msgsnd 69
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_msgrcv
|
||||
+#define __NR_msgrcv 70
|
||||
+#endif
|
||||
+
|
||||
+#ifndef __NR_msgctl
|
||||
+#define __NR_msgctl 71
|
||||
+#endif
|
||||
+
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
/*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
|
||||
# include <sys/syscall.h>
|
||||
diff --git a/libbb/semctl.c b/libbb/semctl.c
|
||||
index 2c600e4f0..84ab1c92e 100644
|
||||
--- a/libbb/semctl.c
|
||||
+++ b/libbb/semctl.c
|
||||
@@ -27,6 +27,10 @@
|
||||
#include <sys/sem.h>
|
||||
#include "libbb.h"
|
||||
|
||||
+#ifndef __NR_semctl
|
||||
+#define __NR_semctl 66
|
||||
+#endif
|
||||
+
|
||||
/* code from GLIBC */
|
||||
int semctl(int semid, int semnum, int cmd, ...) {
|
||||
union semun arg;
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,26 +1,28 @@
|
||||
From e58c3ad5272ccb534848d33cbd02a38d6b4d523b Mon Sep 17 00:00:00 2001
|
||||
From 919bf6bfbe8b8a26ad3fc80d53aa5f2221aff1ed Mon Sep 17 00:00:00 2001
|
||||
From: LoveSy <shana@zju.edu.cn>
|
||||
Date: Sun, 20 Mar 2022 00:51:25 +0800
|
||||
Subject: [PATCH 28/35] Replace `realpath` to BSD inplementation
|
||||
Subject: [PATCH 13/17] Replace `realpath` to BSD inplementation
|
||||
|
||||
---
|
||||
libbb/Kbuild.src | 1 +
|
||||
libbb/Kbuild.src | 3 +
|
||||
libbb/wrap_funcs.c | 221 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 222 insertions(+)
|
||||
2 files changed, 224 insertions(+)
|
||||
create mode 100644 libbb/wrap_funcs.c
|
||||
|
||||
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
|
||||
index 33c33b6be..390b1eb10 100644
|
||||
index 653025e56..4ac314bdb 100644
|
||||
--- a/libbb/Kbuild.src
|
||||
+++ b/libbb/Kbuild.src
|
||||
@@ -120,6 +120,7 @@ lib-y += xrealloc_vector.o
|
||||
@@ -118,6 +118,9 @@ lib-y += xgethostbyname.o
|
||||
lib-y += xreadlink.o
|
||||
lib-y += xrealloc_vector.o
|
||||
|
||||
# for android-busybox-ndk
|
||||
lib-y += mntent_r.o
|
||||
+# for android-busybox-ndk
|
||||
+lib-y += wrap_funcs.o
|
||||
|
||||
+
|
||||
lib-$(CONFIG_MOUNT) += match_fstype.o
|
||||
lib-$(CONFIG_UMOUNT) += match_fstype.o
|
||||
|
||||
diff --git a/libbb/wrap_funcs.c b/libbb/wrap_funcs.c
|
||||
new file mode 100644
|
||||
index 000000000..d4548859a
|
@ -1,7 +1,7 @@
|
||||
From 00fa13d7d9acfe4f99968ccfd8f6f43cfd49ad3a Mon Sep 17 00:00:00 2001
|
||||
From 8c3bb497fbc8b780c8f6b163882f9b3e636b84ae Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Sat, 2 Sep 2023 05:21:13 -0700
|
||||
Subject: [PATCH 29/35] Replace rename(2) with direct system call
|
||||
Subject: [PATCH 14/17] Replace rename(2) with direct system call
|
||||
|
||||
NDK r26 introduced the following change:
|
||||
https://android-review.googlesource.com/c/platform/bionic/+/2240019
|
@ -1,47 +0,0 @@
|
||||
From d4d38041c251f53f728473d4f8f4720a5c85dc9c Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Sun, 18 Feb 2018 07:54:58 -0400
|
||||
Subject: [PATCH 14/35] fix fsck.minix, mkfs.minix: undef HAVE_SETBIT,
|
||||
MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC
|
||||
|
||||
"there is no setbit/clrbit in bionic"
|
||||
"MINIX2_SUPER_MAGIC / MINIX2_SUPER_MAGIC2 defined in sys/vfs.h, undefine
|
||||
it to use it in the enum"
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>, based on 'no-setbit' and
|
||||
'undefine-minix2-magic-to-use-in-enum' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
Rebased for busybox 1.28.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
include/platform.h | 1 +
|
||||
util-linux/minix.h | 2 ++
|
||||
2 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/include/platform.h b/include/platform.h
|
||||
index ea0512f36..6644d83c6 100644
|
||||
--- a/include/platform.h
|
||||
+++ b/include/platform.h
|
||||
@@ -551,6 +551,7 @@ typedef unsigned smalluint;
|
||||
# undef HAVE_UNLOCKED_LINE_OPS
|
||||
# undef HAVE_NET_ETHERNET_H
|
||||
# undef HAVE_PRINTF_PERCENTM
|
||||
+# undef HAVE_SETBIT
|
||||
#endif
|
||||
|
||||
/*
|
||||
diff --git a/util-linux/minix.h b/util-linux/minix.h
|
||||
index 83ffe6da5..91ced691c 100644
|
||||
--- a/util-linux/minix.h
|
||||
+++ b/util-linux/minix.h
|
||||
@@ -54,6 +54,8 @@ struct minix_dir_entry {
|
||||
/* Believe it or not, but mount.h has this one #defined */
|
||||
#undef BLOCK_SIZE
|
||||
|
||||
+#undef MINIX2_SUPER_MAGIC
|
||||
+#undef MINIX2_SUPER_MAGIC2
|
||||
enum {
|
||||
BLOCK_SIZE = 1024,
|
||||
BITS_PER_BLOCK = BLOCK_SIZE << 3,
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,14 +1,14 @@
|
||||
From c7e6de2748301c1420e8b39d1e438874e52da4ff Mon Sep 17 00:00:00 2001
|
||||
From 0cc05e531c03124e9611f411b97fb32b90a8d229 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Fri, 7 Feb 2020 14:32:06 -0800
|
||||
Subject: [PATCH 31/35] Add runtime toggle to enable standalone ash
|
||||
Subject: [PATCH 15/17] Add runtime toggle to enable standalone ash
|
||||
|
||||
---
|
||||
shell/ash.c | 42 ++++++++++++++++++++++++------------------
|
||||
1 file changed, 24 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/shell/ash.c b/shell/ash.c
|
||||
index 5dd7f80f1..9ab1cb327 100644
|
||||
index 19eed5451..34a540049 100644
|
||||
--- a/shell/ash.c
|
||||
+++ b/shell/ash.c
|
||||
@@ -279,16 +279,14 @@ typedef long arith_t;
|
@ -1,114 +0,0 @@
|
||||
From e0565bde5f6246304751ae2d9f9f3a37c31d551a Mon Sep 17 00:00:00 2001
|
||||
From: Tias Guns <tias@ulyssis.org>
|
||||
Date: Mon, 19 Mar 2012 18:24:29 +0000
|
||||
Subject: [PATCH 15/35] fix ipv6, add ipv6_route.h
|
||||
|
||||
from 'in6_rtmsg' by Dan Drown
|
||||
"in6_rtmsg defined in linux/ipv6_route.h"
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
---
|
||||
include/linux/ipv6_route.h | 58 ++++++++++++++++++++++++++++++++++++++
|
||||
networking/ifconfig.c | 2 ++
|
||||
networking/route.c | 2 ++
|
||||
3 files changed, 62 insertions(+)
|
||||
create mode 100644 include/linux/ipv6_route.h
|
||||
|
||||
diff --git a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h
|
||||
new file mode 100644
|
||||
index 000000000..144875dab
|
||||
--- /dev/null
|
||||
+++ b/include/linux/ipv6_route.h
|
||||
@@ -0,0 +1,58 @@
|
||||
+/*
|
||||
+ * Linux INET6 implementation
|
||||
+ *
|
||||
+ * Authors:
|
||||
+ * Pedro Roque <roque@di.fc.ul.pt>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public License
|
||||
+ * as published by the Free Software Foundation; either version
|
||||
+ * 2 of the License, or (at your option) any later version.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _LINUX_IPV6_ROUTE_H
|
||||
+#define _LINUX_IPV6_ROUTE_H
|
||||
+
|
||||
+#include <linux/types.h>
|
||||
+
|
||||
+#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
|
||||
+#define RTF_ALLONLINK 0x00020000 /* (deprecated and will be removed)
|
||||
+ fallback, no routers on link */
|
||||
+#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
|
||||
+#define RTF_PREFIX_RT 0x00080000 /* A prefix only route - RA */
|
||||
+#define RTF_ANYCAST 0x00100000 /* Anycast */
|
||||
+
|
||||
+#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */
|
||||
+#define RTF_EXPIRES 0x00400000
|
||||
+
|
||||
+#define RTF_ROUTEINFO 0x00800000 /* route information - RA */
|
||||
+
|
||||
+#define RTF_CACHE 0x01000000 /* cache entry */
|
||||
+#define RTF_FLOW 0x02000000 /* flow significant route */
|
||||
+#define RTF_POLICY 0x04000000 /* policy route */
|
||||
+
|
||||
+#define RTF_PREF(pref) ((pref) << 27)
|
||||
+#define RTF_PREF_MASK 0x18000000
|
||||
+
|
||||
+#define RTF_LOCAL 0x80000000
|
||||
+
|
||||
+
|
||||
+struct in6_rtmsg {
|
||||
+ struct in6_addr rtmsg_dst;
|
||||
+ struct in6_addr rtmsg_src;
|
||||
+ struct in6_addr rtmsg_gateway;
|
||||
+ __u32 rtmsg_type;
|
||||
+ __u16 rtmsg_dst_len;
|
||||
+ __u16 rtmsg_src_len;
|
||||
+ __u32 rtmsg_metric;
|
||||
+ unsigned long rtmsg_info;
|
||||
+ __u32 rtmsg_flags;
|
||||
+ int rtmsg_ifindex;
|
||||
+};
|
||||
+
|
||||
+#define RTMSG_NEWDEVICE 0x11
|
||||
+#define RTMSG_DELDEVICE 0x12
|
||||
+#define RTMSG_NEWROUTE 0x21
|
||||
+#define RTMSG_DELROUTE 0x22
|
||||
+
|
||||
+#endif
|
||||
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
|
||||
index 9ee232a66..f9a66e801 100644
|
||||
--- a/networking/ifconfig.c
|
||||
+++ b/networking/ifconfig.c
|
||||
@@ -128,12 +128,14 @@
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_IPV6
|
||||
+#ifndef __BIONIC__
|
||||
struct in6_ifreq {
|
||||
struct in6_addr ifr6_addr;
|
||||
uint32_t ifr6_prefixlen;
|
||||
int ifr6_ifindex;
|
||||
};
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* Here are the bit masks for the "flags" member of struct options below.
|
||||
diff --git a/networking/route.c b/networking/route.c
|
||||
index 26146f8e9..7b5be0e73 100644
|
||||
--- a/networking/route.c
|
||||
+++ b/networking/route.c
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include <net/route.h>
|
||||
#include <net/if.h>
|
||||
+#include <linux/in6.h>
|
||||
+#include <linux/ipv6_route.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "inet_common.h"
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 4e6f42c344f6c0af35037cf78bc9431e64e0bad7 Mon Sep 17 00:00:00 2001
|
||||
From 9e08908e035682a76ca93410bbd651a0407cddc4 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Thu, 25 Jun 2020 03:54:53 -0700
|
||||
Subject: [PATCH 32/35] Resolve /proc/self/exe when re-exec ourselves
|
||||
Subject: [PATCH 16/17] Resolve /proc/self/exe when re-exec ourselves
|
||||
|
||||
Use resolved path of /proc/self/exe to workaround Samsung kernel
|
||||
blocking executables running as UID=0 in paths such as /proc.
|
||||
@ -10,7 +10,7 @@ blocking executables running as UID=0 in paths such as /proc.
|
||||
1 file changed, 10 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/shell/ash.c b/shell/ash.c
|
||||
index 9ab1cb327..11c9cb4cc 100644
|
||||
index 34a540049..4dae9a474 100644
|
||||
--- a/shell/ash.c
|
||||
+++ b/shell/ash.c
|
||||
@@ -8252,6 +8252,7 @@ static struct tblentry **cmdtable;
|
@ -1,54 +0,0 @@
|
||||
From 9b7a89681a0320b930ac9bfda99aa7bb1dd7961f Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Thu, 6 May 2021 16:09:06 -0300
|
||||
Subject: [PATCH 16/35] additional fix-up for IPV6 on Android API 21+
|
||||
|
||||
fixes: networking/interface.c:62:8: error: redefinition of 'struct in6_ifreq'
|
||||
|
||||
and:
|
||||
error: field 'ifru_addr' has incomplete type
|
||||
struct sockaddr ifru_addr;
|
||||
error: field 'ifru_dstaddr' has incomplete type
|
||||
struct sockaddr ifru_dstaddr;
|
||||
...
|
||||
since sockaddr was moved from linux/socket.h to sys/socket.h in newer NDK revisions
|
||||
---
|
||||
networking/interface.c | 2 ++
|
||||
networking/route.c | 1 +
|
||||
2 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/networking/interface.c b/networking/interface.c
|
||||
index 6b6c0944a..d5ca48dd9 100644
|
||||
--- a/networking/interface.c
|
||||
+++ b/networking/interface.c
|
||||
@@ -55,6 +55,7 @@
|
||||
|
||||
#ifdef HAVE_AFINET6
|
||||
# ifndef _LINUX_IN6_H
|
||||
+# ifndef __BIONIC__
|
||||
/*
|
||||
* This is from linux/include/net/ipv6.h
|
||||
*/
|
||||
@@ -63,6 +64,7 @@ struct in6_ifreq {
|
||||
uint32_t ifr6_prefixlen;
|
||||
unsigned int ifr6_ifindex;
|
||||
};
|
||||
+# endif
|
||||
# endif
|
||||
#endif /* HAVE_AFINET6 */
|
||||
|
||||
diff --git a/networking/route.c b/networking/route.c
|
||||
index 7b5be0e73..637433bf8 100644
|
||||
--- a/networking/route.c
|
||||
+++ b/networking/route.c
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <net/route.h>
|
||||
#include <net/if.h>
|
||||
+#include <netinet/in.h>
|
||||
#include <linux/in6.h>
|
||||
#include <linux/ipv6_route.h>
|
||||
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 6af96c729231f9266d83e9f06612e150556f1813 Mon Sep 17 00:00:00 2001
|
||||
From 0efb2683727f165c1e729db9c2c01a341f038c31 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Thu, 21 Jan 2021 00:07:41 -0800
|
||||
Subject: [PATCH 34/35] Allow running as libbusybox.so
|
||||
Subject: [PATCH 17/17] Allow running as libbusybox.so
|
||||
|
||||
---
|
||||
libbb/appletlib.c | 5 ++++-
|
@ -1,711 +0,0 @@
|
||||
From 5e221150789917928c5c9a67f9fd8a76f9ef5cf6 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Wed, 19 Jul 2017 17:22:55 -0300
|
||||
Subject: [PATCH 17/35] fix udhcpc6: add missing ifaddrs.h and
|
||||
getifaddrs/freeifaddrs functions
|
||||
|
||||
ifaddrs implementation from 'android-ifaddrs' by Kenneth MacKay:
|
||||
https://github.com/morristech/android-ifaddrs
|
||||
---
|
||||
networking/udhcp/d6_dhcpc.c | 1 +
|
||||
networking/udhcp/d6_socket.c | 2 +-
|
||||
networking/udhcp/ifaddrs.c | 600 +++++++++++++++++++++++++++++++++++
|
||||
networking/udhcp/ifaddrs.h | 54 ++++
|
||||
4 files changed, 656 insertions(+), 1 deletion(-)
|
||||
create mode 100644 networking/udhcp/ifaddrs.c
|
||||
create mode 100644 networking/udhcp/ifaddrs.h
|
||||
|
||||
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
|
||||
index cdd06188e..498ea2690 100644
|
||||
--- a/networking/udhcp/d6_dhcpc.c
|
||||
+++ b/networking/udhcp/d6_dhcpc.c
|
||||
@@ -48,6 +48,7 @@
|
||||
//applet:IF_UDHCPC6(APPLET(udhcpc6, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
|
||||
//kbuild:lib-$(CONFIG_UDHCPC6) += d6_dhcpc.o d6_packet.o d6_socket.o common.o socket.o signalpipe.o
|
||||
+//kbuild:lib-$(CONFIG_UDHCPC6) += ifaddrs.o
|
||||
//kbuild:lib-$(CONFIG_FEATURE_UDHCPC6_RFC3646) += domain_codec.o
|
||||
//kbuild:lib-$(CONFIG_FEATURE_UDHCPC6_RFC4704) += domain_codec.o
|
||||
|
||||
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c
|
||||
index acf108367..38de5d0d0 100644
|
||||
--- a/networking/udhcp/d6_socket.c
|
||||
+++ b/networking/udhcp/d6_socket.c
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "common.h"
|
||||
#include "d6_common.h"
|
||||
#include <net/if.h>
|
||||
-#include <ifaddrs.h>
|
||||
+#include "ifaddrs.h"
|
||||
#include <netpacket/packet.h>
|
||||
|
||||
int FAST_FUNC d6_read_interface(
|
||||
diff --git a/networking/udhcp/ifaddrs.c b/networking/udhcp/ifaddrs.c
|
||||
new file mode 100644
|
||||
index 000000000..338fff887
|
||||
--- /dev/null
|
||||
+++ b/networking/udhcp/ifaddrs.c
|
||||
@@ -0,0 +1,600 @@
|
||||
+/*
|
||||
+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.
|
||||
+*/
|
||||
+
|
||||
+#include "ifaddrs.h"
|
||||
+
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <errno.h>
|
||||
+#include <unistd.h>
|
||||
+#include <sys/socket.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)
|
||||
+{
|
||||
+ char l_buffer[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))];
|
||||
+ memset(l_buffer, 0, sizeof(l_buffer));
|
||||
+ struct nlmsghdr *l_hdr = (struct nlmsghdr *)l_buffer;
|
||||
+ struct rtgenmsg *l_msg = (struct rtgenmsg *)NLMSG_DATA(l_hdr);
|
||||
+
|
||||
+ l_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*l_msg));
|
||||
+ l_hdr->nlmsg_type = p_request;
|
||||
+ l_hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
|
||||
+ l_hdr->nlmsg_pid = 0;
|
||||
+ l_hdr->nlmsg_seq = p_socket;
|
||||
+ l_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_hdr, l_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;
|
||||
+ int l_result;
|
||||
+
|
||||
+ 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);
|
||||
+
|
||||
+ 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 l_buffer;
|
||||
+ }
|
||||
+
|
||||
+ l_size *= 2;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size)
|
||||
+{
|
||||
+ NetlinkList *l_item = malloc(sizeof(NetlinkList));
|
||||
+ 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)
|
||||
+ { // error
|
||||
+ freeResultList(l_list);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ NetlinkList *l_item = newListItem(l_hdr, l_size);
|
||||
+ 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 void interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, 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 = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifinfomsg))); 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 = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize + l_dataSize);
|
||||
+ memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||
+ l_entry->ifa_name = "";
|
||||
+
|
||||
+ char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||
+ char *l_addr = l_name + l_nameSize;
|
||||
+ char *l_data = l_addr + l_addrSize;
|
||||
+
|
||||
+ l_entry->ifa_flags = l_info->ifi_flags;
|
||||
+
|
||||
+ l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg));
|
||||
+ for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifinfomsg))); 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, 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);
|
||||
+ p_links[l_info->ifi_index - 1] = l_entry;
|
||||
+}
|
||||
+
|
||||
+static void interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, struct ifaddrs **p_resultList)
|
||||
+{
|
||||
+ struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr);
|
||||
+
|
||||
+ 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 = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))); 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);
|
||||
+ if(l_info->ifa_family == AF_PACKET)
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ 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 = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize);
|
||||
+ memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||
+ l_entry->ifa_name = p_links[l_info->ifa_index - 1]->ifa_name;
|
||||
+
|
||||
+ char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||
+ char *l_addr = l_name + l_nameSize;
|
||||
+
|
||||
+ l_entry->ifa_flags = l_info->ifa_flags | p_links[l_info->ifa_index - 1]->ifa_flags;
|
||||
+
|
||||
+ l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
|
||||
+ for(l_rta = (struct rtattr *)(((char *)l_info) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))); 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, 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;
|
||||
+ }
|
||||
+ 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);
|
||||
+}
|
||||
+
|
||||
+static void interpret(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_links, struct ifaddrs **p_resultList)
|
||||
+{
|
||||
+ 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)
|
||||
+ {
|
||||
+ interpretLink(l_hdr, p_links, p_resultList);
|
||||
+ }
|
||||
+ else if(l_hdr->nlmsg_type == RTM_NEWADDR)
|
||||
+ {
|
||||
+ interpretAddr(l_hdr, p_links, p_resultList);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static unsigned countLinks(int p_socket, NetlinkList *p_netlinkList)
|
||||
+{
|
||||
+ unsigned l_links = 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)
|
||||
+ {
|
||||
+ ++l_links;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return l_links;
|
||||
+}
|
||||
+
|
||||
+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;
|
||||
+ }
|
||||
+
|
||||
+ unsigned l_numLinks = countLinks(l_socket, l_linkResults) + countLinks(l_socket, l_addrResults);
|
||||
+ struct ifaddrs *l_links[l_numLinks];
|
||||
+ memset(l_links, 0, l_numLinks * sizeof(struct ifaddrs *));
|
||||
+
|
||||
+ interpret(l_socket, l_linkResults, l_links, ifap);
|
||||
+ interpret(l_socket, l_addrResults, l_links, ifap);
|
||||
+
|
||||
+ freeResultList(l_linkResults);
|
||||
+ freeResultList(l_addrResults);
|
||||
+ close(l_socket);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void freeifaddrs(struct ifaddrs *ifa)
|
||||
+{
|
||||
+ struct ifaddrs *l_cur;
|
||||
+ while(ifa)
|
||||
+ {
|
||||
+ l_cur = ifa;
|
||||
+ ifa = ifa->ifa_next;
|
||||
+ free(l_cur);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/networking/udhcp/ifaddrs.h b/networking/udhcp/ifaddrs.h
|
||||
new file mode 100644
|
||||
index 000000000..9cd19fec1
|
||||
--- /dev/null
|
||||
+++ b/networking/udhcp/ifaddrs.h
|
||||
@@ -0,0 +1,54 @@
|
||||
+/*
|
||||
+ * 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
|
||||
+ */
|
||||
+
|
||||
+#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
|
||||
+extern int getifaddrs(struct ifaddrs **ifap);
|
||||
+extern void freeifaddrs(struct ifaddrs *ifa);
|
||||
+__END_DECLS
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,74 +0,0 @@
|
||||
From 52cb97b856e3f7e6ff9972fc8099170c5574f274 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Sat, 2 Oct 2021 01:11:12 -0300
|
||||
Subject: [PATCH 18/35] fix hush: add missing definitions on Android API 21+
|
||||
|
||||
platform FAST_FUNC adjustment to support NDK unified headers by John Wu <topjohnwu@gmail.com>
|
||||
|
||||
issetugid is required for hush via glob.c; add the hacky pre-API 21 definition back
|
||||
|
||||
Rebased for busybox 1.34.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
include/platform.h | 10 +++++++++-
|
||||
libbb/platform.c | 8 ++++++++
|
||||
2 files changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/platform.h b/include/platform.h
|
||||
index 6644d83c6..57f0ef57d 100644
|
||||
--- a/include/platform.h
|
||||
+++ b/include/platform.h
|
||||
@@ -124,7 +124,7 @@
|
||||
* (-DFAST_FUNC= )
|
||||
*/
|
||||
#ifndef FAST_FUNC
|
||||
-# if __GNUC_PREREQ(3,0) && defined(i386)
|
||||
+# if !defined(__ANDROID__) && __GNUC_PREREQ(3,0) && defined(i386)
|
||||
/* stdcall makes callee to pop arguments from stack, not caller */
|
||||
# define FAST_FUNC __attribute__((regparm(3),stdcall))
|
||||
/* #elif ... - add your favorite arch today! */
|
||||
@@ -429,6 +429,7 @@ typedef unsigned smalluint;
|
||||
#define HAVE_SYS_STATFS_H 1
|
||||
#define HAVE_PRINTF_PERCENTM 1
|
||||
#define HAVE_WAIT3 1
|
||||
+#define HAVE_ISSETUGID 1
|
||||
#define HAVE_DEV_FD 1
|
||||
#define DEV_FD_PREFIX "/dev/fd/"
|
||||
|
||||
@@ -536,6 +537,9 @@ typedef unsigned smalluint;
|
||||
# else
|
||||
/* ANDROID >= 21 has standard dprintf */
|
||||
# endif
|
||||
+# if __ANDROID_API__ > 18
|
||||
+# undef HAVE_ISSETUGID
|
||||
+# endif
|
||||
# if __ANDROID_API__ < 21
|
||||
# undef HAVE_TTYNAME_R
|
||||
# undef HAVE_GETLINE
|
||||
@@ -636,4 +640,8 @@ extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC
|
||||
extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC;
|
||||
#endif
|
||||
|
||||
+#ifndef HAVE_ISSETUGID
|
||||
+extern int issetugid(void) FAST_FUNC;
|
||||
+#endif
|
||||
+
|
||||
#endif
|
||||
diff --git a/libbb/platform.c b/libbb/platform.c
|
||||
index 7913353e2..b652a2112 100644
|
||||
--- a/libbb/platform.c
|
||||
+++ b/libbb/platform.c
|
||||
@@ -225,3 +225,11 @@ int ttyname_r(int fd, char *buf, size_t buflen)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+#ifndef HAVE_ISSETUGID
|
||||
+int issetugid(void)
|
||||
+{
|
||||
+ /* for Bionic, this is sufficient */
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,967 +0,0 @@
|
||||
From 2e11b46a8df4509d8b134f3c0d9df0c626180511 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Tue, 10 Jan 2017 10:49:59 -0400
|
||||
Subject: [PATCH 19/35] fix hush, add glob and sigisemptyset
|
||||
|
||||
Patch by Tias Guns <tias@ulyssis.org>, based on 'glob' by Dan Drown
|
||||
http://dan.drown.org/android/src/busybox/
|
||||
Rebased for busybox 1.26.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
shell/glob.c | 786 ++++++++++++++++++++++++++++++++++++++++++
|
||||
shell/glob.h | 113 ++++++
|
||||
shell/hush.c | 3 +-
|
||||
shell/sigisemptyset.c | 8 +
|
||||
4 files changed, 909 insertions(+), 1 deletion(-)
|
||||
create mode 100644 shell/glob.c
|
||||
create mode 100644 shell/glob.h
|
||||
create mode 100644 shell/sigisemptyset.c
|
||||
|
||||
diff --git a/shell/glob.c b/shell/glob.c
|
||||
new file mode 100644
|
||||
index 000000000..556d72099
|
||||
--- /dev/null
|
||||
+++ b/shell/glob.c
|
||||
@@ -0,0 +1,786 @@
|
||||
+/*
|
||||
+ * Modified for the Android NDK by Gabor Cselle, http://www.gaborcselle.com/
|
||||
+ * Tested with Android NDK version 5b: http://developer.android.com/sdk/ndk/index.html
|
||||
+ * Last modified: March 3 2011
|
||||
+ *
|
||||
+ * Copyright (c) 1989, 1993
|
||||
+ * The Regents of the University of California. All rights reserved.
|
||||
+ *
|
||||
+ * This code is derived from software contributed to Berkeley by
|
||||
+ * Guido van Rossum.
|
||||
+ *
|
||||
+ * 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.
|
||||
+ */
|
||||
+
|
||||
+#if defined(LIBC_SCCS) && !defined(lint)
|
||||
+static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
|
||||
+#endif /* LIBC_SCCS and not lint */
|
||||
+#include <sys/cdefs.h>
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * glob(3) -- a superset of the one defined in POSIX 1003.2.
|
||||
+ *
|
||||
+ * The [!...] convention to negate a range is supported (SysV, Posix, ksh).
|
||||
+ *
|
||||
+ * Optional extra services, controlled by flags not defined by POSIX:
|
||||
+ *
|
||||
+ * GLOB_QUOTE:
|
||||
+ * Escaping convention: \ inhibits any special meaning the following
|
||||
+ * character might have (except \ at end of string is retained).
|
||||
+ * GLOB_MAGCHAR:
|
||||
+ * Set in gl_flags if pattern contained a globbing character.
|
||||
+ * GLOB_NOMAGIC:
|
||||
+ * Same as GLOB_NOCHECK, but it will only append pattern if it did
|
||||
+ * not contain any magic characters. [Used in csh style globbing]
|
||||
+ * GLOB_ALTDIRFUNC:
|
||||
+ * Use alternately specified directory access functions.
|
||||
+ * GLOB_TILDE:
|
||||
+ * expand ~user/foo to the /home/dir/of/user/foo
|
||||
+ * GLOB_BRACE:
|
||||
+ * expand {1,2}{a,b} to 1a 1b 2a 2b
|
||||
+ * gl_matchc:
|
||||
+ * Number of matches in the current invocation of glob.
|
||||
+ */
|
||||
+
|
||||
+/*
|
||||
+ * Some notes on multibyte character support:
|
||||
+ * 1. Patterns with illegal byte sequences match nothing - even if
|
||||
+ * GLOB_NOCHECK is specified.
|
||||
+ * 2. Illegal byte sequences in filenames are handled by treating them as
|
||||
+ * single-byte characters with a value of the first byte of the sequence
|
||||
+ * cast to wchar_t.
|
||||
+ * 3. State-dependent encodings are not currently supported.
|
||||
+ */
|
||||
+
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/stat.h>
|
||||
+
|
||||
+#include <ctype.h>
|
||||
+#include <dirent.h>
|
||||
+#include <errno.h>
|
||||
+#include "glob.h"
|
||||
+#include <limits.h>
|
||||
+#include <pwd.h>
|
||||
+#include <stdint.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+//#include "collate.h" - NOTE(gabor): I took this out because it's not available for Android
|
||||
+// and collate is only used once for string comparisons. As a side-effect, you might not
|
||||
+// be able to match non-ASCII filenames.
|
||||
+
|
||||
+#define DOLLAR '$'
|
||||
+#define DOT '.'
|
||||
+#define EOS '\0'
|
||||
+#define LBRACKET '['
|
||||
+#define NOT '!'
|
||||
+#define QUESTION '?'
|
||||
+#define QUOTE '\\'
|
||||
+#define RANGE '-'
|
||||
+#define RBRACKET ']'
|
||||
+#define SEP '/'
|
||||
+#define STAR '*'
|
||||
+#define TILDE '~'
|
||||
+#define UNDERSCORE '_'
|
||||
+#define LBRACE '{'
|
||||
+#define RBRACE '}'
|
||||
+#define SLASH '/'
|
||||
+#define COMMA ','
|
||||
+
|
||||
+#define M_PROTECT 0x40
|
||||
+#define M_MASK 0xff
|
||||
+
|
||||
+
|
||||
+#define M_ALL '*'
|
||||
+#define M_END ']'
|
||||
+#define M_NOT '!'
|
||||
+#define M_ONE '?'
|
||||
+#define M_RNG '-'
|
||||
+#define M_SET '['
|
||||
+
|
||||
+
|
||||
+static int g_stat(char *, struct stat *, glob_t *);
|
||||
+static int g_lstat(char *, struct stat *, glob_t *);
|
||||
+static DIR *g_opendir(char *, glob_t *);
|
||||
+static int compare(const void *, const void *);
|
||||
+static int glob0(const char *, glob_t *, size_t *);
|
||||
+static int glob1(char *, glob_t *, size_t *);
|
||||
+static int glob2(char *, char *, char *, char *, glob_t *, size_t *);
|
||||
+static int glob3(char *, char *, char *, char *, char *, glob_t *, size_t *);
|
||||
+static int globextend(const char *, glob_t *, size_t *);
|
||||
+static const char *
|
||||
+ globtilde(const char *, char *, size_t, glob_t *);
|
||||
+static int globexp1(const char *, glob_t *, size_t *);
|
||||
+static int globexp2(const char *, const char *, glob_t *, int *, size_t *);
|
||||
+static int match(char *, char *, char *);
|
||||
+
|
||||
+int ismeta(char c) {
|
||||
+ return c == M_ALL || c == M_END || c == M_NOT || c == M_ONE || c == M_RNG || c == M_SET;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
|
||||
+{
|
||||
+ const char *patnext;
|
||||
+ size_t limit;
|
||||
+ char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
|
||||
+
|
||||
+ patnext = pattern;
|
||||
+ if (!(flags & GLOB_APPEND)) {
|
||||
+ pglob->gl_pathc = 0;
|
||||
+ pglob->gl_pathv = NULL;
|
||||
+ if (!(flags & GLOB_DOOFFS))
|
||||
+ pglob->gl_offs = 0;
|
||||
+ }
|
||||
+ if (flags & GLOB_LIMIT) {
|
||||
+ limit = pglob->gl_matchc;
|
||||
+ if (limit == 0)
|
||||
+ limit = 131072;
|
||||
+ } else
|
||||
+ limit = 0;
|
||||
+ pglob->gl_flags = flags & ~GLOB_MAGCHAR;
|
||||
+ pglob->gl_errfunc = errfunc;
|
||||
+ pglob->gl_matchc = 0;
|
||||
+
|
||||
+ bufnext = patbuf;
|
||||
+ bufend = bufnext + MAXPATHLEN - 1;
|
||||
+ if (flags & GLOB_NOESCAPE) {
|
||||
+ strncpy(bufnext, patnext, sizeof(patbuf));
|
||||
+ } else {
|
||||
+ /* Protect the quoted characters. */
|
||||
+ while (bufend >= bufnext && *patnext != EOS) {
|
||||
+ if (*patnext == QUOTE) {
|
||||
+ if (*++patnext == EOS) {
|
||||
+ *bufnext++ = QUOTE | M_PROTECT;
|
||||
+ continue;
|
||||
+ }
|
||||
+ prot = M_PROTECT;
|
||||
+ } else
|
||||
+ prot = 0;
|
||||
+ *bufnext++ = *patnext;
|
||||
+ patnext++;
|
||||
+ }
|
||||
+ }
|
||||
+ *bufnext = EOS;
|
||||
+
|
||||
+ if (flags & GLOB_BRACE)
|
||||
+ return globexp1(patbuf, pglob, &limit);
|
||||
+ else
|
||||
+ return glob0(patbuf, pglob, &limit);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Expand recursively a glob {} pattern. When there is no more expansion
|
||||
+ * invoke the standard globbing routine to glob the rest of the magic
|
||||
+ * characters
|
||||
+ */
|
||||
+static int
|
||||
+globexp1(const char *pattern, glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ const char* ptr = pattern;
|
||||
+ int rv;
|
||||
+
|
||||
+ /* Protect a single {}, for find(1), like csh */
|
||||
+ if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
|
||||
+ return glob0(pattern, pglob, limit);
|
||||
+
|
||||
+ while ((ptr = strchr(ptr, LBRACE)) != NULL)
|
||||
+ if (!globexp2(ptr, pattern, pglob, &rv, limit))
|
||||
+ return rv;
|
||||
+
|
||||
+ return glob0(pattern, pglob, limit);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Recursive brace globbing helper. Tries to expand a single brace.
|
||||
+ * If it succeeds then it invokes globexp1 with the new pattern.
|
||||
+ * If it fails then it tries to glob the rest of the pattern and returns.
|
||||
+ */
|
||||
+static int
|
||||
+globexp2(const char *ptr, const char *pattern, glob_t *pglob, int *rv, size_t *limit)
|
||||
+{
|
||||
+ int i;
|
||||
+ char *lm, *ls;
|
||||
+ const char *pe, *pm, *pm1, *pl;
|
||||
+ char patbuf[MAXPATHLEN];
|
||||
+
|
||||
+ /* copy part up to the brace */
|
||||
+ for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
|
||||
+ continue;
|
||||
+ *lm = EOS;
|
||||
+ ls = lm;
|
||||
+
|
||||
+ /* Find the balanced brace */
|
||||
+ for (i = 0, pe = ++ptr; *pe; pe++)
|
||||
+ if (*pe == LBRACKET) {
|
||||
+ /* Ignore everything between [] */
|
||||
+ for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
|
||||
+ continue;
|
||||
+ if (*pe == EOS) {
|
||||
+ /*
|
||||
+ * We could not find a matching RBRACKET.
|
||||
+ * Ignore and just look for RBRACE
|
||||
+ */
|
||||
+ pe = pm;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (*pe == LBRACE)
|
||||
+ i++;
|
||||
+ else if (*pe == RBRACE) {
|
||||
+ if (i == 0)
|
||||
+ break;
|
||||
+ i--;
|
||||
+ }
|
||||
+
|
||||
+ /* Non matching braces; just glob the pattern */
|
||||
+ if (i != 0 || *pe == EOS) {
|
||||
+ *rv = glob0(patbuf, pglob, limit);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0, pl = pm = ptr; pm <= pe; pm++)
|
||||
+ switch (*pm) {
|
||||
+ case LBRACKET:
|
||||
+ /* Ignore everything between [] */
|
||||
+ for (pm1 = pm++; *pm != RBRACKET && *pm != EOS; pm++)
|
||||
+ continue;
|
||||
+ if (*pm == EOS) {
|
||||
+ /*
|
||||
+ * We could not find a matching RBRACKET.
|
||||
+ * Ignore and just look for RBRACE
|
||||
+ */
|
||||
+ pm = pm1;
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ case LBRACE:
|
||||
+ i++;
|
||||
+ break;
|
||||
+
|
||||
+ case RBRACE:
|
||||
+ if (i) {
|
||||
+ i--;
|
||||
+ break;
|
||||
+ }
|
||||
+ /* FALLTHROUGH */
|
||||
+ case COMMA:
|
||||
+ if (i && *pm == COMMA)
|
||||
+ break;
|
||||
+ else {
|
||||
+ /* Append the current string */
|
||||
+ for (lm = ls; (pl < pm); *lm++ = *pl++)
|
||||
+ continue;
|
||||
+ /*
|
||||
+ * Append the rest of the pattern after the
|
||||
+ * closing brace
|
||||
+ */
|
||||
+ for (pl = pe + 1; (*lm++ = *pl++) != EOS;)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Expand the current pattern */
|
||||
+ *rv = globexp1(patbuf, pglob, limit);
|
||||
+
|
||||
+ /* move after the comma, to the next string */
|
||||
+ pl = pm + 1;
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ *rv = 0;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * expand tilde from the passwd file.
|
||||
+ */
|
||||
+static const char *
|
||||
+globtilde(const char *pattern, char *patbuf, size_t patbuf_len, glob_t *pglob)
|
||||
+{
|
||||
+ struct passwd *pwd;
|
||||
+ char *h;
|
||||
+ const char *p;
|
||||
+ char *b, *eb;
|
||||
+
|
||||
+ if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
|
||||
+ return pattern;
|
||||
+
|
||||
+ /*
|
||||
+ * Copy up to the end of the string or /
|
||||
+ */
|
||||
+ eb = &patbuf[patbuf_len - 1];
|
||||
+ for (p = pattern + 1, h = (char *) patbuf;
|
||||
+ h < (char *)eb && *p && *p != SLASH; *h++ = *p++)
|
||||
+ continue;
|
||||
+
|
||||
+ *h = EOS;
|
||||
+
|
||||
+ if (((char *) patbuf)[0] == EOS) {
|
||||
+ /*
|
||||
+ * handle a plain ~ or ~/ by expanding $HOME first (iff
|
||||
+ * we're not running setuid or setgid) and then trying
|
||||
+ * the password file
|
||||
+ */
|
||||
+#ifndef __GLIBC__
|
||||
+ if (issetugid() != 0 ||
|
||||
+ (h = getenv("HOME")) == NULL) {
|
||||
+ if (((h = getlogin()) != NULL &&
|
||||
+ (pwd = getpwnam(h)) != NULL) ||
|
||||
+ (pwd = getpwuid(getuid())) != NULL)
|
||||
+ h = pwd->pw_dir;
|
||||
+ else
|
||||
+ return pattern;
|
||||
+ }
|
||||
+#endif
|
||||
+ }
|
||||
+ else {
|
||||
+ /*
|
||||
+ * Expand a ~user
|
||||
+ */
|
||||
+ if ((pwd = getpwnam((char*) patbuf)) == NULL)
|
||||
+ return pattern;
|
||||
+ else
|
||||
+ h = pwd->pw_dir;
|
||||
+ }
|
||||
+
|
||||
+ /* Copy the home directory */
|
||||
+ for (b = patbuf; b < eb && *h; *b++ = *h++)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Append the rest of the pattern */
|
||||
+ while (b < eb && (*b++ = *p++) != EOS)
|
||||
+ continue;
|
||||
+ *b = EOS;
|
||||
+
|
||||
+ return patbuf;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * The main glob() routine: compiles the pattern (optionally processing
|
||||
+ * quotes), calls glob1() to do the real pattern matching, and finally
|
||||
+ * sorts the list (unless unsorted operation is requested). Returns 0
|
||||
+ * if things went well, nonzero if errors occurred.
|
||||
+ */
|
||||
+static int
|
||||
+glob0(const char *pattern, glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ const char *qpatnext;
|
||||
+ int err;
|
||||
+ size_t oldpathc;
|
||||
+ char *bufnext, c, patbuf[MAXPATHLEN];
|
||||
+
|
||||
+ qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
|
||||
+ oldpathc = pglob->gl_pathc;
|
||||
+ bufnext = patbuf;
|
||||
+
|
||||
+ /* We don't need to check for buffer overflow any more. */
|
||||
+ while ((c = *qpatnext++) != EOS) {
|
||||
+ switch (c) {
|
||||
+ case LBRACKET:
|
||||
+ c = *qpatnext;
|
||||
+ if (c == NOT)
|
||||
+ ++qpatnext;
|
||||
+ if (*qpatnext == EOS ||
|
||||
+ strchr(qpatnext+1, RBRACKET) == NULL) {
|
||||
+ *bufnext++ = LBRACKET;
|
||||
+ if (c == NOT)
|
||||
+ --qpatnext;
|
||||
+ break;
|
||||
+ }
|
||||
+ *bufnext++ = M_SET;
|
||||
+ if (c == NOT)
|
||||
+ *bufnext++ = M_NOT;
|
||||
+ c = *qpatnext++;
|
||||
+ do {
|
||||
+ *bufnext++ = c;
|
||||
+ if (*qpatnext == RANGE &&
|
||||
+ (c = qpatnext[1]) != RBRACKET) {
|
||||
+ *bufnext++ = M_RNG;
|
||||
+ *bufnext++ = c;
|
||||
+ qpatnext += 2;
|
||||
+ }
|
||||
+ } while ((c = *qpatnext++) != RBRACKET);
|
||||
+ pglob->gl_flags |= GLOB_MAGCHAR;
|
||||
+ *bufnext++ = M_END;
|
||||
+ break;
|
||||
+ case QUESTION:
|
||||
+ pglob->gl_flags |= GLOB_MAGCHAR;
|
||||
+ *bufnext++ = M_ONE;
|
||||
+ break;
|
||||
+ case STAR:
|
||||
+ pglob->gl_flags |= GLOB_MAGCHAR;
|
||||
+ /* collapse adjacent stars to one,
|
||||
+ * to avoid exponential behavior
|
||||
+ */
|
||||
+ if (bufnext == patbuf || bufnext[-1] != M_ALL)
|
||||
+ *bufnext++ = M_ALL;
|
||||
+ break;
|
||||
+ default:
|
||||
+ *bufnext++ = c;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ *bufnext = EOS;
|
||||
+
|
||||
+ if ((err = glob1(patbuf, pglob, limit)) != 0)
|
||||
+ return(err);
|
||||
+
|
||||
+ /*
|
||||
+ * If there was no match we are going to append the pattern
|
||||
+ * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
|
||||
+ * and the pattern did not contain any magic characters
|
||||
+ * GLOB_NOMAGIC is there just for compatibility with csh.
|
||||
+ */
|
||||
+ if (pglob->gl_pathc == oldpathc) {
|
||||
+ if (((pglob->gl_flags & GLOB_NOCHECK) ||
|
||||
+ ((pglob->gl_flags & GLOB_NOMAGIC) &&
|
||||
+ !(pglob->gl_flags & GLOB_MAGCHAR))))
|
||||
+ return(globextend(pattern, pglob, limit));
|
||||
+ else
|
||||
+ return(GLOB_NOMATCH);
|
||||
+ }
|
||||
+ if (!(pglob->gl_flags & GLOB_NOSORT))
|
||||
+ qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
|
||||
+ pglob->gl_pathc - oldpathc, sizeof(char *), compare);
|
||||
+ return(0);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+compare(const void *p, const void *q)
|
||||
+{
|
||||
+ return(strcmp(*(char **)p, *(char **)q));
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+glob1(char *pattern, glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ char pathbuf[MAXPATHLEN];
|
||||
+
|
||||
+ /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
|
||||
+ if (*pattern == EOS)
|
||||
+ return(0);
|
||||
+ return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
|
||||
+ pattern, pglob, limit));
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * The functions glob2 and glob3 are mutually recursive; there is one level
|
||||
+ * of recursion for each segment in the pattern that contains one or more
|
||||
+ * meta characters.
|
||||
+ */
|
||||
+static int
|
||||
+glob2(char *pathbuf, char *pathend, char *pathend_last, char *pattern,
|
||||
+ glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ struct stat sb;
|
||||
+ char *p, *q;
|
||||
+ int anymeta;
|
||||
+
|
||||
+ /*
|
||||
+ * Loop over pattern segments until end of pattern or until
|
||||
+ * segment with meta character found.
|
||||
+ */
|
||||
+ for (anymeta = 0;;) {
|
||||
+ if (*pattern == EOS) { /* End of pattern? */
|
||||
+ *pathend = EOS;
|
||||
+ if (g_lstat(pathbuf, &sb, pglob))
|
||||
+ return(0);
|
||||
+
|
||||
+ if (((pglob->gl_flags & GLOB_MARK) &&
|
||||
+ pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
|
||||
+ || (S_ISLNK(sb.st_mode) &&
|
||||
+ (g_stat(pathbuf, &sb, pglob) == 0) &&
|
||||
+ S_ISDIR(sb.st_mode)))) {
|
||||
+ if (pathend + 1 > pathend_last)
|
||||
+ return (GLOB_ABORTED);
|
||||
+ *pathend++ = SEP;
|
||||
+ *pathend = EOS;
|
||||
+ }
|
||||
+ ++pglob->gl_matchc;
|
||||
+ return(globextend(pathbuf, pglob, limit));
|
||||
+ }
|
||||
+
|
||||
+ /* Find end of next segment, copy tentatively to pathend. */
|
||||
+ q = pathend;
|
||||
+ p = pattern;
|
||||
+ while (*p != EOS && *p != SEP) {
|
||||
+ if (ismeta(*p))
|
||||
+ anymeta = 1;
|
||||
+ if (q + 1 > pathend_last)
|
||||
+ return (GLOB_ABORTED);
|
||||
+ *q++ = *p++;
|
||||
+ }
|
||||
+
|
||||
+ if (!anymeta) { /* No expansion, do next segment. */
|
||||
+ pathend = q;
|
||||
+ pattern = p;
|
||||
+ while (*pattern == SEP) {
|
||||
+ if (pathend + 1 > pathend_last)
|
||||
+ return (GLOB_ABORTED);
|
||||
+ *pathend++ = *pattern++;
|
||||
+ }
|
||||
+ } else /* Need expansion, recurse. */
|
||||
+ return(glob3(pathbuf, pathend, pathend_last, pattern, p,
|
||||
+ pglob, limit));
|
||||
+ }
|
||||
+ /* NOTREACHED */
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+glob3(char *pathbuf, char *pathend, char *pathend_last,
|
||||
+ char *pattern, char *restpattern,
|
||||
+ glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ struct dirent *dp;
|
||||
+ DIR *dirp;
|
||||
+ int err;
|
||||
+ char buf[MAXPATHLEN];
|
||||
+
|
||||
+ /*
|
||||
+ * The readdirfunc declaration can't be prototyped, because it is
|
||||
+ * assigned, below, to two functions which are prototyped in glob.h
|
||||
+ * and dirent.h as taking pointers to differently typed opaque
|
||||
+ * structures.
|
||||
+ */
|
||||
+ struct dirent *(*readdirfunc)();
|
||||
+
|
||||
+ if (pathend > pathend_last)
|
||||
+ return (GLOB_ABORTED);
|
||||
+ *pathend = EOS;
|
||||
+ errno = 0;
|
||||
+
|
||||
+ if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
|
||||
+ /* TODO: don't call for ENOENT or ENOTDIR? */
|
||||
+ if (pglob->gl_errfunc) {
|
||||
+ if (pglob->gl_errfunc(buf, errno) ||
|
||||
+ pglob->gl_flags & GLOB_ERR)
|
||||
+ return (GLOB_ABORTED);
|
||||
+ }
|
||||
+ return(0);
|
||||
+ }
|
||||
+
|
||||
+ err = 0;
|
||||
+
|
||||
+ /* Search directory for matching names. */
|
||||
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
+ readdirfunc = pglob->gl_readdir;
|
||||
+ else
|
||||
+ readdirfunc = readdir;
|
||||
+ while ((dp = (*readdirfunc)(dirp))) {
|
||||
+ char *sc;
|
||||
+ char *dc;
|
||||
+
|
||||
+ /* Initial DOT must be matched literally. */
|
||||
+ if (dp->d_name[0] == DOT && *pattern != DOT)
|
||||
+ continue;
|
||||
+ dc = pathend;
|
||||
+ sc = dp->d_name;
|
||||
+ while (dc < pathend_last) {
|
||||
+ if ((*dc++ = *sc) == EOS)
|
||||
+ break;
|
||||
+ sc++;
|
||||
+ }
|
||||
+ if (!match(pathend, pattern, restpattern)) {
|
||||
+ *pathend = EOS;
|
||||
+ continue;
|
||||
+ }
|
||||
+ err = glob2(pathbuf, --dc, pathend_last, restpattern,
|
||||
+ pglob, limit);
|
||||
+ if (err)
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
+ (*pglob->gl_closedir)(dirp);
|
||||
+ else
|
||||
+ closedir(dirp);
|
||||
+ return(err);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
|
||||
+ * add the new item, and update gl_pathc.
|
||||
+ *
|
||||
+ * This assumes the BSD realloc, which only copies the block when its size
|
||||
+ * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
|
||||
+ * behavior.
|
||||
+ *
|
||||
+ * Return 0 if new item added, error code if memory couldn't be allocated.
|
||||
+ *
|
||||
+ * Invariant of the glob_t structure:
|
||||
+ * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
|
||||
+ * gl_pathv points to (gl_offs + gl_pathc + 1) items.
|
||||
+ */
|
||||
+static int
|
||||
+globextend(const char *path, glob_t *pglob, size_t *limit)
|
||||
+{
|
||||
+ char **pathv;
|
||||
+ size_t i, newsize, len;
|
||||
+ char *copy;
|
||||
+ const char *p;
|
||||
+
|
||||
+ if (*limit && pglob->gl_pathc > *limit) {
|
||||
+ errno = 0;
|
||||
+ return (GLOB_NOSPACE);
|
||||
+ }
|
||||
+
|
||||
+ newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
|
||||
+ pathv = pglob->gl_pathv ?
|
||||
+ realloc((char *)pglob->gl_pathv, newsize) :
|
||||
+ malloc(newsize);
|
||||
+ if (pathv == NULL) {
|
||||
+ if (pglob->gl_pathv) {
|
||||
+ free(pglob->gl_pathv);
|
||||
+ pglob->gl_pathv = NULL;
|
||||
+ }
|
||||
+ return(GLOB_NOSPACE);
|
||||
+ }
|
||||
+
|
||||
+ if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
|
||||
+ /* first time around -- clear initial gl_offs items */
|
||||
+ pathv += pglob->gl_offs;
|
||||
+ for (i = pglob->gl_offs + 1; --i > 0; )
|
||||
+ *--pathv = NULL;
|
||||
+ }
|
||||
+ pglob->gl_pathv = pathv;
|
||||
+
|
||||
+ for (p = path; *p++;)
|
||||
+ continue;
|
||||
+ len = (size_t)(p - path); /* XXX overallocation */
|
||||
+ if ((copy = malloc(len)) != NULL) {
|
||||
+ strncpy(copy, path, len);
|
||||
+ pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
|
||||
+ }
|
||||
+ pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||
+ return(copy == NULL ? GLOB_NOSPACE : 0);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * pattern matching function for filenames. Each occurrence of the *
|
||||
+ * pattern causes a recursion level.
|
||||
+ */
|
||||
+static int
|
||||
+match(char *name, char *pat, char *patend)
|
||||
+{
|
||||
+ int ok, negate_range;
|
||||
+ char c, k;
|
||||
+
|
||||
+ while (pat < patend) {
|
||||
+ c = *pat++;
|
||||
+ switch (c & M_MASK) {
|
||||
+ case M_ALL:
|
||||
+ if (pat == patend)
|
||||
+ return(1);
|
||||
+ do
|
||||
+ if (match(name, pat, patend))
|
||||
+ return(1);
|
||||
+ while (*name++ != EOS);
|
||||
+ return(0);
|
||||
+ case M_ONE:
|
||||
+ if (*name++ == EOS)
|
||||
+ return(0);
|
||||
+ break;
|
||||
+ case M_SET:
|
||||
+ ok = 0;
|
||||
+ if ((k = *name++) == EOS)
|
||||
+ return(0);
|
||||
+ if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
|
||||
+ ++pat;
|
||||
+ while (((c = *pat++) & M_MASK) != M_END)
|
||||
+ if ((*pat & M_MASK) == M_RNG) {
|
||||
+ // NOTE(gabor): This used to be as below, but I took out the collate.h
|
||||
+ // if (__collate_load_error ?
|
||||
+ // CHAR(c) <= CHAR(k) && CHAR(k) <= CHAR(pat[1]) :
|
||||
+ // __collate_range_cmp(CHAR(c), CHAR(k)) <= 0
|
||||
+ // && __collate_range_cmp(CHAR(k), CHAR(pat[1])) <= 0
|
||||
+ // )
|
||||
+
|
||||
+ if (c <= k && k <= pat[1])
|
||||
+ ok = 1;
|
||||
+ pat += 2;
|
||||
+ } else if (c == k)
|
||||
+ ok = 1;
|
||||
+ if (ok == negate_range)
|
||||
+ return(0);
|
||||
+ break;
|
||||
+ default:
|
||||
+ if (*name++ != c)
|
||||
+ return(0);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ return(*name == EOS);
|
||||
+}
|
||||
+
|
||||
+/* Free allocated data belonging to a glob_t structure. */
|
||||
+void
|
||||
+globfree(glob_t *pglob)
|
||||
+{
|
||||
+ size_t i;
|
||||
+ char **pp;
|
||||
+
|
||||
+ if (pglob->gl_pathv != NULL) {
|
||||
+ pp = pglob->gl_pathv + pglob->gl_offs;
|
||||
+ for (i = pglob->gl_pathc; i--; ++pp)
|
||||
+ if (*pp)
|
||||
+ free(*pp);
|
||||
+ free(pglob->gl_pathv);
|
||||
+ pglob->gl_pathv = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+g_stat(char *fn, struct stat *sb, glob_t *pglob)
|
||||
+{
|
||||
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
+ return((*pglob->gl_stat)(fn, sb));
|
||||
+ return(stat(fn, sb));
|
||||
+}
|
||||
+
|
||||
+static DIR *
|
||||
+g_opendir(char *str, glob_t *pglob)
|
||||
+{
|
||||
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
+ return((*pglob->gl_opendir)(str));
|
||||
+
|
||||
+ return(opendir(str));
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+g_lstat(char *fn, struct stat *sb, glob_t *pglob)
|
||||
+{
|
||||
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
+ return((*pglob->gl_lstat)(fn, sb));
|
||||
+ return(lstat(fn, sb));
|
||||
+}
|
||||
diff --git a/shell/glob.h b/shell/glob.h
|
||||
new file mode 100644
|
||||
index 000000000..e8e65786d
|
||||
--- /dev/null
|
||||
+++ b/shell/glob.h
|
||||
@@ -0,0 +1,113 @@
|
||||
+/*
|
||||
+ * Modified for the Android NDK by Gabor Cselle, http://www.gaborcselle.com/
|
||||
+ * Tested with Android NDK version 5b: http://developer.android.com/sdk/ndk/index.html
|
||||
+ * Last modified: March 3 2011
|
||||
+ *
|
||||
+ * Copyright (c) 1989, 1993
|
||||
+ * The Regents of the University of California. All rights reserved.
|
||||
+ *
|
||||
+ * This code is derived from software contributed to Berkeley by
|
||||
+ * Guido van Rossum.
|
||||
+ *
|
||||
+ * 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.
|
||||
+ * 3. All advertising materials mentioning features or use of this software
|
||||
+ * must display the following acknowledgement:
|
||||
+ * This product includes software developed by the University of
|
||||
+ * California, Berkeley and its contributors.
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * @(#)glob.h 8.1 (Berkeley) 6/2/93
|
||||
+ * $FreeBSD$
|
||||
+ */
|
||||
+
|
||||
+#ifndef _GLOB_H_
|
||||
+#define _GLOB_H_
|
||||
+
|
||||
+#include <sys/cdefs.h>
|
||||
+//#include <sys/_types.h>
|
||||
+
|
||||
+#ifndef _SIZE_T_DECLARED
|
||||
+typedef __size_t size_t;
|
||||
+#define _SIZE_T_DECLARED
|
||||
+#endif
|
||||
+
|
||||
+struct stat;
|
||||
+typedef struct {
|
||||
+ size_t gl_pathc; /* Count of total paths so far. */
|
||||
+ size_t gl_matchc; /* Count of paths matching pattern. */
|
||||
+ size_t gl_offs; /* Reserved at beginning of gl_pathv. */
|
||||
+ int gl_flags; /* Copy of flags parameter to glob. */
|
||||
+ char **gl_pathv; /* List of paths matching pattern. */
|
||||
+ /* Copy of errfunc parameter to glob. */
|
||||
+ int (*gl_errfunc)(const char *, int);
|
||||
+
|
||||
+ /*
|
||||
+ * Alternate filesystem access methods for glob; replacement
|
||||
+ * versions of closedir(3), readdir(3), opendir(3), stat(2)
|
||||
+ * and lstat(2).
|
||||
+ */
|
||||
+ void (*gl_closedir)(void *);
|
||||
+ struct dirent *(*gl_readdir)(void *);
|
||||
+ void *(*gl_opendir)(const char *);
|
||||
+ int (*gl_lstat)(const char *, struct stat *);
|
||||
+ int (*gl_stat)(const char *, struct stat *);
|
||||
+} glob_t;
|
||||
+
|
||||
+#if __POSIX_VISIBLE >= 199209
|
||||
+/* Believed to have been introduced in 1003.2-1992 */
|
||||
+#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
|
||||
+#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
|
||||
+#define GLOB_ERR 0x0004 /* Return on error. */
|
||||
+#define GLOB_MARK 0x0008 /* Append / to matching directories. */
|
||||
+#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
|
||||
+#define GLOB_NOSORT 0x0020 /* Don't sort. */
|
||||
+#define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */
|
||||
+
|
||||
+/* Error values returned by glob(3) */
|
||||
+#define GLOB_NOSPACE (-1) /* Malloc call failed. */
|
||||
+#define GLOB_ABORTED (-2) /* Unignored error. */
|
||||
+#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */
|
||||
+#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
|
||||
+#endif /* __POSIX_VISIBLE >= 199209 */
|
||||
+
|
||||
+#if __BSD_VISIBLE
|
||||
+#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
|
||||
+#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
|
||||
+#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
|
||||
+#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
|
||||
+#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
|
||||
+#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
|
||||
+#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
|
||||
+
|
||||
+/* source compatibility, these are the old names */
|
||||
+#define GLOB_MAXPATH GLOB_LIMIT
|
||||
+#define GLOB_ABEND GLOB_ABORTED
|
||||
+#endif /* __BSD_VISIBLE */
|
||||
+
|
||||
+__BEGIN_DECLS
|
||||
+int glob(const char *, int, int (*)(const char *, int), glob_t *);
|
||||
+void globfree(glob_t *);
|
||||
+__END_DECLS
|
||||
+
|
||||
+#endif /* !_GLOB_H_ */
|
||||
diff --git a/shell/hush.c b/shell/hush.c
|
||||
index d111f0cc5..af7f0d50c 100644
|
||||
--- a/shell/hush.c
|
||||
+++ b/shell/hush.c
|
||||
@@ -331,6 +331,7 @@
|
||||
//applet:IF_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, hush))
|
||||
|
||||
//kbuild:lib-$(CONFIG_SHELL_HUSH) += hush.o match.o shell_common.o
|
||||
+//kbuild:lib-$(CONFIG_SHELL_HUSH) += glob.o sigisemptyset.o
|
||||
//kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o
|
||||
|
||||
/* -i (interactive) is also accepted,
|
||||
@@ -348,7 +349,7 @@
|
||||
)
|
||||
# include <malloc.h> /* for malloc_trim */
|
||||
#endif
|
||||
-#include <glob.h>
|
||||
+#include "glob.h"
|
||||
/* #include <dmalloc.h> */
|
||||
#if ENABLE_HUSH_CASE
|
||||
# include <fnmatch.h>
|
||||
diff --git a/shell/sigisemptyset.c b/shell/sigisemptyset.c
|
||||
new file mode 100644
|
||||
index 000000000..649b974c0
|
||||
--- /dev/null
|
||||
+++ b/shell/sigisemptyset.c
|
||||
@@ -0,0 +1,8 @@
|
||||
+#include <signal.h>
|
||||
+
|
||||
+int sigisemptyset(const sigset_t *set)
|
||||
+{
|
||||
+ sigset_t empty;
|
||||
+ sigemptyset(&empty);
|
||||
+ return memcmp(&empty, set, sizeof(sigset_t)) == 0;
|
||||
+}
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,43 +0,0 @@
|
||||
From fcf2cf5c422df1f347eb24312722b5a01ae3ca44 Mon Sep 17 00:00:00 2001
|
||||
From: John Wu <topjohnwu@gmail.com>
|
||||
Date: Sun, 12 Aug 2018 18:31:26 +0800
|
||||
Subject: [PATCH 20/35] glob: minor adjustments to support unified headers
|
||||
|
||||
---
|
||||
shell/glob.h | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/shell/glob.h b/shell/glob.h
|
||||
index e8e65786d..c274a8f6a 100644
|
||||
--- a/shell/glob.h
|
||||
+++ b/shell/glob.h
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
//#include <sys/_types.h>
|
||||
|
||||
-#ifndef _SIZE_T_DECLARED
|
||||
+#if !defined(_SIZE_T_DECLARED) && !defined(__ANDROID__)
|
||||
typedef __size_t size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
#endif
|
||||
@@ -74,7 +74,7 @@ typedef struct {
|
||||
int (*gl_stat)(const char *, struct stat *);
|
||||
} glob_t;
|
||||
|
||||
-#if __POSIX_VISIBLE >= 199209
|
||||
+#if __POSIX_VISIBLE >= 199209 || defined(__ANDROID__)
|
||||
/* Believed to have been introduced in 1003.2-1992 */
|
||||
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
|
||||
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
|
||||
@@ -91,7 +91,7 @@ typedef struct {
|
||||
#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
|
||||
#endif /* __POSIX_VISIBLE >= 199209 */
|
||||
|
||||
-#if __BSD_VISIBLE
|
||||
+#if __BSD_VISIBLE || defined(__ANDROID__)
|
||||
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
|
||||
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
|
||||
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,153 +0,0 @@
|
||||
From 3b78ffa6a62431a85fd47ea716b5d8c6a899ae51 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Thu, 6 May 2021 16:30:26 -0300
|
||||
Subject: [PATCH 21/35] modinfo/modprobe: use ifdef block for android
|
||||
without-utsrel modules path
|
||||
|
||||
and fixes the modules.dep requirement, it is now optional...
|
||||
|
||||
Patch by Tanguy Pruvot <tanguy.pruvot@gmail.com>
|
||||
Change-Id: Ifccb530fa23b021fd12e2395f5d0c66600b25c04
|
||||
from https://github.com/tpruvot/android_external_busybox
|
||||
|
||||
and commit 2df42d3971f1e260e67c3fa4831cb9195fb276c4
|
||||
from https://github.com/tpruvot/android_external_busybox
|
||||
|
||||
Rebased for busybox 1.33.1 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
modutils/modinfo.c | 33 +++++++++++++++++++++++++++++----
|
||||
modutils/modprobe.c | 18 +++++++++++++++++-
|
||||
2 files changed, 46 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/modutils/modinfo.c b/modutils/modinfo.c
|
||||
index 0a86c3296..de6b24b4d 100644
|
||||
--- a/modutils/modinfo.c
|
||||
+++ b/modutils/modinfo.c
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "libbb.h"
|
||||
#include "modutils.h"
|
||||
|
||||
+#if defined(ANDROID) || defined(__ANDROID__)
|
||||
+#define DONT_USE_UTS_REL_FOLDER
|
||||
+#endif
|
||||
+
|
||||
static const char *const shortcuts[] ALIGN_PTR = {
|
||||
"filename", // -n
|
||||
"author", // -a
|
||||
@@ -63,7 +67,7 @@ static void modinfo(const char *path, const char *version,
|
||||
{
|
||||
size_t len;
|
||||
int j;
|
||||
- char *ptr, *the_module;
|
||||
+ char *ptr, *fullpath, *the_module;
|
||||
char *allocated;
|
||||
int tags = option_mask32;
|
||||
|
||||
@@ -74,8 +78,14 @@ static void modinfo(const char *path, const char *version,
|
||||
if (path[0] == '/')
|
||||
return;
|
||||
/* Newer depmod puts relative paths in modules.dep */
|
||||
- path = allocated = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path);
|
||||
- the_module = xmalloc_open_zipped_read_close(path, &len);
|
||||
+ fullpath = allocated = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path);
|
||||
+ the_module = xmalloc_open_zipped_read_close(fullpath, &len);
|
||||
+#ifdef DONT_USE_UTS_REL_FOLDER
|
||||
+ if (!the_module) {
|
||||
+ fullpath = allocated = xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, path);
|
||||
+ the_module = xmalloc_open_zipped_read_close(fullpath, &len);
|
||||
+ }
|
||||
+#endif
|
||||
if (!the_module) {
|
||||
bb_error_msg("module '%s' not found", path);
|
||||
goto ret;
|
||||
@@ -156,9 +166,23 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
|
||||
uname(&uts);
|
||||
parser = config_open2(
|
||||
xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE),
|
||||
- xfopen_for_read
|
||||
+ fopen_for_read
|
||||
);
|
||||
|
||||
+#ifdef DONT_USE_UTS_REL_FOLDER
|
||||
+ if (!parser) {
|
||||
+ parser = config_open2(
|
||||
+ xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, CONFIG_DEFAULT_DEPMOD_FILE),
|
||||
+ fopen_for_read
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ if (!parser) {
|
||||
+ strcpy(uts.release,"");
|
||||
+ goto no_modules_dep;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
while (config_read(parser, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
|
||||
colon = last_char_is(tokens[0], ':');
|
||||
if (colon == NULL)
|
||||
@@ -175,6 +199,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
config_close(parser);
|
||||
|
||||
+no_modules_dep:
|
||||
for (i = 0; argv[i]; i++) {
|
||||
if (argv[i][0]) {
|
||||
modinfo(argv[i], uts.release, field);
|
||||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
|
||||
index 235706fd5..4f4ee11e1 100644
|
||||
--- a/modutils/modprobe.c
|
||||
+++ b/modutils/modprobe.c
|
||||
@@ -172,6 +172,10 @@ static const char modprobe_longopts[] ALIGN1 =
|
||||
#define MODULE_FLAG_BLACKLISTED 0x0008
|
||||
#define MODULE_FLAG_BUILTIN 0x0010
|
||||
|
||||
+#if defined(ANDROID) || defined(__ANDROID__)
|
||||
+#define DONT_USE_UTS_REL_FOLDER
|
||||
+#endif
|
||||
+
|
||||
struct globals {
|
||||
llist_t *probes; /* MEs of module(s) requested on cmdline */
|
||||
#if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS
|
||||
@@ -474,10 +478,17 @@ static int do_modprobe(struct module_entry *m)
|
||||
#endif
|
||||
|
||||
if (option_mask32 & OPT_SHOW_DEPS) {
|
||||
+#ifndef DONT_USE_UTS_REL_FOLDER
|
||||
printf(options ? "insmod %s/%s/%s %s\n"
|
||||
: "insmod %s/%s/%s\n",
|
||||
CONFIG_DEFAULT_MODULES_DIR, G.uts.release, fn,
|
||||
options);
|
||||
+#else
|
||||
+ printf(options ? "insmod %s/%s %s\n"
|
||||
+ : "insmod %s/%s\n",
|
||||
+ CONFIG_DEFAULT_MODULES_DIR, fn,
|
||||
+ options);
|
||||
+#endif
|
||||
free(options);
|
||||
continue;
|
||||
}
|
||||
@@ -559,6 +570,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
|
||||
int rc;
|
||||
unsigned opt;
|
||||
struct module_entry *me;
|
||||
+ struct stat info;
|
||||
|
||||
INIT_G();
|
||||
|
||||
@@ -570,8 +582,12 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
/* Goto modules location */
|
||||
xchdir(CONFIG_DEFAULT_MODULES_DIR);
|
||||
+#ifndef DONT_USE_UTS_REL_FOLDER
|
||||
uname(&G.uts);
|
||||
- xchdir(G.uts.release);
|
||||
+ if (stat(G.uts.release, &info) == 0) {
|
||||
+ xchdir(G.uts.release);
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
if (opt & OPT_LIST_ONLY) {
|
||||
int i;
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,32 +0,0 @@
|
||||
From c48e14ccd0add532a5b139c8b400fa283bd9bfb2 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 12 Sep 2016 16:55:01 -0300
|
||||
Subject: [PATCH 22/35] depmod: fix syntax with modules in parameter
|
||||
|
||||
Patch by Tanguy Pruvot <tanguy.pruvot@gmail.com>
|
||||
Change-Id: I21b8664db01cf0132db82f8d6caa1a0e77e71004
|
||||
from https://github.com/tpruvot/android_external_busybox
|
||||
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
|
||||
---
|
||||
modutils/depmod.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modutils/depmod.c b/modutils/depmod.c
|
||||
index bb42bbefe..5e4c4c538 100644
|
||||
--- a/modutils/depmod.c
|
||||
+++ b/modutils/depmod.c
|
||||
@@ -49,7 +49,10 @@ static int FAST_FUNC parse_module(struct recursive_state *state,
|
||||
image = xmalloc_open_zipped_read_close(fname, &len);
|
||||
|
||||
e = moddb_get_or_create(modules, bb_get_last_path_component_nostrip(fname));
|
||||
- e->name = xstrdup(fname + 2); /* skip "./" */
|
||||
+ if (strncmp(fname, "./", 2) == 0)
|
||||
+ e->name = xstrdup(fname + 2);
|
||||
+ else
|
||||
+ e->name = xstrdup(fname);
|
||||
|
||||
for (ptr = image; ptr < image + len - 10; ptr++) {
|
||||
if (is_prefixed_with(ptr, "depends=")) {
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,108 +0,0 @@
|
||||
From 2c443ce15e52b95157ce009f920e19792e00a277 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 26 Jun 2017 23:53:06 -0300
|
||||
Subject: [PATCH 23/35] fix reboot+poweroff: hack android_reboot support
|
||||
|
||||
based on 'reboot.c' and 'halt.c' patches from CyanogenMod:
|
||||
https://github.com/CyanogenMod/android_external_busybox/commit/8aeb3719294721f744239ced474d159f073eef55#diff-51036c2b1c4282b63402a0e0286a066a
|
||||
https://github.com/CyanogenMod/android_external_busybox/commit/8aeb3719294721f744239ced474d159f073eef55#diff-fa7fd08ce03ea9138df81c149792b371
|
||||
https://github.com/CyanogenMod/android_external_busybox/commit/d0b802581eb4f83e81b652f0b59b8b9b98105e66
|
||||
|
||||
then updated and simplified using:
|
||||
https://github.com/android/platform_system_core/blob/master/libcutils/android_reboot.c
|
||||
https://github.com/android/platform_system_core/blob/master/libcutils/include/cutils/android_reboot.h
|
||||
|
||||
and added work around to write the property value directly via shell since property_set and __system_property_set require linkage to libcutils and/or libc
|
||||
---
|
||||
init/halt.c | 27 +++++++++++++++++++++++++++
|
||||
init/reboot.c | 33 +++++++++++++++++++++++++++++++++
|
||||
2 files changed, 60 insertions(+)
|
||||
create mode 100644 init/reboot.c
|
||||
|
||||
diff --git a/init/halt.c b/init/halt.c
|
||||
index fe3cb9e75..895009972 100644
|
||||
--- a/init/halt.c
|
||||
+++ b/init/halt.c
|
||||
@@ -94,6 +94,10 @@
|
||||
#include "libbb.h"
|
||||
#include "reboot.h"
|
||||
|
||||
+#ifdef __BIONIC__
|
||||
+#include "reboot.c"
|
||||
+#endif
|
||||
+
|
||||
#if ENABLE_FEATURE_WTMP
|
||||
#include <sys/utsname.h>
|
||||
|
||||
@@ -204,6 +208,29 @@ int halt_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!(flags & 2)) /* no -n */
|
||||
sync();
|
||||
|
||||
+#ifdef __BIONIC__
|
||||
+ char *mode[4];
|
||||
+ int c = 1;
|
||||
+ mode[0] = strdup("reboot");
|
||||
+ mode[1] = mode[2] = mode[3] = NULL;
|
||||
+ switch (which) {
|
||||
+ case 0:
|
||||
+ case 1:
|
||||
+ //-p for halt
|
||||
+ mode[1] = strdup("-p");
|
||||
+ c = 2;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ //reboot
|
||||
+ if (argc > 1) {
|
||||
+ mode[1] = strdup(argv[1]);
|
||||
+ c = 2;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ return reboot_android(c, mode);
|
||||
+#endif
|
||||
+
|
||||
/* Perform action. */
|
||||
rc = 1;
|
||||
if (!(flags & 4)) { /* no -f */
|
||||
diff --git a/init/reboot.c b/init/reboot.c
|
||||
new file mode 100644
|
||||
index 000000000..97fe523a7
|
||||
--- /dev/null
|
||||
+++ b/init/reboot.c
|
||||
@@ -0,0 +1,33 @@
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int reboot_android(int argc, char *argv[])
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ const char* restart_cmd = NULL;
|
||||
+ char* prop_value;
|
||||
+ char* prop_cmd;
|
||||
+
|
||||
+ restart_cmd = "reboot";
|
||||
+ while (true) {
|
||||
+ int c = getopt(argc, argv, "p");
|
||||
+ if (c == EOF)
|
||||
+ break;
|
||||
+ switch (c) {
|
||||
+ case 'p':
|
||||
+ restart_cmd = "shutdown";
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (argc > optind)
|
||||
+ asprintf(&prop_value, "%s,%s", restart_cmd, argv[optind]);
|
||||
+ else
|
||||
+ asprintf(&prop_value, "%s", restart_cmd);
|
||||
+
|
||||
+ asprintf(&prop_cmd, "setprop sys.powerctl %s", prop_value);
|
||||
+ ret = execlp("sh", "sh", "-c", prop_cmd, NULL);
|
||||
+ return ret;
|
||||
+}
|
||||
--
|
||||
2.45.2
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,45 +0,0 @@
|
||||
From 4b30a324c4f5b6f57f0a6c13741b251b445ee72a Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Wed, 30 Oct 2019 02:47:24 -0300
|
||||
Subject: [PATCH 25/35] hack: use dietlibc's resolver to avoid static
|
||||
compiliation issues with bionic's getaddrinfo() returning only null instead
|
||||
of opening the expected connection to /dev/socket/dnsproxyd
|
||||
|
||||
---
|
||||
libbb/xconnect.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
|
||||
index 0e0b247b8..2116c0b6f 100644
|
||||
--- a/libbb/xconnect.c
|
||||
+++ b/libbb/xconnect.c
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/un.h>
|
||||
+#include <netdb.h>
|
||||
+#include "../libres/dietdns.h"
|
||||
#if ENABLE_IFPLUGD || ENABLE_FEATURE_MDEV_DAEMON || ENABLE_UEVENT
|
||||
# include <linux/netlink.h>
|
||||
#endif
|
||||
@@ -277,7 +279,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
|
||||
* for each possible socket type (tcp,udp,raw...): */
|
||||
hint.ai_socktype = SOCK_STREAM;
|
||||
hint.ai_flags = ai_flags & ~DIE_ON_ERROR;
|
||||
- rc = getaddrinfo(host, NULL, &hint, &result);
|
||||
+ rc = diet_getaddrinfo(host, NULL, &hint, &result); /* hack to use dietlibc's resolver to work around static compile issue */
|
||||
if (rc || !result) {
|
||||
bb_error_msg("bad address '%s'", org_host);
|
||||
if (ai_flags & DIE_ON_ERROR)
|
||||
@@ -304,7 +306,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
|
||||
set_nport(&r->u.sa, htons(port));
|
||||
ret:
|
||||
if (result)
|
||||
- freeaddrinfo(result);
|
||||
+ diet_freeaddrinfo(result); /* hack to use dietlibc's resolver to work around static compile issue */
|
||||
return r;
|
||||
}
|
||||
#if !ENABLE_FEATURE_IPV6
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,50 +0,0 @@
|
||||
From d882a3fe4415965688b4e450d8c5191cd87817ee Mon Sep 17 00:00:00 2001
|
||||
From: Chris Renshaw <osm0sis@outlook.com>
|
||||
Date: Mon, 3 Jul 2017 03:17:06 -0300
|
||||
Subject: [PATCH 26/35] dietlibc/dnscruft: try to get dns server via command if
|
||||
__sys_property_get fails
|
||||
|
||||
- bionic libc's property_get and __sys_property_get fail for statically compiled binaries
|
||||
- fallback to a default known dns server if all else fails
|
||||
---
|
||||
libres/dnscruft.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libres/dnscruft.c b/libres/dnscruft.c
|
||||
index 142ffecd1..7804765b9 100644
|
||||
--- a/libres/dnscruft.c
|
||||
+++ b/libres/dnscruft.c
|
||||
@@ -61,6 +61,9 @@ void __dns_readstartfiles(void) {
|
||||
#ifdef __BIONIC__
|
||||
char propvalue[PROP_VALUE_MAX];
|
||||
char propname[PROP_NAME_MAX];
|
||||
+ char propcmd[PROP_NAME_MAX+8];
|
||||
+ char pbuf[256];
|
||||
+ FILE *fp;
|
||||
int i;
|
||||
#endif
|
||||
|
||||
@@ -73,7 +76,19 @@ void __dns_readstartfiles(void) {
|
||||
for(i = 1; i <= MAX_DNS_PROPERTIES; i++) {
|
||||
snprintf(propname, sizeof(propname), "%s%d", DNS_PROP_NAME_PREFIX, i);
|
||||
if(__system_property_get(propname, propvalue) < 1) {
|
||||
- break;
|
||||
+ /* attempt to get the property via command instead since the call to Bionic libc failed */
|
||||
+ snprintf(propcmd, sizeof(propcmd), "getprop %s", propname);
|
||||
+ if((fp = popen(propcmd, "r"))) {
|
||||
+ if((fgets(pbuf, sizeof(pbuf)-1, fp) != NULL) && (strlen(pbuf) > 0)) {
|
||||
+ if (pbuf[strlen(pbuf)-1] == '\n')
|
||||
+ pbuf[strlen(pbuf)-1] = '\0'; /* strip trailing newline */
|
||||
+ strncpy(propvalue, pbuf, sizeof(propvalue));
|
||||
+ }
|
||||
+ }
|
||||
+ pclose(fp);
|
||||
+ memset(&propname[0], 0, sizeof(propname)); /* clear propname to avoid unpredictable behavior */
|
||||
+ if(strlen(propvalue) < 1)
|
||||
+ strcpy(propvalue, "8.8.8.8"); /* use a fallback nameserver since we still fail to get the property correctly */
|
||||
}
|
||||
|
||||
if (parsesockaddr(propvalue,&_diet_res.nsaddr_list[_diet_res.nscount]))
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,55 +0,0 @@
|
||||
From 07edcd9e82a33f32070e4f124bdb634b50269b7a Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Fri, 3 Apr 2020 02:09:55 -0700
|
||||
Subject: [PATCH 30/35] Fix incorrect assumptions about NDK
|
||||
|
||||
---
|
||||
include/platform.h | 4 +++-
|
||||
libbb/missing_syscalls.c | 15 ---------------
|
||||
2 files changed, 3 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/include/platform.h b/include/platform.h
|
||||
index 57f0ef57d..69687eca7 100644
|
||||
--- a/include/platform.h
|
||||
+++ b/include/platform.h
|
||||
@@ -549,8 +549,10 @@ typedef unsigned smalluint;
|
||||
# if __ANDROID_API__ >= 21
|
||||
# undef HAVE_WAIT3
|
||||
# endif
|
||||
+# if __ANDROID_API__ < 24
|
||||
+# undef HAVE_STRCHRNUL
|
||||
+# endif
|
||||
# undef HAVE_MEMPCPY
|
||||
-# undef HAVE_STRCHRNUL
|
||||
# undef HAVE_STRVERSCMP
|
||||
# undef HAVE_UNLOCKED_LINE_OPS
|
||||
# undef HAVE_NET_ETHERNET_H
|
||||
diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c
|
||||
index f02e8d14c..a6db67da9 100644
|
||||
--- a/libbb/missing_syscalls.c
|
||||
+++ b/libbb/missing_syscalls.c
|
||||
@@ -54,21 +54,6 @@
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
/*# include <linux/timex.h> - for struct timex, but may collide with <time.h> */
|
||||
# include <sys/syscall.h>
|
||||
-pid_t getsid(pid_t pid)
|
||||
-{
|
||||
- return syscall(__NR_getsid, pid);
|
||||
-}
|
||||
-
|
||||
-int sethostname(const char *name, size_t len)
|
||||
-{
|
||||
- return syscall(__NR_sethostname, name, len);
|
||||
-}
|
||||
-
|
||||
-struct timex;
|
||||
-int adjtimex(struct timex *buf)
|
||||
-{
|
||||
- return syscall(__NR_adjtimex, buf);
|
||||
-}
|
||||
|
||||
int pivot_root(const char *new_root, const char *put_old)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
@ -1,25 +0,0 @@
|
||||
From c032074c4576b20d1dc7c38b0d187529d23c1ac9 Mon Sep 17 00:00:00 2001
|
||||
From: topjohnwu <topjohnwu@gmail.com>
|
||||
Date: Fri, 21 Jun 2024 03:09:47 -0700
|
||||
Subject: [PATCH 35/35] Allow variable page size on x64
|
||||
|
||||
---
|
||||
include/libbb.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/libbb.h b/include/libbb.h
|
||||
index 112e45197..401a8ec9a 100644
|
||||
--- a/include/libbb.h
|
||||
+++ b/include/libbb.h
|
||||
@@ -435,7 +435,7 @@ void *mmap_read(int fd, size_t size) FAST_FUNC;
|
||||
void *mmap_anon(size_t size) FAST_FUNC;
|
||||
void *xmmap_anon(size_t size) FAST_FUNC;
|
||||
|
||||
-#if defined(__x86_64__) || defined(i386)
|
||||
+#if defined(i386) /* only 32bit, x64 has emulated variable page size */
|
||||
# define BB_ARCH_FIXED_PAGESIZE 4096
|
||||
#elif defined(__arm__) /* only 32bit, 64bit ARM has variable page size */
|
||||
# define BB_ARCH_FIXED_PAGESIZE 4096
|
||||
--
|
||||
2.45.2
|
||||
|
Loading…
Reference in New Issue
Block a user