Update for BusyBox 1.36.1

- remove upstreamed/resolved patches
- rebase patches over released stable 1.36.1
- fix KBuild parsing of .S files for Android.mk
- add new patch to fix direct loopback mount and losetup next loop
- switch to recommending the Magisk SELinux fork to ensure Android compatibility
This commit is contained in:
osm0sis 2023-05-23 18:33:58 -03:00 committed by John Wu
parent 92c1537f51
commit ce046d06f9
40 changed files with 258 additions and 627 deletions

View File

@ -8,11 +8,11 @@ Clone the following repos:
```
git clone https://git.busybox.net/busybox/
git clone https://github.com/SELinuxProject/selinux.git jni/selinux
git clone https://github.com/topjohnwu/selinux jni/selinux
git clone https://android.googlesource.com/platform/external/pcre jni/pcre
```
Currently, the script supports BusyBox version `1.34.1`, please checkout to the correct tags before running scripts
Currently, the script supports BusyBox version `1.36.1`, please checkout to the correct tags before running scripts
## Busybox

View File

@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.34.1
# Sat Oct 2 02:32:02 2021
# Busybox version: 1.36.1
# Tue May 23 17:20:45 2023
#
CONFIG_HAVE_DOT_CONFIG=y
@ -93,10 +93,16 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SMALL=1
CONFIG_SHA1_SMALL=3
CONFIG_SHA1_HWACCEL=1
CONFIG_SHA256_HWACCEL=1
CONFIG_SHA3_SMALL=1
CONFIG_FEATURE_FAST_TOP=y
# CONFIG_FEATURE_ETC_NETWORKS is not set
# CONFIG_FEATURE_ETC_SERVICES is not set
# CONFIG_FEATURE_NON_POSIX_CP is not set
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_USE_SENDFILE=y
CONFIG_FEATURE_COPYBUF_KB=4
CONFIG_MONOTONIC_SYSCALL=y
CONFIG_IOCTL_HEX2STR_ERROR=y
CONFIG_FEATURE_EDITING=y
CONFIG_FEATURE_EDITING_MAX_LEN=1024
CONFIG_FEATURE_EDITING_VI=y
@ -120,14 +126,9 @@ CONFIG_UNICODE_WIDE_WCHARS=y
CONFIG_UNICODE_BIDI_SUPPORT=y
CONFIG_UNICODE_NEUTRAL_TABLE=y
CONFIG_UNICODE_PRESERVE_BROKEN=y
# CONFIG_FEATURE_NON_POSIX_CP is not set
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_USE_SENDFILE=y
CONFIG_FEATURE_COPYBUF_KB=4
# CONFIG_FEATURE_SKIP_ROOTFS is not set
CONFIG_MONOTONIC_SYSCALL=y
CONFIG_IOCTL_HEX2STR_ERROR=y
# CONFIG_FEATURE_HWIB is not set
# CONFIG_LOOP_CONFIGURE is not set
CONFIG_NO_LOOP_CONFIGURE=y
# CONFIG_TRY_LOOP_CONFIGURE is not set
#
# Applets
@ -162,6 +163,8 @@ CONFIG_FEATURE_BZIP2_DECOMPRESS=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
CONFIG_FEATURE_CPIO_P=y
CONFIG_FEATURE_CPIO_IGNORE_DEVNO=y
CONFIG_FEATURE_CPIO_RENUMBER_INODES=y
# CONFIG_DPKG is not set
# CONFIG_DPKG_DEB is not set
CONFIG_GZIP=y
@ -197,6 +200,22 @@ CONFIG_FEATURE_LZMA_FAST=y
#
# Coreutils
#
CONFIG_FEATURE_VERBOSE=y
#
# Common options for date and touch
#
CONFIG_FEATURE_TIMEZONE=y
#
# Common options for cp and mv
#
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
#
# Common options for df, du, ls
#
CONFIG_FEATURE_HUMAN_READABLE=y
CONFIG_BASENAME=y
CONFIG_CAT=y
CONFIG_FEATURE_CATN=y
@ -225,6 +244,7 @@ CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_FEATURE_DD_STATUS=y
CONFIG_DF=y
CONFIG_FEATURE_DF_FANCY=y
# CONFIG_FEATURE_SKIP_ROOTFS is not set
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
@ -324,6 +344,7 @@ CONFIG_FEATURE_TR_CLASSES=y
CONFIG_FEATURE_TR_EQUIV=y
CONFIG_TRUE=y
CONFIG_TRUNCATE=y
CONFIG_TSORT=y
CONFIG_TTY=y
CONFIG_UNAME=y
CONFIG_UNAME_OSNAME="Android"
@ -343,21 +364,6 @@ CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHOAMI=y
CONFIG_YES=y
#
# Common options
#
CONFIG_FEATURE_VERBOSE=y
#
# Common options for cp and mv
#
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
#
# Common options for df, du, ls
#
CONFIG_FEATURE_HUMAN_READABLE=y
#
# Console Utilities
#
@ -448,7 +454,11 @@ CONFIG_FEATURE_ALLOW_EXEC=y
CONFIG_FIND=y
CONFIG_FEATURE_FIND_PRINT0=y
CONFIG_FEATURE_FIND_MTIME=y
CONFIG_FEATURE_FIND_ATIME=y
CONFIG_FEATURE_FIND_CTIME=y
CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_AMIN=y
CONFIG_FEATURE_FIND_CMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_EXECUTABLE=y
@ -456,6 +466,7 @@ CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_MAXDEPTH=y
CONFIG_FEATURE_FIND_NEWER=y
CONFIG_FEATURE_FIND_INUM=y
CONFIG_FEATURE_FIND_SAMEFILE=y
CONFIG_FEATURE_FIND_EXEC=y
CONFIG_FEATURE_FIND_EXEC_PLUS=y
CONFIG_FEATURE_FIND_USER=y
@ -827,10 +838,12 @@ CONFIG_RAIDAUTORUN=y
CONFIG_RFKILL=y
# CONFIG_RUNLEVEL is not set
CONFIG_RX=y
CONFIG_SEEDRNG=y
CONFIG_SETFATTR=y
CONFIG_SETSERIAL=y
CONFIG_STRINGS=y
CONFIG_TIME=y
CONFIG_TREE=y
CONFIG_TS=y
CONFIG_TTYSIZE=y
CONFIG_UBIATTACH=y
@ -851,6 +864,9 @@ CONFIG_FEATURE_IPV6=y
CONFIG_FEATURE_UNIX_LOCAL=y
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
# CONFIG_FEATURE_ETC_NETWORKS is not set
# CONFIG_FEATURE_ETC_SERVICES is not set
# CONFIG_FEATURE_HWIB is not set
# CONFIG_FEATURE_TLS_SHA1 is not set
CONFIG_ARP=y
CONFIG_ARPING=y
@ -869,6 +885,7 @@ CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
CONFIG_DNSDOMAINNAME=y
CONFIG_HTTPD=y
CONFIG_FEATURE_HTTPD_PORT_DEFAULT=80
CONFIG_FEATURE_HTTPD_RANGES=y
CONFIG_FEATURE_HTTPD_SETUID=y
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
@ -961,6 +978,7 @@ CONFIG_FEATURE_TELNET_AUTOLOGIN=y
CONFIG_FEATURE_TELNET_WIDTH=y
CONFIG_TELNETD=y
CONFIG_FEATURE_TELNETD_STANDALONE=y
CONFIG_FEATURE_TELNETD_PORT_DEFAULT=23
CONFIG_FEATURE_TELNETD_INETD_WAIT=y
CONFIG_TFTP=y
CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
@ -998,6 +1016,7 @@ CONFIG_UDHCPC=y
CONFIG_FEATURE_UDHCPC_ARPING=y
CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UDHCPC6_DEFAULT_SCRIPT="/usr/share/udhcpc/default6.script"
CONFIG_UDHCPC6=y
CONFIG_FEATURE_UDHCPC6_RFC3646=y
CONFIG_FEATURE_UDHCPC6_RFC4704=y
@ -1025,17 +1044,19 @@ CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"
#
# Mail Utilities
#
CONFIG_FEATURE_MIME_CHARSET="us-ascii"
CONFIG_MAKEMIME=y
CONFIG_POPMAILDIR=y
CONFIG_FEATURE_POPMAILDIR_DELIVERY=y
CONFIG_REFORMIME=y
CONFIG_FEATURE_REFORMIME_COMPAT=y
CONFIG_SENDMAIL=y
CONFIG_FEATURE_MIME_CHARSET="us-ascii"
#
# Process Utilities
#
CONFIG_FEATURE_FAST_TOP=y
CONFIG_FEATURE_SHOW_THREADS=y
CONFIG_FREE=y
CONFIG_FUSER=y
CONFIG_IOSTAT=y
@ -1074,7 +1095,6 @@ CONFIG_FEATURE_TOPMEM=y
CONFIG_UPTIME=y
# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set
CONFIG_WATCH=y
CONFIG_FEATURE_SHOW_THREADS=y
#
# Runit Utilities
@ -1135,6 +1155,7 @@ CONFIG_ASH_IDLE_TIMEOUT=y
CONFIG_ASH_ECHO=y
CONFIG_ASH_PRINTF=y
CONFIG_ASH_TEST=y
CONFIG_ASH_SLEEP=y
CONFIG_ASH_HELP=y
CONFIG_ASH_GETOPTS=y
CONFIG_ASH_CMDCMD=y

View File

@ -1,7 +1,7 @@
From c9fbf480bdca1c8c8d64e809a8fd548a2e38870a Mon Sep 17 00:00:00 2001
From 082d517952ead36be2bf42eced10bdc940a14a71 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/36] Fix mconf/lkc host "warning statement with no effect"
Subject: [PATCH 01/34] Fix mconf/lkc host "warning statement with no effect"
---
scripts/kconfig/lkc.h | 4 ++--
@ -23,5 +23,5 @@ index 527f60c99..1972cb9a0 100644
#ifdef __cplusplus
--
2.35.1
2.34.1

View File

@ -0,0 +1,36 @@
From 7ac428e3a697781aecf00db66219f06643575d3e 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/34] Fix direct mount .img (auto loopback) and losetup for
Android /dev/block/loop
---
include/libbb.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/libbb.h b/include/libbb.h
index cca33a177..87dd74e48 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2390,9 +2390,15 @@ extern const char bb_default_login_shell[] ALIGN1;
# define VC_4 "/dev/tty4"
# define VC_5 "/dev/tty5"
# define VC_FORMAT "/dev/tty%d"
-# define LOOP_FORMAT "/dev/loop%u"
-# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
-# define LOOP_NAME "/dev/loop"
+# if defined(__ANDROID__)
+# define LOOP_FORMAT "/dev/block/loop%u"
+# define LOOP_NAMESIZE (sizeof("/dev/block/loop") + sizeof(int)*3 + 1)
+# define LOOP_NAME "/dev/block/loop"
+# else
+# define LOOP_FORMAT "/dev/loop%u"
+# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1)
+# define LOOP_NAME "/dev/loop"
+# endif
# define FB_0 "/dev/fb0"
#endif
--
2.34.1

View File

@ -1,7 +1,7 @@
From a1fb60cf04de4f8f95ada00c09ab5f74e016e3dd Mon Sep 17 00:00:00 2001
From d425f05d36c37ab07f2b52e4acb866ba51fc4f2d Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Tue, 4 May 2021 00:56:55 -0300
Subject: [PATCH 02/36] android: fix 'mount', 'umount', 'fsck', 'df'
Subject: [PATCH 03/34] 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
@ -13,10 +13,10 @@ Rebased for busybox 1.33.1 by Chris Renshaw <osm0sis@outlook.com>
create mode 100644 libbb/mntent_r.c
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 676300801..a71cc4527 100644
index 653025e56..33c33b6be 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -112,6 +112,9 @@ lib-y += xgethostbyname.o
@@ -118,6 +118,9 @@ lib-y += xgethostbyname.o
lib-y += xreadlink.o
lib-y += xrealloc_vector.o
@ -321,5 +321,5 @@ index 000000000..107748740
+ return NULL;
+}
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 657c71ad7841c8d1399fdd523c965fa4bb849b2e Mon Sep 17 00:00:00 2001
From 3717ec5b419921515b6d2f1e9cdc2d9c79565c05 Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Thu, 3 Dec 2015 17:01:57 -0400
Subject: [PATCH 03/36] eject: add missing headers
Subject: [PATCH 04/34] eject: add missing headers
Imported from dorimanx's combined ported header toolchain:
https://github.com/dorimanx/android-busybox-ndk
@ -526,5 +526,5 @@ index 000000000..767945236
+
+#endif /* scsi/sg.h */
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 8fbbf922b761d901768bc752bf0f1b05283fd659 Mon Sep 17 00:00:00 2001
From 093cfaff6563220c1e0bbbde9313933c5b2ee33f Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Tue, 10 Jan 2017 10:24:29 -0400
Subject: [PATCH 04/36] fix udhcpd and nameif, add ether_ntoa_r and
Subject: [PATCH 05/34] 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
@ -24,7 +24,7 @@ Rebased for busybox 1.26.1 by Chris Renshaw <osm0sis@outlook.com>
create mode 100644 networking/ether_port.h
diff --git a/networking/arping.c b/networking/arping.c
index d44d7d697..80e9571ec 100644
index 86f0221ed..6a1b8bae1 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -14,6 +14,7 @@
@ -232,7 +232,7 @@ index fcb725fbc..2d5739c7e 100644
lib-$(CONFIG_DHCPRELAY) += dhcprelay.o common.o socket.o packet.o
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 91f70970a..732c0bcfa 100644
index 66750e2e6..aeebb12f3 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -40,8 +40,12 @@
@ -249,5 +249,5 @@ index 91f70970a..732c0bcfa 100644
#include "dhcpc.h"
#include "dhcpd.h"
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 640579c63ab00f44a41dd8e5692bc1301a600853 Mon Sep 17 00:00:00 2001
From f6bdc7f3f8d8d1b964a50d4c3a8631e6ccaf9c8c Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Wed, 2 Dec 2015 23:44:06 -0400
Subject: [PATCH 05/36] fix ether-wake, avoid ether_hostton and include
Subject: [PATCH 06/34] 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
@ -34,5 +34,5 @@ index 809c0d9f0..920f0c4a0 100644
bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa_r(eaddr, ether_buf));
#endif
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 40cd1220200b93f9db133d0cd68f1cd054c1473c Mon Sep 17 00:00:00 2001
From a49c61220926ad1fcb938fe3db2fe341db3985ca Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Thu, 3 Dec 2015 01:29:35 -0400
Subject: [PATCH 06/36] loadfont/setfont/conspy: add missing header
Subject: [PATCH 07/34] loadfont/setfont/conspy: add missing header
Imported from dorimanx's combined ported header toolchain:
https://github.com/dorimanx/android-busybox-ndk
@ -51,5 +51,5 @@ index 000000000..8b8e56d4d
+
+#endif /* sys/kd.h */
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 2148257822c6b74e77274be6ad436c753187b8b4 Mon Sep 17 00:00:00 2001
From 3a7129680c8af82bd8df43389c0946d11fbe60fe Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Mon, 12 Sep 2016 14:45:35 -0300
Subject: [PATCH 07/36] android syscalls: shmget/msgget/semget
Subject: [PATCH 08/34] 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/
@ -37,5 +37,5 @@ index dc40d9155..82b600ced 100644
int tcdrain(int fd)
{
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 9eb6343f23bc887b33a049f172060760edbd0fa7 Mon Sep 17 00:00:00 2001
From 089bbedd023b97c2e1f1d83520e39235d9aaa8e7 Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Mon, 12 Sep 2016 14:46:40 -0300
Subject: [PATCH 08/36] android syscalls: msgctl shmctl
Subject: [PATCH 09/34] android syscalls: msgctl shmctl
Patch by Tias Guns <tias@ulyssis.org>
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
@ -34,5 +34,5 @@ index 82b600ced..018f72d62 100644
int tcdrain(int fd)
{
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 89683c3fdcc92305d2eb23623e0a4f5a1ead1e9c Mon Sep 17 00:00:00 2001
From 6b21e58417f5f8facc2bba3d42ef267d71772054 Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Mon, 12 Sep 2016 14:48:30 -0300
Subject: [PATCH 09/36] android syscalls: shmdt shmat sembuf
Subject: [PATCH 10/34] android syscalls: shmdt shmat sembuf
Patch by Tias Guns <tias@ulyssis.org>
Rebased for busybox 1.25.0 by Chris Renshaw <osm0sis@outlook.com>
@ -44,5 +44,5 @@ index 018f72d62..b5ea2612e 100644
int tcdrain(int fd)
{
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 02535ff6c29017a2f314122ff819c4b8886d02c6 Mon Sep 17 00:00:00 2001
From 44d79b91948149d505320d0d3b08a51331924852 Mon Sep 17 00:00:00 2001
From: Tias Guns <tias@ulyssis.org>
Date: Sun, 5 Aug 2012 15:25:34 +0200
Subject: [PATCH 10/36] android syscall (non-trivial): semctl
Subject: [PATCH 11/34] android syscall (non-trivial): semctl
needed by ipcs and ipcrm, also needed (but not sufficient) for syslogd and logread
@ -80,5 +80,5 @@ index 000000000..2c600e4f0
+ return syscall(__NR_semctl, semid, semnum, cmd, arg);
+}
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From f13b59490de357e8cf526ba3bd1c3511bb29a409 Mon Sep 17 00:00:00 2001
From 3e5d3b5de31fb086b61dbfb07ff0b8db185ca345 Mon Sep 17 00:00:00 2001
From: Umakanthan Chandran <cumakt@gmail.com>
Date: Fri, 3 Mar 2017 07:32:22 +0530
Subject: [PATCH 11/36] missing_syscalls/semctl: fix missing definitions on x86
Subject: [PATCH 12/34] missing_syscalls/semctl: fix missing definitions on x86
and MIPS NDK cross-compiles
Signed-off-by: Umakanthan Chandran <cumakt@gmail.com>
@ -81,5 +81,5 @@ index 2c600e4f0..84ab1c92e 100644
int semctl(int semid, int semnum, int cmd, ...) {
union semun arg;
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 8128d92f56396a819225d1d802956de29bc65bff Mon Sep 17 00:00:00 2001
From 8919cbeec5b95fbd06b913936a84a438e6faa08a Mon Sep 17 00:00:00 2001
From: Tias Guns <tias@ulyssis.org>
Date: Tue, 20 Mar 2012 21:26:07 +0000
Subject: [PATCH 12/36] fix ipcs, ipcrm no sys/sem-shm-msg, etc
Subject: [PATCH 13/34] 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/
@ -27,7 +27,7 @@ index 3d3ad0b56..a97f39f29 100644
#else
/* according to X/OPEN we have to define it ourselves */
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index ef2529c05..3a08020e8 100644
index 5973cbf57..2e43b7758 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -71,7 +71,8 @@ struct shm_info {
@ -41,5 +41,5 @@ index ef2529c05..3a08020e8 100644
#else
/* according to X/OPEN we have to define it ourselves */
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From bc154ac766f31b242e82cb6b9478abb024881e9c Mon Sep 17 00:00:00 2001
From cadc8d649f4c6ba0af9121ddd888fc5b4ce7e0c3 Mon Sep 17 00:00:00 2001
From: Tias Guns <tias@ulyssis.org>
Date: Tue, 20 Mar 2012 21:30:10 +0000
Subject: [PATCH 13/36] fix syslogd, logread: add syslog.h, semop shmdt-at
Subject: [PATCH 14/34] fix syslogd, logread: add syslog.h, semop shmdt-at
patch from 'no-sys-shm,msg,sem' and 'sys-syslog' by Dan Drown
"sys/syslog.h header for syslogd"
@ -169,5 +169,5 @@ index 94d8273b6..9a768daa5 100644
#if 0
/* For the record: with SYSLOG_NAMES <syslog.h> defines
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From d5018f13db3b01797245f0f163bd3b48d6bc26a3 Mon Sep 17 00:00:00 2001
From b1ea18dbf49d506385b1c447c6324aec74d643a2 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/36] fix fsck.minix, mkfs.minix: undef HAVE_SETBIT,
Subject: [PATCH 15/34] fix fsck.minix, mkfs.minix: undef HAVE_SETBIT,
MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC
"there is no setbit/clrbit in bionic"
@ -18,10 +18,10 @@ Rebased for busybox 1.28.1 by Chris Renshaw <osm0sis@outlook.com>
2 files changed, 3 insertions(+)
diff --git a/include/platform.h b/include/platform.h
index 9e1fb047d..668b50df4 100644
index ea0512f36..6644d83c6 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -548,6 +548,7 @@ typedef unsigned smalluint;
@@ -551,6 +551,7 @@ typedef unsigned smalluint;
# undef HAVE_UNLOCKED_LINE_OPS
# undef HAVE_NET_ETHERNET_H
# undef HAVE_PRINTF_PERCENTM
@ -43,5 +43,5 @@ index 83ffe6da5..91ced691c 100644
BLOCK_SIZE = 1024,
BITS_PER_BLOCK = BLOCK_SIZE << 3,
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From da4ee617840f197c402b00d30954fbb19a5d0fe3 Mon Sep 17 00:00:00 2001
From c095be676c407395cbe5c4ae48536bebb9afec1d 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/36] fix ipv6, add ipv6_route.h
Subject: [PATCH 16/34] fix ipv6, add ipv6_route.h
from 'in6_rtmsg' by Dan Drown
"in6_rtmsg defined in linux/ipv6_route.h"
@ -97,7 +97,7 @@ index 9ee232a66..f9a66e801 100644
/*
* Here are the bit masks for the "flags" member of struct options below.
diff --git a/networking/route.c b/networking/route.c
index ff5daa8a7..89617db9d 100644
index 26146f8e9..7b5be0e73 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -36,6 +36,8 @@
@ -110,5 +110,5 @@ index ff5daa8a7..89617db9d 100644
#include "libbb.h"
#include "inet_common.h"
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 33f7280a5cd1ce160a2239be320601888292f95f Mon Sep 17 00:00:00 2001
From 729225f1fc624a0cf773a4eb3107090ed9f75333 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/36] additional fix-up for IPV6 on Android API 21+
Subject: [PATCH 17/34] additional fix-up for IPV6 on Android API 21+
fixes: networking/interface.c:62:8: error: redefinition of 'struct in6_ifreq'
@ -18,7 +18,7 @@ since sockaddr was moved from linux/socket.h to sys/socket.h in newer NDK revisi
2 files changed, 3 insertions(+)
diff --git a/networking/interface.c b/networking/interface.c
index ea6a2c8a8..6f0716680 100644
index 6b6c0944a..d5ca48dd9 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -55,6 +55,7 @@
@ -38,7 +38,7 @@ index ea6a2c8a8..6f0716680 100644
#endif /* HAVE_AFINET6 */
diff --git a/networking/route.c b/networking/route.c
index 89617db9d..f20070889 100644
index 7b5be0e73..637433bf8 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -36,6 +36,7 @@
@ -50,5 +50,5 @@ index 89617db9d..f20070889 100644
#include <linux/ipv6_route.h>
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 9fe432ccdd315f78da7d6532e2492394231b7059 Mon Sep 17 00:00:00 2001
From d473798bfb7d7535f477cc3ae00c8120152e7904 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/36] fix udhcpc6: add missing ifaddrs.h and
Subject: [PATCH 18/34] fix udhcpc6: add missing ifaddrs.h and
getifaddrs/freeifaddrs functions
ifaddrs implementation from 'android-ifaddrs' by Kenneth MacKay:
@ -16,7 +16,7 @@ https://github.com/morristech/android-ifaddrs
create mode 100644 networking/udhcp/ifaddrs.h
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 8d11a7539..e5529bade 100644
index cdd06188e..498ea2690 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -48,6 +48,7 @@
@ -28,7 +28,7 @@ index 8d11a7539..e5529bade 100644
//kbuild:lib-$(CONFIG_FEATURE_UDHCPC6_RFC4704) += domain_codec.o
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c
index 8ddee5a8e..ccba87469 100644
index acf108367..38de5d0d0 100644
--- a/networking/udhcp/d6_socket.c
+++ b/networking/udhcp/d6_socket.c
@@ -7,7 +7,7 @@
@ -707,5 +707,5 @@ index 000000000..9cd19fec1
+
+#endif
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 0da392210ffdf897f9dfbc7ca235b9d2784af466 Mon Sep 17 00:00:00 2001
From 64a5ee014e20ad44932a31c1aa1d9fe949a2bdd5 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/36] fix hush: add missing definitions on Android API 21+
Subject: [PATCH 19/34] fix hush: add missing definitions on Android API 21+
platform FAST_FUNC adjustment to support NDK unified headers by John Wu <topjohnwu@gmail.com>
@ -14,7 +14,7 @@ Rebased for busybox 1.34.1 by Chris Renshaw <osm0sis@outlook.com>
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/platform.h b/include/platform.h
index 668b50df4..8b7ed16e2 100644
index 6644d83c6..57f0ef57d 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -124,7 +124,7 @@
@ -26,7 +26,7 @@ index 668b50df4..8b7ed16e2 100644
/* stdcall makes callee to pop arguments from stack, not caller */
# define FAST_FUNC __attribute__((regparm(3),stdcall))
/* #elif ... - add your favorite arch today! */
@@ -426,6 +426,7 @@ typedef unsigned smalluint;
@@ -429,6 +429,7 @@ typedef unsigned smalluint;
#define HAVE_SYS_STATFS_H 1
#define HAVE_PRINTF_PERCENTM 1
#define HAVE_WAIT3 1
@ -34,7 +34,7 @@ index 668b50df4..8b7ed16e2 100644
#define HAVE_DEV_FD 1
#define DEV_FD_PREFIX "/dev/fd/"
@@ -533,6 +534,9 @@ typedef unsigned smalluint;
@@ -536,6 +537,9 @@ typedef unsigned smalluint;
# else
/* ANDROID >= 21 has standard dprintf */
# endif
@ -44,7 +44,7 @@ index 668b50df4..8b7ed16e2 100644
# if __ANDROID_API__ < 21
# undef HAVE_TTYNAME_R
# undef HAVE_GETLINE
@@ -633,4 +637,8 @@ extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC
@@ -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
@ -70,5 +70,5 @@ index 7913353e2..b652a2112 100644
+}
+#endif
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From b0fa1f42f97cdfe4688d8f3a4936de7202cb0534 Mon Sep 17 00:00:00 2001
From 68c77fe2a544cbdd29083ad46357e0f73f906d86 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/36] fix hush, add glob and sigisemptyset
Subject: [PATCH 20/34] 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/
@ -928,7 +928,7 @@ index 000000000..e8e65786d
+
+#endif /* !_GLOB_H_ */
diff --git a/shell/hush.c b/shell/hush.c
index 27092c12f..c3e1321db 100644
index d111f0cc5..af7f0d50c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -331,6 +331,7 @@
@ -963,5 +963,5 @@ index 000000000..82973138e
+ return set;
+}
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From f6519d3325f39ffeaa94222821c33f939c81ad65 Mon Sep 17 00:00:00 2001
From 5058766bed060fb4db9cc52667efabda5ebb56a9 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/36] glob: minor adjustments to support unified headers
Subject: [PATCH 21/34] glob: minor adjustments to support unified headers
---
shell/glob.h | 6 +++---
@ -39,5 +39,5 @@ index e8e65786d..c274a8f6a 100644
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From bf6a4c512499e7df05228a895690f599a0fd8f28 Mon Sep 17 00:00:00 2001
From fb0a64e76d9f1c9964a0b01d14bf87df9194d35e 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/36] modinfo/modprobe: use ifdef block for android
Subject: [PATCH 22/34] modinfo/modprobe: use ifdef block for android
without-utsrel modules path
and fixes the modules.dep requirement, it is now optional...
@ -149,5 +149,5 @@ index 235706fd5..4f4ee11e1 100644
if (opt & OPT_LIST_ONLY) {
int i;
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From b8f5ac4fa5179fba6b9af14a0ab7bfd3dc35a42f Mon Sep 17 00:00:00 2001
From 6fec006e6b0e01cff7b2131f4ab4ff03f8bcb1fd 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/36] depmod: fix syntax with modules in parameter
Subject: [PATCH 23/34] depmod: fix syntax with modules in parameter
Patch by Tanguy Pruvot <tanguy.pruvot@gmail.com>
Change-Id: I21b8664db01cf0132db82f8d6caa1a0e77e71004
@ -28,5 +28,5 @@ index bb42bbefe..5e4c4c538 100644
for (ptr = image; ptr < image + len - 10; ptr++) {
if (is_prefixed_with(ptr, "depends=")) {
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 0e0d4777bd7e047e6e4f7e441c8012477ca41fa1 Mon Sep 17 00:00:00 2001
From 6b12e7d66a42b7daa757dbbe44a58a821bed3a58 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/36] fix reboot+poweroff: hack android_reboot support
Subject: [PATCH 24/34] 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
@ -104,5 +104,5 @@ index 000000000..97fe523a7
+ return ret;
+}
--
2.35.1
2.34.1

View File

@ -1,27 +0,0 @@
From 608f5da2ca492898cfae4f982f5d420ac8cdb75c Mon Sep 17 00:00:00 2001
From: osm0sis <osm0sis@outlook.com>
Date: Thu, 20 Jul 2017 09:16:07 -0300
Subject: [PATCH 24/36] fix tls: avoid problematic ASM code only triggered by
x86 NDK builds
https://bugs.busybox.net/show_bug.cgi?id=13716#c7
---
networking/tls.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/networking/tls.h b/networking/tls.h
index 215e92b02..1cd351f4a 100644
--- a/networking/tls.h
+++ b/networking/tls.h
@@ -26,7 +26,7 @@
#undef USE_SEED
/* pstm: multiprecision numbers */
#undef DISABLE_PSTM
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && defined(__i386__) && !defined(__ANDROID__)
/* PSTM_X86 works correctly. +25 bytes. */
# define PSTM_32BIT
# define PSTM_X86
--
2.35.1

View File

@ -1,7 +1,7 @@
From 052f60d1708392714a6b5d2db27be44f69eefdfa Mon Sep 17 00:00:00 2001
From 4c3007dc036298af0b414ee3f3192ad972ad39a5 Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Sat, 21 Jul 2018 20:02:13 -0300
Subject: [PATCH 25/36] fix nslookup, add libres, a dietlibc resolver
Subject: [PATCH 25/34] fix nslookup, add libres, a dietlibc resolver
Using bionic's resolver functions does not allow changing the dns
server. Use dietlibc's resolver code instead (see package libres-devel)
@ -52,7 +52,7 @@ Rebased for busybox 1.29.1 by Chris Renshaw <osm0sis@outlook.com>
create mode 100644 libres/test.c
diff --git a/Makefile b/Makefile
index 31d1b0568..b303f3ec6 100644
index fa8cb7614..13e857655 100644
--- a/Makefile
+++ b/Makefile
@@ -477,6 +477,7 @@ libs-y := \
@ -1156,7 +1156,7 @@ index 000000000..45095d81d
+ return 0;
+}
diff --git a/networking/nslookup.c b/networking/nslookup.c
index de7b5c0e7..1de598505 100644
index 6da97baf4..8c20d8364 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -36,8 +36,9 @@
@ -1241,5 +1241,5 @@ index de7b5c0e7..1de598505 100644
/* (but it also says "may be enabled in /etc/resolv.conf") */
/*_res.options |= RES_USE_INET6;*/
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From d8270cbc21e248803c0479771986042c416a2c93 Mon Sep 17 00:00:00 2001
From 32fe84da06c36c42cdd163b849f00c28a06f173d Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Wed, 30 Oct 2019 02:47:24 -0300
Subject: [PATCH 26/36] hack: use dietlibc's resolver to avoid static
Subject: [PATCH 26/34] 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
@ -10,7 +10,7 @@ Subject: [PATCH 26/36] hack: use dietlibc's resolver to avoid static
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 5dd9cfd28..ecfcdaefa 100644
index 0e0b247b8..2116c0b6f 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -11,6 +11,8 @@
@ -22,7 +22,7 @@ index 5dd9cfd28..ecfcdaefa 100644
#if ENABLE_IFPLUGD || ENABLE_FEATURE_MDEV_DAEMON || ENABLE_UEVENT
# include <linux/netlink.h>
#endif
@@ -285,7 +287,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
@@ -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;
@ -31,7 +31,7 @@ index 5dd9cfd28..ecfcdaefa 100644
if (rc || !result) {
bb_error_msg("bad address '%s'", org_host);
if (ai_flags & DIE_ON_ERROR)
@@ -312,7 +314,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
@@ -304,7 +306,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
set_nport(&r->u.sa, htons(port));
ret:
if (result)
@ -41,5 +41,5 @@ index 5dd9cfd28..ecfcdaefa 100644
}
#if !ENABLE_FEATURE_IPV6
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 8226c6de8ac012f8c94c5a0e196d731876e2f7ec Mon Sep 17 00:00:00 2001
From ebbf946870306acb6da62e2f84ace869ab372b86 Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Mon, 3 Jul 2017 03:17:06 -0300
Subject: [PATCH 27/36] dietlibc/dnscruft: try to get dns server via command if
Subject: [PATCH 27/34] 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
@ -46,5 +46,5 @@ index 142ffecd1..7804765b9 100644
if (parsesockaddr(propvalue,&_diet_res.nsaddr_list[_diet_res.nscount]))
--
2.35.1
2.34.1

View File

@ -1,13 +1,13 @@
From 207e3d751c707fca0401613112a30ba8a0ec6fbc Mon Sep 17 00:00:00 2001
From 343289d903a290035f07c09926be4031669b910f Mon Sep 17 00:00:00 2001
From: Chris Renshaw <osm0sis@outlook.com>
Date: Wed, 11 Aug 2021 23:54:04 -0300
Subject: [PATCH 28/36] ash history
Date: Tue, 23 May 2023 18:30:43 -0300
Subject: [PATCH 28/34] ash history
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.33.1 by Chris Renshaw <osm0sis@outlook.com>
Rebased for busybox 1.36.1 by Chris Renshaw <osm0sis@outlook.com>
---
include/libbb.h | 4 ++--
init/init.c | 2 +-
@ -16,10 +16,10 @@ Rebased for busybox 1.33.1 by Chris Renshaw <osm0sis@outlook.com>
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/include/libbb.h b/include/libbb.h
index 7d6ab4a93..c5883b3e9 100644
index 87dd74e48..112e45197 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2306,12 +2306,12 @@ static ALWAYS_INLINE void* not_const_pp(const void *p) { return (void*)p; }
@@ -2341,12 +2341,12 @@ void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC;
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
@ -35,18 +35,18 @@ index 7d6ab4a93..c5883b3e9 100644
/* The following devices are the same on all systems. */
#define CURRENT_TTY "/dev/tty"
diff --git a/init/init.c b/init/init.c
index efab5dcb4..bd084b546 100644
index 1e1ce833d..57129e9c2 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1107,7 +1107,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
@@ -1106,7 +1106,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
/* Make sure environs is set to something sane */
putenv((char *) "HOME=/");
putenv((char *) bb_PATH_root_path);
- putenv((char *) "SHELL=/bin/sh");
+ putenv((char *) "SHELL=/system/bin/sh");
putenv((char *) "USER=root"); /* needed? why? */
if (argv[1])
/* Linux kernel sets HOME="/" when execing init,
* and it can be overridden (but not unset?) on kernel's command line.
diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c
index 5aebe9cdc..5af53bdda 100644
--- a/libbb/get_shell_name.c
@ -63,10 +63,10 @@ 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 53c140930..eded57508 100644
index 9344e4de1..5dd7f80f1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14443,7 +14443,7 @@ procargs(char **argv)
@@ -14537,7 +14537,7 @@ procargs(char **argv)
int login_sh;
xargv = argv;
@ -75,7 +75,7 @@ index 53c140930..eded57508 100644
#if NUM_SCRIPTS > 0
if (minusc)
goto setarg0;
@@ -14619,7 +14619,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14713,7 +14713,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
const char *hp;
state = 1;
@ -84,7 +84,7 @@ index 53c140930..eded57508 100644
state1:
state = 2;
hp = lookupvar("HOME");
@@ -14664,6 +14664,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14758,6 +14758,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
if (line_input_state) {
const char *hp = lookupvar("HISTFILE");
if (!hp) {
@ -94,7 +94,7 @@ index 53c140930..eded57508 100644
hp = lookupvar("HOME");
if (hp) {
INT_OFF;
@@ -14673,6 +14676,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14767,6 +14770,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
INT_ON;
hp = lookupvar("HISTFILE");
}
@ -103,5 +103,5 @@ index 53c140930..eded57508 100644
if (hp)
line_input_state->hist_file = xstrdup(hp);
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 250bb07b342e81239c71d5f787e82bb4f0b073b8 Mon Sep 17 00:00:00 2001
From c931a69ce8fa327a94e7e29b0f126a0f2e9d24aa Mon Sep 17 00:00:00 2001
From: LoveSy <shana@zju.edu.cn>
Date: Sun, 20 Mar 2022 00:51:25 +0800
Subject: [PATCH 31/36] Replace `realpath` to BSD inplementation
Subject: [PATCH 29/34] Replace `realpath` to BSD inplementation
---
libbb/Kbuild.src | 1 +
@ -10,10 +10,10 @@ Subject: [PATCH 31/36] Replace `realpath` to BSD inplementation
create mode 100644 libbb/xrealpath.c
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 5c75fc48c..88a302edb 100644
index 33c33b6be..2093c2dff 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -115,6 +115,7 @@ lib-y += xrealloc_vector.o
@@ -120,6 +120,7 @@ lib-y += xrealloc_vector.o
# for android-busybox-ndk
lib-y += mntent_r.o
@ -249,5 +249,5 @@ index 000000000..d4548859a
+ return (resolved);
+}
--
2.35.1
2.34.1

View File

@ -1,222 +0,0 @@
From 9a6dc236900eb57c505888af6e4b974aaff30463 Mon Sep 17 00:00:00 2001
From: YU Jincheng <shana@zju.edu.cn>
Date: Wed, 29 Sep 2021 17:37:26 +0800
Subject: [PATCH 29/36] generalize "const trick"
While at it, change all "__asm__" to "asm"
Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
coreutils/test.c | 5 ++---
include/libbb.h | 34 +++++++++++++++++++++++++---------
libbb/appletlib.c | 3 +--
libbb/lineedit.c | 5 ++---
procps/powertop.c | 2 +-
shell/ash.c | 23 +++--------------------
6 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/coreutils/test.c b/coreutils/test.c
index 7c6574334..fc956724b 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -435,7 +435,7 @@ struct test_statics {
};
/* See test_ptr_hack.c */
-extern struct test_statics *const test_ptr_to_statics;
+extern struct test_statics *BB_GLOBAL_CONST test_ptr_to_statics;
#define S (*test_ptr_to_statics)
#define args (S.args )
@@ -446,8 +446,7 @@ extern struct test_statics *const test_ptr_to_statics;
#define leaving (S.leaving )
#define INIT_S() do { \
- (*(struct test_statics**)not_const_pp(&test_ptr_to_statics)) = xzalloc(sizeof(S)); \
- barrier(); \
+ ASSIGN_CONST_PTR(test_ptr_to_statics, xzalloc(sizeof(S))); \
} while (0)
#define DEINIT_S() do { \
free(group_array); \
diff --git a/include/libbb.h b/include/libbb.h
index c5883b3e9..9524a9e03 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -365,13 +365,27 @@ struct BUG_off_t_size_is_misdetected {
#endif
#endif
+/* We use a trick to have more optimized code (fewer pointer reloads
+ * and reduced binary size by a few kilobytes) like:
+ * ash.c: extern struct globals *const ash_ptr_to_globals;
+ * ash_ptr_hack.c: struct globals *ash_ptr_to_globals;
+ * This way, compiler in ash.c knows the pointer can not change.
+ *
+ * However, this may break on weird arches or toolchains. In this case,
+ * set "-DBB_GLOBAL_CONST=''" in CONFIG_EXTRA_CFLAGS to disable
+ * this optimization.
+ */
+#ifndef BB_GLOBAL_CONST
+# define BB_GLOBAL_CONST const
+#endif
+
#if defined(errno)
/* If errno is a define, assume it's "define errno (*__errno_location())"
* and we will cache it's result in this variable */
-extern int *const bb_errno;
-#undef errno
-#define errno (*bb_errno)
-#define bb_cached_errno_ptr 1
+extern int *BB_GLOBAL_CONST bb_errno;
+# undef errno
+# define errno (*bb_errno)
+# define bb_cached_errno_ptr 1
#endif
#if !(ULONG_MAX > 0xffffffff)
@@ -2271,6 +2285,8 @@ struct globals;
* If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */
extern struct globals *const ptr_to_globals;
+#define barrier() asm volatile ("":::"memory")
+
#if defined(__clang_major__) && __clang_major__ >= 9
/* Clang/llvm drops assignment to "constant" storage. Silently.
* Needs serious convincing to not eliminate the store.
@@ -2278,7 +2294,7 @@ extern struct globals *const ptr_to_globals;
static ALWAYS_INLINE void* not_const_pp(const void *p)
{
void *pp;
- __asm__ __volatile__(
+ asm volatile (
"# forget that p points to const"
: /*outputs*/ "=r" (pp)
: /*inputs*/ "0" (p)
@@ -2289,13 +2305,13 @@ static ALWAYS_INLINE void* not_const_pp(const void *p)
static ALWAYS_INLINE void* not_const_pp(const void *p) { return (void*)p; }
#endif
-/* At least gcc 3.4.6 on mipsel system needs optimization barrier */
-#define barrier() __asm__ __volatile__("":::"memory")
-#define SET_PTR_TO_GLOBALS(x) do { \
- (*(struct globals**)not_const_pp(&ptr_to_globals)) = (void*)(x); \
+#define ASSIGN_CONST_PTR(p, v) do { \
+ *(void**)not_const_pp(&p) = (void*)(v); \
+ /* At least gcc 3.4.6 on mipsel needs optimization barrier */ \
barrier(); \
} while (0)
+#define SET_PTR_TO_GLOBALS(x) ASSIGN_CONST_PTR(ptr_to_globals, x)
#define FREE_PTR_TO_GLOBALS() do { \
if (ENABLE_FEATURE_CLEAN_UP) { \
free(ptr_to_globals); \
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 14be33603..8b4c0f0e7 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -247,8 +247,7 @@ void lbb_prepare(const char *applet
IF_FEATURE_INDIVIDUAL(, char **argv))
{
#ifdef bb_cached_errno_ptr
- (*(int **)not_const_pp(&bb_errno)) = get_perrno();
- barrier();
+ ASSIGN_CONST_PTR(bb_errno, get_perrno());
#endif
applet_name = applet;
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 68d19e127..0bbbe80de 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -192,7 +192,7 @@ struct lineedit_statics {
};
/* See lineedit_ptr_hack.c */
-extern struct lineedit_statics *const lineedit_ptr_to_statics;
+extern struct lineedit_statics *BB_GLOBAL_CONST lineedit_ptr_to_statics;
#define S (*lineedit_ptr_to_statics)
#define state (S.state )
@@ -214,8 +214,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics;
#define delbuf (S.delbuf )
#define INIT_S() do { \
- (*(struct lineedit_statics**)not_const_pp(&lineedit_ptr_to_statics)) = xzalloc(sizeof(S)); \
- barrier(); \
+ ASSIGN_CONST_PTR(lineedit_ptr_to_statics, xzalloc(sizeof(S))); \
} while (0)
static void deinit_S(void)
diff --git a/procps/powertop.c b/procps/powertop.c
index fc6018b7a..24c2b320f 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -505,7 +505,7 @@ static void cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
unsigned int *edx)
{
/* EAX value specifies what information to return */
- __asm__(
+ asm (
" pushl %%ebx\n" /* Save EBX */
" cpuid\n"
" movl %%ebx, %1\n" /* Save content of EBX */
diff --git a/shell/ash.c b/shell/ash.c
index eded57508..9250b8f91 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -299,20 +299,6 @@ typedef long arith_t;
# error "Do not even bother, ash will not run on NOMMU machine"
#endif
-/* We use a trick to have more optimized code (fewer pointer reloads):
- * ash.c: extern struct globals *const ash_ptr_to_globals;
- * ash_ptr_hack.c: struct globals *ash_ptr_to_globals;
- * This way, compiler in ash.c knows the pointer can not change.
- *
- * However, this may break on weird arches or toolchains. In this case,
- * set "-DBB_GLOBAL_CONST=''" in CONFIG_EXTRA_CFLAGS to disable
- * this optimization.
- */
-#ifndef BB_GLOBAL_CONST
-# define BB_GLOBAL_CONST const
-#endif
-
-
/* ============ Hash table sizes. Configurable. */
#define VTABSIZE 39
@@ -506,8 +492,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
#define random_gen (G_misc.random_gen )
#define backgndpid (G_misc.backgndpid )
#define INIT_G_misc() do { \
- (*(struct globals_misc**)not_const_pp(&ash_ptr_to_globals_misc)) = xzalloc(sizeof(G_misc)); \
- barrier(); \
+ ASSIGN_CONST_PTR(ash_ptr_to_globals_misc, xzalloc(sizeof(G_misc))); \
savestatus = -1; \
curdir = nullstr; \
physdir = nullstr; \
@@ -1579,8 +1564,7 @@ extern struct globals_memstack *BB_GLOBAL_CONST ash_ptr_to_globals_memstack;
#define g_stacknleft (G_memstack.g_stacknleft)
#define stackbase (G_memstack.stackbase )
#define INIT_G_memstack() do { \
- (*(struct globals_memstack**)not_const_pp(&ash_ptr_to_globals_memstack)) = xzalloc(sizeof(G_memstack)); \
- barrier(); \
+ ASSIGN_CONST_PTR(ash_ptr_to_globals_memstack, xzalloc(sizeof(G_memstack))); \
g_stackp = &stackbase; \
g_stacknxt = stackbase.space; \
g_stacknleft = MINSIZE; \
@@ -2201,8 +2185,7 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var;
#endif
#define INIT_G_var() do { \
unsigned i; \
- (*(struct globals_var**)not_const_pp(&ash_ptr_to_globals_var)) = xzalloc(sizeof(G_var)); \
- barrier(); \
+ ASSIGN_CONST_PTR(ash_ptr_to_globals_var, xzalloc(sizeof(G_var))); \
for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \
varinit[i].flags = varinit_data[i].flags; \
varinit[i].var_text = varinit_data[i].var_text; \
--
2.35.1

View File

@ -1,7 +1,7 @@
From 683390d584c0c821fe5eb6ce1019ed60f5d43b31 Mon Sep 17 00:00:00 2001
From 96a4a2663497869af67a842b35fa97388068c36b Mon Sep 17 00:00:00 2001
From: topjohnwu <topjohnwu@gmail.com>
Date: Fri, 3 Apr 2020 02:09:55 -0700
Subject: [PATCH 32/36] Fix incorrect assumptions about NDK
Subject: [PATCH 30/34] Fix incorrect assumptions about NDK
---
include/platform.h | 4 +++-
@ -9,10 +9,10 @@ Subject: [PATCH 32/36] Fix incorrect assumptions about NDK
2 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/include/platform.h b/include/platform.h
index 8b7ed16e2..8eb5a69db 100644
index 57f0ef57d..69687eca7 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -546,8 +546,10 @@ typedef unsigned smalluint;
@@ -549,8 +549,10 @@ typedef unsigned smalluint;
# if __ANDROID_API__ >= 21
# undef HAVE_WAIT3
# endif
@ -51,5 +51,5 @@ index f02e8d14c..a6db67da9 100644
int pivot_root(const char *new_root, const char *put_old)
{
--
2.35.1
2.34.1

View File

@ -1,178 +0,0 @@
From 9aa7088ec54da743229cfd8868112838e2dcc4c3 Mon Sep 17 00:00:00 2001
From: YU Jincheng <shana@zju.edu.cn>
Date: Sun, 10 Oct 2021 02:19:51 +0800
Subject: [PATCH 30/36] Make const ptr assign as function call in clang
- This can act as memory barrier in clang to avoid
read before assign of a const ptr
Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
coreutils/test.c | 2 +-
include/libbb.h | 21 +++++++++++++++------
libbb/Kbuild.src | 1 +
libbb/appletlib.c | 2 +-
libbb/const_hack.c | 16 ++++++++++++++++
libbb/lineedit.c | 2 +-
shell/ash.c | 6 +++---
7 files changed, 38 insertions(+), 12 deletions(-)
create mode 100644 libbb/const_hack.c
diff --git a/coreutils/test.c b/coreutils/test.c
index fc956724b..a914c7490 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -446,7 +446,7 @@ extern struct test_statics *BB_GLOBAL_CONST test_ptr_to_statics;
#define leaving (S.leaving )
#define INIT_S() do { \
- ASSIGN_CONST_PTR(test_ptr_to_statics, xzalloc(sizeof(S))); \
+ XZALLOC_CONST_PTR(&test_ptr_to_statics, sizeof(S)); \
} while (0)
#define DEINIT_S() do { \
free(group_array); \
diff --git a/include/libbb.h b/include/libbb.h
index 9524a9e03..43aa6d53a 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2277,6 +2277,7 @@ extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */
extern const int const_int_0;
//extern const int const_int_1;
+
/* This struct is deliberately not defined. */
/* See docs/keep_data_small.txt */
struct globals;
@@ -2301,23 +2302,31 @@ static ALWAYS_INLINE void* not_const_pp(const void *p)
);
return pp;
}
+# define ASSIGN_CONST_PTR(pptr, v) do { \
+ *(void**)not_const_pp(pptr) = (void*)(v); \
+ barrier(); \
+} while (0)
+/* XZALLOC_CONST_PTR() is an out-of-line function to prevent
+ * clang from reading pointer before it is assigned.
+ */
+void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC;
#else
-static ALWAYS_INLINE void* not_const_pp(const void *p) { return (void*)p; }
-#endif
-
-#define ASSIGN_CONST_PTR(p, v) do { \
- *(void**)not_const_pp(&p) = (void*)(v); \
+# define ASSIGN_CONST_PTR(pptr, v) do { \
+ *(void**)(pptr) = (void*)(v); \
/* At least gcc 3.4.6 on mipsel needs optimization barrier */ \
barrier(); \
} while (0)
+# define XZALLOC_CONST_PTR(pptr, size) ASSIGN_CONST_PTR(pptr, xzalloc(size))
+#endif
-#define SET_PTR_TO_GLOBALS(x) ASSIGN_CONST_PTR(ptr_to_globals, x)
+#define SET_PTR_TO_GLOBALS(x) ASSIGN_CONST_PTR(&ptr_to_globals, x)
#define FREE_PTR_TO_GLOBALS() do { \
if (ENABLE_FEATURE_CLEAN_UP) { \
free(ptr_to_globals); \
} \
} while (0)
+
/* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index a71cc4527..5c75fc48c 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -24,6 +24,7 @@ lib-y += chomp.o
lib-y += compare_string_array.o
lib-y += concat_path_file.o
lib-y += concat_subpath_file.o
+lib-y += const_hack.o
lib-y += copy_file.o
lib-y += copyfd.o
lib-y += crc32.o
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 8b4c0f0e7..a38b968fe 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -247,7 +247,7 @@ void lbb_prepare(const char *applet
IF_FEATURE_INDIVIDUAL(, char **argv))
{
#ifdef bb_cached_errno_ptr
- ASSIGN_CONST_PTR(bb_errno, get_perrno());
+ ASSIGN_CONST_PTR(&bb_errno, get_perrno());
#endif
applet_name = applet;
diff --git a/libbb/const_hack.c b/libbb/const_hack.c
new file mode 100644
index 000000000..9575e6d67
--- /dev/null
+++ b/libbb/const_hack.c
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Trick to assign a const ptr with barrier for clang
+ *
+ * Copyright (C) 2021 by YU Jincheng <shana@zju.edu.cn>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+#include "libbb.h"
+
+#if defined(__clang_major__) && __clang_major__ >= 9
+void FAST_FUNC XZALLOC_CONST_PTR(const void *pptr, size_t size)
+{
+ ASSIGN_CONST_PTR(pptr, xzalloc(size));
+}
+#endif
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 0bbbe80de..fc12bfa2d 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -214,7 +214,7 @@ extern struct lineedit_statics *BB_GLOBAL_CONST lineedit_ptr_to_statics;
#define delbuf (S.delbuf )
#define INIT_S() do { \
- ASSIGN_CONST_PTR(lineedit_ptr_to_statics, xzalloc(sizeof(S))); \
+ XZALLOC_CONST_PTR(&lineedit_ptr_to_statics, sizeof(S)); \
} while (0)
static void deinit_S(void)
diff --git a/shell/ash.c b/shell/ash.c
index 9250b8f91..150599f36 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -492,7 +492,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
#define random_gen (G_misc.random_gen )
#define backgndpid (G_misc.backgndpid )
#define INIT_G_misc() do { \
- ASSIGN_CONST_PTR(ash_ptr_to_globals_misc, xzalloc(sizeof(G_misc))); \
+ XZALLOC_CONST_PTR(&ash_ptr_to_globals_misc, sizeof(G_misc)); \
savestatus = -1; \
curdir = nullstr; \
physdir = nullstr; \
@@ -1564,7 +1564,7 @@ extern struct globals_memstack *BB_GLOBAL_CONST ash_ptr_to_globals_memstack;
#define g_stacknleft (G_memstack.g_stacknleft)
#define stackbase (G_memstack.stackbase )
#define INIT_G_memstack() do { \
- ASSIGN_CONST_PTR(ash_ptr_to_globals_memstack, xzalloc(sizeof(G_memstack))); \
+ XZALLOC_CONST_PTR(&ash_ptr_to_globals_memstack, sizeof(G_memstack)); \
g_stackp = &stackbase; \
g_stacknxt = stackbase.space; \
g_stacknleft = MINSIZE; \
@@ -2185,7 +2185,7 @@ extern struct globals_var *BB_GLOBAL_CONST ash_ptr_to_globals_var;
#endif
#define INIT_G_var() do { \
unsigned i; \
- ASSIGN_CONST_PTR(ash_ptr_to_globals_var, xzalloc(sizeof(G_var))); \
+ XZALLOC_CONST_PTR(&ash_ptr_to_globals_var, sizeof(G_var)); \
for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \
varinit[i].flags = varinit_data[i].flags; \
varinit[i].var_text = varinit_data[i].var_text; \
--
2.35.1

View File

@ -1,17 +1,17 @@
From d4c52d4d0b13528849c1ac8231a9c2f1d7396ab2 Mon Sep 17 00:00:00 2001
From 2648c15b53747345898affdaafe0d6ca6b2822e5 Mon Sep 17 00:00:00 2001
From: topjohnwu <topjohnwu@gmail.com>
Date: Fri, 7 Feb 2020 14:32:06 -0800
Subject: [PATCH 33/36] Add runtime toggle to enable standalone ash
Subject: [PATCH 31/34] 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 150599f36..57a38f21a 100644
index 5dd7f80f1..9ab1cb327 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -274,16 +274,14 @@ typedef long arith_t;
@@ -279,16 +279,14 @@ typedef long arith_t;
#endif
#include "NUM_APPLETS.h"
@ -36,10 +36,10 @@ index 150599f36..57a38f21a 100644
#ifndef F_DUPFD_CLOEXEC
# define F_DUPFD_CLOEXEC F_DUPFD
@@ -334,7 +332,9 @@ static const char *const optletters_optnames[] = {
"a" "allexport",
@@ -344,7 +342,9 @@ static const char *const optletters_optnames[] ALIGN_PTR = {
"b" "notify",
"u" "nounset",
"E" "errtrace",
- "\0" "vi"
+ "\0" "vi",
+/* Magisk: toggle whether use standalone shell mode */
@ -47,26 +47,26 @@ index 150599f36..57a38f21a 100644
#if BASH_PIPEFAIL
,"\0" "pipefail"
#endif
@@ -429,14 +429,15 @@ struct globals_misc {
#define bflag optlist[12]
@@ -441,14 +441,15 @@ struct globals_misc {
#define uflag optlist[13]
#define viflag optlist[14]
+#define saflag optlist[15]
#define Eflag optlist[14]
#define viflag optlist[15]
+#define saflag optlist[16]
#if BASH_PIPEFAIL
-# define pipefail optlist[15]
+# define pipefail optlist[16]
-# define pipefail optlist[16]
+# define pipefail optlist[17]
#else
# define pipefail 0
#endif
#if DEBUG
-# define nolog optlist[15 + BASH_PIPEFAIL]
-# define debug optlist[16 + BASH_PIPEFAIL]
+# define nolog optlist[16 + BASH_PIPEFAIL]
+# define debug optlist[17 + BASH_PIPEFAIL]
-# define nolog optlist[16 + BASH_PIPEFAIL]
-# define debug optlist[17 + BASH_PIPEFAIL]
+# define nolog optlist[17 + BASH_PIPEFAIL]
+# define debug optlist[18 + BASH_PIPEFAIL]
#endif
/* trap handler commands */
@@ -8216,7 +8217,7 @@ static void
@@ -8256,7 +8257,7 @@ static void
tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, char **envp)
{
#if ENABLE_FEATURE_SH_STANDALONE
@ -75,7 +75,7 @@ index 150599f36..57a38f21a 100644
if (APPLET_IS_NOEXEC(applet_no)) {
clearenv();
while (*envp)
@@ -8285,7 +8286,7 @@ static void shellexec(char *prog, char **argv, const char *path, int idx)
@@ -8325,7 +8326,7 @@ static void shellexec(char *prog, char **argv, const char *path, int idx)
envp = listvars(VEXPORT, VUNSET, /*strlist:*/ NULL, /*end:*/ NULL);
if (strchr(prog, '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
@ -84,7 +84,7 @@ index 150599f36..57a38f21a 100644
#endif
) {
tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp);
@@ -13715,7 +13716,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
@@ -13823,7 +13824,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
goto fail;
#if ENABLE_FEATURE_SH_STANDALONE
@ -93,7 +93,7 @@ index 150599f36..57a38f21a 100644
int applet_no = find_applet_by_name(name);
if (applet_no >= 0) {
entry->cmdtype = CMDNORMAL;
@@ -13937,7 +13938,7 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
@@ -14045,7 +14046,7 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
}
}
# if ENABLE_FEATURE_SH_STANDALONE
@ -102,7 +102,7 @@ index 150599f36..57a38f21a 100644
const char *a = applet_names;
while (*a) {
col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), a);
@@ -14598,6 +14599,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14709,6 +14710,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
trace_puts_args(argv);
#endif
@ -115,5 +115,5 @@ index 150599f36..57a38f21a 100644
const char *hp;
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From c0fcddedbbed301e214f95e3e7065f110e356f4d Mon Sep 17 00:00:00 2001
From 8b9cd817e505924a91aef69058f252ded1afeb9c Mon Sep 17 00:00:00 2001
From: topjohnwu <topjohnwu@gmail.com>
Date: Thu, 25 Jun 2020 03:54:53 -0700
Subject: [PATCH 34/36] Resolve /proc/self/exe when re-exec ourselves
Subject: [PATCH 32/34] 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,10 +10,10 @@ 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 57a38f21a..f1104f108 100644
index 9ab1cb327..11c9cb4cc 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8212,6 +8212,7 @@ static struct tblentry **cmdtable;
@@ -8252,6 +8252,7 @@ static struct tblentry **cmdtable;
static int builtinloc = -1; /* index in path of %builtin, or -1 */
@ -21,7 +21,7 @@ index 57a38f21a..f1104f108 100644
static void
tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, char **envp)
@@ -8226,7 +8227,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
@@ -8266,7 +8267,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
run_noexec_applet_and_exit(applet_no, cmd, argv);
}
/* re-exec ourselves with the new arguments */
@ -30,7 +30,7 @@ index 57a38f21a..f1104f108 100644
/* If they called chroot or otherwise made the binary no longer
* executable, fall through */
}
@@ -8241,7 +8242,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
@@ -8281,7 +8282,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
execve(cmd, argv, envp);
#endif
@ -39,7 +39,7 @@ index 57a38f21a..f1104f108 100644
/* Run "cmd" as a shell script:
* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
* "If the execve() function fails with ENOEXEC, the shell
@@ -8259,7 +8260,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
@@ -8299,7 +8300,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
* to interpret foreign ELF binaries as shell scripts.
*/
argv[0] = (char*) cmd;
@ -48,7 +48,7 @@ index 57a38f21a..f1104f108 100644
/* NB: this is only possible because all callers of shellexec()
* ensure that the argv[-1] slot exists!
*/
@@ -14588,6 +14589,12 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
@@ -14699,6 +14700,12 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
init();
setstackmark(&smark);
@ -62,5 +62,5 @@ index 57a38f21a..f1104f108 100644
if (argc < 0)
/* Non-NULL minusc tells procargs that an embedded script is being run */
--
2.35.1
2.34.1

View File

@ -1,7 +1,7 @@
From 3942c732b4cff737ea948baed7d8d86495a2a5ae Mon Sep 17 00:00:00 2001
From 44c6b86843b228a387e1c025d3952fea604144e6 Mon Sep 17 00:00:00 2001
From: topjohnwu <topjohnwu@gmail.com>
Date: Sat, 2 May 2020 01:48:30 -0700
Subject: [PATCH 35/36] Disable SELinux features for install
Subject: [PATCH 33/34] Disable SELinux features for install
matchpathcon is not usable on Android
---
@ -32,5 +32,5 @@ index c0f1c538a..16c014384 100644
static const char install_longopts[] ALIGN1 =
IF_FEATURE_VERBOSE(
--
2.35.1
2.34.1

View File

@ -1,17 +1,17 @@
From 8178fff10870b9dab70f90794e07b7084569a294 Mon Sep 17 00:00:00 2001
From bffb42bc1d70bbdfe187d8f72c07c765b50d4dde Mon Sep 17 00:00:00 2001
From: topjohnwu <topjohnwu@gmail.com>
Date: Thu, 21 Jan 2021 00:07:41 -0800
Subject: [PATCH 36/36] Allow running as libbusybox.so
Subject: [PATCH 34/34] Allow running as libbusybox.so
---
libbb/appletlib.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index a38b968fe..a07c85347 100644
index d5335d353..460ce823f 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1102,7 +1102,10 @@ int main(int argc UNUSED_PARAM, char **argv)
@@ -1104,7 +1104,10 @@ int main(int argc UNUSED_PARAM, char **argv)
if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox"))
argv++;
# endif
@ -24,5 +24,5 @@ index a38b968fe..a07c85347 100644
applet_name++;
applet_name = bb_basename(applet_name);
--
2.35.1
2.34.1

5
run.sh
View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
BUSYBOX_TAG='1_34_1'
BUSYBOX_TAG='1_36_1'
progress() {
echo -e "\n\033[44m${1}\033[0m\n"
@ -18,7 +18,8 @@ parse_kbuild() {
CONFIG=`echo ${LINE%+=*} | grep -o '$(.*)' | cut -d\( -f2 | cut -d\) -f1`
if eval [ -z \"$CONFIG\" -o \"\$$CONFIG\" = \"1\" ]; then
for FILE in `echo $FILE_LIST | grep -o '\S*\.o\b'`; do
readlink -f $DIR/$FILE | sed -e "s:${CWD}/::" -e 's/.o$/.c \\/g'
EXT=c; [ -f $(readlink -f $DIR/$FILE | sed 's/.o$/.S/g') ] && EXT=S
readlink -f $DIR/$FILE | sed -e "s:${CWD}/::" -e 's/.o$/.'"${EXT}"' \\/g'
done
fi
done