├── .github └── FUNDING.yml ├── README.md ├── errorlist-full-deprecated.log ├── errorlist-full-unified.log ├── experimental └── 0001-add-LFS-support-EXPERIMENTAL.patch ├── old_config ├── android_ndk_config-w-patches ├── android_ndk_defconfigPlus └── android_ndk_stericson-like ├── osm0sis-basic-deprecated.config ├── osm0sis-basic-unified.config ├── osm0sis-full-deprecated.config ├── osm0sis-full-selinux.config ├── osm0sis-full-unified.config └── patches ├── 000-customMakefile.patch ├── 001-mconf-lkc.patch ├── 002-mount-auto-loopback-and-losetup.patch ├── 003-a-mount-umount-fsck-df.patch ├── 003-b-swapon-swapoff.patch ├── 006-eject.patch ├── 010-ubiX.patch ├── 012-a-ether_ntoa-udhcpd.patch ├── 012-b-ether-wake.patch ├── 012-c-arping.patch ├── 013-loadfont-setfont-conspy.patch ├── 014-nandwrite-nanddump.patch ├── 015-zcip.patch ├── 017-a-shmget-msgget-semget-syscalls.patch ├── 017-b-msgctl-shmctl-syscalls.patch ├── 017-c-shmdt-shmat-semop-syscalls.patch ├── 018-a-semctl-syscall.patch ├── 018-b-semctl-missing_syscalls.patch ├── 019-ipcs-ipcrm.patch ├── 020-syslogd-logread.patch ├── 021-fsck.minix-mkfs.minix.patch ├── 022-a-ipv6.patch ├── 022-b-interface-route.patch ├── 022-c-d6_dhcpc-d6_socket.patch ├── 024-a-hush-platform.patch ├── 024-b-hush.patch ├── 024-c-glob.patch ├── 026-modinfo-modprobe-without-utsrel.patch ├── 027-depmod-parameter.patch ├── 028-reboot-poweroff.patch ├── 050-a-dietlibc_resolver-nslookup.patch ├── 050-b-xconnect-dietlibc.patch ├── 050-c-dietlibc-dnscruft.patch ├── 051-ash-history.patch └── 052-install-disable-selinux.patch /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: osm0sis # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://www.paypal.me/osm0sis # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | The aim is to gather information and patches on how to build busybox using the compilers shipped with the Android NDK. 2 | 3 | Currently up-to-date as of busybox 1.36.1, with both NDK API 21 Unified and Deprecated headers. 4 | 5 | Building busybox with the standard Android NDK 6 | ============================================== 7 | 8 | tias@ulyssis.org discovered that a number [[1](http://lists.busybox.net/pipermail/busybox/2012-March/077486.html),[2](http://lists.busybox.net/pipermail/busybox/2012-March/077505.html)] of upstream changes make it possible to build the latest git version of busybox, **without requiring any patches**: 9 | 10 | # get busybox sources 11 | git clone git://busybox.net/busybox.git 12 | cd busybox 13 | # use default upstream config 14 | cp configs/android_ndk_defconfig .config 15 | 16 | # add the target NDK cross-compiler to your exported PATH and CROSS_COMPILE prefix 17 | export PATH="/path/to/your/android-ndk/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin:$PATH" 18 | export CROSS_COMPILE="/path/to/your/android-ndk/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/arm-linux-androideabi-" 19 | 20 | # if android-ndk is not installed in /opt/android-ndk, edit SYSROOT= in .config 21 | # (alternately make all but CFLAGS blank if using standalone cross-compiler) 22 | nano .config 23 | 24 | # adjust enabled applets/features (optional) 25 | make menuconfig 26 | 27 | # build it! 28 | make ARCH=arm CROSS_COMPILE="$CROSS_COMPILE" 29 | 30 | These applets are available without any patches: 31 | > [, [[, acpid, adjtimex, ar, arp, ascii, ash, awk, base32, base64, basename, bbconfig, beep, blkdiscard, blkid, blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crc32, crond, crontab, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du, dumpkmap, echo, ed, egrep, env, envdir, envuidgid, expand, expr, factor, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flashcp, flock, fold, free, freeramdisk, fsfreeze, fsync, fuser, getopt, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, iplink, ipneigh, iproute, iprule, iptunnel, kbd\_mode, kill, killall, killall5, klogd, less, link, linuxrc, ln, loadkmap, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lspci, lsscsi, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mesg, microcom, mim, mkdir, mkdosfs, mkfifo, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mpstat, mv, nameif, netstat, nice, nl, nmeter, nohup, nologin, od, openvt, partprobe, paste, patch, pidof, pipe\_progress, pivot\_root, pkill, pmap, popmaildir, poweroff, printenv, printf, ps, pstree, pwd, pwdx, raidautorun, rdate, rdev, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rev, rfkill, rm, rmdir, rmmod, rpm, rpm2cpio, rtcwake, run-init, run-parts, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setconsole, setkeycodes, setlogcons, setpriv (without capabilities), setserial, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, shred, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, sum, sv, svc, svlogd, switch\_root, sync, sysctl, tac, tail, tar, tc, tcpsvd, tee, telnetd, test, tftpd, timeout, top, touch, tr, tree, true, tsort, tty, ttysize, tunctl, tune2fs, udhcpc, udhcpd, udpsvd, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, volname, watch, watchdog, wc, which, whoami, xargs, xxd, xz, xzcat, yes, zcat 32 | 33 | By **applying the included patches** to the busybox code-base you additionally get: 34 | > arping, conspy, eject, ether-wake, flash\_eraseall, flash\_lock, flash\_unlock, fsck.minix, ftpd, hush, ipcrm, ipcs, loadfont, logread, mkfs.minix, nanddump, nandwrite, nslookup (with own resolver), pgrep, ping6, route, setfont, ssl\_client, swapon, swapoff, syslogd, time, traceroute6, ubi*, udhcpc6, unshare, zcip 35 | 36 | Also worth noting that while they do build without issue these applets do not entirely work correctly on Android without any patches: 37 | > df, fsck, ftpget, ftpput, losetup, mke2fs, mkfs.ext2, mkfs.reiser, mount, mountpoint, nbd-client, nc, ping, poweroff, pscan, reboot, telnet, tftp, traceroute, umount, wget, whois 38 | 39 | (when applying certain patches you should include all patches with a lower number as well, there are often dependencies between them). 40 | 41 | The **remaining config options** of 'make defconfig' do not build properly. See below for the list of config options and corresponding error. 42 | 43 | Config options that do not build, code error 44 | -------------------------------------------- 45 | These errors indicate bugs (usually in the restricted Android libc library, called bionic), and can often be fixed by adding patches to the busybox code. 46 | 47 | * All of *Login/Password Management Utilities*, CONFIG\_USE\_BB\_PWD\_GRP -- error: 'struct passwd' has no member named 'pw\_gecos' 48 | * disables CONFIG\_ADD\_SHELL, CONFIG\_ADDGROUP, CONFIG\_ADDUSER, CONFIG\_CHPASSWD, CONFIG\_CRYPTPW, CONFIG\_DELGROUP, CONFIG\_DELUSER, CONFIG\_GETTY, CONFIG\_LOGIN, CONFIG\_MKPASSWD, CONFIG\_PASSWD, CONFIG\_REMOVE\_SHELL, CONFIG\_SU, CONFIG\_SULOGIN, CONFIG\_VLOCK 49 | * CONFIG\_ARPING -- **has patch** -- networking/arping.c:122:4: error: dereferencing pointer to incomplete type 50 | * CONFIG\_BC -- miscutils/bc.c:224:18: error: expected ':', ',', ';', '}' or '\_\_attribute\_\_' before 'num' 51 | * CONFIG\_ETHER\_WAKE -- **has patch** -- networking/ether-wake.c:131:6: warning: assignment makes pointer from integer without a cast 52 | * CONFIG\_FEATURE\_IPV6 -- **has patch** -- networking/ifconfig.c:132:8 error: redefinition of 'struct in6\_ifreq' 53 | * disables CONFIG\_FEATURE\_IFUPDOWN\_IPV6, CONFIG\_FEATURE\_PREFER\_IPV4\_ADDRESS, CONFIG\_PING6, CONFIG\_TRACEROUTE6, CONFIG\_UDHCPC6, CONFIG\_FEATURE\_UDHCPC6\_RFC* 54 | * CONFIG\_FEATURE\_NSLOOKUP\_BIG, CONFIG\_FEATURE\_NSLOOKUP\_LONG\_OPTIONS -- networking/nslookup.c:278:4: error: 'ns\_t\_soa' undeclared here (not in a function) 55 | * CONFIG\_FEATURE\_UTMP, CONFIG\_FEATURE\_WTMP -- init/halt.c:86: error: 'RUN\_LVL' undeclared (first use in this function) 56 | * disables CONFIG\_LAST, CONFIG\_RUNLEVEL, CONFIG\_USERS, CONFIG\_WALL, CONFIG\_WHO 57 | * CONFIG\_IPCS -- **has patch** -- util-linux/ipcs.c:79:7: error: redefinition of 'union semun' 58 | * CONFIG\_IPCRM -- **has patch** -- util-linux/ipcrm.c:35:7: error: redefinition of 'union semun' 59 | * CONFIG\_LFS -- **[on purpose?](http://lists.busybox.net/pipermail/busybox-cvs/2011-November/033019.html)** -- **has patch (experimental)** -- include/libbb.h:256: error: size of array 'BUG\_off\_t\_size\_is\_misdetected' is negative 60 | * CONFIG\_LOGGER -- sysklogd/logger.c:36: error: expected ';', ',' or ')' before '*' token 61 | * CONFIG\_LOGREAD -- **has patch** -- sysklogd/logread.c:124:8: warning: assignment makes pointer from integer without a cast 62 | * CONFIG\_NSLOOKUP -- **has patch (with own resolver)** -- networking/nslookup.c:154:27: error: dereferencing pointer to incomplete type 63 | * CONFIG\_POWERTOP -- procps/powertop.c:508:2: error: inconsistent operand constraints in an 'asm' 64 | * CONFIG\_ROUTE -- **has patch** -- from networking/route.c:46: [...]include/linux/if.h:160:18: error: field 'ifru\_addr' has incomplete type 65 | * CONFIG\_SHA1\_HWACCEL, CONFIG\_SHA256\_HWACCEL -- ibbb/hash\_md5\_sha.c:20:2: error: inconsistent operand constraints in an 'asm' 66 | * CONFIG\_SWAPOFF, CONFIG\_SWAPON -- **has patch** -- util-linux/swaponoff.c:244:35: error: 'MNTOPT\_NOAUTO' undeclared (first use in this function) 67 | * CONFIG\_SYSLOGD -- **has patch** -- sysklogd/syslogd\_and\_logger.c:53:14: error: unknown type name 'CODE' 68 | * CONFIG\_ZCIP -- **has patch** -- networking/zcip.c:71:19: error: field 'arp' has incomplete type 69 | 70 | Config options that do not build, missing header 71 | ------------------------------------------------ 72 | These errors indicate that the header is missing from Android's libc implementation. 73 | 74 | sys/kd.h -- **has patch** 75 | * CONFIG\_CONSPY -- miscutils/conspy.c:45:20: error: sys/kd.h: No such file or directory 76 | * CONFIG\_LOADFONT, CONFIG\_SETFONT -- console-tools/loadfont.c:61:20: error: sys/kd.h: No such file or directory 77 | 78 | others 79 | * CONFIG\_EJECT -- **has patch** -- util-linux/eject.c:49:22: error: scsi/sg.h: No such file or directory 80 | * CONFIG\_FEATURE\_INETD\_RPC -- networking/inetd.c:176:22: error: rpc/rpc.h: No such file or directory 81 | * CONFIG\_FEATURE\_SHADOWPASSWDS -- include/libbb.h:61:22: error: shadow.h: No such file or directory 82 | * CONFIG\_USE\_BB\_PWD\_GRP, CONFIG\_USE\_BB\_SHADOW would potentially work around, but there is a code error as listed above 83 | * CONFIG\_HUSH -- **has patch** -- shell/hush.c:342:18: error: glob.h: No such file or directory 84 | * CONFIG\_I2C* -- miscutils/i2c\_tools.c:65:27: error: linux/i2c-dev.h: No such file or directory 85 | * disables CONFIG\_I2CDETECT, CONFIG\_I2CDUMP, CONFIG\_I2CGET, CONFIG\_I2CSET 86 | * CONFIG\_LINUX32, CONFIG_LINUX64, CONFIG\_SETARCH -- util-linux/setarch.c:23:29: error: sys/personality.h: No such file or directory 87 | * CONFIG\_MT -- miscutils/mt.c:19:22: error: sys/mtio.h: No such file or directory 88 | * CONFIG\_NANDDUMP, CONFIG\_NANDWRITE -- **has patch** -- miscutils/nandwrite.c:54:26: error: mtd/mtd-user.h: No such file or directory 89 | * CONFIG\_NTPD -- networking/ntpd.c:49:23: error: sys/timex.h: No such file or directory 90 | * CONFIG\_SEEDRNG -- miscutils/seedrng.c:45:24: error: sys/random.h: No such file or directory 91 | * CONFIG\_UDHCPC6 -- **has patch** -- networking/udhcp/d6\_socket.c:10:21: error: ifaddrs.h: No such file or directory 92 | * CONFIG\_UBI* -- **has patch** -- miscutils/ubi\_tools.c:69:26: error: mtd/ubi-user.h: No such file or directory 93 | * disables CONFIG\_UBIATTACH, CONFIG\_UBIDETACH, CONFIG\_UBIMKVOL, CONFIG\_UBIRENAME, CONFIG\_UBIRMVOL, CONFIG\_UBIRSVOL, CONFIG\_UBIUPDATEVOL 94 | 95 | Config options that give a linking error 96 | ---------------------------------------- 97 | Android's libc implementation claims to implement the methods in the error, but surprisingly does not. 98 | 99 | bit -- **has patch** 100 | * CONFIG\_FSCK\_MINIX -- undefined reference to 'setbit', 'clrbit' 101 | * CONFIG\_MKFS\_MINIX -- undefined reference to 'setbit', 'clrbit' 102 | 103 | mntopt -- **has patch** 104 | * CONFIG\_SWAPOFF -- undefined reference to 'hasmntopt' 105 | * CONFIG\_SWAPON -- undefined reference to 'hasmntopt' 106 | 107 | others 108 | * CONFIG\_ETHER\_WAKE -- **has patch** -- undefined reference to 'ether\_hostton' 109 | * CONFIG\_FALLOCATE -- undefined reference to 'posix\_fallocate' 110 | * CONFIG\_FEATURE\_HTTPD\_AUTH\_MD5 -- undefined reference to 'crypt' 111 | * CONFIG\_FEATURE\_SYNC\_FANCY -- undefined reference to 'syncfs' 112 | * CONFIG\_HOSTID -- undefined reference to 'gethostid' 113 | * CONFIG\_LOGNAME -- undefined reference to 'getlogin\_r' 114 | * CONFIG\_MDEV -- undefined reference to 'sigtimedwait' 115 | * CONFIG\_NPROC -- undefined reference to 'sched\_getaffinity' 116 | * CONFIG\_NSENTER -- undefined reference to 'setns' 117 | * CONFIG\_UDHCPC6 -- **has patch** -- undefined reference to 'getifaddrs', 'freeifaddrs' 118 | * CONFIG\_UNSHARE -- undefined reference to 'unshare' 119 | -------------------------------------------------------------------------------- /errorlist-full-deprecated.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osm0sis/android-busybox-ndk/3c96be250994e00fb3feb9b5a5b902e5e0222ca3/errorlist-full-deprecated.log -------------------------------------------------------------------------------- /errorlist-full-unified.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osm0sis/android-busybox-ndk/3c96be250994e00fb3feb9b5a5b902e5e0222ca3/errorlist-full-unified.log -------------------------------------------------------------------------------- /experimental/0001-add-LFS-support-EXPERIMENTAL.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Tue, 20 Mar 2012 22:57:40 +0000 3 | Subject: [PATCH] add LFS support EXPERIMENTAL 4 | 5 | the original patch (see below) was written for busybox-1.18.5 6 | I've ported the patch to 1.20.0git, 7 | **HOWEVER** 8 | I can not give guarantees that this patch covers all cases. In fact, 9 | this stuff is beyond me. 10 | 11 | Use at your own risk. Do report if you can verify that this patch is 12 | sufficient and guaranteed to work. 13 | 14 | from 'off_t-is-long-stat.st_size-is-long-long' by Dan Drown 15 | """ 16 | android/bionic is special, off_t and stat.st_size do not match 17 | off_t is defined as "long" 18 | stat.st_size is defined as "long long" (loff_t) 19 | """ 20 | http://dan.drown.org/android/src/busybox/ 21 | --- 22 | archival/libarchive/get_header_tar.c | 4 +- 23 | archival/tar.c | 4 +- 24 | coreutils/od_bloaty.c | 36 +++++++++++++++++----------------- 25 | editors/cmp.c | 2 +- 26 | include/bb_archive.h | 2 +- 27 | include/libbb.h | 6 ----- 28 | libbb/loop.c | 2 +- 29 | libbb/xfuncs_printf.c | 2 +- 30 | 8 files changed, 26 insertions(+), 32 deletions(-) 31 | 32 | diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c 33 | index 80a7091..4e3efb0 100644 34 | --- a/archival/libarchive/get_header_tar.c 35 | +++ b/archival/libarchive/get_header_tar.c 36 | @@ -413,9 +413,9 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) 37 | } 38 | skip_ext_hdr: 39 | { 40 | - off_t sz; 41 | + loff_t sz; 42 | bb_error_msg("warning: skipping header '%c'", tar.typeflag); 43 | - sz = (file_header->size + 511) & ~(off_t)511; 44 | + sz = (file_header->size + 511) & ~(loff_t)511; 45 | archive_handle->offset += sz; 46 | sz >>= 9; /* sz /= 512 but w/o contortions for signed div */ 47 | while (sz--) 48 | diff --git a/archival/tar.c b/archival/tar.c 49 | index cf972c2..34476c3 100644 50 | --- a/archival/tar.c 51 | +++ b/archival/tar.c 52 | @@ -161,9 +161,9 @@ static HardLinkInfo *findHardLinkInfo(HardLinkInfo *hlInfo, struct stat *statbuf 53 | /* Put an octal string into the specified buffer. 54 | * The number is zero padded and possibly null terminated. 55 | * Stores low-order bits only if whole value does not fit. */ 56 | -static void putOctal(char *cp, int len, off_t value) 57 | +static void putOctal(char *cp, int len, loff_t value) 58 | { 59 | - char tempBuffer[sizeof(off_t)*3 + 1]; 60 | + char tempBuffer[sizeof(loff_t)*3 + 1]; 61 | char *tempString = tempBuffer; 62 | int width; 63 | 64 | diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c 65 | index 347f879..68470c8 100644 66 | --- a/coreutils/od_bloaty.c 67 | +++ b/coreutils/od_bloaty.c 68 | @@ -184,11 +184,11 @@ static struct tspec *spec; 69 | 70 | /* Function that accepts an address and an optional following char, 71 | and prints the address and char to stdout. */ 72 | -static void (*format_address)(off_t, char); 73 | +static void (*format_address)(loff_t, char); 74 | /* The difference between the old-style pseudo starting address and 75 | the number of bytes to skip. */ 76 | #if ENABLE_LONG_OPTS 77 | -static off_t pseudo_offset; 78 | +static loff_t pseudo_offset; 79 | #else 80 | enum { pseudo_offset = 0 }; 81 | #endif 82 | @@ -760,7 +760,7 @@ decode_format_string(const char *s) 83 | advance IN_STREAM. */ 84 | 85 | static void 86 | -skip(off_t n_skip) 87 | +skip(loff_t n_skip) 88 | { 89 | if (n_skip == 0) 90 | return; 91 | @@ -822,10 +822,10 @@ skip(off_t n_skip) 92 | } 93 | 94 | 95 | -typedef void FN_format_address(off_t address, char c); 96 | +typedef void FN_format_address(loff_t address, char c); 97 | 98 | static void 99 | -format_address_none(off_t address UNUSED_PARAM, char c UNUSED_PARAM) 100 | +format_address_none(loff_t address UNUSED_PARAM, char c UNUSED_PARAM) 101 | { 102 | } 103 | 104 | @@ -836,7 +836,7 @@ static char address_fmt[] ALIGN1 = "%0n"OFF_FMT"xc"; 105 | #define address_pad_len_char address_fmt[2] 106 | 107 | static void 108 | -format_address_std(off_t address, char c) 109 | +format_address_std(loff_t address, char c) 110 | { 111 | /* Corresponds to 'c' */ 112 | address_fmt[sizeof(address_fmt)-2] = c; 113 | @@ -846,7 +846,7 @@ format_address_std(off_t address, char c) 114 | #if ENABLE_LONG_OPTS 115 | /* only used with --traditional */ 116 | static void 117 | -format_address_paren(off_t address, char c) 118 | +format_address_paren(loff_t address, char c) 119 | { 120 | putchar('('); 121 | format_address_std(address, ')'); 122 | @@ -854,7 +854,7 @@ format_address_paren(off_t address, char c) 123 | } 124 | 125 | static void 126 | -format_address_label(off_t address, char c) 127 | +format_address_label(loff_t address, char c) 128 | { 129 | format_address_std(address, ' '); 130 | format_address_paren(address + pseudo_offset, c); 131 | @@ -885,7 +885,7 @@ dump_hexl_mode_trailer(size_t n_bytes, const char *block) 132 | only when it has not been padded to length BYTES_PER_BLOCK. */ 133 | 134 | static void 135 | -write_block(off_t current_offset, size_t n_bytes, 136 | +write_block(loff_t current_offset, size_t n_bytes, 137 | const char *prev_block, const char *curr_block) 138 | { 139 | static char first = 1; 140 | @@ -976,7 +976,7 @@ get_lcm(void) 141 | read. */ 142 | 143 | static void 144 | -dump(off_t current_offset, off_t end_offset) 145 | +dump(loff_t current_offset, loff_t end_offset) 146 | { 147 | char *block[2]; 148 | int idx; 149 | @@ -993,7 +993,7 @@ dump(off_t current_offset, off_t end_offset) 150 | n_bytes_read = 0; 151 | break; 152 | } 153 | - n_needed = MIN(end_offset - current_offset, (off_t) bytes_per_block); 154 | + n_needed = MIN(end_offset - current_offset, (loff_t) bytes_per_block); 155 | read_block(n_needed, block[idx], &n_bytes_read); 156 | if (n_bytes_read < bytes_per_block) 157 | break; 158 | @@ -1059,7 +1059,7 @@ dump(off_t current_offset, off_t end_offset) 159 | traditional version of od. */ 160 | 161 | static void 162 | -dump_strings(off_t address, off_t end_offset) 163 | +dump_strings(loff_t address, loff_t end_offset) 164 | { 165 | unsigned bufsize = MAX(100, string_min); 166 | unsigned char *buf = xmalloc(bufsize); 167 | @@ -1131,7 +1131,7 @@ dump_strings(off_t address, off_t end_offset) 168 | leading '+' return nonzero and set *OFFSET to the offset it denotes. */ 169 | 170 | static int 171 | -parse_old_offset(const char *s, off_t *offset) 172 | +parse_old_offset(const char *s, loff_t *offset) 173 | { 174 | static const struct suffix_mult Bb[] = { 175 | { "B", 1024 }, 176 | @@ -1192,11 +1192,11 @@ int od_main(int argc UNUSED_PARAM, char **argv) 177 | unsigned opt; 178 | int l_c_m; 179 | /* The number of input bytes to skip before formatting and writing. */ 180 | - off_t n_bytes_to_skip = 0; 181 | + loff_t n_bytes_to_skip = 0; 182 | /* The offset of the first byte after the last byte to be formatted. */ 183 | - off_t end_offset = 0; 184 | + loff_t end_offset = 0; 185 | /* The maximum number of bytes that will be formatted. */ 186 | - off_t max_bytes_to_format = 0; 187 | + loff_t max_bytes_to_format = 0; 188 | 189 | spec = NULL; 190 | format_address = format_address_std; 191 | @@ -1267,8 +1267,8 @@ int od_main(int argc UNUSED_PARAM, char **argv) 192 | #if ENABLE_LONG_OPTS 193 | if (opt & OPT_traditional) { 194 | if (argv[0]) { 195 | - off_t pseudo_start = -1; 196 | - off_t o1, o2; 197 | + loff_t pseudo_start = -1; 198 | + loff_t o1, o2; 199 | 200 | if (!argv[1]) { /* one arg */ 201 | if (parse_old_offset(argv[0], &o1)) { 202 | diff --git a/editors/cmp.c b/editors/cmp.c 203 | index fbe6b97..a566e70 100644 204 | --- a/editors/cmp.c 205 | +++ b/editors/cmp.c 206 | @@ -34,7 +34,7 @@ int cmp_main(int argc UNUSED_PARAM, char **argv) 207 | { 208 | FILE *fp1, *fp2, *outfile = stdout; 209 | const char *filename1, *filename2 = "-"; 210 | - off_t skip1 = 0, skip2 = 0, char_pos = 0; 211 | + loff_t skip1 = 0, skip2 = 0, char_pos = 0; 212 | int line_pos = 1; /* Hopefully won't overflow... */ 213 | const char *fmt; 214 | int c1, c2; 215 | diff --git a/include/bb_archive.h b/include/bb_archive.h 216 | index 2043d85..d633dd3 100644 217 | --- a/include/bb_archive.h 218 | +++ b/include/bb_archive.h 219 | @@ -35,7 +35,7 @@ typedef struct file_header_t { 220 | char *tar__uname; 221 | char *tar__gname; 222 | #endif 223 | - off_t size; 224 | + loff_t size; 225 | uid_t uid; 226 | gid_t gid; 227 | mode_t mode; 228 | diff --git a/include/libbb.h b/include/libbb.h 229 | index 2cc1466..464acf2 100644 230 | --- a/include/libbb.h 231 | +++ b/include/libbb.h 232 | @@ -249,12 +249,6 @@ typedef unsigned long uoff_t; 233 | #endif 234 | /* scary. better ideas? (but do *test* them first!) */ 235 | #define OFF_T_MAX ((off_t)~((off_t)1 << (sizeof(off_t)*8-1))) 236 | -/* Users report bionic to use 32-bit off_t even if LARGEFILE support is requested. 237 | - * We misdetected that. Don't let it build: 238 | - */ 239 | -struct BUG_off_t_size_is_misdetected { 240 | - char BUG_off_t_size_is_misdetected[sizeof(off_t) == sizeof(uoff_t) ? 1 : -1]; 241 | -}; 242 | 243 | /* Some useful definitions */ 244 | #undef FALSE 245 | diff --git a/libbb/loop.c b/libbb/loop.c 246 | index b3a5208..7c37e29 100644 247 | --- a/libbb/loop.c 248 | +++ b/libbb/loop.c 249 | @@ -56,7 +56,7 @@ char* FAST_FUNC query_loop(const char *device) 250 | fd = open(device, O_RDONLY); 251 | if (fd >= 0) { 252 | if (ioctl(fd, BB_LOOP_GET_STATUS, &loopinfo) == 0) { 253 | - dev = xasprintf("%"OFF_FMT"u %s", (off_t) loopinfo.lo_offset, 254 | + dev = xasprintf("%"OFF_FMT"u %s", (loff_t) loopinfo.lo_offset, 255 | (char *)loopinfo.lo_file_name); 256 | } 257 | close(fd); 258 | diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c 259 | index d8a42ba..5bb1b55 100644 260 | --- a/libbb/xfuncs_printf.c 261 | +++ b/libbb/xfuncs_printf.c 262 | @@ -234,7 +234,7 @@ off_t FAST_FUNC xlseek(int fd, off_t offset, int whence) 263 | off_t off = lseek(fd, offset, whence); 264 | if (off == (off_t)-1) { 265 | if (whence == SEEK_SET) 266 | - bb_perror_msg_and_die("lseek(%"OFF_FMT"u)", offset); 267 | + bb_perror_msg_and_die("lseek(%lu)", offset); 268 | bb_perror_msg_and_die("lseek"); 269 | } 270 | return off; 271 | -- 272 | 1.7.0.4 273 | 274 | -------------------------------------------------------------------------------- /old_config/android_ndk_config-w-patches: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated make config: don't edit 3 | # Busybox version: 1.21.0 4 | # Wed Jan 23 21:30:34 2013 5 | # 6 | CONFIG_HAVE_DOT_CONFIG=y 7 | 8 | # 9 | # Busybox Settings 10 | # 11 | 12 | # 13 | # General Configuration 14 | # 15 | CONFIG_DESKTOP=y 16 | # CONFIG_EXTRA_COMPAT is not set 17 | CONFIG_INCLUDE_SUSv2=y 18 | # CONFIG_USE_PORTABLE_CODE is not set 19 | CONFIG_PLATFORM_LINUX=y 20 | CONFIG_FEATURE_BUFFERS_USE_MALLOC=y 21 | # CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set 22 | # CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set 23 | CONFIG_SHOW_USAGE=y 24 | CONFIG_FEATURE_VERBOSE_USAGE=y 25 | CONFIG_FEATURE_COMPRESS_USAGE=y 26 | CONFIG_FEATURE_INSTALLER=y 27 | CONFIG_INSTALL_NO_USR=y 28 | # CONFIG_LOCALE_SUPPORT is not set 29 | CONFIG_UNICODE_SUPPORT=y 30 | # CONFIG_UNICODE_USING_LOCALE is not set 31 | # CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set 32 | CONFIG_SUBST_WCHAR=63 33 | CONFIG_LAST_SUPPORTED_WCHAR=767 34 | # CONFIG_UNICODE_COMBINING_WCHARS is not set 35 | # CONFIG_UNICODE_WIDE_WCHARS is not set 36 | # CONFIG_UNICODE_BIDI_SUPPORT is not set 37 | # CONFIG_UNICODE_NEUTRAL_TABLE is not set 38 | # CONFIG_UNICODE_PRESERVE_BROKEN is not set 39 | CONFIG_LONG_OPTS=y 40 | CONFIG_FEATURE_DEVPTS=y 41 | # CONFIG_FEATURE_CLEAN_UP is not set 42 | # CONFIG_FEATURE_UTMP is not set 43 | # CONFIG_FEATURE_WTMP is not set 44 | CONFIG_FEATURE_PIDFILE=y 45 | CONFIG_PID_FILE_PATH="/var/run" 46 | CONFIG_FEATURE_SUID=y 47 | CONFIG_FEATURE_SUID_CONFIG=y 48 | CONFIG_FEATURE_SUID_CONFIG_QUIET=y 49 | # CONFIG_SELINUX is not set 50 | # CONFIG_FEATURE_PREFER_APPLETS is not set 51 | CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" 52 | CONFIG_FEATURE_SYSLOG=y 53 | # CONFIG_FEATURE_HAVE_RPC is not set 54 | 55 | # 56 | # Build Options 57 | # 58 | # CONFIG_STATIC is not set 59 | # CONFIG_PIE is not set 60 | # CONFIG_NOMMU is not set 61 | # CONFIG_BUILD_LIBBUSYBOX is not set 62 | # CONFIG_FEATURE_INDIVIDUAL is not set 63 | # CONFIG_FEATURE_SHARED_BUSYBOX is not set 64 | # CONFIG_LFS is not set 65 | CONFIG_CROSS_COMPILER_PREFIX="arm-linux-androideabi-" 66 | CONFIG_SYSROOT="/opt/android-ndk/platforms/android-9/arch-arm" 67 | CONFIG_EXTRA_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=armv7-a -msoft-float -mfloat-abi=softfp -mfpu=neon -mthumb -mthumb-interwork -fpic -fno-short-enums -fgcse-after-reload -frename-registers" 68 | CONFIG_EXTRA_LDFLAGS="-Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined ${SYSROOT}/usr/lib/crtbegin_dynamic.o ${SYSROOT}/usr/lib/crtend_android.o" 69 | CONFIG_EXTRA_LDLIBS="dl m c gcc" 70 | 71 | # 72 | # Debugging Options 73 | # 74 | # CONFIG_DEBUG is not set 75 | # CONFIG_DEBUG_PESSIMIZE is not set 76 | # CONFIG_WERROR is not set 77 | CONFIG_NO_DEBUG_LIB=y 78 | # CONFIG_DMALLOC is not set 79 | # CONFIG_EFENCE is not set 80 | 81 | # 82 | # Installation Options ("make install" behavior) 83 | # 84 | CONFIG_INSTALL_APPLET_SYMLINKS=y 85 | # CONFIG_INSTALL_APPLET_HARDLINKS is not set 86 | # CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set 87 | # CONFIG_INSTALL_APPLET_DONT is not set 88 | # CONFIG_INSTALL_SH_APPLET_SYMLINK is not set 89 | # CONFIG_INSTALL_SH_APPLET_HARDLINK is not set 90 | # CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set 91 | CONFIG_PREFIX="./_install" 92 | 93 | # 94 | # Busybox Library Tuning 95 | # 96 | CONFIG_FEATURE_SYSTEMD=y 97 | CONFIG_FEATURE_RTMINMAX=y 98 | CONFIG_PASSWORD_MINLEN=6 99 | CONFIG_MD5_SMALL=1 100 | CONFIG_SHA3_SMALL=1 101 | CONFIG_FEATURE_FAST_TOP=y 102 | # CONFIG_FEATURE_ETC_NETWORKS is not set 103 | CONFIG_FEATURE_USE_TERMIOS=y 104 | CONFIG_FEATURE_EDITING=y 105 | CONFIG_FEATURE_EDITING_MAX_LEN=1024 106 | # CONFIG_FEATURE_EDITING_VI is not set 107 | CONFIG_FEATURE_EDITING_HISTORY=255 108 | CONFIG_FEATURE_EDITING_SAVEHISTORY=y 109 | # CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set 110 | CONFIG_FEATURE_REVERSE_SEARCH=y 111 | CONFIG_FEATURE_TAB_COMPLETION=y 112 | # CONFIG_FEATURE_USERNAME_COMPLETION is not set 113 | CONFIG_FEATURE_EDITING_FANCY_PROMPT=y 114 | # CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set 115 | CONFIG_FEATURE_NON_POSIX_CP=y 116 | CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y 117 | CONFIG_FEATURE_COPYBUF_KB=4 118 | # CONFIG_FEATURE_SKIP_ROOTFS is not set 119 | # CONFIG_MONOTONIC_SYSCALL is not set 120 | CONFIG_IOCTL_HEX2STR_ERROR=y 121 | CONFIG_FEATURE_HWIB=y 122 | 123 | # 124 | # Applets 125 | # 126 | 127 | # 128 | # Archival Utilities 129 | # 130 | CONFIG_FEATURE_SEAMLESS_XZ=y 131 | CONFIG_FEATURE_SEAMLESS_LZMA=y 132 | CONFIG_FEATURE_SEAMLESS_BZ2=y 133 | CONFIG_FEATURE_SEAMLESS_GZ=y 134 | CONFIG_FEATURE_SEAMLESS_Z=y 135 | CONFIG_AR=y 136 | CONFIG_FEATURE_AR_LONG_FILENAMES=y 137 | CONFIG_FEATURE_AR_CREATE=y 138 | CONFIG_BUNZIP2=y 139 | CONFIG_BZIP2=y 140 | CONFIG_CPIO=y 141 | CONFIG_FEATURE_CPIO_O=y 142 | CONFIG_FEATURE_CPIO_P=y 143 | CONFIG_DPKG=y 144 | CONFIG_DPKG_DEB=y 145 | # CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set 146 | CONFIG_GUNZIP=y 147 | CONFIG_GZIP=y 148 | CONFIG_FEATURE_GZIP_LONG_OPTIONS=y 149 | CONFIG_GZIP_FAST=0 150 | CONFIG_LZOP=y 151 | CONFIG_LZOP_COMPR_HIGH=y 152 | CONFIG_RPM2CPIO=y 153 | CONFIG_RPM=y 154 | CONFIG_TAR=y 155 | CONFIG_FEATURE_TAR_CREATE=y 156 | CONFIG_FEATURE_TAR_AUTODETECT=y 157 | CONFIG_FEATURE_TAR_FROM=y 158 | CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y 159 | CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y 160 | CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y 161 | CONFIG_FEATURE_TAR_LONG_OPTIONS=y 162 | CONFIG_FEATURE_TAR_TO_COMMAND=y 163 | CONFIG_FEATURE_TAR_UNAME_GNAME=y 164 | CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y 165 | # CONFIG_FEATURE_TAR_SELINUX is not set 166 | CONFIG_UNCOMPRESS=y 167 | CONFIG_UNLZMA=y 168 | CONFIG_FEATURE_LZMA_FAST=y 169 | CONFIG_LZMA=y 170 | CONFIG_UNXZ=y 171 | CONFIG_XZ=y 172 | CONFIG_UNZIP=y 173 | 174 | # 175 | # Coreutils 176 | # 177 | CONFIG_BASENAME=y 178 | CONFIG_CAT=y 179 | CONFIG_DATE=y 180 | CONFIG_FEATURE_DATE_ISOFMT=y 181 | # CONFIG_FEATURE_DATE_NANO is not set 182 | CONFIG_FEATURE_DATE_COMPAT=y 183 | # CONFIG_HOSTID is not set 184 | CONFIG_ID=y 185 | CONFIG_GROUPS=y 186 | CONFIG_TEST=y 187 | CONFIG_FEATURE_TEST_64=y 188 | CONFIG_TOUCH=y 189 | CONFIG_FEATURE_TOUCH_SUSV3=y 190 | CONFIG_TR=y 191 | CONFIG_FEATURE_TR_CLASSES=y 192 | CONFIG_FEATURE_TR_EQUIV=y 193 | CONFIG_BASE64=y 194 | # CONFIG_WHO is not set 195 | # CONFIG_USERS is not set 196 | CONFIG_CAL=y 197 | CONFIG_CATV=y 198 | CONFIG_CHGRP=y 199 | CONFIG_CHMOD=y 200 | CONFIG_CHOWN=y 201 | CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y 202 | CONFIG_CHROOT=y 203 | CONFIG_CKSUM=y 204 | CONFIG_COMM=y 205 | CONFIG_CP=y 206 | CONFIG_FEATURE_CP_LONG_OPTIONS=y 207 | CONFIG_CUT=y 208 | CONFIG_DD=y 209 | CONFIG_FEATURE_DD_SIGNAL_HANDLING=y 210 | CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y 211 | CONFIG_FEATURE_DD_IBS_OBS=y 212 | CONFIG_DF=y 213 | CONFIG_FEATURE_DF_FANCY=y 214 | CONFIG_DIRNAME=y 215 | CONFIG_DOS2UNIX=y 216 | CONFIG_UNIX2DOS=y 217 | CONFIG_DU=y 218 | CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y 219 | CONFIG_ECHO=y 220 | CONFIG_FEATURE_FANCY_ECHO=y 221 | CONFIG_ENV=y 222 | CONFIG_FEATURE_ENV_LONG_OPTIONS=y 223 | CONFIG_EXPAND=y 224 | CONFIG_FEATURE_EXPAND_LONG_OPTIONS=y 225 | CONFIG_EXPR=y 226 | CONFIG_EXPR_MATH_SUPPORT_64=y 227 | CONFIG_FALSE=y 228 | CONFIG_FOLD=y 229 | CONFIG_FSYNC=y 230 | CONFIG_HEAD=y 231 | CONFIG_FEATURE_FANCY_HEAD=y 232 | CONFIG_INSTALL=y 233 | CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y 234 | CONFIG_LN=y 235 | # CONFIG_LOGNAME is not set 236 | CONFIG_LS=y 237 | CONFIG_FEATURE_LS_FILETYPES=y 238 | CONFIG_FEATURE_LS_FOLLOWLINKS=y 239 | CONFIG_FEATURE_LS_RECURSIVE=y 240 | CONFIG_FEATURE_LS_SORTFILES=y 241 | CONFIG_FEATURE_LS_TIMESTAMPS=y 242 | CONFIG_FEATURE_LS_USERNAME=y 243 | CONFIG_FEATURE_LS_COLOR=y 244 | CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y 245 | CONFIG_MD5SUM=y 246 | CONFIG_MKDIR=y 247 | CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y 248 | CONFIG_MKFIFO=y 249 | CONFIG_MKNOD=y 250 | CONFIG_MV=y 251 | CONFIG_FEATURE_MV_LONG_OPTIONS=y 252 | CONFIG_NICE=y 253 | CONFIG_NOHUP=y 254 | CONFIG_OD=y 255 | CONFIG_PRINTENV=y 256 | CONFIG_PRINTF=y 257 | CONFIG_PWD=y 258 | CONFIG_READLINK=y 259 | CONFIG_FEATURE_READLINK_FOLLOW=y 260 | CONFIG_REALPATH=y 261 | CONFIG_RM=y 262 | CONFIG_RMDIR=y 263 | CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y 264 | CONFIG_SEQ=y 265 | CONFIG_SHA1SUM=y 266 | CONFIG_SHA256SUM=y 267 | CONFIG_SHA512SUM=y 268 | CONFIG_SHA3SUM=y 269 | CONFIG_SLEEP=y 270 | CONFIG_FEATURE_FANCY_SLEEP=y 271 | CONFIG_FEATURE_FLOAT_SLEEP=y 272 | CONFIG_SORT=y 273 | CONFIG_FEATURE_SORT_BIG=y 274 | CONFIG_SPLIT=y 275 | CONFIG_FEATURE_SPLIT_FANCY=y 276 | CONFIG_STAT=y 277 | CONFIG_FEATURE_STAT_FORMAT=y 278 | CONFIG_STTY=y 279 | CONFIG_SUM=y 280 | CONFIG_SYNC=y 281 | CONFIG_TAC=y 282 | CONFIG_TAIL=y 283 | CONFIG_FEATURE_FANCY_TAIL=y 284 | CONFIG_TEE=y 285 | CONFIG_FEATURE_TEE_USE_BLOCK_IO=y 286 | CONFIG_TRUE=y 287 | CONFIG_TTY=y 288 | CONFIG_UNAME=y 289 | CONFIG_UNEXPAND=y 290 | CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS=y 291 | CONFIG_UNIQ=y 292 | CONFIG_USLEEP=y 293 | CONFIG_UUDECODE=y 294 | CONFIG_UUENCODE=y 295 | CONFIG_WC=y 296 | CONFIG_FEATURE_WC_LARGE=y 297 | CONFIG_WHOAMI=y 298 | CONFIG_YES=y 299 | 300 | # 301 | # Common options for cp and mv 302 | # 303 | CONFIG_FEATURE_PRESERVE_HARDLINKS=y 304 | 305 | # 306 | # Common options for ls, more and telnet 307 | # 308 | CONFIG_FEATURE_AUTOWIDTH=y 309 | 310 | # 311 | # Common options for df, du, ls 312 | # 313 | CONFIG_FEATURE_HUMAN_READABLE=y 314 | 315 | # 316 | # Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum 317 | # 318 | CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y 319 | 320 | # 321 | # Console Utilities 322 | # 323 | CONFIG_CHVT=y 324 | CONFIG_FGCONSOLE=y 325 | CONFIG_CLEAR=y 326 | CONFIG_DEALLOCVT=y 327 | CONFIG_DUMPKMAP=y 328 | CONFIG_KBD_MODE=y 329 | # CONFIG_LOADFONT is not set 330 | CONFIG_LOADKMAP=y 331 | CONFIG_OPENVT=y 332 | CONFIG_RESET=y 333 | CONFIG_RESIZE=y 334 | CONFIG_FEATURE_RESIZE_PRINT=y 335 | CONFIG_SETCONSOLE=y 336 | CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y 337 | # CONFIG_SETFONT is not set 338 | # CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set 339 | CONFIG_DEFAULT_SETFONT_DIR="" 340 | CONFIG_SETKEYCODES=y 341 | CONFIG_SETLOGCONS=y 342 | CONFIG_SHOWKEY=y 343 | # CONFIG_FEATURE_LOADFONT_PSF2 is not set 344 | # CONFIG_FEATURE_LOADFONT_RAW is not set 345 | 346 | # 347 | # Debian Utilities 348 | # 349 | CONFIG_MKTEMP=y 350 | CONFIG_PIPE_PROGRESS=y 351 | CONFIG_RUN_PARTS=y 352 | CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y 353 | CONFIG_FEATURE_RUN_PARTS_FANCY=y 354 | CONFIG_START_STOP_DAEMON=y 355 | CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y 356 | CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y 357 | CONFIG_WHICH=y 358 | 359 | # 360 | # Editors 361 | # 362 | CONFIG_PATCH=y 363 | CONFIG_VI=y 364 | CONFIG_FEATURE_VI_MAX_LEN=4096 365 | CONFIG_FEATURE_VI_8BIT=y 366 | CONFIG_FEATURE_VI_COLON=y 367 | CONFIG_FEATURE_VI_YANKMARK=y 368 | CONFIG_FEATURE_VI_SEARCH=y 369 | # CONFIG_FEATURE_VI_REGEX_SEARCH is not set 370 | # CONFIG_FEATURE_VI_USE_SIGNALS is not set [Broken for X86, siglongjmp missing from NDK r8b] 371 | CONFIG_FEATURE_VI_DOT_CMD=y 372 | CONFIG_FEATURE_VI_READONLY=y 373 | CONFIG_FEATURE_VI_SETOPTS=y 374 | CONFIG_FEATURE_VI_SET=y 375 | CONFIG_FEATURE_VI_WIN_RESIZE=y 376 | CONFIG_FEATURE_VI_ASK_TERMINAL=y 377 | CONFIG_AWK=y 378 | CONFIG_FEATURE_AWK_LIBM=y 379 | CONFIG_CMP=y 380 | CONFIG_DIFF=y 381 | CONFIG_FEATURE_DIFF_LONG_OPTIONS=y 382 | CONFIG_FEATURE_DIFF_DIR=y 383 | CONFIG_ED=y 384 | CONFIG_SED=y 385 | CONFIG_FEATURE_ALLOW_EXEC=y 386 | 387 | # 388 | # Finding Utilities 389 | # 390 | CONFIG_FIND=y 391 | CONFIG_FEATURE_FIND_PRINT0=y 392 | CONFIG_FEATURE_FIND_MTIME=y 393 | CONFIG_FEATURE_FIND_MMIN=y 394 | CONFIG_FEATURE_FIND_PERM=y 395 | CONFIG_FEATURE_FIND_TYPE=y 396 | CONFIG_FEATURE_FIND_XDEV=y 397 | CONFIG_FEATURE_FIND_MAXDEPTH=y 398 | CONFIG_FEATURE_FIND_NEWER=y 399 | CONFIG_FEATURE_FIND_INUM=y 400 | CONFIG_FEATURE_FIND_EXEC=y 401 | CONFIG_FEATURE_FIND_USER=y 402 | CONFIG_FEATURE_FIND_GROUP=y 403 | CONFIG_FEATURE_FIND_NOT=y 404 | CONFIG_FEATURE_FIND_DEPTH=y 405 | CONFIG_FEATURE_FIND_PAREN=y 406 | CONFIG_FEATURE_FIND_SIZE=y 407 | CONFIG_FEATURE_FIND_PRUNE=y 408 | CONFIG_FEATURE_FIND_DELETE=y 409 | CONFIG_FEATURE_FIND_PATH=y 410 | CONFIG_FEATURE_FIND_REGEX=y 411 | # CONFIG_FEATURE_FIND_CONTEXT is not set 412 | CONFIG_FEATURE_FIND_LINKS=y 413 | CONFIG_GREP=y 414 | CONFIG_FEATURE_GREP_EGREP_ALIAS=y 415 | CONFIG_FEATURE_GREP_FGREP_ALIAS=y 416 | CONFIG_FEATURE_GREP_CONTEXT=y 417 | CONFIG_XARGS=y 418 | CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y 419 | CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y 420 | CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y 421 | CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y 422 | 423 | # 424 | # Init Utilities 425 | # 426 | CONFIG_BOOTCHARTD=y 427 | CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER=y 428 | CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE=y 429 | CONFIG_HALT=y 430 | # CONFIG_FEATURE_CALL_TELINIT is not set 431 | CONFIG_TELINIT_PATH="" 432 | CONFIG_INIT=y 433 | CONFIG_FEATURE_USE_INITTAB=y 434 | # CONFIG_FEATURE_KILL_REMOVED is not set 435 | CONFIG_FEATURE_KILL_DELAY=0 436 | CONFIG_FEATURE_INIT_SCTTY=y 437 | CONFIG_FEATURE_INIT_SYSLOG=y 438 | CONFIG_FEATURE_EXTRA_QUIET=y 439 | CONFIG_FEATURE_INIT_COREDUMPS=y 440 | CONFIG_FEATURE_INITRD=y 441 | CONFIG_INIT_TERMINAL_TYPE="linux" 442 | CONFIG_MESG=y 443 | CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y 444 | 445 | # 446 | # Login/Password Management Utilities 447 | # 448 | # CONFIG_ADD_SHELL is not set 449 | # CONFIG_REMOVE_SHELL is not set 450 | # CONFIG_FEATURE_SHADOWPASSWDS is not set 451 | # CONFIG_USE_BB_PWD_GRP is not set 452 | # CONFIG_USE_BB_SHADOW is not set 453 | # CONFIG_USE_BB_CRYPT is not set 454 | # CONFIG_USE_BB_CRYPT_SHA is not set 455 | # CONFIG_ADDUSER is not set 456 | # CONFIG_FEATURE_ADDUSER_LONG_OPTIONS is not set 457 | # CONFIG_FEATURE_CHECK_NAMES is not set 458 | CONFIG_FIRST_SYSTEM_ID=0 459 | CONFIG_LAST_SYSTEM_ID=0 460 | # CONFIG_ADDGROUP is not set 461 | # CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS is not set 462 | # CONFIG_FEATURE_ADDUSER_TO_GROUP is not set 463 | # CONFIG_DELUSER is not set 464 | # CONFIG_DELGROUP is not set 465 | # CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set 466 | # CONFIG_GETTY is not set 467 | # CONFIG_LOGIN is not set 468 | # CONFIG_LOGIN_SESSION_AS_CHILD is not set 469 | # CONFIG_PAM is not set 470 | # CONFIG_LOGIN_SCRIPTS is not set 471 | # CONFIG_FEATURE_NOLOGIN is not set 472 | # CONFIG_FEATURE_SECURETTY is not set 473 | # CONFIG_PASSWD is not set 474 | # CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set 475 | # CONFIG_CRYPTPW is not set 476 | # CONFIG_CHPASSWD is not set 477 | CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="" 478 | # CONFIG_SU is not set 479 | # CONFIG_FEATURE_SU_SYSLOG is not set 480 | # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set 481 | # CONFIG_SULOGIN is not set 482 | # CONFIG_VLOCK is not set 483 | 484 | # 485 | # Linux Ext2 FS Progs 486 | # 487 | CONFIG_CHATTR=y 488 | CONFIG_FSCK=y 489 | CONFIG_LSATTR=y 490 | CONFIG_TUNE2FS=y 491 | 492 | # 493 | # Linux Module Utilities 494 | # 495 | CONFIG_MODINFO=y 496 | CONFIG_MODPROBE_SMALL=y 497 | CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y 498 | CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y 499 | # CONFIG_INSMOD is not set 500 | # CONFIG_RMMOD is not set 501 | # CONFIG_LSMOD is not set 502 | # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set 503 | # CONFIG_MODPROBE is not set 504 | # CONFIG_FEATURE_MODPROBE_BLACKLIST is not set 505 | # CONFIG_DEPMOD is not set 506 | 507 | # 508 | # Options common to multiple modutils 509 | # 510 | # CONFIG_FEATURE_2_4_MODULES is not set 511 | # CONFIG_FEATURE_INSMOD_TRY_MMAP is not set 512 | # CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set 513 | # CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set 514 | # CONFIG_FEATURE_INSMOD_LOADINKMEM is not set 515 | # CONFIG_FEATURE_INSMOD_LOAD_MAP is not set 516 | # CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set 517 | # CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set 518 | # CONFIG_FEATURE_MODUTILS_ALIAS is not set 519 | # CONFIG_FEATURE_MODUTILS_SYMBOLS is not set 520 | CONFIG_DEFAULT_MODULES_DIR="/system/lib/modules" 521 | CONFIG_DEFAULT_DEPMOD_FILE="modules.dep" 522 | 523 | # 524 | # Linux System Utilities 525 | # 526 | CONFIG_BLOCKDEV=y 527 | CONFIG_MDEV=y 528 | CONFIG_FEATURE_MDEV_CONF=y 529 | CONFIG_FEATURE_MDEV_RENAME=y 530 | CONFIG_FEATURE_MDEV_RENAME_REGEXP=y 531 | CONFIG_FEATURE_MDEV_EXEC=y 532 | CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y 533 | CONFIG_REV=y 534 | CONFIG_ACPID=y 535 | CONFIG_FEATURE_ACPID_COMPAT=y 536 | CONFIG_BLKID=y 537 | CONFIG_FEATURE_BLKID_TYPE=y 538 | CONFIG_DMESG=y 539 | CONFIG_FEATURE_DMESG_PRETTY=y 540 | CONFIG_FBSET=y 541 | CONFIG_FEATURE_FBSET_FANCY=y 542 | CONFIG_FEATURE_FBSET_READMODE=y 543 | CONFIG_FDFLUSH=y 544 | CONFIG_FDFORMAT=y 545 | CONFIG_FDISK=y 546 | CONFIG_FDISK_SUPPORT_LARGE_DISKS=y 547 | CONFIG_FEATURE_FDISK_WRITABLE=y 548 | CONFIG_FEATURE_AIX_LABEL=y 549 | CONFIG_FEATURE_SGI_LABEL=y 550 | CONFIG_FEATURE_SUN_LABEL=y 551 | CONFIG_FEATURE_OSF_LABEL=y 552 | CONFIG_FEATURE_GPT_LABEL=y 553 | CONFIG_FEATURE_FDISK_ADVANCED=y 554 | CONFIG_FINDFS=y 555 | CONFIG_FLOCK=y 556 | CONFIG_FREERAMDISK=y 557 | CONFIG_FSCK_MINIX=y 558 | CONFIG_MKFS_EXT2=y 559 | CONFIG_MKFS_MINIX=y 560 | CONFIG_FEATURE_MINIX2=y 561 | CONFIG_MKFS_REISER=y 562 | CONFIG_MKFS_VFAT=y 563 | CONFIG_GETOPT=y 564 | CONFIG_FEATURE_GETOPT_LONG=y 565 | CONFIG_HEXDUMP=y 566 | CONFIG_FEATURE_HEXDUMP_REVERSE=y 567 | CONFIG_HD=y 568 | CONFIG_HWCLOCK=y 569 | CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y 570 | # CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set 571 | CONFIG_IPCRM=y 572 | CONFIG_IPCS=y 573 | CONFIG_LOSETUP=y 574 | CONFIG_LSPCI=y 575 | CONFIG_LSUSB=y 576 | CONFIG_MKSWAP=y 577 | CONFIG_FEATURE_MKSWAP_UUID=y 578 | CONFIG_MORE=y 579 | CONFIG_MOUNT=y 580 | CONFIG_FEATURE_MOUNT_FAKE=y 581 | CONFIG_FEATURE_MOUNT_VERBOSE=y 582 | CONFIG_FEATURE_MOUNT_HELPERS=y 583 | CONFIG_FEATURE_MOUNT_LABEL=y 584 | # CONFIG_FEATURE_MOUNT_NFS is not set 585 | # CONFIG_FEATURE_MOUNT_CIFS is not set 586 | CONFIG_FEATURE_MOUNT_FLAGS=y 587 | CONFIG_FEATURE_MOUNT_FSTAB=y 588 | CONFIG_PIVOT_ROOT=y 589 | CONFIG_RDATE=y 590 | CONFIG_RDEV=y 591 | CONFIG_READPROFILE=y 592 | CONFIG_RTCWAKE=y 593 | CONFIG_SCRIPT=y 594 | CONFIG_SCRIPTREPLAY=y 595 | # CONFIG_SETARCH is not set 596 | CONFIG_SWAPONOFF=y 597 | # CONFIG_FEATURE_SWAPON_PRI is not set 598 | CONFIG_SWITCH_ROOT=y 599 | CONFIG_UMOUNT=y 600 | CONFIG_FEATURE_UMOUNT_ALL=y 601 | 602 | # 603 | # Common options for mount/umount 604 | # 605 | CONFIG_FEATURE_MOUNT_LOOP=y 606 | CONFIG_FEATURE_MOUNT_LOOP_CREATE=y 607 | # CONFIG_FEATURE_MTAB_SUPPORT is not set 608 | CONFIG_VOLUMEID=y 609 | 610 | # 611 | # Filesystem/Volume identification 612 | # 613 | CONFIG_FEATURE_VOLUMEID_EXT=y 614 | CONFIG_FEATURE_VOLUMEID_BTRFS=y 615 | CONFIG_FEATURE_VOLUMEID_REISERFS=y 616 | CONFIG_FEATURE_VOLUMEID_FAT=y 617 | CONFIG_FEATURE_VOLUMEID_EXFAT=y 618 | CONFIG_FEATURE_VOLUMEID_HFS=y 619 | CONFIG_FEATURE_VOLUMEID_JFS=y 620 | CONFIG_FEATURE_VOLUMEID_XFS=y 621 | CONFIG_FEATURE_VOLUMEID_NILFS=y 622 | CONFIG_FEATURE_VOLUMEID_NTFS=y 623 | CONFIG_FEATURE_VOLUMEID_ISO9660=y 624 | CONFIG_FEATURE_VOLUMEID_UDF=y 625 | CONFIG_FEATURE_VOLUMEID_LUKS=y 626 | CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y 627 | CONFIG_FEATURE_VOLUMEID_CRAMFS=y 628 | CONFIG_FEATURE_VOLUMEID_ROMFS=y 629 | CONFIG_FEATURE_VOLUMEID_SQUASHFS=y 630 | CONFIG_FEATURE_VOLUMEID_SYSV=y 631 | CONFIG_FEATURE_VOLUMEID_OCFS2=y 632 | CONFIG_FEATURE_VOLUMEID_LINUXRAID=y 633 | 634 | # 635 | # Miscellaneous Utilities 636 | # 637 | # CONFIG_CONSPY is not set 638 | CONFIG_LESS=y 639 | CONFIG_FEATURE_LESS_MAXLINES=9999999 640 | CONFIG_FEATURE_LESS_BRACKETS=y 641 | CONFIG_FEATURE_LESS_FLAGS=y 642 | CONFIG_FEATURE_LESS_MARKS=y 643 | CONFIG_FEATURE_LESS_REGEXP=y 644 | CONFIG_FEATURE_LESS_WINCH=y 645 | CONFIG_FEATURE_LESS_ASK_TERMINAL=y 646 | CONFIG_FEATURE_LESS_DASHCMD=y 647 | CONFIG_FEATURE_LESS_LINENUMS=y 648 | CONFIG_NANDWRITE=y 649 | CONFIG_NANDDUMP=y 650 | CONFIG_SETSERIAL=y 651 | CONFIG_UBIATTACH=y 652 | CONFIG_UBIDETACH=y 653 | CONFIG_UBIMKVOL=y 654 | CONFIG_UBIRMVOL=y 655 | CONFIG_UBIRSVOL=y 656 | CONFIG_UBIUPDATEVOL=y 657 | CONFIG_ADJTIMEX=y 658 | CONFIG_BBCONFIG=y 659 | CONFIG_FEATURE_COMPRESS_BBCONFIG=y 660 | CONFIG_BEEP=y 661 | CONFIG_FEATURE_BEEP_FREQ=4000 662 | CONFIG_FEATURE_BEEP_LENGTH_MS=30 663 | CONFIG_CHAT=y 664 | CONFIG_FEATURE_CHAT_NOFAIL=y 665 | # CONFIG_FEATURE_CHAT_TTY_HIFI is not set 666 | CONFIG_FEATURE_CHAT_IMPLICIT_CR=y 667 | CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y 668 | CONFIG_FEATURE_CHAT_SEND_ESCAPES=y 669 | CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y 670 | CONFIG_FEATURE_CHAT_CLR_ABORT=y 671 | CONFIG_CHRT=y 672 | CONFIG_CROND=y 673 | CONFIG_FEATURE_CROND_D=y 674 | CONFIG_FEATURE_CROND_CALL_SENDMAIL=y 675 | CONFIG_FEATURE_CROND_DIR="/var/spool/cron" 676 | CONFIG_CRONTAB=y 677 | CONFIG_DC=y 678 | CONFIG_FEATURE_DC_LIBM=y 679 | # CONFIG_DEVFSD is not set 680 | # CONFIG_DEVFSD_MODLOAD is not set 681 | # CONFIG_DEVFSD_FG_NP is not set 682 | # CONFIG_DEVFSD_VERBOSE is not set 683 | # CONFIG_FEATURE_DEVFS is not set 684 | CONFIG_DEVMEM=y 685 | # CONFIG_EJECT is not set 686 | # CONFIG_FEATURE_EJECT_SCSI is not set 687 | CONFIG_FBSPLASH=y 688 | CONFIG_FLASHCP=y 689 | CONFIG_FLASH_LOCK=y 690 | CONFIG_FLASH_UNLOCK=y 691 | # CONFIG_FLASH_ERASEALL is not set 692 | CONFIG_IONICE=y 693 | CONFIG_INOTIFYD=y 694 | # CONFIG_LAST is not set 695 | # CONFIG_FEATURE_LAST_SMALL is not set 696 | # CONFIG_FEATURE_LAST_FANCY is not set 697 | CONFIG_HDPARM=y 698 | CONFIG_FEATURE_HDPARM_GET_IDENTITY=y 699 | CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y 700 | CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF=y 701 | CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET=y 702 | CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF=y 703 | CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y 704 | CONFIG_MAKEDEVS=y 705 | # CONFIG_FEATURE_MAKEDEVS_LEAF is not set 706 | CONFIG_FEATURE_MAKEDEVS_TABLE=y 707 | CONFIG_MAN=y 708 | CONFIG_MICROCOM=y 709 | CONFIG_MOUNTPOINT=y 710 | # CONFIG_MT is not set 711 | CONFIG_RAIDAUTORUN=y 712 | # CONFIG_READAHEAD is not set 713 | # CONFIG_RFKILL is not set 714 | # CONFIG_RUNLEVEL is not set 715 | CONFIG_RX=y 716 | CONFIG_SETSID=y 717 | CONFIG_STRINGS=y 718 | # CONFIG_TASKSET is not set 719 | # CONFIG_FEATURE_TASKSET_FANCY is not set 720 | CONFIG_TIME=y 721 | CONFIG_TIMEOUT=y 722 | CONFIG_TTYSIZE=y 723 | CONFIG_VOLNAME=y 724 | # CONFIG_WALL is not set 725 | CONFIG_WATCHDOG=y 726 | 727 | # 728 | # Networking Utilities 729 | # 730 | CONFIG_NAMEIF=y 731 | CONFIG_FEATURE_NAMEIF_EXTENDED=y 732 | CONFIG_NBDCLIENT=y 733 | CONFIG_NC=y 734 | CONFIG_NC_SERVER=y 735 | CONFIG_NC_EXTRA=y 736 | # CONFIG_NC_110_COMPAT is not set 737 | CONFIG_PING=y 738 | CONFIG_PING6=y 739 | CONFIG_FEATURE_FANCY_PING=y 740 | CONFIG_WHOIS=y 741 | CONFIG_FEATURE_IPV6=y 742 | # CONFIG_FEATURE_UNIX_LOCAL is not set 743 | CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y 744 | CONFIG_VERBOSE_RESOLUTION_ERRORS=y 745 | CONFIG_ARP=y 746 | CONFIG_ARPING=y 747 | CONFIG_BRCTL=y 748 | CONFIG_FEATURE_BRCTL_FANCY=y 749 | CONFIG_FEATURE_BRCTL_SHOW=y 750 | CONFIG_DNSD=y 751 | CONFIG_ETHER_WAKE=y 752 | CONFIG_FAKEIDENTD=y 753 | CONFIG_FTPD=y 754 | CONFIG_FEATURE_FTP_WRITE=y 755 | CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y 756 | CONFIG_FTPGET=y 757 | CONFIG_FTPPUT=y 758 | CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y 759 | CONFIG_HOSTNAME=y 760 | CONFIG_HTTPD=y 761 | CONFIG_FEATURE_HTTPD_RANGES=y 762 | CONFIG_FEATURE_HTTPD_USE_SENDFILE=y 763 | CONFIG_FEATURE_HTTPD_SETUID=y 764 | CONFIG_FEATURE_HTTPD_BASIC_AUTH=y 765 | # CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set 766 | CONFIG_FEATURE_HTTPD_CGI=y 767 | CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y 768 | CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y 769 | CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y 770 | CONFIG_FEATURE_HTTPD_ERROR_PAGES=y 771 | CONFIG_FEATURE_HTTPD_PROXY=y 772 | CONFIG_FEATURE_HTTPD_GZIP=y 773 | CONFIG_IFCONFIG=y 774 | CONFIG_FEATURE_IFCONFIG_STATUS=y 775 | # CONFIG_FEATURE_IFCONFIG_SLIP is not set 776 | CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y 777 | CONFIG_FEATURE_IFCONFIG_HW=y 778 | CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y 779 | # CONFIG_IFENSLAVE is not set 780 | # CONFIG_IFPLUGD is not set 781 | CONFIG_IFUPDOWN=y 782 | CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate" 783 | CONFIG_FEATURE_IFUPDOWN_IP=y 784 | CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN=y 785 | # CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set 786 | CONFIG_FEATURE_IFUPDOWN_IPV4=y 787 | CONFIG_FEATURE_IFUPDOWN_IPV6=y 788 | CONFIG_FEATURE_IFUPDOWN_MAPPING=y 789 | CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y 790 | CONFIG_INETD=y 791 | CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y 792 | CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y 793 | CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y 794 | CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y 795 | CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y 796 | # CONFIG_FEATURE_INETD_RPC is not set 797 | CONFIG_IP=y 798 | CONFIG_FEATURE_IP_ADDRESS=y 799 | CONFIG_FEATURE_IP_LINK=y 800 | CONFIG_FEATURE_IP_ROUTE=y 801 | CONFIG_FEATURE_IP_TUNNEL=y 802 | CONFIG_FEATURE_IP_RULE=y 803 | CONFIG_FEATURE_IP_SHORT_FORMS=y 804 | CONFIG_FEATURE_IP_RARE_PROTOCOLS=y 805 | CONFIG_IPADDR=y 806 | CONFIG_IPLINK=y 807 | CONFIG_IPROUTE=y 808 | CONFIG_IPTUNNEL=y 809 | CONFIG_IPRULE=y 810 | CONFIG_IPCALC=y 811 | CONFIG_FEATURE_IPCALC_FANCY=y 812 | CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y 813 | CONFIG_NETSTAT=y 814 | CONFIG_FEATURE_NETSTAT_WIDE=y 815 | CONFIG_FEATURE_NETSTAT_PRG=y 816 | CONFIG_NSLOOKUP=y 817 | # CONFIG_NTPD is not set 818 | # CONFIG_FEATURE_NTPD_SERVER is not set 819 | CONFIG_PSCAN=y 820 | CONFIG_ROUTE=y 821 | CONFIG_SLATTACH=y 822 | CONFIG_TCPSVD=y 823 | CONFIG_TELNET=y 824 | CONFIG_FEATURE_TELNET_TTYPE=y 825 | CONFIG_FEATURE_TELNET_AUTOLOGIN=y 826 | CONFIG_TELNETD=y 827 | CONFIG_FEATURE_TELNETD_STANDALONE=y 828 | CONFIG_FEATURE_TELNETD_INETD_WAIT=y 829 | CONFIG_TFTP=y 830 | CONFIG_TFTPD=y 831 | 832 | # 833 | # Common options for tftp/tftpd 834 | # 835 | CONFIG_FEATURE_TFTP_GET=y 836 | CONFIG_FEATURE_TFTP_PUT=y 837 | CONFIG_FEATURE_TFTP_BLOCKSIZE=y 838 | CONFIG_FEATURE_TFTP_PROGRESS_BAR=y 839 | # CONFIG_TFTP_DEBUG is not set 840 | CONFIG_TRACEROUTE=y 841 | CONFIG_TRACEROUTE6=y 842 | CONFIG_FEATURE_TRACEROUTE_VERBOSE=y 843 | # CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set 844 | # CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set 845 | CONFIG_TUNCTL=y 846 | CONFIG_FEATURE_TUNCTL_UG=y 847 | # CONFIG_UDHCPC6 is not set 848 | CONFIG_UDHCPD=y 849 | CONFIG_DHCPRELAY=y 850 | CONFIG_DUMPLEASES=y 851 | CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y 852 | # CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set 853 | CONFIG_DHCPD_LEASES_FILE="/var/lib/misc/udhcpd.leases" 854 | CONFIG_UDHCPC=y 855 | CONFIG_FEATURE_UDHCPC_ARPING=y 856 | CONFIG_FEATURE_UDHCP_PORT=y 857 | CONFIG_UDHCP_DEBUG=9 858 | CONFIG_FEATURE_UDHCP_RFC3397=y 859 | CONFIG_FEATURE_UDHCP_8021Q=y 860 | CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script" 861 | CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80 862 | CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n" 863 | CONFIG_UDPSVD=y 864 | CONFIG_VCONFIG=y 865 | CONFIG_WGET=y 866 | CONFIG_FEATURE_WGET_STATUSBAR=y 867 | CONFIG_FEATURE_WGET_AUTHENTICATION=y 868 | CONFIG_FEATURE_WGET_LONG_OPTIONS=y 869 | CONFIG_FEATURE_WGET_TIMEOUT=y 870 | CONFIG_ZCIP=y 871 | 872 | # 873 | # Print Utilities 874 | # 875 | CONFIG_LPD=y 876 | CONFIG_LPR=y 877 | CONFIG_LPQ=y 878 | 879 | # 880 | # Mail Utilities 881 | # 882 | CONFIG_MAKEMIME=y 883 | CONFIG_FEATURE_MIME_CHARSET="us-ascii" 884 | CONFIG_POPMAILDIR=y 885 | CONFIG_FEATURE_POPMAILDIR_DELIVERY=y 886 | CONFIG_REFORMIME=y 887 | CONFIG_FEATURE_REFORMIME_COMPAT=y 888 | CONFIG_SENDMAIL=y 889 | 890 | # 891 | # Process Utilities 892 | # 893 | CONFIG_IOSTAT=y 894 | CONFIG_LSOF=y 895 | CONFIG_MPSTAT=y 896 | CONFIG_NMETER=y 897 | CONFIG_PMAP=y 898 | CONFIG_POWERTOP=y 899 | CONFIG_PSTREE=y 900 | CONFIG_PWDX=y 901 | CONFIG_SMEMCAP=y 902 | CONFIG_UPTIME=y 903 | # CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set 904 | CONFIG_FREE=y 905 | CONFIG_FUSER=y 906 | CONFIG_KILL=y 907 | CONFIG_KILLALL=y 908 | CONFIG_KILLALL5=y 909 | CONFIG_PGREP=y 910 | CONFIG_PIDOF=y 911 | CONFIG_FEATURE_PIDOF_SINGLE=y 912 | CONFIG_FEATURE_PIDOF_OMIT=y 913 | CONFIG_PKILL=y 914 | CONFIG_PS=y 915 | # CONFIG_FEATURE_PS_WIDE is not set 916 | # CONFIG_FEATURE_PS_LONG is not set 917 | CONFIG_FEATURE_PS_TIME=y 918 | CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y 919 | # CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set 920 | CONFIG_RENICE=y 921 | CONFIG_BB_SYSCTL=y 922 | CONFIG_TOP=y 923 | CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y 924 | CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y 925 | CONFIG_FEATURE_TOP_SMP_CPU=y 926 | CONFIG_FEATURE_TOP_DECIMALS=y 927 | CONFIG_FEATURE_TOP_SMP_PROCESS=y 928 | CONFIG_FEATURE_TOPMEM=y 929 | CONFIG_FEATURE_SHOW_THREADS=y 930 | CONFIG_WATCH=y 931 | 932 | # 933 | # Runit Utilities 934 | # 935 | CONFIG_RUNSV=y 936 | CONFIG_RUNSVDIR=y 937 | # CONFIG_FEATURE_RUNSVDIR_LOG is not set 938 | CONFIG_SV=y 939 | CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service" 940 | CONFIG_SVLOGD=y 941 | CONFIG_CHPST=y 942 | CONFIG_SETUIDGID=y 943 | CONFIG_ENVUIDGID=y 944 | CONFIG_ENVDIR=y 945 | CONFIG_SOFTLIMIT=y 946 | # CONFIG_CHCON is not set 947 | # CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set 948 | # CONFIG_GETENFORCE is not set 949 | # CONFIG_GETSEBOOL is not set 950 | # CONFIG_LOAD_POLICY is not set 951 | # CONFIG_MATCHPATHCON is not set 952 | # CONFIG_RESTORECON is not set 953 | # CONFIG_RUNCON is not set 954 | # CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set 955 | # CONFIG_SELINUXENABLED is not set 956 | # CONFIG_SETENFORCE is not set 957 | # CONFIG_SETFILES is not set 958 | # CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set 959 | # CONFIG_SETSEBOOL is not set 960 | # CONFIG_SESTATUS is not set 961 | 962 | # 963 | # Shells 964 | # 965 | CONFIG_ASH=y 966 | CONFIG_ASH_BASH_COMPAT=y 967 | # CONFIG_ASH_IDLE_TIMEOUT is not set 968 | CONFIG_ASH_JOB_CONTROL=y 969 | CONFIG_ASH_ALIAS=y 970 | CONFIG_ASH_GETOPTS=y 971 | CONFIG_ASH_BUILTIN_ECHO=y 972 | CONFIG_ASH_BUILTIN_PRINTF=y 973 | CONFIG_ASH_BUILTIN_TEST=y 974 | CONFIG_ASH_CMDCMD=y 975 | # CONFIG_ASH_MAIL is not set 976 | CONFIG_ASH_OPTIMIZE_FOR_SIZE=y 977 | CONFIG_ASH_RANDOM_SUPPORT=y 978 | CONFIG_ASH_EXPAND_PRMT=y 979 | CONFIG_CTTYHACK=y 980 | CONFIG_HUSH=y 981 | CONFIG_HUSH_BASH_COMPAT=y 982 | CONFIG_HUSH_BRACE_EXPANSION=y 983 | CONFIG_HUSH_HELP=y 984 | CONFIG_HUSH_INTERACTIVE=y 985 | CONFIG_HUSH_SAVEHISTORY=y 986 | CONFIG_HUSH_JOB=y 987 | CONFIG_HUSH_TICK=y 988 | CONFIG_HUSH_IF=y 989 | CONFIG_HUSH_LOOPS=y 990 | CONFIG_HUSH_CASE=y 991 | CONFIG_HUSH_FUNCTIONS=y 992 | CONFIG_HUSH_LOCAL=y 993 | CONFIG_HUSH_RANDOM_SUPPORT=y 994 | CONFIG_HUSH_EXPORT_N=y 995 | CONFIG_HUSH_MODE_X=y 996 | # CONFIG_MSH is not set 997 | CONFIG_FEATURE_SH_IS_ASH=y 998 | # CONFIG_FEATURE_SH_IS_HUSH is not set 999 | # CONFIG_FEATURE_SH_IS_NONE is not set 1000 | # CONFIG_FEATURE_BASH_IS_ASH is not set 1001 | # CONFIG_FEATURE_BASH_IS_HUSH is not set 1002 | CONFIG_FEATURE_BASH_IS_NONE=y 1003 | CONFIG_SH_MATH_SUPPORT=y 1004 | CONFIG_SH_MATH_SUPPORT_64=y 1005 | CONFIG_FEATURE_SH_EXTRA_QUIET=y 1006 | # CONFIG_FEATURE_SH_STANDALONE is not set 1007 | # CONFIG_FEATURE_SH_NOFORK is not set 1008 | CONFIG_FEATURE_SH_HISTFILESIZE=y 1009 | 1010 | # 1011 | # System Logging Utilities 1012 | # 1013 | CONFIG_SYSLOGD=y 1014 | CONFIG_FEATURE_ROTATE_LOGFILE=y 1015 | CONFIG_FEATURE_REMOTE_LOG=y 1016 | CONFIG_FEATURE_SYSLOGD_DUP=y 1017 | CONFIG_FEATURE_SYSLOGD_CFG=y 1018 | CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256 1019 | CONFIG_FEATURE_IPC_SYSLOG=y 1020 | CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16 1021 | CONFIG_LOGREAD=y 1022 | CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y 1023 | CONFIG_FEATURE_KMSG_SYSLOG=y 1024 | CONFIG_KLOGD=y 1025 | CONFIG_FEATURE_KLOGD_KLOGCTL=y 1026 | # CONFIG_LOGGER is not set 1027 | -------------------------------------------------------------------------------- /patches/000-customMakefile.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Fri, 19 May 2023 12:07:35 -0300 3 | Subject: [PATCH] Add custom busybox version tagging 4 | 5 | --- 6 | Makefile | 2 +- 7 | 1 file changed, 1 insertion(+), 1 deletion(-) 8 | 9 | diff --git a/Makefile b/Makefile 10 | index ea9dd3d..c378593 100644 11 | --- a/Makefile 12 | +++ b/Makefile 13 | @@ -1,7 +1,7 @@ 14 | VERSION = 1 15 | PATCHLEVEL = 36 16 | SUBLEVEL = 1 17 | -EXTRAVERSION = 18 | +EXTRAVERSION = -osm0sis 19 | NAME = Unnamed 20 | 21 | # *DOCUMENTATION* 22 | -- 23 | 2.31.1 24 | 25 | -------------------------------------------------------------------------------- /patches/001-mconf-lkc.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Fri, 27 Nov 2015 11:40:52 -0400 3 | Subject: [PATCH] Fix mconf/lkc host "warning statement with no effect" 4 | 5 | --- 6 | scripts/kconfig/lkc.h | 4 ++-- 7 | 1 file changed, 2 insertions(+), 2 deletions(-) 8 | 9 | diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h 10 | index 527f60c..1972cb9 100644 11 | --- a/scripts/kconfig/lkc.h 12 | +++ b/scripts/kconfig/lkc.h 13 | @@ -12,8 +12,8 @@ 14 | # include 15 | #else 16 | # define gettext(Msgid) ((const char *) (Msgid)) 17 | -# define textdomain(Domainname) ((const char *) (Domainname)) 18 | -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) 19 | +# define textdomain(Domainname) 20 | +# define bindtextdomain(Domainname, Dirname) 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | -- 25 | 2.5.3 26 | 27 | -------------------------------------------------------------------------------- /patches/002-mount-auto-loopback-and-losetup.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Wed, 24 May 2023 14:15:00 -0300 3 | Subject: Fix direct mount .img (auto loopback) and losetup for Android 4 | /dev/block/loop 5 | 6 | --- 7 | include/libbb.h | 12 +++++++++--- 8 | 1 file changed, 9 insertions(+), 3 deletions(-) 9 | 10 | diff --git a/include/libbb.h b/include/libbb.h 11 | index cca33a177..87dd74e48 100644 12 | --- a/include/libbb.h 13 | +++ b/include/libbb.h 14 | @@ -2390,9 +2390,15 @@ extern const char bb_default_login_shell[] ALIGN1; 15 | # define VC_4 "/dev/tty4" 16 | # define VC_5 "/dev/tty5" 17 | # define VC_FORMAT "/dev/tty%d" 18 | -# define LOOP_FORMAT "/dev/loop%u" 19 | -# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1) 20 | -# define LOOP_NAME "/dev/loop" 21 | +# if defined(__ANDROID__) 22 | +# define LOOP_FORMAT "/dev/block/loop%u" 23 | +# define LOOP_NAMESIZE (sizeof("/dev/block/loop") + sizeof(int)*3 + 1) 24 | +# define LOOP_NAME "/dev/block/loop" 25 | +# else 26 | +# define LOOP_FORMAT "/dev/loop%u" 27 | +# define LOOP_NAMESIZE (sizeof("/dev/loop") + sizeof(int)*3 + 1) 28 | +# define LOOP_NAME "/dev/loop" 29 | +# endif 30 | # define FB_0 "/dev/fb0" 31 | #endif 32 | 33 | -- 34 | 2.34.1 35 | 36 | -------------------------------------------------------------------------------- /patches/003-a-mount-umount-fsck-df.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Tue, 4 May 2021 00:56:55 -0300 3 | Subject: [PATCH] android: fix 'mount', 'umount', 'fsck', 'df' 4 | 5 | Patch by Tias Guns , based on 'Bionic Patch V1.0' by Vitaly Greck 6 | https://code.google.com/p/busybox-android/downloads/detail?name=patch 7 | Rebased for busybox 1.33.1 by Chris Renshaw 8 | --- 9 | libbb/Kbuild.src | 3 + 10 | libbb/mntent_r.c | 288 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11 | 2 files changed, 291 insertions(+) 12 | create mode 100644 libbb/mntent_r.c 13 | 14 | diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src 15 | index 61eec26..d456c3d 100644 16 | --- a/libbb/Kbuild.src 17 | +++ b/libbb/Kbuild.src 18 | @@ -112,6 +112,9 @@ lib-y += xgethostbyname.o 19 | lib-y += xreadlink.o 20 | lib-y += xrealloc_vector.o 21 | 22 | +# for android-busybox-ndk 23 | +lib-y += mntent_r.o 24 | + 25 | lib-$(CONFIG_MOUNT) += match_fstype.o 26 | lib-$(CONFIG_UMOUNT) += match_fstype.o 27 | 28 | diff --git a/libbb/mntent_r.c b/libbb/mntent_r.c 29 | new file mode 100644 30 | index 0000000..1077487 31 | --- /dev/null 32 | +++ b/libbb/mntent_r.c 33 | @@ -0,0 +1,288 @@ 34 | +/* Utilities for reading/writing fstab, mtab, etc. 35 | + Copyright (C) 1995-2000, 2001, 2002, 2003, 2006, 2010, 2011 36 | + Free Software Foundation, Inc. 37 | + This file is part of the GNU C Library. 38 | + 39 | + The GNU C Library is free software; you can redistribute it and/or 40 | + modify it under the terms of the GNU Lesser General Public 41 | + License as published by the Free Software Foundation; either 42 | + version 2.1 of the License, or (at your option) any later version. 43 | + 44 | + The GNU C Library is distributed in the hope that it will be useful, 45 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 46 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 47 | + Lesser General Public License for more details. 48 | + 49 | + You should have received a copy of the GNU Lesser General Public 50 | + License along with the GNU C Library; if not, see 51 | + . */ 52 | + 53 | +// file extracted from patch 'Bionic Patch V1.0 (Vitaly Greck)': 54 | +// https://busybox-android.googlecode.com/files/patch 55 | +// 56 | +// looks like its based on misc/mntent_r.c from glibc, 57 | +// contains all fixes in current master (2012-03-19), 58 | +// but is not source identical (mostly stuff removed) 59 | +// using the upstream one fails to build 60 | + 61 | + 62 | +#include 63 | +#include 64 | +#include 65 | +#include 66 | +#include 67 | + 68 | + 69 | +/* Prepare to begin reading and/or writing mount table entries from the 70 | + beginning of FILE. MODE is as for `fopen'. */ 71 | +FILE *setmntent (const char *file, const char *mode) 72 | +{ 73 | + /* Extend the mode parameter with "c" to disable cancellation in the 74 | + I/O functions and "e" to set FD_CLOEXEC. */ 75 | + size_t modelen = strlen (mode); 76 | + char newmode[modelen + 3]; 77 | + memcpy (newmode, mode, modelen); 78 | + memcpy (newmode + modelen, "ce", 3); 79 | + FILE *result = fopen (file, newmode); 80 | + 81 | + return result; 82 | +} 83 | + 84 | + 85 | +/* Close a stream opened with `setmntent'. */ 86 | +int endmntent (FILE *stream) 87 | +{ 88 | + if (stream) /* SunOS 4.x allows for NULL stream */ 89 | + fclose (stream); 90 | + return 1; /* SunOS 4.x says to always return 1 */ 91 | +} 92 | + 93 | + 94 | +/* Since the values in a line are separated by spaces, a name cannot 95 | + contain a space. Therefore some programs encode spaces in names 96 | + by the strings "\040". We undo the encoding when reading an entry. 97 | + The decoding happens in place. */ 98 | +static char * 99 | +decode_name (char *buf) 100 | +{ 101 | + char *rp = buf; 102 | + char *wp = buf; 103 | + 104 | + do 105 | + if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '4' && rp[3] == '0') 106 | + { 107 | + /* \040 is a SPACE. */ 108 | + *wp++ = ' '; 109 | + rp += 3; 110 | + } 111 | + else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '1') 112 | + { 113 | + /* \011 is a TAB. */ 114 | + *wp++ = '\t'; 115 | + rp += 3; 116 | + } 117 | + else if (rp[0] == '\\' && rp[1] == '0' && rp[2] == '1' && rp[3] == '2') 118 | + { 119 | + /* \012 is a NEWLINE. */ 120 | + *wp++ = '\n'; 121 | + rp += 3; 122 | + } 123 | + else if (rp[0] == '\\' && rp[1] == '\\') 124 | + { 125 | + /* We have to escape \\ to be able to represent all characters. */ 126 | + *wp++ = '\\'; 127 | + rp += 1; 128 | + } 129 | + else if (rp[0] == '\\' && rp[1] == '1' && rp[2] == '3' && rp[3] == '4') 130 | + { 131 | + /* \134 is also \\. */ 132 | + *wp++ = '\\'; 133 | + rp += 3; 134 | + } 135 | + else 136 | + *wp++ = *rp; 137 | + while (*rp++ != '\0'); 138 | + 139 | + return buf; 140 | +} 141 | + 142 | + 143 | +/* Read one mount table entry from STREAM. Returns a pointer to storage 144 | + reused on the next call, or null for EOF or error (use feof/ferror to 145 | + check). */ 146 | +struct mntent *getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) 147 | +{ 148 | + char *cp; 149 | + char *head; 150 | + 151 | + do 152 | + { 153 | + char *end_ptr; 154 | + 155 | + if (fgets (buffer, bufsiz, stream) == NULL) 156 | + { 157 | + return NULL; 158 | + } 159 | + 160 | + end_ptr = strchr (buffer, '\n'); 161 | + if (end_ptr != NULL) /* chop newline */ 162 | + *end_ptr = '\0'; 163 | + else 164 | + { 165 | + /* Not the whole line was read. Do it now but forget it. */ 166 | + char tmp[1024]; 167 | + while (fgets (tmp, sizeof tmp, stream) != NULL) 168 | + if (strchr (tmp, '\n') != NULL) 169 | + break; 170 | + } 171 | + 172 | + head = buffer + strspn (buffer, " \t"); 173 | + /* skip empty lines and comment lines: */ 174 | + } 175 | + while (head[0] == '\0' || head[0] == '#'); 176 | + 177 | + cp = strsep (&head, " \t"); 178 | + mp->mnt_fsname = cp != NULL ? decode_name (cp) : (char *) ""; 179 | + if (head) 180 | + head += strspn (head, " \t"); 181 | + cp = strsep (&head, " \t"); 182 | + mp->mnt_dir = cp != NULL ? decode_name (cp) : (char *) ""; 183 | + if (head) 184 | + head += strspn (head, " \t"); 185 | + cp = strsep (&head, " \t"); 186 | + mp->mnt_type = cp != NULL ? decode_name (cp) : (char *) ""; 187 | + if (head) 188 | + head += strspn (head, " \t"); 189 | + cp = strsep (&head, " \t"); 190 | + mp->mnt_opts = cp != NULL ? decode_name (cp) : (char *) ""; 191 | + switch (head ? sscanf (head, " %d %d ", &mp->mnt_freq, &mp->mnt_passno) : 0) 192 | + { 193 | + case 0: 194 | + mp->mnt_freq = 0; 195 | + case 1: 196 | + mp->mnt_passno = 0; 197 | + case 2: 198 | + break; 199 | + } 200 | + 201 | + return mp; 202 | +} 203 | + 204 | +struct mntent *getmntent (FILE *stream) 205 | +{ 206 | + static struct mntent m; 207 | + static char *getmntent_buffer; 208 | + 209 | + #define BUFFER_SIZE 4096 210 | + if (getmntent_buffer == NULL) { 211 | + getmntent_buffer = (char *) malloc (BUFFER_SIZE); 212 | + } 213 | + 214 | + return getmntent_r (stream, &m, getmntent_buffer, BUFFER_SIZE); 215 | + #undef BUFFER_SIZE 216 | +} 217 | + 218 | + 219 | +/* We have to use an encoding for names if they contain spaces or tabs. 220 | + To be able to represent all characters we also have to escape the 221 | + backslash itself. This "function" must be a macro since we use 222 | + `alloca'. */ 223 | +#define encode_name(name) \ 224 | + do { \ 225 | + const char *rp = name; \ 226 | + \ 227 | + while (*rp != '\0') \ 228 | + if (*rp == ' ' || *rp == '\t' || *rp == '\n' || *rp == '\\') \ 229 | + break; \ 230 | + else \ 231 | + ++rp; \ 232 | + \ 233 | + if (*rp != '\0') \ 234 | + { \ 235 | + /* In the worst case the length of the string can increase to \ 236 | + four times the current length. */ \ 237 | + char *wp; \ 238 | + \ 239 | + rp = name; \ 240 | + name = wp = (char *) alloca (strlen (name) * 4 + 1); \ 241 | + \ 242 | + do \ 243 | + if (*rp == ' ') \ 244 | + { \ 245 | + *wp++ = '\\'; \ 246 | + *wp++ = '0'; \ 247 | + *wp++ = '4'; \ 248 | + *wp++ = '0'; \ 249 | + } \ 250 | + else if (*rp == '\t') \ 251 | + { \ 252 | + *wp++ = '\\'; \ 253 | + *wp++ = '0'; \ 254 | + *wp++ = '1'; \ 255 | + *wp++ = '1'; \ 256 | + } \ 257 | + else if (*rp == '\n') \ 258 | + { \ 259 | + *wp++ = '\\'; \ 260 | + *wp++ = '0'; \ 261 | + *wp++ = '1'; \ 262 | + *wp++ = '2'; \ 263 | + } \ 264 | + else if (*rp == '\\') \ 265 | + { \ 266 | + *wp++ = '\\'; \ 267 | + *wp++ = '\\'; \ 268 | + } \ 269 | + else \ 270 | + *wp++ = *rp; \ 271 | + while (*rp++ != '\0'); \ 272 | + } \ 273 | + } while (0) 274 | + 275 | + 276 | +/* Write the mount table entry described by MNT to STREAM. 277 | + Return zero on success, nonzero on failure. */ 278 | +int addmntent (FILE *stream, const struct mntent *mnt) 279 | +{ 280 | + struct mntent mntcopy = *mnt; 281 | + if (fseek (stream, 0, SEEK_END)) 282 | + return 1; 283 | + 284 | + /* Encode spaces and tabs in the names. */ 285 | + encode_name (mntcopy.mnt_fsname); 286 | + encode_name (mntcopy.mnt_dir); 287 | + encode_name (mntcopy.mnt_type); 288 | + encode_name (mntcopy.mnt_opts); 289 | + 290 | + return (fprintf (stream, "%s %s %s %s %d %d\n", 291 | + mntcopy.mnt_fsname, 292 | + mntcopy.mnt_dir, 293 | + mntcopy.mnt_type, 294 | + mntcopy.mnt_opts, 295 | + mntcopy.mnt_freq, 296 | + mntcopy.mnt_passno) < 0 297 | + || fflush (stream) != 0); 298 | +} 299 | + 300 | + 301 | +/* Search MNT->mnt_opts for an option matching OPT. 302 | + Returns the address of the substring, or null if none found. */ 303 | +char *hasmntopt (const struct mntent *mnt, const char *opt) 304 | +{ 305 | + const size_t optlen = strlen (opt); 306 | + char *rest = mnt->mnt_opts, *p; 307 | + 308 | + while ((p = strstr (rest, opt)) != NULL) 309 | + { 310 | + if ((p == rest || p[-1] == ',') 311 | + && (p[optlen] == '\0' || p[optlen] == '=' || p[optlen] == ',')) 312 | + return p; 313 | + 314 | + rest = strchr (p, ','); 315 | + if (rest == NULL) 316 | + break; 317 | + ++rest; 318 | + } 319 | + 320 | + return NULL; 321 | +} 322 | -- 323 | 2.31.1 324 | 325 | -------------------------------------------------------------------------------- /patches/003-b-swapon-swapoff.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Thu, 3 Dec 2015 11:19:25 -0400 3 | Subject: [PATCH] fix swapon, swapoff: comment out MNTOPT_NOAUTO 4 | 5 | Patch modified by Tias Guns from 'swap-on-off' by Dan Drown 6 | "syscalls for swapon/swapoff and defines" 7 | http://dan.drown.org/android/src/busybox/ 8 | Rebased for busybox 1.24.1 by Chris Renshaw 9 | --- 10 | util-linux/swaponoff.c | 6 +++++- 11 | 1 files changed, 5 insertions(+), 1 deletion(-) 12 | 13 | diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c 14 | index 5cd1fbe..e447526 100644 15 | --- a/util-linux/swaponoff.c 16 | +++ b/util-linux/swaponoff.c 17 | @@ -186,7 +186,11 @@ static int do_em_all_in_fstab(void) 18 | /* swapon -a should ignore entries with noauto, 19 | * but swapoff -a should process them 20 | */ 21 | - if (do_swapoff || hasmntopt(m, MNTOPT_NOAUTO) == NULL) { 22 | + if (do_swapoff 23 | +#ifdef MNTOPT_NOAUTO 24 | + || hasmntopt(m, MNTOPT_NOAUTO) == NULL 25 | +#endif 26 | + ) { 27 | /* each swap space might have different flags */ 28 | /* save global flags for the next round */ 29 | save_g_flags(); 30 | -- 31 | 2.5.3 32 | 33 | -------------------------------------------------------------------------------- /patches/006-eject.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Thu, 3 Dec 2015 17:01:57 -0400 3 | Subject: [PATCH] eject: add missing headers 4 | 5 | Imported from dorimanx's combined ported header toolchain: 6 | https://github.com/dorimanx/android-busybox-ndk 7 | --- 8 | include/scsi/scsi.h | 225 ++++++++++++++++++++++++++++++++++++++++++ 9 | include/scsi/sg.h | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 | 2 files changed, 501 insertions(+) 11 | create mode 100644 include/scsi/scsi.h 12 | create mode 100644 include/scsi/sg.h 13 | 14 | diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h 15 | new file mode 100644 16 | index 0000000..06377ab 17 | --- /dev/null 18 | +++ b/include/scsi/scsi.h 19 | @@ -0,0 +1,225 @@ 20 | +/* Copyright (C) 1998-2015 Free Software Foundation, Inc. 21 | + This file is part of the GNU C Library. 22 | + 23 | + The GNU C Library is free software; you can redistribute it and/or 24 | + modify it under the terms of the GNU Lesser General Public 25 | + License as published by the Free Software Foundation; either 26 | + version 2.1 of the License, or (at your option) any later version. 27 | + 28 | + The GNU C Library is distributed in the hope that it will be useful, 29 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 | + Lesser General Public License for more details. 32 | + 33 | + You should have received a copy of the GNU Lesser General Public 34 | + License along with the GNU C Library; if not, see 35 | + . */ 36 | + 37 | +/* 38 | + * This header file contains public constants and structures used by 39 | + * the scsi code for linux. 40 | + */ 41 | + 42 | +#ifndef _SCSI_SCSI_H 43 | +#define _SCSI_SCSI_H 1 44 | + 45 | +#include 46 | + 47 | +/* 48 | + * SCSI opcodes 49 | + */ 50 | + 51 | +#define TEST_UNIT_READY 0x00 52 | +#define REZERO_UNIT 0x01 53 | +#define REQUEST_SENSE 0x03 54 | +#define FORMAT_UNIT 0x04 55 | +#define READ_BLOCK_LIMITS 0x05 56 | +#define REASSIGN_BLOCKS 0x07 57 | +#define READ_6 0x08 58 | +#define WRITE_6 0x0a 59 | +#define SEEK_6 0x0b 60 | +#define READ_REVERSE 0x0f 61 | +#define WRITE_FILEMARKS 0x10 62 | +#define SPACE 0x11 63 | +#define INQUIRY 0x12 64 | +#define RECOVER_BUFFERED_DATA 0x14 65 | +#define MODE_SELECT 0x15 66 | +#define RESERVE 0x16 67 | +#define RELEASE 0x17 68 | +#define COPY 0x18 69 | +#define ERASE 0x19 70 | +#define MODE_SENSE 0x1a 71 | +#define START_STOP 0x1b 72 | +#define RECEIVE_DIAGNOSTIC 0x1c 73 | +#define SEND_DIAGNOSTIC 0x1d 74 | +#define ALLOW_MEDIUM_REMOVAL 0x1e 75 | + 76 | +#define SET_WINDOW 0x24 77 | +#define READ_CAPACITY 0x25 78 | +#define READ_10 0x28 79 | +#define WRITE_10 0x2a 80 | +#define SEEK_10 0x2b 81 | +#define WRITE_VERIFY 0x2e 82 | +#define VERIFY 0x2f 83 | +#define SEARCH_HIGH 0x30 84 | +#define SEARCH_EQUAL 0x31 85 | +#define SEARCH_LOW 0x32 86 | +#define SET_LIMITS 0x33 87 | +#define PRE_FETCH 0x34 88 | +#define READ_POSITION 0x34 89 | +#define SYNCHRONIZE_CACHE 0x35 90 | +#define LOCK_UNLOCK_CACHE 0x36 91 | +#define READ_DEFECT_DATA 0x37 92 | +#define MEDIUM_SCAN 0x38 93 | +#define COMPARE 0x39 94 | +#define COPY_VERIFY 0x3a 95 | +#define WRITE_BUFFER 0x3b 96 | +#define READ_BUFFER 0x3c 97 | +#define UPDATE_BLOCK 0x3d 98 | +#define READ_LONG 0x3e 99 | +#define WRITE_LONG 0x3f 100 | +#define CHANGE_DEFINITION 0x40 101 | +#define WRITE_SAME 0x41 102 | +#define READ_TOC 0x43 103 | +#define LOG_SELECT 0x4c 104 | +#define LOG_SENSE 0x4d 105 | +#define MODE_SELECT_10 0x55 106 | +#define RESERVE_10 0x56 107 | +#define RELEASE_10 0x57 108 | +#define MODE_SENSE_10 0x5a 109 | +#define PERSISTENT_RESERVE_IN 0x5e 110 | +#define PERSISTENT_RESERVE_OUT 0x5f 111 | +#define MOVE_MEDIUM 0xa5 112 | +#define READ_12 0xa8 113 | +#define WRITE_12 0xaa 114 | +#define WRITE_VERIFY_12 0xae 115 | +#define SEARCH_HIGH_12 0xb0 116 | +#define SEARCH_EQUAL_12 0xb1 117 | +#define SEARCH_LOW_12 0xb2 118 | +#define READ_ELEMENT_STATUS 0xb8 119 | +#define SEND_VOLUME_TAG 0xb6 120 | +#define WRITE_LONG_2 0xea 121 | + 122 | +/* 123 | + * Status codes 124 | + */ 125 | + 126 | +#define GOOD 0x00 127 | +#define CHECK_CONDITION 0x01 128 | +#define CONDITION_GOOD 0x02 129 | +#define BUSY 0x04 130 | +#define INTERMEDIATE_GOOD 0x08 131 | +#define INTERMEDIATE_C_GOOD 0x0a 132 | +#define RESERVATION_CONFLICT 0x0c 133 | +#define COMMAND_TERMINATED 0x11 134 | +#define QUEUE_FULL 0x14 135 | + 136 | +#define STATUS_MASK 0x3e 137 | + 138 | +/* 139 | + * SENSE KEYS 140 | + */ 141 | + 142 | +#define NO_SENSE 0x00 143 | +#define RECOVERED_ERROR 0x01 144 | +#define NOT_READY 0x02 145 | +#define MEDIUM_ERROR 0x03 146 | +#define HARDWARE_ERROR 0x04 147 | +#define ILLEGAL_REQUEST 0x05 148 | +#define UNIT_ATTENTION 0x06 149 | +#define DATA_PROTECT 0x07 150 | +#define BLANK_CHECK 0x08 151 | +#define COPY_ABORTED 0x0a 152 | +#define ABORTED_COMMAND 0x0b 153 | +#define VOLUME_OVERFLOW 0x0d 154 | +#define MISCOMPARE 0x0e 155 | + 156 | + 157 | +/* 158 | + * DEVICE TYPES 159 | + */ 160 | + 161 | +#define TYPE_DISK 0x00 162 | +#define TYPE_TAPE 0x01 163 | +#define TYPE_PROCESSOR 0x03 /* HP scanners use this */ 164 | +#define TYPE_WORM 0x04 /* Treated as ROM by our system */ 165 | +#define TYPE_ROM 0x05 166 | +#define TYPE_SCANNER 0x06 167 | +#define TYPE_MOD 0x07 /* Magneto-optical disk - 168 | + * - treated as TYPE_DISK */ 169 | +#define TYPE_MEDIUM_CHANGER 0x08 170 | +#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */ 171 | +#define TYPE_NO_LUN 0x7f 172 | + 173 | +/* 174 | + * standard mode-select header prepended to all mode-select commands 175 | + * 176 | + * moved here from cdrom.h -- kraxel 177 | + */ 178 | + 179 | +struct ccs_modesel_head 180 | + { 181 | + unsigned char _r1; /* reserved. */ 182 | + unsigned char medium; /* device-specific medium type. */ 183 | + unsigned char _r2; /* reserved. */ 184 | + unsigned char block_desc_length; /* block descriptor length. */ 185 | + unsigned char density; /* device-specific density code. */ 186 | + unsigned char number_blocks_hi; /* number of blocks in this block 187 | + desc. */ 188 | + unsigned char number_blocks_med; 189 | + unsigned char number_blocks_lo; 190 | + unsigned char _r3; 191 | + unsigned char block_length_hi; /* block length for blocks in this 192 | + desc. */ 193 | + unsigned char block_length_med; 194 | + unsigned char block_length_lo; 195 | + }; 196 | + 197 | +/* 198 | + * MESSAGE CODES 199 | + */ 200 | + 201 | +#define COMMAND_COMPLETE 0x00 202 | +#define EXTENDED_MESSAGE 0x01 203 | +#define EXTENDED_MODIFY_DATA_POINTER 0x00 204 | +#define EXTENDED_SDTR 0x01 205 | +#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */ 206 | +#define EXTENDED_WDTR 0x03 207 | +#define SAVE_POINTERS 0x02 208 | +#define RESTORE_POINTERS 0x03 209 | +#define DISCONNECT 0x04 210 | +#define INITIATOR_ERROR 0x05 211 | +#define ABORT 0x06 212 | +#define MESSAGE_REJECT 0x07 213 | +#define NOP 0x08 214 | +#define MSG_PARITY_ERROR 0x09 215 | +#define LINKED_CMD_COMPLETE 0x0a 216 | +#define LINKED_FLG_CMD_COMPLETE 0x0b 217 | +#define BUS_DEVICE_RESET 0x0c 218 | + 219 | +#define INITIATE_RECOVERY 0x0f /* SCSI-II only */ 220 | +#define RELEASE_RECOVERY 0x10 /* SCSI-II only */ 221 | + 222 | +#define SIMPLE_QUEUE_TAG 0x20 223 | +#define HEAD_OF_QUEUE_TAG 0x21 224 | +#define ORDERED_QUEUE_TAG 0x22 225 | + 226 | +/* 227 | + * Here are some scsi specific ioctl commands which are sometimes useful. 228 | + */ 229 | +/* These are a few other constants only used by scsi devices. */ 230 | + 231 | +#define SCSI_IOCTL_GET_IDLUN 0x5382 232 | + 233 | +/* Used to turn on and off tagged queuing for scsi devices. */ 234 | + 235 | +#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 236 | +#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 237 | + 238 | +/* Used to obtain the host number of a device. */ 239 | +#define SCSI_IOCTL_PROBE_HOST 0x5385 240 | + 241 | +/* Used to get the bus number for a device. */ 242 | +#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386 243 | + 244 | +#endif /* scsi/scsi.h */ 245 | diff --git a/include/scsi/sg.h b/include/scsi/sg.h 246 | new file mode 100644 247 | index 0000000..7679452 248 | --- /dev/null 249 | +++ b/include/scsi/sg.h 250 | @@ -0,0 +1,276 @@ 251 | +/* Copyright (C) 1997-2015 Free Software Foundation, Inc. 252 | + This file is part of the GNU C Library. 253 | + 254 | + The GNU C Library is free software; you can redistribute it and/or 255 | + modify it under the terms of the GNU Lesser General Public 256 | + License as published by the Free Software Foundation; either 257 | + version 2.1 of the License, or (at your option) any later version. 258 | + 259 | + The GNU C Library is distributed in the hope that it will be useful, 260 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 261 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 262 | + Lesser General Public License for more details. 263 | + 264 | + You should have received a copy of the GNU Lesser General Public 265 | + License along with the GNU C Library; if not, see 266 | + . */ 267 | + 268 | +/* 269 | + History: 270 | + Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user 271 | + process control of SCSI devices. 272 | + Development Sponsored by Killy Corp. NY NY 273 | +*/ 274 | + 275 | +#ifndef _SCSI_SG_H 276 | +#define _SCSI_SG_H 1 277 | + 278 | +#include 279 | +#define __need_size_t 280 | +#include 281 | + 282 | + 283 | +/* New interface introduced in the 3.x SG drivers follows */ 284 | + 285 | +/* Same structure as used by readv() Linux system call. It defines one 286 | + scatter-gather element. */ 287 | +typedef struct sg_iovec 288 | +{ 289 | + void * iov_base; /* Starting address */ 290 | + size_t iov_len; /* Length in bytes */ 291 | +} sg_iovec_t; 292 | + 293 | + 294 | +typedef struct sg_io_hdr 295 | +{ 296 | + int interface_id; /* [i] 'S' for SCSI generic (required) */ 297 | + int dxfer_direction; /* [i] data transfer direction */ 298 | + unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ 299 | + unsigned char mx_sb_len; /* [i] max length to write to sbp */ 300 | + unsigned short int iovec_count; /* [i] 0 implies no scatter gather */ 301 | + unsigned int dxfer_len; /* [i] byte count of data transfer */ 302 | + void * dxferp; /* [i], [*io] points to data transfer memory 303 | + or scatter gather list */ 304 | + unsigned char * cmdp; /* [i], [*i] points to command to perform */ 305 | + unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */ 306 | + unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ 307 | + unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */ 308 | + int pack_id; /* [i->o] unused internally (normally) */ 309 | + void * usr_ptr; /* [i->o] unused internally */ 310 | + unsigned char status; /* [o] scsi status */ 311 | + unsigned char masked_status;/* [o] shifted, masked scsi status */ 312 | + unsigned char msg_status; /* [o] messaging level data (optional) */ 313 | + unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ 314 | + unsigned short int host_status; /* [o] errors from host adapter */ 315 | + unsigned short int driver_status;/* [o] errors from software driver */ 316 | + int resid; /* [o] dxfer_len - actual_transferred */ 317 | + unsigned int duration; /* [o] time taken by cmd (unit: millisec) */ 318 | + unsigned int info; /* [o] auxiliary information */ 319 | +} sg_io_hdr_t; 320 | + 321 | + 322 | +/* Use negative values to flag difference from original sg_header structure. */ 323 | +#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */ 324 | +#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */ 325 | +#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */ 326 | +#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the 327 | + additional property than during indirect 328 | + IO the user buffer is copied into the 329 | + kernel buffers before the transfer */ 330 | + 331 | + 332 | +/* following flag values can be "or"-ed together */ 333 | +#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */ 334 | +#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */ 335 | + /* the 2nd byte of SCSI command */ 336 | +#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */ 337 | + /* user space (debug indirect IO) */ 338 | + 339 | +/* The following 'info' values are "or"-ed together. */ 340 | +#define SG_INFO_OK_MASK 0x1 341 | +#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */ 342 | +#define SG_INFO_CHECK 0x1 /* something abnormal happened */ 343 | + 344 | +#define SG_INFO_DIRECT_IO_MASK 0x6 345 | +#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */ 346 | +#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ 347 | +#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ 348 | + 349 | + 350 | +/* Request information about a specific SG device, used by 351 | + SG_GET_SCSI_ID ioctl (). */ 352 | +struct sg_scsi_id { 353 | + /* Host number as in "scsi" where 'n' is one of 0, 1, 2 etc. */ 354 | + int host_no; 355 | + int channel; 356 | + /* SCSI id of target device. */ 357 | + int scsi_id; 358 | + int lun; 359 | + /* TYPE_... defined in . */ 360 | + int scsi_type; 361 | + /* Host (adapter) maximum commands per lun. */ 362 | + short int h_cmd_per_lun; 363 | + /* Device (or adapter) maximum queue length. */ 364 | + short int d_queue_depth; 365 | + /* Unused, set to 0 for now. */ 366 | + int unused[2]; 367 | +}; 368 | + 369 | +/* Used by SG_GET_REQUEST_TABLE ioctl(). */ 370 | +typedef struct sg_req_info { 371 | + char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */ 372 | + char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */ 373 | + char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */ 374 | + char problem; /* 0 -> no problem detected, 1 -> error to report */ 375 | + int pack_id; /* pack_id associated with request */ 376 | + void * usr_ptr; /* user provided pointer (in new interface) */ 377 | + unsigned int duration; /* millisecs elapsed since written (req_state==1) 378 | + or request duration (req_state==2) */ 379 | + int unused; 380 | +} sg_req_info_t; 381 | + 382 | + 383 | +/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow. 384 | + [Those that only apply to the SG 2.x drivers are at the end of the file.] 385 | + (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */ 386 | + 387 | +#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */ 388 | + 389 | +/* Used to configure SCSI command transformation layer for ATAPI devices */ 390 | +/* Only supported by the ide-scsi driver */ 391 | +#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */ 392 | + /* 3rd arg = 0 to disable transform, 1 to enable it */ 393 | +#define SG_GET_TRANSFORM 0x2205 394 | + 395 | +#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */ 396 | +#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */ 397 | + 398 | +/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */ 399 | +#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */ 400 | +/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */ 401 | + 402 | +/* Override host setting and always DMA using low memory ( <16MB on i386) */ 403 | +#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */ 404 | +#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */ 405 | + 406 | +/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which 407 | + tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN. 408 | + If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0 409 | + then pack_id ignored by read() and oldest readable fetched. */ 410 | +#define SG_SET_FORCE_PACK_ID 0x227b 411 | +#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */ 412 | + 413 | +#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */ 414 | + 415 | +/* Yields max scatter gather tablesize allowed by current host adapter */ 416 | +#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */ 417 | + 418 | +#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */ 419 | + 420 | +/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ 421 | +#define SG_SCSI_RESET 0x2284 422 | +/* Associated values that can be given to SG_SCSI_RESET follow */ 423 | +#define SG_SCSI_RESET_NOTHING 0 424 | +#define SG_SCSI_RESET_DEVICE 1 425 | +#define SG_SCSI_RESET_BUS 2 426 | +#define SG_SCSI_RESET_HOST 3 427 | + 428 | +/* synchronous SCSI command ioctl, (only in version 3 interface) */ 429 | +#define SG_IO 0x2285 /* similar effect as write() followed by read() */ 430 | + 431 | +#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */ 432 | + 433 | +/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */ 434 | +#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */ 435 | +#define SG_GET_KEEP_ORPHAN 0x2288 436 | + 437 | + 438 | +#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */ 439 | +/* Largest size (in bytes) a single scatter-gather list element can have. 440 | + The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on 441 | + i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported 442 | + by adapter then this value is the largest data block that can be 443 | + read/written by a single scsi command. The user can find the value of 444 | + PAGE_SIZE by calling getpagesize() defined in unistd.h . */ 445 | + 446 | +#define SG_DEFAULT_RETRIES 1 447 | + 448 | +/* Defaults, commented if they differ from original sg driver */ 449 | +#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */ 450 | +#define SG_DEF_FORCE_PACK_ID 0 451 | +#define SG_DEF_KEEP_ORPHAN 0 452 | +#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */ 453 | + 454 | +/* maximum outstanding requests, write() yields EDOM if exceeded */ 455 | +#define SG_MAX_QUEUE 16 456 | + 457 | +#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */ 458 | + 459 | +/* Alternate style type names, "..._t" variants preferred */ 460 | +typedef struct sg_io_hdr Sg_io_hdr; 461 | +typedef struct sg_io_vec Sg_io_vec; 462 | +typedef struct sg_scsi_id Sg_scsi_id; 463 | +typedef struct sg_req_info Sg_req_info; 464 | + 465 | + 466 | +/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ 467 | +/* The older SG interface based on the 'sg_header' structure follows. */ 468 | +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ 469 | + 470 | +#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */ 471 | + 472 | +struct sg_header 473 | + { 474 | + /* Length of incoming packet (including header). */ 475 | + int pack_len; 476 | + /* Maximal length of expected reply. */ 477 | + int reply_len; 478 | + /* Id number of packet. */ 479 | + int pack_id; 480 | + /* 0==ok, otherwise error number. */ 481 | + int result; 482 | + /* Force 12 byte command length for group 6 & 7 commands. */ 483 | + unsigned int twelve_byte:1; 484 | + /* SCSI status from target. */ 485 | + unsigned int target_status:5; 486 | + /* Host status (see "DID" codes). */ 487 | + unsigned int host_status:8; 488 | + /* Driver status+suggestion. */ 489 | + unsigned int driver_status:8; 490 | + /* Unused. */ 491 | + unsigned int other_flags:10; 492 | + /* Output in 3 cases: 493 | + when target_status is CHECK_CONDITION or 494 | + when target_status is COMMAND_TERMINATED or 495 | + when (driver_status & DRIVER_SENSE) is true. */ 496 | + unsigned char sense_buffer[SG_MAX_SENSE]; 497 | + }; 498 | + 499 | + 500 | +/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t 501 | + interface is used. They are kept for backward compatibility with 502 | + the original and version 2 drivers. */ 503 | + 504 | +#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */ 505 | +#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */ 506 | + 507 | +/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */ 508 | +#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */ 509 | +#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */ 510 | + 511 | +/* Turn on error sense trace (1..8), dump this device to log/console (9) 512 | + or dump all sg device states ( >9 ) to log/console. */ 513 | +#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */ 514 | + 515 | +#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given 516 | + number on the next write() on this file 517 | + descriptor. */ 518 | + 519 | +/* Defaults, commented if they differ from original sg driver */ 520 | +#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */ 521 | +#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when 522 | + the new interface is used */ 523 | +#define SG_DEF_UNDERRUN_FLAG 0 524 | + 525 | + 526 | +#endif /* scsi/sg.h */ 527 | -- 528 | 2.5.3 529 | 530 | -------------------------------------------------------------------------------- /patches/010-ubiX.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Mon, 19 Mar 2012 17:32:55 +0000 3 | Subject: [PATCH] add include/mtd/ubi-user.h from linux kernel 4 | 5 | patch from 'missing-headers' by Dan Drown 6 | http://dan.drown.org/android/src/busybox/ 7 | --- 8 | include/mtd/ubi-user.h | 412 ++++++++++++++++++++++++++++++++++++++++++++++++ 9 | 1 files changed, 412 insertions(+), 0 deletions(-) 10 | create mode 100644 include/mtd/ubi-user.h 11 | 12 | diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h 13 | new file mode 100644 14 | index 0000000..466a832 15 | --- /dev/null 16 | +++ b/include/mtd/ubi-user.h 17 | @@ -0,0 +1,412 @@ 18 | +/* 19 | + * Copyright (c) International Business Machines Corp., 2006 20 | + * 21 | + * This program is free software; you can redistribute it and/or modify 22 | + * it under the terms of the GNU General Public License as published by 23 | + * the Free Software Foundation; either version 2 of the License, or 24 | + * (at your option) any later version. 25 | + * 26 | + * This program is distributed in the hope that it will be useful, 27 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 29 | + * the GNU General Public License for more details. 30 | + * 31 | + * You should have received a copy of the GNU General Public License 32 | + * along with this program; if not, write to the Free Software 33 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 34 | + * 35 | + * Author: Artem Bityutskiy (Битюцкий Артём) 36 | + */ 37 | + 38 | +#ifndef __UBI_USER_H__ 39 | +#define __UBI_USER_H__ 40 | + 41 | +#include 42 | + 43 | +/* 44 | + * UBI device creation (the same as MTD device attachment) 45 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | + * 47 | + * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI 48 | + * control device. The caller has to properly fill and pass 49 | + * &struct ubi_attach_req object - UBI will attach the MTD device specified in 50 | + * the request and return the newly created UBI device number as the ioctl 51 | + * return value. 52 | + * 53 | + * UBI device deletion (the same as MTD device detachment) 54 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | + * 56 | + * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI 57 | + * control device. 58 | + * 59 | + * UBI volume creation 60 | + * ~~~~~~~~~~~~~~~~~~~ 61 | + * 62 | + * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character 63 | + * device. A &struct ubi_mkvol_req object has to be properly filled and a 64 | + * pointer to it has to be passed to the ioctl. 65 | + * 66 | + * UBI volume deletion 67 | + * ~~~~~~~~~~~~~~~~~~~ 68 | + * 69 | + * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character 70 | + * device should be used. A pointer to the 32-bit volume ID hast to be passed 71 | + * to the ioctl. 72 | + * 73 | + * UBI volume re-size 74 | + * ~~~~~~~~~~~~~~~~~~ 75 | + * 76 | + * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character 77 | + * device should be used. A &struct ubi_rsvol_req object has to be properly 78 | + * filled and a pointer to it has to be passed to the ioctl. 79 | + * 80 | + * UBI volumes re-name 81 | + * ~~~~~~~~~~~~~~~~~~~ 82 | + * 83 | + * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command 84 | + * of the UBI character device should be used. A &struct ubi_rnvol_req object 85 | + * has to be properly filled and a pointer to it has to be passed to the ioctl. 86 | + * 87 | + * UBI volume update 88 | + * ~~~~~~~~~~~~~~~~~ 89 | + * 90 | + * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the 91 | + * corresponding UBI volume character device. A pointer to a 64-bit update 92 | + * size should be passed to the ioctl. After this, UBI expects user to write 93 | + * this number of bytes to the volume character device. The update is finished 94 | + * when the claimed number of bytes is passed. So, the volume update sequence 95 | + * is something like: 96 | + * 97 | + * fd = open("/dev/my_volume"); 98 | + * ioctl(fd, UBI_IOCVOLUP, &image_size); 99 | + * write(fd, buf, image_size); 100 | + * close(fd); 101 | + * 102 | + * Logical eraseblock erase 103 | + * ~~~~~~~~~~~~~~~~~~~~~~~~ 104 | + * 105 | + * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the 106 | + * corresponding UBI volume character device should be used. This command 107 | + * unmaps the requested logical eraseblock, makes sure the corresponding 108 | + * physical eraseblock is successfully erased, and returns. 109 | + * 110 | + * Atomic logical eraseblock change 111 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 112 | + * 113 | + * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH 114 | + * ioctl command of the corresponding UBI volume character device. A pointer to 115 | + * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the 116 | + * user is expected to write the requested amount of bytes (similarly to what 117 | + * should be done in case of the "volume update" ioctl). 118 | + * 119 | + * Logical eraseblock map 120 | + * ~~~~~~~~~~~~~~~~~~~~~ 121 | + * 122 | + * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP 123 | + * ioctl command should be used. A pointer to a &struct ubi_map_req object is 124 | + * expected to be passed. The ioctl maps the requested logical eraseblock to 125 | + * a physical eraseblock and returns. Only non-mapped logical eraseblocks can 126 | + * be mapped. If the logical eraseblock specified in the request is already 127 | + * mapped to a physical eraseblock, the ioctl fails and returns error. 128 | + * 129 | + * Logical eraseblock unmap 130 | + * ~~~~~~~~~~~~~~~~~~~~~~~~ 131 | + * 132 | + * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP 133 | + * ioctl command should be used. The ioctl unmaps the logical eraseblocks, 134 | + * schedules corresponding physical eraseblock for erasure, and returns. Unlike 135 | + * the "LEB erase" command, it does not wait for the physical eraseblock being 136 | + * erased. Note, the side effect of this is that if an unclean reboot happens 137 | + * after the unmap ioctl returns, you may find the LEB mapped again to the same 138 | + * physical eraseblock after the UBI is run again. 139 | + * 140 | + * Check if logical eraseblock is mapped 141 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 142 | + * 143 | + * To check if a logical eraseblock is mapped to a physical eraseblock, the 144 | + * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is 145 | + * not mapped, and %1 if it is mapped. 146 | + * 147 | + * Set an UBI volume property 148 | + * ~~~~~~~~~~~~~~~~~~~~~~~~~ 149 | + * 150 | + * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be 151 | + * used. A pointer to a &struct ubi_set_prop_req object is expected to be 152 | + * passed. The object describes which property should be set, and to which value 153 | + * it should be set. 154 | + */ 155 | + 156 | +/* 157 | + * When a new UBI volume or UBI device is created, users may either specify the 158 | + * volume/device number they want to create or to let UBI automatically assign 159 | + * the number using these constants. 160 | + */ 161 | +#define UBI_VOL_NUM_AUTO (-1) 162 | +#define UBI_DEV_NUM_AUTO (-1) 163 | + 164 | +/* Maximum volume name length */ 165 | +#define UBI_MAX_VOLUME_NAME 127 166 | + 167 | +/* ioctl commands of UBI character devices */ 168 | + 169 | +#define UBI_IOC_MAGIC 'o' 170 | + 171 | +/* Create an UBI volume */ 172 | +#define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req) 173 | +/* Remove an UBI volume */ 174 | +#define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, __s32) 175 | +/* Re-size an UBI volume */ 176 | +#define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) 177 | +/* Re-name volumes */ 178 | +#define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) 179 | + 180 | +/* ioctl commands of the UBI control character device */ 181 | + 182 | +#define UBI_CTRL_IOC_MAGIC 'o' 183 | + 184 | +/* Attach an MTD device */ 185 | +#define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req) 186 | +/* Detach an MTD device */ 187 | +#define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, __s32) 188 | + 189 | +/* ioctl commands of UBI volume character devices */ 190 | + 191 | +#define UBI_VOL_IOC_MAGIC 'O' 192 | + 193 | +/* Start UBI volume update */ 194 | +#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, __s64) 195 | +/* LEB erasure command, used for debugging, disabled by default */ 196 | +#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, __s32) 197 | +/* Atomic LEB change command */ 198 | +#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, __s32) 199 | +/* Map LEB command */ 200 | +#define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req) 201 | +/* Unmap LEB command */ 202 | +#define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, __s32) 203 | +/* Check if LEB is mapped command */ 204 | +#define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32) 205 | +/* Set an UBI volume property */ 206 | +#define UBI_IOCSETPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_prop_req) 207 | + 208 | +/* Maximum MTD device name length supported by UBI */ 209 | +#define MAX_UBI_MTD_NAME_LEN 127 210 | + 211 | +/* Maximum amount of UBI volumes that can be re-named at one go */ 212 | +#define UBI_MAX_RNVOL 32 213 | + 214 | +/* 215 | + * UBI data type hint constants. 216 | + * 217 | + * UBI_LONGTERM: long-term data 218 | + * UBI_SHORTTERM: short-term data 219 | + * UBI_UNKNOWN: data persistence is unknown 220 | + * 221 | + * These constants are used when data is written to UBI volumes in order to 222 | + * help the UBI wear-leveling unit to find more appropriate physical 223 | + * eraseblocks. 224 | + */ 225 | +enum { 226 | + UBI_LONGTERM = 1, 227 | + UBI_SHORTTERM = 2, 228 | + UBI_UNKNOWN = 3, 229 | +}; 230 | + 231 | +/* 232 | + * UBI volume type constants. 233 | + * 234 | + * @UBI_DYNAMIC_VOLUME: dynamic volume 235 | + * @UBI_STATIC_VOLUME: static volume 236 | + */ 237 | +enum { 238 | + UBI_DYNAMIC_VOLUME = 3, 239 | + UBI_STATIC_VOLUME = 4, 240 | +}; 241 | + 242 | +/* 243 | + * UBI set property ioctl constants 244 | + * 245 | + * @UBI_PROP_DIRECT_WRITE: allow / disallow user to directly write and 246 | + * erase individual eraseblocks on dynamic volumes 247 | + */ 248 | +enum { 249 | + UBI_PROP_DIRECT_WRITE = 1, 250 | +}; 251 | + 252 | +/** 253 | + * struct ubi_attach_req - attach MTD device request. 254 | + * @ubi_num: UBI device number to create 255 | + * @mtd_num: MTD device number to attach 256 | + * @vid_hdr_offset: VID header offset (use defaults if %0) 257 | + * @padding: reserved for future, not used, has to be zeroed 258 | + * 259 | + * This data structure is used to specify MTD device UBI has to attach and the 260 | + * parameters it has to use. The number which should be assigned to the new UBI 261 | + * device is passed in @ubi_num. UBI may automatically assign the number if 262 | + * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in 263 | + * @ubi_num. 264 | + * 265 | + * Most applications should pass %0 in @vid_hdr_offset to make UBI use default 266 | + * offset of the VID header within physical eraseblocks. The default offset is 267 | + * the next min. I/O unit after the EC header. For example, it will be offset 268 | + * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or 269 | + * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. 270 | + * 271 | + * But in rare cases, if this optimizes things, the VID header may be placed to 272 | + * a different offset. For example, the boot-loader might do things faster if 273 | + * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. 274 | + * As the boot-loader would not normally need to read EC headers (unless it 275 | + * needs UBI in RW mode), it might be faster to calculate ECC. This is weird 276 | + * example, but it real-life example. So, in this example, @vid_hdr_offer would 277 | + * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes 278 | + * aligned, which is OK, as UBI is clever enough to realize this is 4th 279 | + * sub-page of the first page and add needed padding. 280 | + */ 281 | +struct ubi_attach_req { 282 | + __s32 ubi_num; 283 | + __s32 mtd_num; 284 | + __s32 vid_hdr_offset; 285 | + __s8 padding[12]; 286 | +}; 287 | + 288 | +/** 289 | + * struct ubi_mkvol_req - volume description data structure used in 290 | + * volume creation requests. 291 | + * @vol_id: volume number 292 | + * @alignment: volume alignment 293 | + * @bytes: volume size in bytes 294 | + * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) 295 | + * @padding1: reserved for future, not used, has to be zeroed 296 | + * @name_len: volume name length 297 | + * @padding2: reserved for future, not used, has to be zeroed 298 | + * @name: volume name 299 | + * 300 | + * This structure is used by user-space programs when creating new volumes. The 301 | + * @used_bytes field is only necessary when creating static volumes. 302 | + * 303 | + * The @alignment field specifies the required alignment of the volume logical 304 | + * eraseblock. This means, that the size of logical eraseblocks will be aligned 305 | + * to this number, i.e., 306 | + * (UBI device logical eraseblock size) mod (@alignment) = 0. 307 | + * 308 | + * To put it differently, the logical eraseblock of this volume may be slightly 309 | + * shortened in order to make it properly aligned. The alignment has to be 310 | + * multiple of the flash minimal input/output unit, or %1 to utilize the entire 311 | + * available space of logical eraseblocks. 312 | + * 313 | + * The @alignment field may be useful, for example, when one wants to maintain 314 | + * a block device on top of an UBI volume. In this case, it is desirable to fit 315 | + * an integer number of blocks in logical eraseblocks of this UBI volume. With 316 | + * alignment it is possible to update this volume using plane UBI volume image 317 | + * BLOBs, without caring about how to properly align them. 318 | + */ 319 | +struct ubi_mkvol_req { 320 | + __s32 vol_id; 321 | + __s32 alignment; 322 | + __s64 bytes; 323 | + __s8 vol_type; 324 | + __s8 padding1; 325 | + __s16 name_len; 326 | + __s8 padding2[4]; 327 | + char name[UBI_MAX_VOLUME_NAME + 1]; 328 | +} __attribute__ ((packed)); 329 | + 330 | +/** 331 | + * struct ubi_rsvol_req - a data structure used in volume re-size requests. 332 | + * @vol_id: ID of the volume to re-size 333 | + * @bytes: new size of the volume in bytes 334 | + * 335 | + * Re-sizing is possible for both dynamic and static volumes. But while dynamic 336 | + * volumes may be re-sized arbitrarily, static volumes cannot be made to be 337 | + * smaller than the number of bytes they bear. To arbitrarily shrink a static 338 | + * volume, it must be wiped out first (by means of volume update operation with 339 | + * zero number of bytes). 340 | + */ 341 | +struct ubi_rsvol_req { 342 | + __s64 bytes; 343 | + __s32 vol_id; 344 | +} __attribute__ ((packed)); 345 | + 346 | +/** 347 | + * struct ubi_rnvol_req - volumes re-name request. 348 | + * @count: count of volumes to re-name 349 | + * @padding1: reserved for future, not used, has to be zeroed 350 | + * @vol_id: ID of the volume to re-name 351 | + * @name_len: name length 352 | + * @padding2: reserved for future, not used, has to be zeroed 353 | + * @name: new volume name 354 | + * 355 | + * UBI allows to re-name up to %32 volumes at one go. The count of volumes to 356 | + * re-name is specified in the @count field. The ID of the volumes to re-name 357 | + * and the new names are specified in the @vol_id and @name fields. 358 | + * 359 | + * The UBI volume re-name operation is atomic, which means that should power cut 360 | + * happen, the volumes will have either old name or new name. So the possible 361 | + * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes 362 | + * A and B one may create temporary volumes %A1 and %B1 with the new contents, 363 | + * then atomically re-name A1->A and B1->B, in which case old %A and %B will 364 | + * be removed. 365 | + * 366 | + * If it is not desirable to remove old A and B, the re-name request has to 367 | + * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1 368 | + * become A and B, and old A and B will become A1 and B1. 369 | + * 370 | + * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1 371 | + * and B1 become A and B, and old A and B become X and Y. 372 | + * 373 | + * In other words, in case of re-naming into an existing volume name, the 374 | + * existing volume is removed, unless it is re-named as well at the same 375 | + * re-name request. 376 | + */ 377 | +struct ubi_rnvol_req { 378 | + __s32 count; 379 | + __s8 padding1[12]; 380 | + struct { 381 | + __s32 vol_id; 382 | + __s16 name_len; 383 | + __s8 padding2[2]; 384 | + char name[UBI_MAX_VOLUME_NAME + 1]; 385 | + } ents[UBI_MAX_RNVOL]; 386 | +} __attribute__ ((packed)); 387 | + 388 | +/** 389 | + * struct ubi_leb_change_req - a data structure used in atomic LEB change 390 | + * requests. 391 | + * @lnum: logical eraseblock number to change 392 | + * @bytes: how many bytes will be written to the logical eraseblock 393 | + * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) 394 | + * @padding: reserved for future, not used, has to be zeroed 395 | + */ 396 | +struct ubi_leb_change_req { 397 | + __s32 lnum; 398 | + __s32 bytes; 399 | + __s8 dtype; 400 | + __s8 padding[7]; 401 | +} __attribute__ ((packed)); 402 | + 403 | +/** 404 | + * struct ubi_map_req - a data structure used in map LEB requests. 405 | + * @lnum: logical eraseblock number to unmap 406 | + * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) 407 | + * @padding: reserved for future, not used, has to be zeroed 408 | + */ 409 | +struct ubi_map_req { 410 | + __s32 lnum; 411 | + __s8 dtype; 412 | + __s8 padding[3]; 413 | +} __attribute__ ((packed)); 414 | + 415 | + 416 | +/** 417 | + * struct ubi_set_prop_req - a data structure used to set an ubi volume 418 | + * property. 419 | + * @property: property to set (%UBI_PROP_DIRECT_WRITE) 420 | + * @padding: reserved for future, not used, has to be zeroed 421 | + * @value: value to set 422 | + */ 423 | +struct ubi_set_prop_req { 424 | + __u8 property; 425 | + __u8 padding[7]; 426 | + __u64 value; 427 | +} __attribute__ ((packed)); 428 | + 429 | +#endif /* __UBI_USER_H__ */ 430 | -- 431 | 1.7.0.4 432 | 433 | -------------------------------------------------------------------------------- /patches/012-a-ether_ntoa-udhcpd.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Tue, 10 Jan 2017 10:24:29 -0400 3 | Subject: [PATCH] fix udhcpd and nameif, add ether_ntoa_r and ether_aton_r from glibc 4 | 5 | this patch also fixes part of arping and ether-wake, but not sufficiently yet 6 | 7 | Patch modified by Tias Guns from 'ether_XtoY-from-glibc' by Dan Drown 8 | http://dan.drown.org/android/src/busybox/ 9 | Rebased for busybox 1.26.1 by Chris Renshaw 10 | --- 11 | networking/arping.c | 1 + 12 | networking/ether-wake.c | 6 +++-- 13 | networking/ether_aton_r.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ 14 | networking/ether_ntoa_r.c | 33 ++++++++++++++++++++++++ 15 | networking/ether_port.h | 29 +++++++++++++++++++++ 16 | networking/nameif.c | 1 + 17 | networking/udhcp/Kbuild.src | 1 + 18 | networking/udhcp/dhcpd.c | 4 +++ 19 | 8 files changed, 136 insertions(+), 2 deletions(-) 20 | create mode 100644 networking/ether_aton_r.c 21 | create mode 100644 networking/ether_ntoa_r.c 22 | create mode 100644 networking/ether_port.h 23 | 24 | diff --git a/networking/arping.c b/networking/arping.c 25 | index 5bfeb1b..1980620 100644 26 | --- a/networking/arping.c 27 | +++ b/networking/arping.c 28 | @@ -16,6 +16,7 @@ 29 | //applet:IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP)) 30 | 31 | //kbuild:lib-$(CONFIG_ARPING) += arping.o 32 | +//kbuild:lib-$(CONFIG_ARPING) += ether_ntoa_r.o 33 | 34 | //usage:#define arping_trivial_usage 35 | //usage: "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP" 36 | diff --git a/networking/ether-wake.c b/networking/ether-wake.c 37 | index d7d6917..7a1fc45 100644 38 | --- a/networking/ether-wake.c 39 | +++ b/networking/ether-wake.c 40 | @@ -73,6 +73,7 @@ 41 | //applet:IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake)) 42 | 43 | //kbuild:lib-$(CONFIG_ETHER_WAKE) += ether-wake.o 44 | +//kbuild:lib-$(CONFIG_ETHER_WAKE) += ether_aton_r.o ether_ntoa_r.o 45 | 46 | //usage:#define ether_wake_trivial_usage 47 | //usage: "[-b] [-i IFACE] [-p aa:bb:cc:dd[:ee:ff]/a.b.c.d] MAC" 48 | @@ -127,13 +128,14 @@ void bb_debug_dump_packet(unsigned char *outpack, int pktsize) 49 | static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) 50 | { 51 | struct ether_addr *eap; 52 | + char ether_buf[20]; 53 | 54 | eap = ether_aton_r(hostid, eaddr); 55 | if (eap) { 56 | - bb_debug_msg("The target station address is %s\n\n", ether_ntoa(eap)); 57 | + bb_debug_msg("The target station address is %s\n\n", ether_ntoa_r(eap, ether_buf)); 58 | #if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30) 59 | } else if (ether_hostton(hostid, eaddr) == 0) { 60 | - bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa(eaddr)); 61 | + bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa_r(eaddr, ether_buf)); 62 | #endif 63 | } else { 64 | bb_show_usage(); 65 | diff --git a/networking/ether_aton_r.c b/networking/ether_aton_r.c 66 | new file mode 100644 67 | index 0000000..0215f16 68 | --- /dev/null 69 | +++ b/networking/ether_aton_r.c 70 | @@ -0,0 +1,63 @@ 71 | +/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc. 72 | + This file is part of the GNU C Library. 73 | + Contributed by Ulrich Drepper , 1996. 74 | + 75 | + The GNU C Library is free software; you can redistribute it and/or 76 | + modify it under the terms of the GNU Lesser General Public 77 | + License as published by the Free Software Foundation; either 78 | + version 2.1 of the License, or (at your option) any later version. 79 | + 80 | + The GNU C Library is distributed in the hope that it will be useful, 81 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 82 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 83 | + Lesser General Public License for more details. 84 | + 85 | + You should have received a copy of the GNU Lesser General Public 86 | + License along with the GNU C Library; if not, write to the Free 87 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 88 | + 02111-1307 USA. */ 89 | + 90 | +#include 91 | +#include 92 | +#include 93 | +#include 94 | + 95 | + 96 | +struct ether_addr * 97 | +ether_aton_r (const char *asc, struct ether_addr *addr) 98 | +{ 99 | + size_t cnt; 100 | + 101 | + for (cnt = 0; cnt < 6; ++cnt) 102 | + { 103 | + unsigned int number; 104 | + char ch; 105 | + 106 | + ch = tolower (*asc++); 107 | + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f')) 108 | + return NULL; 109 | + number = isdigit (ch) ? (ch - '0') : (ch - 'a' + 10); 110 | + 111 | + ch = tolower (*asc); 112 | + if ((cnt < 5 && ch != ':') || (cnt == 5 && ch != '\0' && !isspace (ch))) 113 | + { 114 | + ++asc; 115 | + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f')) 116 | + return NULL; 117 | + number <<= 4; 118 | + number += isdigit (ch) ? (ch - '0') : (ch - 'a' + 10); 119 | + 120 | + ch = *asc; 121 | + if (cnt < 5 && ch != ':') 122 | + return NULL; 123 | + } 124 | + 125 | + /* Store result. */ 126 | + addr->ether_addr_octet[cnt] = (unsigned char) number; 127 | + 128 | + /* Skip ':'. */ 129 | + ++asc; 130 | + } 131 | + 132 | + return addr; 133 | +} 134 | diff --git a/networking/ether_ntoa_r.c b/networking/ether_ntoa_r.c 135 | new file mode 100644 136 | index 0000000..cd50614 137 | --- /dev/null 138 | +++ b/networking/ether_ntoa_r.c 139 | @@ -0,0 +1,33 @@ 140 | +/* Copyright (C) 1996,97,2002 Free Software Foundation, Inc. 141 | + This file is part of the GNU C Library. 142 | + Contributed by Ulrich Drepper , 1996. 143 | + 144 | + The GNU C Library is free software; you can redistribute it and/or 145 | + modify it under the terms of the GNU Lesser General Public 146 | + License as published by the Free Software Foundation; either 147 | + version 2.1 of the License, or (at your option) any later version. 148 | + 149 | + The GNU C Library is distributed in the hope that it will be useful, 150 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 151 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 152 | + Lesser General Public License for more details. 153 | + 154 | + You should have received a copy of the GNU Lesser General Public 155 | + License along with the GNU C Library; if not, write to the Free 156 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 157 | + 02111-1307 USA. */ 158 | + 159 | +#include 160 | +#include 161 | +#include 162 | + 163 | + 164 | +char * 165 | +ether_ntoa_r (const struct ether_addr *addr, char *buf) 166 | +{ 167 | + sprintf (buf, "%x:%x:%x:%x:%x:%x", 168 | + addr->ether_addr_octet[0], addr->ether_addr_octet[1], 169 | + addr->ether_addr_octet[2], addr->ether_addr_octet[3], 170 | + addr->ether_addr_octet[4], addr->ether_addr_octet[5]); 171 | + return buf; 172 | +} 173 | diff --git a/networking/ether_port.h b/networking/ether_port.h 174 | new file mode 100644 175 | index 0000000..5e0146b 176 | --- /dev/null 177 | +++ b/networking/ether_port.h 178 | @@ -0,0 +1,29 @@ 179 | +/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc. 180 | + This file is part of the GNU C Library. 181 | + Contributed by Ulrich Drepper , 1996. 182 | + 183 | + The GNU C Library is free software; you can redistribute it and/or 184 | + modify it under the terms of the GNU Lesser General Public 185 | + License as published by the Free Software Foundation; either 186 | + version 2.1 of the License, or (at your option) any later version. 187 | + 188 | + The GNU C Library is distributed in the hope that it will be useful, 189 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 190 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 191 | + Lesser General Public License for more details. 192 | + 193 | + You should have received a copy of the GNU Lesser General Public 194 | + License along with the GNU C Library; if not, write to the Free 195 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 196 | + 02111-1307 USA. */ 197 | + 198 | +#ifndef ETHER_PORT_H 199 | +#define ETHER_PORT_H 1 200 | + 201 | +#include 202 | +#include 203 | + 204 | +struct ether_addr * ether_aton_r (const char *asc, struct ether_addr *addr); 205 | +char * ether_ntoa_r (const struct ether_addr *addr, char *buf); 206 | + 207 | +#endif /* ETHER_PORT_H */ 208 | diff --git a/networking/nameif.c b/networking/nameif.c 209 | index cffd5bf..f634375 100644 210 | --- a/networking/nameif.c 211 | +++ b/networking/nameif.c 212 | @@ -43,6 +43,7 @@ 213 | //applet:IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP)) 214 | 215 | //kbuild:lib-$(CONFIG_NAMEIF) += nameif.o 216 | +//kbuild:lib-$(CONFIG_NAMEIF) += ether_aton_r.o 217 | 218 | //usage:#define nameif_trivial_usage 219 | //usage: IF_NOT_FEATURE_NAMEIF_EXTENDED( 220 | diff --git a/networking/udhcp/Kbuild.src b/networking/udhcp/Kbuild.src 221 | index fcb725f..2d5739c 100644 222 | --- a/networking/udhcp/Kbuild.src 223 | +++ b/networking/udhcp/Kbuild.src 224 | @@ -14,6 +14,7 @@ lib-$(CONFIG_UDHCPD) += common.o packet.o signalpipe.o socket.o 225 | 226 | lib-$(CONFIG_UDHCPC) += dhcpc.o 227 | lib-$(CONFIG_UDHCPD) += dhcpd.o arpping.o 228 | +lib-$(CONFIG_UDHCPD) += ../ether_aton_r.o ../ether_ntoa_r.o 229 | lib-$(CONFIG_DUMPLEASES) += dumpleases.o 230 | lib-$(CONFIG_DHCPRELAY) += dhcprelay.o common.o socket.o packet.o 231 | 232 | diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c 233 | index e116ba3..ef5024c 100644 234 | --- a/networking/udhcp/dhcpd.c 235 | +++ b/networking/udhcp/dhcpd.c 236 | @@ -38,8 +38,12 @@ 237 | //usage: "\n -P N Use port N (default 67)" 238 | //usage: ) 239 | 240 | +#include 241 | #include 242 | #include 243 | + 244 | +#include "../ether_port.h" 245 | + 246 | #include "common.h" 247 | #include "dhcpc.h" 248 | #include "dhcpd.h" 249 | -- 250 | 2.8.3 251 | 252 | -------------------------------------------------------------------------------- /patches/012-b-ether-wake.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Wed, 2 Dec 2015 23:44:06 -0400 3 | Subject: [PATCH] fix ether-wake, avoid ether_hostton and include if_ether 4 | 5 | Patch by Tias Guns , based on 'no-ether_hostton' by Dan Drown 6 | "there is no /etc/ethers or ether_hostton on bionic" 7 | http://dan.drown.org/android/src/busybox/ 8 | Rebased for busybox 1.24.1 by Chris Renshaw 9 | --- 10 | networking/ether-wake.c | 3 ++- 11 | 1 files changed, 2 insertions(+), 1 deletions(-) 12 | 13 | diff --git a/networking/ether-wake.c b/networking/ether-wake.c 14 | index 103a421..ee33dc5 100644 15 | --- a/networking/ether-wake.c 16 | +++ b/networking/ether-wake.c 17 | @@ -77,6 +77,7 @@ 18 | #include "libbb.h" 19 | #include 20 | #include 21 | +#include 22 | #include 23 | 24 | /* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to 25 | @@ -122,7 +123,7 @@ static void get_dest_addr(const char *hostid, struct ether_addr *eaddr) 26 | eap = ether_aton_r(hostid, eaddr); 27 | if (eap) { 28 | bb_debug_msg("The target station address is %s\n\n", ether_ntoa_r(eap, ether_buf)); 29 | -#if !defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30) 30 | +#if !defined(__BIONIC__) && (!defined(__UCLIBC__) || UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)) 31 | } else if (ether_hostton(hostid, eaddr) == 0) { 32 | bb_debug_msg("Station address for hostname %s is %s\n\n", hostid, ether_ntoa_r(eaddr, ether_buf)); 33 | #endif 34 | -- 35 | 2.5.3 36 | 37 | -------------------------------------------------------------------------------- /patches/012-c-arping.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Mon, 19 Mar 2012 18:03:19 +0000 3 | Subject: [PATCH] fix arping: include if_arp.h (for arphdr) and add mempcpy.c 4 | 5 | fixing arping also requires adding ether_ntoa_r, see 'fix udhcpd' patch 6 | 7 | patch from 'struct-arphdr' and 'mempcpy-function' by Dan Drown 8 | http://dan.drown.org/android/src/busybox/ 9 | --- 10 | networking/arping.c | 1 + 11 | 1 file changed, 1 insertion(+) 12 | 13 | diff --git a/networking/arping.c b/networking/arping.c 14 | index 37dfec1..c34e002 100644 15 | --- a/networking/arping.c 16 | +++ b/networking/arping.c 17 | @@ -26,6 +26,7 @@ 18 | #include 19 | #include 20 | #include 21 | +#include /* for arphdr */ 22 | 23 | #include "libbb.h" 24 | 25 | -- 26 | 1.7.10.4 27 | 28 | -------------------------------------------------------------------------------- /patches/013-loadfont-setfont-conspy.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Thu, 3 Dec 2015 01:29:35 -0400 3 | Subject: [PATCH] loadfont/setfont/conspy: add missing header 4 | 5 | Imported from dorimanx's combined ported header toolchain: 6 | https://github.com/dorimanx/android-busybox-ndk 7 | --- 8 | include/sys/kd.h | 34 ++++++++++++++++++++++++++++++++++ 9 | 1 file changed, 34 insertions(+) 10 | create mode 100644 include/sys/kd.h 11 | 12 | diff --git a/include/sys/kd.h b/include/sys/kd.h 13 | new file mode 100644 14 | index 0000000..8b8e56d 15 | --- /dev/null 16 | +++ b/include/sys/kd.h 17 | @@ -0,0 +1,34 @@ 18 | +/* Copyright (C) 1996-2015 Free Software Foundation, Inc. 19 | + This file is part of the GNU C Library. 20 | + 21 | + The GNU C Library is free software; you can redistribute it and/or 22 | + modify it under the terms of the GNU Lesser General Public 23 | + License as published by the Free Software Foundation; either 24 | + version 2.1 of the License, or (at your option) any later version. 25 | + 26 | + The GNU C Library is distributed in the hope that it will be useful, 27 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | + Lesser General Public License for more details. 30 | + 31 | + You should have received a copy of the GNU Lesser General Public 32 | + License along with the GNU C Library; if not, see 33 | + . */ 34 | + 35 | +#ifndef _SYS_KD_H 36 | +#define _SYS_KD_H 1 37 | + 38 | +/* Make sure the header is not loaded. */ 39 | +#ifndef _LINUX_TYPES_H 40 | +# define _LINUX_TYPES_H 1 41 | +# define __undef_LINUX_TYPES_H 42 | +#endif 43 | + 44 | +#include 45 | + 46 | +#ifdef __undef_LINUX_TYPES_H 47 | +# undef _LINUX_TYPES_H 48 | +# undef __undef_LINUX_TYPES_H 49 | +#endif 50 | + 51 | +#endif /* sys/kd.h */ 52 | -- 53 | 2.5.3 54 | 55 | -------------------------------------------------------------------------------- /patches/014-nandwrite-nanddump.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Sun, 6 Dec 2015 12:27:41 -0400 3 | Subject: [PATCH] nandwrite/nanddump: add missing headers 4 | needed for Android API 21 5 | 6 | --- 7 | include/mtd/mtd-abi.h | 277 +++++++++++++++++++++++++++++++++++++++++++++++++ 8 | include/mtd/mtd-user.h | 34 ++++++ 9 | 2 files changed, 311 insertions(+) 10 | create mode 100644 include/mtd/mtd-abi.h 11 | create mode 100644 include/mtd/mtd-user.h 12 | 13 | diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h 14 | new file mode 100644 15 | index 0000000..4de167b 16 | --- /dev/null 17 | +++ b/include/mtd/mtd-abi.h 18 | @@ -0,0 +1,277 @@ 19 | +/* 20 | + * Copyright © 1999-2010 David Woodhouse et al. 21 | + * 22 | + * This program is free software; you can redistribute it and/or modify 23 | + * it under the terms of the GNU General Public License as published by 24 | + * the Free Software Foundation; either version 2 of the License, or 25 | + * (at your option) any later version. 26 | + * 27 | + * This program is distributed in the hope that it will be useful, 28 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | + * GNU General Public License for more details. 31 | + * 32 | + * You should have received a copy of the GNU General Public License 33 | + * along with this program; if not, write to the Free Software 34 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 35 | + * 36 | + */ 37 | + 38 | +#ifndef __MTD_ABI_H__ 39 | +#define __MTD_ABI_H__ 40 | + 41 | +#include 42 | + 43 | +struct erase_info_user { 44 | + __u32 start; 45 | + __u32 length; 46 | +}; 47 | + 48 | +struct erase_info_user64 { 49 | + __u64 start; 50 | + __u64 length; 51 | +}; 52 | + 53 | +struct mtd_oob_buf { 54 | + __u32 start; 55 | + __u32 length; 56 | + unsigned char *ptr; 57 | +}; 58 | + 59 | +struct mtd_oob_buf64 { 60 | + __u64 start; 61 | + __u32 pad; 62 | + __u32 length; 63 | + __u64 usr_ptr; 64 | +}; 65 | + 66 | +/** 67 | + * MTD operation modes 68 | + * 69 | + * @MTD_OPS_PLACE_OOB: OOB data are placed at the given offset (default) 70 | + * @MTD_OPS_AUTO_OOB: OOB data are automatically placed at the free areas 71 | + * which are defined by the internal ecclayout 72 | + * @MTD_OPS_RAW: data are transferred as-is, with no error correction; 73 | + * this mode implies %MTD_OPS_PLACE_OOB 74 | + * 75 | + * These modes can be passed to ioctl(MEMWRITE) and are also used internally. 76 | + * See notes on "MTD file modes" for discussion on %MTD_OPS_RAW vs. 77 | + * %MTD_FILE_MODE_RAW. 78 | + */ 79 | +enum { 80 | + MTD_OPS_PLACE_OOB = 0, 81 | + MTD_OPS_AUTO_OOB = 1, 82 | + MTD_OPS_RAW = 2, 83 | +}; 84 | + 85 | +/** 86 | + * struct mtd_write_req - data structure for requesting a write operation 87 | + * 88 | + * @start: start address 89 | + * @len: length of data buffer 90 | + * @ooblen: length of OOB buffer 91 | + * @usr_data: user-provided data buffer 92 | + * @usr_oob: user-provided OOB buffer 93 | + * @mode: MTD mode (see "MTD operation modes") 94 | + * @padding: reserved, must be set to 0 95 | + * 96 | + * This structure supports ioctl(MEMWRITE) operations, allowing data and/or OOB 97 | + * writes in various modes. To write to OOB-only, set @usr_data == NULL, and to 98 | + * write data-only, set @usr_oob == NULL. However, setting both @usr_data and 99 | + * @usr_oob to NULL is not allowed. 100 | + */ 101 | +struct mtd_write_req { 102 | + __u64 start; 103 | + __u64 len; 104 | + __u64 ooblen; 105 | + __u64 usr_data; 106 | + __u64 usr_oob; 107 | + __u8 mode; 108 | + __u8 padding[7]; 109 | +}; 110 | + 111 | +#define MTD_ABSENT 0 112 | +#define MTD_RAM 1 113 | +#define MTD_ROM 2 114 | +#define MTD_NORFLASH 3 115 | +#define MTD_NANDFLASH 4 116 | +#define MTD_DATAFLASH 6 117 | +#define MTD_UBIVOLUME 7 118 | +#define MTD_MLCNANDFLASH 8 119 | + 120 | +#define MTD_WRITEABLE 0x400 /* Device is writeable */ 121 | +#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ 122 | +#define MTD_NO_ERASE 0x1000 /* No erase necessary */ 123 | +#define MTD_POWERUP_LOCK 0x2000 /* Always locked after reset */ 124 | + 125 | +/* Some common devices / combinations of capabilities */ 126 | +#define MTD_CAP_ROM 0 127 | +#define MTD_CAP_RAM (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE) 128 | +#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE) 129 | +#define MTD_CAP_NANDFLASH (MTD_WRITEABLE) 130 | + 131 | +/* Obsolete ECC byte placement modes (used with obsolete MEMGETOOBSEL) */ 132 | +#define MTD_NANDECC_OFF 0 // Switch off ECC (Not recommended) 133 | +#define MTD_NANDECC_PLACE 1 // Use the given placement in the structure (YAFFS1 legacy mode) 134 | +#define MTD_NANDECC_AUTOPLACE 2 // Use the default placement scheme 135 | +#define MTD_NANDECC_PLACEONLY 3 // Use the given placement in the structure (Do not store ecc result on read) 136 | +#define MTD_NANDECC_AUTOPL_USR 4 // Use the given autoplacement scheme rather than using the default 137 | + 138 | +/* OTP mode selection */ 139 | +#define MTD_OTP_OFF 0 140 | +#define MTD_OTP_FACTORY 1 141 | +#define MTD_OTP_USER 2 142 | + 143 | +struct mtd_info_user { 144 | + __u8 type; 145 | + __u32 flags; 146 | + __u32 size; /* Total size of the MTD */ 147 | + __u32 erasesize; 148 | + __u32 writesize; 149 | + __u32 oobsize; /* Amount of OOB data per block (e.g. 16) */ 150 | + __u64 padding; /* Old obsolete field; do not use */ 151 | +}; 152 | + 153 | +struct region_info_user { 154 | + __u32 offset; /* At which this region starts, 155 | + * from the beginning of the MTD */ 156 | + __u32 erasesize; /* For this region */ 157 | + __u32 numblocks; /* Number of blocks in this region */ 158 | + __u32 regionindex; 159 | +}; 160 | + 161 | +struct otp_info { 162 | + __u32 start; 163 | + __u32 length; 164 | + __u32 locked; 165 | +}; 166 | + 167 | +/* 168 | + * Note, the following ioctl existed in the past and was removed: 169 | + * #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo) 170 | + * Try to avoid adding a new ioctl with the same ioctl number. 171 | + */ 172 | + 173 | +/* Get basic MTD characteristics info (better to use sysfs) */ 174 | +#define MEMGETINFO _IOR('M', 1, struct mtd_info_user) 175 | +/* Erase segment of MTD */ 176 | +#define MEMERASE _IOW('M', 2, struct erase_info_user) 177 | +/* Write out-of-band data from MTD */ 178 | +#define MEMWRITEOOB _IOWR('M', 3, struct mtd_oob_buf) 179 | +/* Read out-of-band data from MTD */ 180 | +#define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) 181 | +/* Lock a chip (for MTD that supports it) */ 182 | +#define MEMLOCK _IOW('M', 5, struct erase_info_user) 183 | +/* Unlock a chip (for MTD that supports it) */ 184 | +#define MEMUNLOCK _IOW('M', 6, struct erase_info_user) 185 | +/* Get the number of different erase regions */ 186 | +#define MEMGETREGIONCOUNT _IOR('M', 7, int) 187 | +/* Get information about the erase region for a specific index */ 188 | +#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) 189 | +/* Get info about OOB modes (e.g., RAW, PLACE, AUTO) - legacy interface */ 190 | +#define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo) 191 | +/* Check if an eraseblock is bad */ 192 | +#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t) 193 | +/* Mark an eraseblock as bad */ 194 | +#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t) 195 | +/* Set OTP (One-Time Programmable) mode (factory vs. user) */ 196 | +#define OTPSELECT _IOR('M', 13, int) 197 | +/* Get number of OTP (One-Time Programmable) regions */ 198 | +#define OTPGETREGIONCOUNT _IOW('M', 14, int) 199 | +/* Get all OTP (One-Time Programmable) info about MTD */ 200 | +#define OTPGETREGIONINFO _IOW('M', 15, struct otp_info) 201 | +/* Lock a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */ 202 | +#define OTPLOCK _IOR('M', 16, struct otp_info) 203 | +/* Get ECC layout (deprecated) */ 204 | +#define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout_user) 205 | +/* Get statistics about corrected/uncorrected errors */ 206 | +#define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) 207 | +/* Set MTD mode on a per-file-descriptor basis (see "MTD file modes") */ 208 | +#define MTDFILEMODE _IO('M', 19) 209 | +/* Erase segment of MTD (supports 64-bit address) */ 210 | +#define MEMERASE64 _IOW('M', 20, struct erase_info_user64) 211 | +/* Write data to OOB (64-bit version) */ 212 | +#define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64) 213 | +/* Read data from OOB (64-bit version) */ 214 | +#define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64) 215 | +/* Check if chip is locked (for MTD that supports it) */ 216 | +#define MEMISLOCKED _IOR('M', 23, struct erase_info_user) 217 | +/* 218 | + * Most generic write interface; can write in-band and/or out-of-band in various 219 | + * modes (see "struct mtd_write_req") 220 | + */ 221 | +#define MEMWRITE _IOWR('M', 24, struct mtd_write_req) 222 | + 223 | +/* 224 | + * Obsolete legacy interface. Keep it in order not to break userspace 225 | + * interfaces 226 | + */ 227 | +struct nand_oobinfo { 228 | + __u32 useecc; 229 | + __u32 eccbytes; 230 | + __u32 oobfree[8][2]; 231 | + __u32 eccpos[32]; 232 | +}; 233 | + 234 | +struct nand_oobfree { 235 | + __u32 offset; 236 | + __u32 length; 237 | +}; 238 | + 239 | +#define MTD_MAX_OOBFREE_ENTRIES 8 240 | +#define MTD_MAX_ECCPOS_ENTRIES 64 241 | +/* 242 | + * OBSOLETE: ECC layout control structure. Exported to user-space via ioctl 243 | + * ECCGETLAYOUT for backwards compatbility and should not be mistaken as a 244 | + * complete set of ECC information. The ioctl truncates the larger internal 245 | + * structure to retain binary compatibility with the static declaration of the 246 | + * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of 247 | + * the user struct, not the MAX size of the internal struct nand_ecclayout. 248 | + */ 249 | +struct nand_ecclayout_user { 250 | + __u32 eccbytes; 251 | + __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES]; 252 | + __u32 oobavail; 253 | + struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; 254 | +}; 255 | + 256 | +/** 257 | + * struct mtd_ecc_stats - error correction stats 258 | + * 259 | + * @corrected: number of corrected bits 260 | + * @failed: number of uncorrectable errors 261 | + * @badblocks: number of bad blocks in this partition 262 | + * @bbtblocks: number of blocks reserved for bad block tables 263 | + */ 264 | +struct mtd_ecc_stats { 265 | + __u32 corrected; 266 | + __u32 failed; 267 | + __u32 badblocks; 268 | + __u32 bbtblocks; 269 | +}; 270 | + 271 | +/* 272 | + * MTD file modes - for read/write access to MTD 273 | + * 274 | + * @MTD_FILE_MODE_NORMAL: OTP disabled, ECC enabled 275 | + * @MTD_FILE_MODE_OTP_FACTORY: OTP enabled in factory mode 276 | + * @MTD_FILE_MODE_OTP_USER: OTP enabled in user mode 277 | + * @MTD_FILE_MODE_RAW: OTP disabled, ECC disabled 278 | + * 279 | + * These modes can be set via ioctl(MTDFILEMODE). The mode mode will be retained 280 | + * separately for each open file descriptor. 281 | + * 282 | + * Note: %MTD_FILE_MODE_RAW provides the same functionality as %MTD_OPS_RAW - 283 | + * raw access to the flash, without error correction or autoplacement schemes. 284 | + * Wherever possible, the MTD_OPS_* mode will override the MTD_FILE_MODE_* mode 285 | + * (e.g., when using ioctl(MEMWRITE)), but in some cases, the MTD_FILE_MODE is 286 | + * used out of necessity (e.g., `write()', ioctl(MEMWRITEOOB64)). 287 | + */ 288 | +enum mtd_file_modes { 289 | + MTD_FILE_MODE_NORMAL = MTD_OTP_OFF, 290 | + MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY, 291 | + MTD_FILE_MODE_OTP_USER = MTD_OTP_USER, 292 | + MTD_FILE_MODE_RAW, 293 | +}; 294 | + 295 | +#endif /* __MTD_ABI_H__ */ 296 | diff --git a/include/mtd/mtd-user.h b/include/mtd/mtd-user.h 297 | new file mode 100644 298 | index 0000000..83327c8 299 | --- /dev/null 300 | +++ b/include/mtd/mtd-user.h 301 | @@ -0,0 +1,34 @@ 302 | +/* 303 | + * Copyright © 1999-2010 David Woodhouse 304 | + * 305 | + * This program is free software; you can redistribute it and/or modify 306 | + * it under the terms of the GNU General Public License as published by 307 | + * the Free Software Foundation; either version 2 of the License, or 308 | + * (at your option) any later version. 309 | + * 310 | + * This program is distributed in the hope that it will be useful, 311 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 312 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 313 | + * GNU General Public License for more details. 314 | + * 315 | + * You should have received a copy of the GNU General Public License 316 | + * along with this program; if not, write to the Free Software 317 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 318 | + * 319 | + */ 320 | + 321 | +#ifndef __MTD_USER_H__ 322 | +#define __MTD_USER_H__ 323 | + 324 | +#include 325 | + 326 | +/* This file is blessed for inclusion by userspace */ 327 | +#include 328 | + 329 | +typedef struct mtd_info_user mtd_info_t; 330 | +typedef struct erase_info_user erase_info_t; 331 | +typedef struct region_info_user region_info_t; 332 | +typedef struct nand_oobinfo nand_oobinfo_t; 333 | +typedef struct nand_ecclayout_user nand_ecclayout_t; 334 | + 335 | +#endif /* __MTD_USER_H__ */ 336 | -- 337 | 2.5.3 338 | 339 | -------------------------------------------------------------------------------- /patches/015-zcip.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Mon, 19 Mar 2012 18:34:51 +0000 3 | Subject: [PATCH] fix zcip: struct ether_arp missing, use FreeBSD's 4 | 5 | patch from 'struct-etherarp' by Dan Drown 6 | http://dan.drown.org/android/src/busybox/ 7 | --- 8 | networking/struct-etherarp.h | 75 ++++++++++++++++++++++++++++++++++++++++++ 9 | networking/zcip.c | 1 + 10 | 2 files changed, 76 insertions(+), 0 deletions(-) 11 | create mode 100644 networking/struct-etherarp.h 12 | 13 | diff --git a/networking/struct-etherarp.h b/networking/struct-etherarp.h 14 | new file mode 100644 15 | index 0000000..02a9c5b 16 | --- /dev/null 17 | +++ b/networking/struct-etherarp.h 18 | @@ -0,0 +1,75 @@ 19 | +/* 20 | + * Copyright (c) 1982, 1986, 1993 21 | + * The Regents of the University of California. All rights reserved. 22 | + * 23 | + * Redistribution and use in source and binary forms, with or without 24 | + * modification, are permitted provided that the following conditions 25 | + * are met: 26 | + * 1. Redistributions of source code must retain the above copyright 27 | + * notice, this list of conditions and the following disclaimer. 28 | + * 2. Redistributions in binary form must reproduce the above copyright 29 | + * notice, this list of conditions and the following disclaimer in the 30 | + * documentation and/or other materials provided with the distribution. 31 | + * 4. Neither the name of the University nor the names of its contributors 32 | + * may be used to endorse or promote products derived from this software 33 | + * without specific prior written permission. 34 | + * 35 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 36 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 38 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 39 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 40 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 41 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 43 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 44 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 45 | + * SUCH DAMAGE. 46 | + * 47 | + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 48 | + * $FreeBSD$ 49 | + */ 50 | +#ifndef STRUCT_ETHERARP_H 51 | +#define STRUCT_ETHERARP_H 1 52 | + 53 | +#include 54 | + 55 | +/* 56 | + * Macro to map an IP multicast address to an Ethernet multicast address. 57 | + * The high-order 25 bits of the Ethernet address are statically assigned, 58 | + * and the low-order 23 bits are taken from the low end of the IP address. 59 | + */ 60 | +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ 61 | + /* struct in_addr *ipaddr; */ \ 62 | + /* u_char enaddr[ETH_ALEN]; */ \ 63 | +{ \ 64 | + (enaddr)[0] = 0x01; \ 65 | + (enaddr)[1] = 0x00; \ 66 | + (enaddr)[2] = 0x5e; \ 67 | + (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \ 68 | + (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \ 69 | + (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \ 70 | +} 71 | + 72 | +/* 73 | + * Ethernet Address Resolution Protocol. 74 | + * 75 | + * See RFC 826 for protocol description. Structure below is adapted 76 | + * to resolving internet addresses. Field names used correspond to 77 | + * RFC 826. 78 | + */ 79 | +struct ether_arp { 80 | + struct arphdr ea_hdr; /* fixed-size header */ 81 | + u_int8_t arp_sha[ETH_ALEN]; /* sender hardware address */ 82 | + u_int8_t arp_spa[4]; /* sender protocol address */ 83 | + u_int8_t arp_tha[ETH_ALEN]; /* target hardware address */ 84 | + u_int8_t arp_tpa[4]; /* target protocol address */ 85 | +}; 86 | +#define arp_hrd ea_hdr.ar_hrd 87 | +#define arp_pro ea_hdr.ar_pro 88 | +#define arp_hln ea_hdr.ar_hln 89 | +#define arp_pln ea_hdr.ar_pln 90 | +#define arp_op ea_hdr.ar_op 91 | + 92 | + 93 | +#endif /* STRUCT_ETHERARP_H */ 94 | diff --git a/networking/zcip.c b/networking/zcip.c 95 | index 7314ff8..52fcf57 100644 96 | --- a/networking/zcip.c 97 | +++ b/networking/zcip.c 98 | @@ -40,6 +40,7 @@ 99 | #include 100 | #include 101 | #include 102 | +#include "struct-etherarp.h" 103 | 104 | #include 105 | 106 | -- 107 | 1.7.0.4 108 | 109 | -------------------------------------------------------------------------------- /patches/017-a-shmget-msgget-semget-syscalls.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 12 Sep 2016 14:45:35 -0300 3 | Subject: [PATCH] android syscalls: shmget/msgget/semget 4 | 5 | Patch modified by Tias Guns from 'no-sys-shm,msg,sem' by Dan Drown 6 | http://dan.drown.org/android/src/busybox/ 7 | Rebased for busybox 1.25.0 by Chris Renshaw 8 | --- 9 | libbb/missing_syscalls.c | 15 +++++++++++++++ 10 | 1 file changed, 15 insertions(+) 11 | 12 | diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c 13 | index 235f4b8..a75a332 100644 14 | --- a/libbb/missing_syscalls.c 15 | +++ b/libbb/missing_syscalls.c 16 | @@ -49,4 +49,19 @@ int swapon(const char *path, int swapflags) 17 | { 18 | return syscall(__NR_swapon, path, swapflags); 19 | } 20 | + 21 | +int shmget(key_t key, size_t size, int shmflg) 22 | +{ 23 | + return syscall(__NR_shmget, key, size, shmflg); 24 | +} 25 | + 26 | +int msgget(key_t key, int msgflg) 27 | +{ 28 | + return syscall(__NR_msgget, key, msgflg); 29 | +} 30 | + 31 | +int semget(key_t key, int nsems, int semflg) 32 | +{ 33 | + return syscall(__NR_semget, key, nsems, semflg); 34 | +} 35 | 36 | -- 37 | 2.8.3 38 | 39 | -------------------------------------------------------------------------------- /patches/017-b-msgctl-shmctl-syscalls.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 12 Sep 2016 14:46:40 -0300 3 | Subject: [PATCH] android syscalls: msgctl shmctl 4 | 5 | Patch by Tias Guns 6 | Rebased for busybox 1.25.0 by Chris Renshaw 7 | --- 8 | libbb/missing_syscalls.c | 13 +++++++++++++ 9 | 1 file changed, 13 insertions(+) 10 | 11 | diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c 12 | index a75a332..ac75829 100644 13 | --- a/libbb/missing_syscalls.c 14 | +++ b/libbb/missing_syscalls.c 15 | @@ -64,4 +64,17 @@ int semget(key_t key, int nsems, int semflg) 16 | { 17 | return syscall(__NR_semget, key, nsems, semflg); 18 | } 19 | + 20 | +struct msqid_ds; /* #include */ 21 | +int msgctl(int msqid, int cmd, struct msqid_ds *buf) 22 | +{ 23 | + return syscall(__NR_msgctl, msqid, cmd, buf); 24 | +} 25 | + 26 | +struct shmid_ds; /* #include */ 27 | +// NOTE: IPC_INFO takes a struct shminfo64 28 | +int shmctl(int shmid, int cmd, struct shmid_ds *buf) 29 | +{ 30 | + return syscall(__NR_shmctl, shmid, cmd, buf); 31 | +} 32 | 33 | -- 34 | 2.8.3 35 | 36 | -------------------------------------------------------------------------------- /patches/017-c-shmdt-shmat-semop-syscalls.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 12 Sep 2016 14:48:30 -0300 3 | Subject: [PATCH] android syscalls: shmdt shmat sembuf 4 | 5 | Patch by Tias Guns 6 | Rebased for busybox 1.25.0 by Chris Renshaw 7 | --- 8 | libbb/missing_syscalls.c | 16 ++++++++++++++++ 9 | 1 file changed, 16 insertions(+) 10 | 11 | diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c 12 | index ac75829..474accb 100644 13 | --- a/libbb/missing_syscalls.c 14 | +++ b/libbb/missing_syscalls.c 15 | @@ -55,6 +55,16 @@ int shmget(key_t key, size_t size, int shmflg) 16 | return syscall(__NR_shmget, key, size, shmflg); 17 | } 18 | 19 | +int shmdt(const void *shmaddr) 20 | +{ 21 | + return syscall(__NR_shmdt, shmaddr); 22 | +} 23 | + 24 | +void *shmat(int shmid, const void *shmaddr, int shmflg) 25 | +{ 26 | + return (void *)syscall(__NR_shmat, shmid, shmaddr, shmflg); 27 | +} 28 | + 29 | int msgget(key_t key, int msgflg) 30 | { 31 | return syscall(__NR_msgget, key, msgflg); 32 | @@ -77,4 +87,10 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf) 33 | { 34 | return syscall(__NR_shmctl, shmid, cmd, buf); 35 | } 36 | + 37 | +struct sembuf; /* #include */ 38 | +int semop(int semid, struct sembuf *sops, unsigned nsops) 39 | +{ 40 | + return syscall(__NR_semop, semid, sops, nsops); 41 | +} 42 | 43 | -- 44 | 2.8.3 45 | 46 | -------------------------------------------------------------------------------- /patches/018-a-semctl-syscall.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Sun, 5 Aug 2012 15:25:34 +0200 3 | Subject: [PATCH] android syscall (non-trivial): semctl 4 | 5 | needed by ipcs and ipcrm, also needed (but not sufficient) for syslogd and logread 6 | 7 | semctl from glibc 8 | patch from 'no-sys-shm,msg,sem' by Dan Drown 9 | http://dan.drown.org/android/src/busybox/ 10 | 11 | Signed-off-by: Tias Guns 12 | --- 13 | libbb/semctl.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 14 | 1 file changed, 58 insertions(+) 15 | create mode 100644 libbb/semctl.c 16 | 17 | diff --git a/libbb/semctl.c b/libbb/semctl.c 18 | new file mode 100644 19 | index 0000000..68f846a 20 | --- /dev/null 21 | +++ b/libbb/semctl.c 22 | @@ -0,0 +1,58 @@ 23 | +/* Copyright (C) 1995,1997,1998,2000,2003,2004,2006 24 | + Free Software Foundation, Inc. 25 | + This file is part of the GNU C Library. 26 | + Contributed by Ulrich Drepper , August 1995. 27 | + 28 | + The GNU C Library is free software; you can redistribute it and/or 29 | + modify it under the terms of the GNU Lesser General Public 30 | + License as published by the Free Software Foundation; either 31 | + version 2.1 of the License, or (at your option) any later version. 32 | + 33 | + The GNU C Library is distributed in the hope that it will be useful, 34 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | + Lesser General Public License for more details. 37 | + 38 | + You should have received a copy of the GNU Lesser General Public 39 | + License along with the GNU C Library; if not, write to the Free 40 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 41 | + 02111-1307 USA. */ 42 | +/* originally from glibc-2.14/sysdeps/unix/sysv/linux/semctl.c, modified */ 43 | + 44 | +// syscall used by syslogd, ipcrm, ipcs 45 | +//kbuild:lib-y += semctl.o 46 | + 47 | +#include /* For __NR_xxx definitions */ 48 | +#include 49 | +#include 50 | +#include "libbb.h" 51 | + 52 | +/* code from GLIBC */ 53 | +int semctl(int semid, int semnum, int cmd, ...) { 54 | + union semun arg; 55 | + va_list ap; 56 | + 57 | + va_start (ap, cmd); 58 | + 59 | + /* Get the argument only if required. */ 60 | + arg.buf = NULL; 61 | + switch (cmd) 62 | + { 63 | + case SETVAL: /* arg.val */ 64 | + case GETALL: /* arg.array */ 65 | + case SETALL: 66 | + case IPC_STAT: /* arg.buf */ 67 | + case IPC_SET: 68 | + case SEM_STAT: 69 | + case IPC_INFO: /* arg.__buf */ 70 | + case SEM_INFO: 71 | + va_start (ap, cmd); 72 | + arg = va_arg (ap, union semun); 73 | + va_end (ap); 74 | + break; 75 | + } 76 | + 77 | + va_end (ap); 78 | + 79 | + return syscall(__NR_semctl, semid, semnum, cmd, arg); 80 | +} 81 | -- 82 | 1.7.10.4 83 | 84 | -------------------------------------------------------------------------------- /patches/018-b-semctl-missing_syscalls.patch: -------------------------------------------------------------------------------- 1 | From: Umakanthan Chandran 2 | Date: Fri, 3 Mar 2017 07:32:22 +0530 3 | Subject: [PATCH] missing_syscalls/semctl: fix missing definitions on x86 and 4 | MIPS NDK cross-compiles 5 | 6 | Signed-off-by: Umakanthan Chandran 7 | --- 8 | libbb/missing_syscalls.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 9 | libbb/semctl.c | 4 ++++ 10 | 2 files changed, 48 insertions(+) 11 | 12 | diff --git a/libbb/missing_syscalls.c b/libbb/missing_syscalls.c 13 | index 9f3025f..ab3dd06 100644 14 | --- a/libbb/missing_syscalls.c 15 | +++ b/libbb/missing_syscalls.c 16 | @@ -10,6 +10,50 @@ 17 | #include 18 | #include "libbb.h" 19 | 20 | +#ifndef __NR_shmget 21 | +#define __NR_shmget 29 22 | +#endif 23 | + 24 | +#ifndef __NR_shmat 25 | +#define __NR_shmat 30 26 | +#endif 27 | + 28 | +#ifndef __NR_shmctl 29 | +#define __NR_shmctl 31 30 | +#endif 31 | + 32 | +#ifndef __NR_semget 33 | +#define __NR_semget 64 34 | +#endif 35 | + 36 | +#ifndef __NR_semop 37 | +#define __NR_semop 65 38 | +#endif 39 | + 40 | +#ifndef __NR_semctl 41 | +#define __NR_semctl 66 42 | +#endif 43 | + 44 | +#ifndef __NR_shmdt 45 | +#define __NR_shmdt 67 46 | +#endif 47 | + 48 | +#ifndef __NR_msgget 49 | +#define __NR_msgget 68 50 | +#endif 51 | + 52 | +#ifndef __NR_msgsnd 53 | +#define __NR_msgsnd 69 54 | +#endif 55 | + 56 | +#ifndef __NR_msgrcv 57 | +#define __NR_msgrcv 70 58 | +#endif 59 | + 60 | +#ifndef __NR_msgctl 61 | +#define __NR_msgctl 71 62 | +#endif 63 | + 64 | #if defined(ANDROID) || defined(__ANDROID__) 65 | pid_t getsid(pid_t pid) 66 | { 67 | diff --git a/libbb/semctl.c b/libbb/semctl.c 68 | index 68f846a..5ddd07f 100644 69 | --- a/libbb/semctl.c 70 | +++ b/libbb/semctl.c 71 | @@ -27,6 +27,10 @@ 72 | #include 73 | #include "libbb.h" 74 | 75 | +#ifndef __NR_semctl 76 | +#define __NR_semctl 66 77 | +#endif 78 | + 79 | /* code from GLIBC */ 80 | int semctl(int semid, int semnum, int cmd, ...) { 81 | union semun arg; 82 | -- 83 | 2.8.3 84 | 85 | -------------------------------------------------------------------------------- /patches/019-ipcs-ipcrm.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Tue, 20 Mar 2012 21:26:07 +0000 3 | Subject: [PATCH] fix ipcs, ipcrm no sys/sem-shm-msg, etc 4 | 5 | patch from 'no-sys-shm,msg,sem' by Dan Drown 6 | http://dan.drown.org/android/src/busybox/ 7 | 8 | Signed-off-by: Tias Guns 9 | --- 10 | util-linux/ipcrm.c | 3 ++- 11 | util-linux/ipcs.c | 3 ++- 12 | 2 files changed, 4 insertions(+), 2 deletions(-) 13 | 14 | diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c 15 | index 274050c..b65e8ef 100644 16 | --- a/util-linux/ipcrm.c 17 | +++ b/util-linux/ipcrm.c 18 | @@ -22,8 +22,9 @@ 19 | #include 20 | #include 21 | #include 22 | 23 | -#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) 24 | +#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \ 25 | + defined(__ANDROID__) 26 | /* union semun is defined by including */ 27 | #else 28 | /* according to X/OPEN we have to define it ourselves */ 29 | diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c 30 | index ee7df5e..fafe4e3 100644 31 | --- a/util-linux/ipcs.c 32 | +++ b/util-linux/ipcs.c 33 | @@ -77,7 +77,8 @@ struct shm_info { 34 | /* The last arg of semctl is a union semun, but where is it defined? 35 | X/OPEN tells us to define it ourselves, but until recently 36 | Linux include files would also define it. */ 37 | -#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) 38 | +#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) || \ 39 | + defined(__ANDROID__) 40 | /* union semun is defined by including */ 41 | #else 42 | /* according to X/OPEN we have to define it ourselves */ 43 | -- 44 | 1.7.10.4 45 | 46 | -------------------------------------------------------------------------------- /patches/020-syslogd-logread.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Tue, 20 Mar 2012 21:30:10 +0000 3 | Subject: [PATCH] fix syslogd, logread: add syslog.h, semop shmdt-at 4 | 5 | patch from 'no-sys-shm,msg,sem' and 'sys-syslog' by Dan Drown 6 | "sys/syslog.h header for syslogd" 7 | http://dan.drown.org/android/src/busybox/ 8 | --- 9 | include/sys/syslog.h | 138 +++++++++++++++++++++++++++++++++++++++++ 10 | sysklogd/syslogd_and_logger.c | 1 + 11 | 2 files changed, 139 insertions(+), 0 deletions(-) 12 | create mode 100644 include/sys/syslog.h 13 | 14 | diff --git a/include/sys/syslog.h b/include/sys/syslog.h 15 | new file mode 100644 16 | index 0000000..3c749a0 17 | --- /dev/null 18 | +++ b/include/sys/syslog.h 19 | @@ -0,0 +1,138 @@ 20 | +/* 21 | + * Copyright (c) 1982, 1986, 1988, 1993 22 | + * The Regents of the University of California. All rights reserved. 23 | + * 24 | + * Redistribution and use in source and binary forms, with or without 25 | + * modification, are permitted provided that the following conditions 26 | + * are met: 27 | + * 1. Redistributions of source code must retain the above copyright 28 | + * notice, this list of conditions and the following disclaimer. 29 | + * 2. Redistributions in binary form must reproduce the above copyright 30 | + * notice, this list of conditions and the following disclaimer in the 31 | + * documentation and/or other materials provided with the distribution. 32 | + * 4. Neither the name of the University nor the names of its contributors 33 | + * may be used to endorse or promote products derived from this software 34 | + * without specific prior written permission. 35 | + * 36 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 37 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 39 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 40 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 41 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 42 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 44 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 45 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 46 | + * SUCH DAMAGE. 47 | + * 48 | + * @(#)syslog.h 8.1 (Berkeley) 6/2/93 49 | + * 50 | + * 2011/7/5 - DD - modified to fit android Bionic environment 51 | + */ 52 | + 53 | +#ifndef _SYS_SYSLOG_H 54 | +#define _SYS_SYSLOG_H 1 55 | + 56 | +#include 57 | +#define __need___va_list 58 | +#include 59 | + 60 | +/* 61 | + * priorities/facilities are encoded into a single 32-bit quantity, where the 62 | + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 63 | + * (0-big number). Both the priorities and the facilities map roughly 64 | + * one-to-one to strings in the syslogd(8) source code. This mapping is 65 | + * included in this file. 66 | + * 67 | + * priorities (these are ordered) 68 | + */ 69 | +#define LOG_EMERG 0 /* system is unusable */ 70 | +#define LOG_ALERT 1 /* action must be taken immediately */ 71 | +#define LOG_CRIT 2 /* critical conditions */ 72 | +#define LOG_ERR 3 /* error conditions */ 73 | +#define LOG_WARNING 4 /* warning conditions */ 74 | +#define LOG_NOTICE 5 /* normal but significant condition */ 75 | +#define LOG_INFO 6 /* informational */ 76 | +#define LOG_DEBUG 7 /* debug-level messages */ 77 | + 78 | +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) 79 | + 80 | +#ifdef SYSLOG_NAMES 81 | +#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ 82 | + /* mark "facility" */ 83 | +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) 84 | +typedef struct _code { 85 | + char *c_name; 86 | + int c_val; 87 | +} CODE; 88 | + 89 | +CODE prioritynames[] = 90 | + { 91 | + { "alert", LOG_ALERT }, 92 | + { "crit", LOG_CRIT }, 93 | + { "debug", LOG_DEBUG }, 94 | + { "emerg", LOG_EMERG }, 95 | + { "err", LOG_ERR }, 96 | + { "error", LOG_ERR }, /* DEPRECATED */ 97 | + { "info", LOG_INFO }, 98 | + { "none", INTERNAL_NOPRI }, /* INTERNAL */ 99 | + { "notice", LOG_NOTICE }, 100 | + { "panic", LOG_EMERG }, /* DEPRECATED */ 101 | + { "warn", LOG_WARNING }, /* DEPRECATED */ 102 | + { "warning", LOG_WARNING }, 103 | + { NULL, -1 } 104 | + }; 105 | +#endif 106 | + 107 | +#define LOG_NFACILITIES 24 /* current number of facilities */ 108 | + 109 | +#ifdef SYSLOG_NAMES 110 | +CODE facilitynames[] = 111 | + { 112 | + { "auth", LOG_AUTH }, 113 | + { "authpriv", LOG_AUTHPRIV }, 114 | + { "cron", LOG_CRON }, 115 | + { "daemon", LOG_DAEMON }, 116 | + { "ftp", LOG_FTP }, 117 | + { "kern", LOG_KERN }, 118 | + { "lpr", LOG_LPR }, 119 | + { "mail", LOG_MAIL }, 120 | + { "mark", INTERNAL_MARK }, /* INTERNAL */ 121 | + { "news", LOG_NEWS }, 122 | + { "security", LOG_AUTH }, /* DEPRECATED */ 123 | + { "syslog", LOG_SYSLOG }, 124 | + { "user", LOG_USER }, 125 | + { "uucp", LOG_UUCP }, 126 | + { "local0", LOG_LOCAL0 }, 127 | + { "local1", LOG_LOCAL1 }, 128 | + { "local2", LOG_LOCAL2 }, 129 | + { "local3", LOG_LOCAL3 }, 130 | + { "local4", LOG_LOCAL4 }, 131 | + { "local5", LOG_LOCAL5 }, 132 | + { "local6", LOG_LOCAL6 }, 133 | + { "local7", LOG_LOCAL7 }, 134 | + { NULL, -1 } 135 | + }; 136 | +#endif 137 | + 138 | +/* 139 | + * arguments to setlogmask. 140 | + */ 141 | +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 142 | +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 143 | + 144 | +/* 145 | + * Option flags for openlog. 146 | + * 147 | + * LOG_ODELAY no longer does anything. 148 | + * LOG_NDELAY is the inverse of what it used to be. 149 | + */ 150 | +#define LOG_PID 0x01 /* log the pid with each message */ 151 | +#define LOG_CONS 0x02 /* log on the console if errors in sending */ 152 | +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 153 | +#define LOG_NDELAY 0x08 /* don't delay open */ 154 | +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 155 | +#define LOG_PERROR 0x20 /* log to stderr as well */ 156 | + 157 | +#endif /* sys/syslog.h */ 158 | diff --git a/sysklogd/syslogd_and_logger.c b/sysklogd/syslogd_and_logger.c 159 | index 0964f23..81c8909 100644 160 | --- a/sysklogd/syslogd_and_logger.c 161 | +++ b/sysklogd/syslogd_and_logger.c 162 | @@ -11,6 +11,7 @@ 163 | #define SYSLOG_NAMES 164 | #define SYSLOG_NAMES_CONST 165 | #include 166 | +#include 167 | 168 | #if 0 169 | /* For the record: with SYSLOG_NAMES defines 170 | -- 171 | 1.7.10.4 172 | 173 | -------------------------------------------------------------------------------- /patches/021-fsck.minix-mkfs.minix.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Sun, 18 Feb 2018 07:54:58 -0400 3 | Subject: [PATCH] fix fsck.minix, mkfs.minix: undef HAVE_SETBIT, 4 | MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC 5 | 6 | "there is no setbit/clrbit in bionic" 7 | "MINIX2_SUPER_MAGIC / MINIX2_SUPER_MAGIC2 defined in sys/vfs.h, undefine 8 | it to use it in the enum" 9 | 10 | Patch by Tias Guns , based on 'no-setbit' and 11 | 'undefine-minix2-magic-to-use-in-enum' by Dan Drown 12 | http://dan.drown.org/android/src/busybox/ 13 | Rebased for busybox 1.28.1 by Chris Renshaw 14 | --- 15 | include/platform.h | 1 + 16 | util-linux/minix.h | 2 ++ 17 | 2 files changed, 3 insertions(+) 18 | 19 | diff --git a/include/platform.h b/include/platform.h 20 | index 3873d84fc..9e9ffa782 100644 21 | --- a/include/platform.h 22 | +++ b/include/platform.h 23 | @@ -534,6 +534,7 @@ typedef unsigned smalluint; 24 | # undef HAVE_UNLOCKED_LINE_OPS 25 | # undef HAVE_NET_ETHERNET_H 26 | # undef HAVE_PRINTF_PERCENTM 27 | +# undef HAVE_SETBIT 28 | #endif 29 | 30 | /* 31 | diff --git a/util-linux/minix.h b/util-linux/minix.h 32 | index 83ffe6da5..91ced691c 100644 33 | --- a/util-linux/minix.h 34 | +++ b/util-linux/minix.h 35 | @@ -54,6 +54,8 @@ struct minix_dir_entry { 36 | /* Believe it or not, but mount.h has this one #defined */ 37 | #undef BLOCK_SIZE 38 | 39 | +#undef MINIX2_SUPER_MAGIC 40 | +#undef MINIX2_SUPER_MAGIC2 41 | enum { 42 | BLOCK_SIZE = 1024, 43 | BITS_PER_BLOCK = BLOCK_SIZE << 3, 44 | -- 45 | 2.16.1 46 | 47 | -------------------------------------------------------------------------------- /patches/022-a-ipv6.patch: -------------------------------------------------------------------------------- 1 | From: Tias Guns 2 | Date: Mon, 19 Mar 2012 18:24:29 +0000 3 | Subject: [PATCH] fix ipv6, add ipv6_route.h 4 | 5 | from 'in6_rtmsg' by Dan Drown 6 | "in6_rtmsg defined in linux/ipv6_route.h" 7 | http://dan.drown.org/android/src/busybox/ 8 | --- 9 | include/linux/ipv6_route.h | 58 ++++++++++++++++++++++++++++++++++++++++++++ 10 | networking/ifconfig.c | 2 + 11 | networking/route.c | 2 + 12 | 3 files changed, 62 insertions(+), 0 deletions(-) 13 | create mode 100644 include/linux/ipv6_route.h 14 | 15 | diff --git a/include/linux/ipv6_route.h b/include/linux/ipv6_route.h 16 | new file mode 100644 17 | index 0000000..144875d 18 | --- /dev/null 19 | +++ b/include/linux/ipv6_route.h 20 | @@ -0,0 +1,58 @@ 21 | +/* 22 | + * Linux INET6 implementation 23 | + * 24 | + * Authors: 25 | + * Pedro Roque 26 | + * 27 | + * This program is free software; you can redistribute it and/or 28 | + * modify it under the terms of the GNU General Public License 29 | + * as published by the Free Software Foundation; either version 30 | + * 2 of the License, or (at your option) any later version. 31 | + */ 32 | + 33 | +#ifndef _LINUX_IPV6_ROUTE_H 34 | +#define _LINUX_IPV6_ROUTE_H 35 | + 36 | +#include 37 | + 38 | +#define RTF_DEFAULT 0x00010000 /* default - learned via ND */ 39 | +#define RTF_ALLONLINK 0x00020000 /* (deprecated and will be removed) 40 | + fallback, no routers on link */ 41 | +#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */ 42 | +#define RTF_PREFIX_RT 0x00080000 /* A prefix only route - RA */ 43 | +#define RTF_ANYCAST 0x00100000 /* Anycast */ 44 | + 45 | +#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */ 46 | +#define RTF_EXPIRES 0x00400000 47 | + 48 | +#define RTF_ROUTEINFO 0x00800000 /* route information - RA */ 49 | + 50 | +#define RTF_CACHE 0x01000000 /* cache entry */ 51 | +#define RTF_FLOW 0x02000000 /* flow significant route */ 52 | +#define RTF_POLICY 0x04000000 /* policy route */ 53 | + 54 | +#define RTF_PREF(pref) ((pref) << 27) 55 | +#define RTF_PREF_MASK 0x18000000 56 | + 57 | +#define RTF_LOCAL 0x80000000 58 | + 59 | + 60 | +struct in6_rtmsg { 61 | + struct in6_addr rtmsg_dst; 62 | + struct in6_addr rtmsg_src; 63 | + struct in6_addr rtmsg_gateway; 64 | + __u32 rtmsg_type; 65 | + __u16 rtmsg_dst_len; 66 | + __u16 rtmsg_src_len; 67 | + __u32 rtmsg_metric; 68 | + unsigned long rtmsg_info; 69 | + __u32 rtmsg_flags; 70 | + int rtmsg_ifindex; 71 | +}; 72 | + 73 | +#define RTMSG_NEWDEVICE 0x11 74 | +#define RTMSG_DELDEVICE 0x12 75 | +#define RTMSG_NEWROUTE 0x21 76 | +#define RTMSG_DELROUTE 0x22 77 | + 78 | +#endif 79 | diff --git a/networking/ifconfig.c b/networking/ifconfig.c 80 | index b6604f5..12e8198 100644 81 | --- a/networking/ifconfig.c 82 | +++ b/networking/ifconfig.c 83 | @@ -79,12 +79,14 @@ 84 | #endif 85 | 86 | #if ENABLE_FEATURE_IPV6 87 | +#ifndef __BIONIC__ 88 | struct in6_ifreq { 89 | struct in6_addr ifr6_addr; 90 | uint32_t ifr6_prefixlen; 91 | int ifr6_ifindex; 92 | }; 93 | #endif 94 | +#endif 95 | 96 | /* 97 | * Here are the bit masks for the "flags" member of struct options below. 98 | diff --git a/networking/route.c b/networking/route.c 99 | index b7b5a02..a060eb2 100644 100 | --- a/networking/route.c 101 | +++ b/networking/route.c 102 | @@ -35,6 +35,8 @@ 103 | 104 | #include 105 | #include 106 | +#include 107 | +#include 108 | 109 | #include "libbb.h" 110 | #include "inet_common.h" 111 | -- 112 | 1.7.0.4 113 | 114 | -------------------------------------------------------------------------------- /patches/022-b-interface-route.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Thu, 6 May 2021 16:09:06 -0300 3 | Subject: [PATCH] additional fix-up for IPV6 on Android API 21+ 4 | 5 | fixes: networking/interface.c:62:8: error: redefinition of 'struct in6_ifreq' 6 | 7 | and: 8 | error: field 'ifru_addr' has incomplete type 9 | struct sockaddr ifru_addr; 10 | error: field 'ifru_dstaddr' has incomplete type 11 | struct sockaddr ifru_dstaddr; 12 | ... 13 | since sockaddr was moved from linux/socket.h to sys/socket.h in newer NDK revisions 14 | --- 15 | networking/interface.c | 2 ++ 16 | networking/route.c | 1 + 17 | 2 files changed, 3 insertions(+) 18 | 19 | diff --git a/networking/interface.c b/networking/interface.c 20 | index ea6a2c8a8..6f0716680 100644 21 | --- a/networking/interface.c 22 | +++ b/networking/interface.c 23 | @@ -55,6 +55,7 @@ 24 | 25 | #ifdef HAVE_AFINET6 26 | # ifndef _LINUX_IN6_H 27 | +# ifndef __BIONIC__ 28 | /* 29 | * This is from linux/include/net/ipv6.h 30 | */ 31 | @@ -63,6 +64,7 @@ struct in6_ifreq { 32 | uint32_t ifr6_prefixlen; 33 | unsigned int ifr6_ifindex; 34 | }; 35 | +# endif 36 | # endif 37 | #endif /* HAVE_AFINET6 */ 38 | 39 | diff --git a/networking/route.c b/networking/route.c 40 | index 89617db9d..f20070889 100644 41 | --- a/networking/route.c 42 | +++ b/networking/route.c 43 | @@ -36,6 +36,7 @@ 44 | 45 | #include 46 | #include 47 | +#include 48 | #include 49 | #include 50 | 51 | -- 52 | 2.31.1 53 | 54 | -------------------------------------------------------------------------------- /patches/022-c-d6_dhcpc-d6_socket.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Wed, 19 Jul 2017 17:22:55 -0300 3 | Subject: [PATCH] fix udhcpc6: add missing ifaddrs.h and getifaddrs/freeifaddrs functions 4 | 5 | ifaddrs implementation from 'android-ifaddrs' by Kenneth MacKay: 6 | https://github.com/morristech/android-ifaddrs 7 | --- 8 | networking/udhcp/d6_dhcpc.c | 1 + 9 | networking/udhcp/d6_socket.c | 2 +- 10 | networking/udhcp/ifaddrs.c | 600 +++++++++++++++++++++++++++++++++++++++++++ 11 | networking/udhcp/ifaddrs.h | 54 ++++ 12 | 4 files changed, 656 insertions(+), 1 deletion(-) 13 | create mode 100644 networking/udhcp/ifaddrs.c 14 | create mode 100644 networking/udhcp/ifaddrs.h 15 | 16 | diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c 17 | index f6d3fb98b..be9787947 100644 18 | --- a/networking/udhcp/d6_dhcpc.c 19 | +++ b/networking/udhcp/d6_dhcpc.c 20 | @@ -43,6 +43,7 @@ 21 | //applet:IF_UDHCPC6(APPLET(udhcpc6, BB_DIR_USR_BIN, BB_SUID_DROP)) 22 | 23 | //kbuild:lib-$(CONFIG_UDHCPC6) += d6_dhcpc.o d6_packet.o d6_socket.o common.o socket.o signalpipe.o 24 | +//kbuild:lib-$(CONFIG_UDHCPC6) += ifaddrs.o 25 | //kbuild:lib-$(CONFIG_FEATURE_UDHCPC6_RFC3646) += domain_codec.o 26 | //kbuild:lib-$(CONFIG_FEATURE_UDHCPC6_RFC4704) += domain_codec.o 27 | 28 | diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c 29 | index 930e5e4f5..1da84fda1 100644 30 | --- a/networking/udhcp/d6_socket.c 31 | +++ b/networking/udhcp/d6_socket.c 32 | @@ -7,7 +7,7 @@ 33 | #include "common.h" 34 | #include "d6_common.h" 35 | #include 36 | -#include 37 | +#include "ifaddrs.h" 38 | #include 39 | 40 | int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_addr *nip6, uint8_t *mac) 41 | diff --git a/networking/udhcp/ifaddrs.c b/networking/udhcp/ifaddrs.c 42 | new file mode 100644 43 | index 000000000..338fff887 44 | --- /dev/null 45 | +++ b/networking/udhcp/ifaddrs.c 46 | @@ -0,0 +1,600 @@ 47 | +/* 48 | +Copyright (c) 2013, Kenneth MacKay 49 | +All rights reserved. 50 | + 51 | +Redistribution and use in source and binary forms, with or without modification, 52 | +are permitted provided that the following conditions are met: 53 | + * Redistributions of source code must retain the above copyright notice, this 54 | + list of conditions and the following disclaimer. 55 | + * Redistributions in binary form must reproduce the above copyright notice, 56 | + this list of conditions and the following disclaimer in the documentation 57 | + and/or other materials provided with the distribution. 58 | + 59 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 60 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 61 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 62 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 63 | +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 64 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 65 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 66 | +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 68 | +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69 | +*/ 70 | + 71 | +#include "ifaddrs.h" 72 | + 73 | +#include 74 | +#include 75 | +#include 76 | +#include 77 | +#include 78 | +#include 79 | +#include 80 | +#include 81 | +#include 82 | + 83 | +typedef struct NetlinkList 84 | +{ 85 | + struct NetlinkList *m_next; 86 | + struct nlmsghdr *m_data; 87 | + unsigned int m_size; 88 | +} NetlinkList; 89 | + 90 | +static int netlink_socket(void) 91 | +{ 92 | + int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); 93 | + if(l_socket < 0) 94 | + { 95 | + return -1; 96 | + } 97 | + 98 | + struct sockaddr_nl l_addr; 99 | + memset(&l_addr, 0, sizeof(l_addr)); 100 | + l_addr.nl_family = AF_NETLINK; 101 | + if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0) 102 | + { 103 | + close(l_socket); 104 | + return -1; 105 | + } 106 | + 107 | + return l_socket; 108 | +} 109 | + 110 | +static int netlink_send(int p_socket, int p_request) 111 | +{ 112 | + char l_buffer[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct rtgenmsg))]; 113 | + memset(l_buffer, 0, sizeof(l_buffer)); 114 | + struct nlmsghdr *l_hdr = (struct nlmsghdr *)l_buffer; 115 | + struct rtgenmsg *l_msg = (struct rtgenmsg *)NLMSG_DATA(l_hdr); 116 | + 117 | + l_hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*l_msg)); 118 | + l_hdr->nlmsg_type = p_request; 119 | + l_hdr->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST; 120 | + l_hdr->nlmsg_pid = 0; 121 | + l_hdr->nlmsg_seq = p_socket; 122 | + l_msg->rtgen_family = AF_UNSPEC; 123 | + 124 | + struct sockaddr_nl l_addr; 125 | + memset(&l_addr, 0, sizeof(l_addr)); 126 | + l_addr.nl_family = AF_NETLINK; 127 | + return (sendto(p_socket, l_hdr, l_hdr->nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr))); 128 | +} 129 | + 130 | +static int netlink_recv(int p_socket, void *p_buffer, size_t p_len) 131 | +{ 132 | + struct msghdr l_msg; 133 | + struct iovec l_iov = { p_buffer, p_len }; 134 | + struct sockaddr_nl l_addr; 135 | + int l_result; 136 | + 137 | + for(;;) 138 | + { 139 | + l_msg.msg_name = (void *)&l_addr; 140 | + l_msg.msg_namelen = sizeof(l_addr); 141 | + l_msg.msg_iov = &l_iov; 142 | + l_msg.msg_iovlen = 1; 143 | + l_msg.msg_control = NULL; 144 | + l_msg.msg_controllen = 0; 145 | + l_msg.msg_flags = 0; 146 | + int l_result = recvmsg(p_socket, &l_msg, 0); 147 | + 148 | + if(l_result < 0) 149 | + { 150 | + if(errno == EINTR) 151 | + { 152 | + continue; 153 | + } 154 | + return -2; 155 | + } 156 | + 157 | + if(l_msg.msg_flags & MSG_TRUNC) 158 | + { // buffer was too small 159 | + return -1; 160 | + } 161 | + return l_result; 162 | + } 163 | +} 164 | + 165 | +static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done) 166 | +{ 167 | + size_t l_size = 4096; 168 | + void *l_buffer = NULL; 169 | + 170 | + for(;;) 171 | + { 172 | + free(l_buffer); 173 | + l_buffer = malloc(l_size); 174 | + 175 | + int l_read = netlink_recv(p_socket, l_buffer, l_size); 176 | + *p_size = l_read; 177 | + if(l_read == -2) 178 | + { 179 | + free(l_buffer); 180 | + return NULL; 181 | + } 182 | + if(l_read >= 0) 183 | + { 184 | + pid_t l_pid = getpid(); 185 | + struct nlmsghdr *l_hdr; 186 | + 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)) 187 | + { 188 | + if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) 189 | + { 190 | + continue; 191 | + } 192 | + 193 | + if(l_hdr->nlmsg_type == NLMSG_DONE) 194 | + { 195 | + *p_done = 1; 196 | + break; 197 | + } 198 | + 199 | + if(l_hdr->nlmsg_type == NLMSG_ERROR) 200 | + { 201 | + free(l_buffer); 202 | + return NULL; 203 | + } 204 | + } 205 | + return l_buffer; 206 | + } 207 | + 208 | + l_size *= 2; 209 | + } 210 | +} 211 | + 212 | +static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size) 213 | +{ 214 | + NetlinkList *l_item = malloc(sizeof(NetlinkList)); 215 | + l_item->m_next = NULL; 216 | + l_item->m_data = p_data; 217 | + l_item->m_size = p_size; 218 | + return l_item; 219 | +} 220 | + 221 | +static void freeResultList(NetlinkList *p_list) 222 | +{ 223 | + NetlinkList *l_cur; 224 | + while(p_list) 225 | + { 226 | + l_cur = p_list; 227 | + p_list = p_list->m_next; 228 | + free(l_cur->m_data); 229 | + free(l_cur); 230 | + } 231 | +} 232 | + 233 | +static NetlinkList *getResultList(int p_socket, int p_request) 234 | +{ 235 | + if(netlink_send(p_socket, p_request) < 0) 236 | + { 237 | + return NULL; 238 | + } 239 | + 240 | + NetlinkList *l_list = NULL; 241 | + NetlinkList *l_end = NULL; 242 | + int l_size; 243 | + int l_done = 0; 244 | + while(!l_done) 245 | + { 246 | + struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done); 247 | + if(!l_hdr) 248 | + { // error 249 | + freeResultList(l_list); 250 | + return NULL; 251 | + } 252 | + 253 | + NetlinkList *l_item = newListItem(l_hdr, l_size); 254 | + if(!l_list) 255 | + { 256 | + l_list = l_item; 257 | + } 258 | + else 259 | + { 260 | + l_end->m_next = l_item; 261 | + } 262 | + l_end = l_item; 263 | + } 264 | + return l_list; 265 | +} 266 | + 267 | +static size_t maxSize(size_t a, size_t b) 268 | +{ 269 | + return (a > b ? a : b); 270 | +} 271 | + 272 | +static size_t calcAddrLen(sa_family_t p_family, int p_dataSize) 273 | +{ 274 | + switch(p_family) 275 | + { 276 | + case AF_INET: 277 | + return sizeof(struct sockaddr_in); 278 | + case AF_INET6: 279 | + return sizeof(struct sockaddr_in6); 280 | + case AF_PACKET: 281 | + return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize); 282 | + default: 283 | + return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize); 284 | + } 285 | +} 286 | + 287 | +static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size) 288 | +{ 289 | + switch(p_family) 290 | + { 291 | + case AF_INET: 292 | + memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size); 293 | + break; 294 | + case AF_INET6: 295 | + memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size); 296 | + break; 297 | + case AF_PACKET: 298 | + memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size); 299 | + ((struct sockaddr_ll*)p_dest)->sll_halen = p_size; 300 | + break; 301 | + default: 302 | + memcpy(p_dest->sa_data, p_data, p_size); 303 | + break; 304 | + } 305 | + p_dest->sa_family = p_family; 306 | +} 307 | + 308 | +static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry) 309 | +{ 310 | + if(!*p_resultList) 311 | + { 312 | + *p_resultList = p_entry; 313 | + } 314 | + else 315 | + { 316 | + struct ifaddrs *l_cur = *p_resultList; 317 | + while(l_cur->ifa_next) 318 | + { 319 | + l_cur = l_cur->ifa_next; 320 | + } 321 | + l_cur->ifa_next = p_entry; 322 | + } 323 | +} 324 | + 325 | +static void interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, struct ifaddrs **p_resultList) 326 | +{ 327 | + struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr); 328 | + 329 | + size_t l_nameSize = 0; 330 | + size_t l_addrSize = 0; 331 | + size_t l_dataSize = 0; 332 | + 333 | + size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); 334 | + struct rtattr *l_rta; 335 | + 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)) 336 | + { 337 | + void *l_rtaData = RTA_DATA(l_rta); 338 | + size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); 339 | + switch(l_rta->rta_type) 340 | + { 341 | + case IFLA_ADDRESS: 342 | + case IFLA_BROADCAST: 343 | + l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize)); 344 | + break; 345 | + case IFLA_IFNAME: 346 | + l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); 347 | + break; 348 | + case IFLA_STATS: 349 | + l_dataSize += NLMSG_ALIGN(l_rtaSize); 350 | + break; 351 | + default: 352 | + break; 353 | + } 354 | + } 355 | + 356 | + struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize + l_dataSize); 357 | + memset(l_entry, 0, sizeof(struct ifaddrs)); 358 | + l_entry->ifa_name = ""; 359 | + 360 | + char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs); 361 | + char *l_addr = l_name + l_nameSize; 362 | + char *l_data = l_addr + l_addrSize; 363 | + 364 | + l_entry->ifa_flags = l_info->ifi_flags; 365 | + 366 | + l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg)); 367 | + 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)) 368 | + { 369 | + void *l_rtaData = RTA_DATA(l_rta); 370 | + size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); 371 | + switch(l_rta->rta_type) 372 | + { 373 | + case IFLA_ADDRESS: 374 | + case IFLA_BROADCAST: 375 | + { 376 | + size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize); 377 | + makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); 378 | + ((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index; 379 | + ((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type; 380 | + if(l_rta->rta_type == IFLA_ADDRESS) 381 | + { 382 | + l_entry->ifa_addr = (struct sockaddr *)l_addr; 383 | + } 384 | + else 385 | + { 386 | + l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; 387 | + } 388 | + l_addr += NLMSG_ALIGN(l_addrLen); 389 | + break; 390 | + } 391 | + case IFLA_IFNAME: 392 | + strncpy(l_name, l_rtaData, l_rtaDataSize); 393 | + l_name[l_rtaDataSize] = '\0'; 394 | + l_entry->ifa_name = l_name; 395 | + break; 396 | + case IFLA_STATS: 397 | + memcpy(l_data, l_rtaData, l_rtaDataSize); 398 | + l_entry->ifa_data = l_data; 399 | + break; 400 | + default: 401 | + break; 402 | + } 403 | + } 404 | + 405 | + addToEnd(p_resultList, l_entry); 406 | + p_links[l_info->ifi_index - 1] = l_entry; 407 | +} 408 | + 409 | +static void interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_links, struct ifaddrs **p_resultList) 410 | +{ 411 | + struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr); 412 | + 413 | + size_t l_nameSize = 0; 414 | + size_t l_addrSize = 0; 415 | + 416 | + int l_addedNetmask = 0; 417 | + 418 | + size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); 419 | + struct rtattr *l_rta; 420 | + 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)) 421 | + { 422 | + void *l_rtaData = RTA_DATA(l_rta); 423 | + size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); 424 | + if(l_info->ifa_family == AF_PACKET) 425 | + { 426 | + continue; 427 | + } 428 | + 429 | + switch(l_rta->rta_type) 430 | + { 431 | + case IFA_ADDRESS: 432 | + case IFA_LOCAL: 433 | + if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask) 434 | + { // make room for netmask 435 | + l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); 436 | + l_addedNetmask = 1; 437 | + } 438 | + case IFA_BROADCAST: 439 | + l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize)); 440 | + break; 441 | + case IFA_LABEL: 442 | + l_nameSize += NLMSG_ALIGN(l_rtaSize + 1); 443 | + break; 444 | + default: 445 | + break; 446 | + } 447 | + } 448 | + 449 | + struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize); 450 | + memset(l_entry, 0, sizeof(struct ifaddrs)); 451 | + l_entry->ifa_name = p_links[l_info->ifa_index - 1]->ifa_name; 452 | + 453 | + char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs); 454 | + char *l_addr = l_name + l_nameSize; 455 | + 456 | + l_entry->ifa_flags = l_info->ifa_flags | p_links[l_info->ifa_index - 1]->ifa_flags; 457 | + 458 | + l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg)); 459 | + 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)) 460 | + { 461 | + void *l_rtaData = RTA_DATA(l_rta); 462 | + size_t l_rtaDataSize = RTA_PAYLOAD(l_rta); 463 | + switch(l_rta->rta_type) 464 | + { 465 | + case IFA_ADDRESS: 466 | + case IFA_BROADCAST: 467 | + case IFA_LOCAL: 468 | + { 469 | + size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize); 470 | + makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize); 471 | + if(l_info->ifa_family == AF_INET6) 472 | + { 473 | + if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData)) 474 | + { 475 | + ((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index; 476 | + } 477 | + } 478 | + 479 | + if(l_rta->rta_type == IFA_ADDRESS) 480 | + { // apparently in a point-to-point network IFA_ADDRESS contains the dest address and IFA_LOCAL contains the local address 481 | + if(l_entry->ifa_addr) 482 | + { 483 | + l_entry->ifa_dstaddr = (struct sockaddr *)l_addr; 484 | + } 485 | + else 486 | + { 487 | + l_entry->ifa_addr = (struct sockaddr *)l_addr; 488 | + } 489 | + } 490 | + else if(l_rta->rta_type == IFA_LOCAL) 491 | + { 492 | + if(l_entry->ifa_addr) 493 | + { 494 | + l_entry->ifa_dstaddr = l_entry->ifa_addr; 495 | + } 496 | + l_entry->ifa_addr = (struct sockaddr *)l_addr; 497 | + } 498 | + else 499 | + { 500 | + l_entry->ifa_broadaddr = (struct sockaddr *)l_addr; 501 | + } 502 | + l_addr += NLMSG_ALIGN(l_addrLen); 503 | + break; 504 | + } 505 | + case IFA_LABEL: 506 | + strncpy(l_name, l_rtaData, l_rtaDataSize); 507 | + l_name[l_rtaDataSize] = '\0'; 508 | + l_entry->ifa_name = l_name; 509 | + break; 510 | + default: 511 | + break; 512 | + } 513 | + } 514 | + 515 | + if(l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6)) 516 | + { 517 | + unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128); 518 | + unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen); 519 | + char l_mask[16] = {0}; 520 | + unsigned i; 521 | + for(i=0; i<(l_prefix/8); ++i) 522 | + { 523 | + l_mask[i] = 0xff; 524 | + } 525 | + l_mask[i] = 0xff << (8 - (l_prefix % 8)); 526 | + 527 | + makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8); 528 | + l_entry->ifa_netmask = (struct sockaddr *)l_addr; 529 | + } 530 | + 531 | + addToEnd(p_resultList, l_entry); 532 | +} 533 | + 534 | +static void interpret(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_links, struct ifaddrs **p_resultList) 535 | +{ 536 | + pid_t l_pid = getpid(); 537 | + for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) 538 | + { 539 | + unsigned int l_nlsize = p_netlinkList->m_size; 540 | + struct nlmsghdr *l_hdr; 541 | + for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) 542 | + { 543 | + if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) 544 | + { 545 | + continue; 546 | + } 547 | + 548 | + if(l_hdr->nlmsg_type == NLMSG_DONE) 549 | + { 550 | + break; 551 | + } 552 | + 553 | + if(l_hdr->nlmsg_type == RTM_NEWLINK) 554 | + { 555 | + interpretLink(l_hdr, p_links, p_resultList); 556 | + } 557 | + else if(l_hdr->nlmsg_type == RTM_NEWADDR) 558 | + { 559 | + interpretAddr(l_hdr, p_links, p_resultList); 560 | + } 561 | + } 562 | + } 563 | +} 564 | + 565 | +static unsigned countLinks(int p_socket, NetlinkList *p_netlinkList) 566 | +{ 567 | + unsigned l_links = 0; 568 | + pid_t l_pid = getpid(); 569 | + for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next) 570 | + { 571 | + unsigned int l_nlsize = p_netlinkList->m_size; 572 | + struct nlmsghdr *l_hdr; 573 | + for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize)) 574 | + { 575 | + if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket) 576 | + { 577 | + continue; 578 | + } 579 | + 580 | + if(l_hdr->nlmsg_type == NLMSG_DONE) 581 | + { 582 | + break; 583 | + } 584 | + 585 | + if(l_hdr->nlmsg_type == RTM_NEWLINK) 586 | + { 587 | + ++l_links; 588 | + } 589 | + } 590 | + } 591 | + 592 | + return l_links; 593 | +} 594 | + 595 | +int getifaddrs(struct ifaddrs **ifap) 596 | +{ 597 | + if(!ifap) 598 | + { 599 | + return -1; 600 | + } 601 | + *ifap = NULL; 602 | + 603 | + int l_socket = netlink_socket(); 604 | + if(l_socket < 0) 605 | + { 606 | + return -1; 607 | + } 608 | + 609 | + NetlinkList *l_linkResults = getResultList(l_socket, RTM_GETLINK); 610 | + if(!l_linkResults) 611 | + { 612 | + close(l_socket); 613 | + return -1; 614 | + } 615 | + 616 | + NetlinkList *l_addrResults = getResultList(l_socket, RTM_GETADDR); 617 | + if(!l_addrResults) 618 | + { 619 | + close(l_socket); 620 | + freeResultList(l_linkResults); 621 | + return -1; 622 | + } 623 | + 624 | + unsigned l_numLinks = countLinks(l_socket, l_linkResults) + countLinks(l_socket, l_addrResults); 625 | + struct ifaddrs *l_links[l_numLinks]; 626 | + memset(l_links, 0, l_numLinks * sizeof(struct ifaddrs *)); 627 | + 628 | + interpret(l_socket, l_linkResults, l_links, ifap); 629 | + interpret(l_socket, l_addrResults, l_links, ifap); 630 | + 631 | + freeResultList(l_linkResults); 632 | + freeResultList(l_addrResults); 633 | + close(l_socket); 634 | + return 0; 635 | +} 636 | + 637 | +void freeifaddrs(struct ifaddrs *ifa) 638 | +{ 639 | + struct ifaddrs *l_cur; 640 | + while(ifa) 641 | + { 642 | + l_cur = ifa; 643 | + ifa = ifa->ifa_next; 644 | + free(l_cur); 645 | + } 646 | +} 647 | diff --git a/networking/udhcp/ifaddrs.h b/networking/udhcp/ifaddrs.h 648 | new file mode 100644 649 | index 000000000..9cd19fec1 650 | --- /dev/null 651 | +++ b/networking/udhcp/ifaddrs.h 652 | @@ -0,0 +1,54 @@ 653 | +/* 654 | + * Copyright (c) 1995, 1999 655 | + * Berkeley Software Design, Inc. All rights reserved. 656 | + * 657 | + * Redistribution and use in source and binary forms, with or without 658 | + * modification, are permitted provided that the following conditions 659 | + * are met: 660 | + * 1. Redistributions of source code must retain the above copyright 661 | + * notice, this list of conditions and the following disclaimer. 662 | + * 663 | + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND 664 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 665 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 666 | + * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE 667 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 668 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 669 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 670 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 671 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 672 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 673 | + * SUCH DAMAGE. 674 | + * 675 | + * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp 676 | + */ 677 | + 678 | +#ifndef _IFADDRS_H_ 679 | +#define _IFADDRS_H_ 680 | + 681 | +struct ifaddrs { 682 | + struct ifaddrs *ifa_next; 683 | + char *ifa_name; 684 | + unsigned int ifa_flags; 685 | + struct sockaddr *ifa_addr; 686 | + struct sockaddr *ifa_netmask; 687 | + struct sockaddr *ifa_dstaddr; 688 | + void *ifa_data; 689 | +}; 690 | + 691 | +/* 692 | + * This may have been defined in . Note that if is 693 | + * to be included it must be included before this header file. 694 | + */ 695 | +#ifndef ifa_broadaddr 696 | +#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 697 | +#endif 698 | + 699 | +#include 700 | + 701 | +__BEGIN_DECLS 702 | +extern int getifaddrs(struct ifaddrs **ifap); 703 | +extern void freeifaddrs(struct ifaddrs *ifa); 704 | +__END_DECLS 705 | + 706 | +#endif 707 | -- 708 | 2.12.3 709 | 710 | -------------------------------------------------------------------------------- /patches/024-a-hush-platform.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Sat, 2 Oct 2021 01:11:12 -0300 3 | Subject: [PATCH] fix hush: add missing definitions on Android API 21+ 4 | 5 | platform FAST_FUNC adjustment to support NDK unified headers by John Wu 6 | 7 | issetugid is required for hush via glob.c; add the hacky pre-API 21 definition back 8 | 9 | Rebased for busybox 1.34.1 by Chris Renshaw 10 | --- 11 | include/platform.h | 10 +++++++++- 12 | libbb/platform.c | 8 ++++++++ 13 | 2 files changed, 17 insertions(+), 1 deletion(-) 14 | 15 | diff --git a/include/platform.h b/include/platform.h 16 | index 9e1fb047d..f248a4384 100644 17 | --- a/include/platform.h 18 | +++ b/include/platform.h 19 | @@ -124,7 +124,7 @@ 20 | * (-DFAST_FUNC= ) 21 | */ 22 | #ifndef FAST_FUNC 23 | -# if __GNUC_PREREQ(3,0) && defined(i386) 24 | +# if !defined(__ANDROID__) && __GNUC_PREREQ(3,0) && defined(i386) 25 | /* stdcall makes callee to pop arguments from stack, not caller */ 26 | # define FAST_FUNC __attribute__((regparm(3),stdcall)) 27 | /* #elif ... - add your favorite arch today! */ 28 | @@ -426,6 +426,7 @@ typedef unsigned smalluint; 29 | #define HAVE_SYS_STATFS_H 1 30 | #define HAVE_PRINTF_PERCENTM 1 31 | #define HAVE_WAIT3 1 32 | +#define HAVE_ISSETUGID 1 33 | #define HAVE_DEV_FD 1 34 | #define DEV_FD_PREFIX "/dev/fd/" 35 | 36 | @@ -533,6 +534,9 @@ typedef unsigned smalluint; 37 | # else 38 | /* ANDROID >= 21 has standard dprintf */ 39 | # endif 40 | +# if __ANDROID_API__ > 18 41 | +# undef HAVE_ISSETUGID 42 | +# endif 43 | # if __ANDROID_API__ < 21 44 | # undef HAVE_TTYNAME_R 45 | # undef HAVE_GETLINE 46 | @@ -632,4 +636,8 @@ extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC 47 | extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC; 48 | #endif 49 | 50 | +#ifndef HAVE_ISSETUGID 51 | +extern int issetugid(void) FAST_FUNC; 52 | +#endif 53 | + 54 | #endif 55 | diff --git a/libbb/platform.c b/libbb/platform.c 56 | index 7913353e2..b652a2112 100644 57 | --- a/libbb/platform.c 58 | +++ b/libbb/platform.c 59 | @@ -225,3 +225,11 @@ int ttyname_r(int fd, char *buf, size_t buflen) 60 | return 0; 61 | } 62 | #endif 63 | + 64 | +#ifndef HAVE_ISSETUGID 65 | +int issetugid(void) 66 | +{ 67 | + /* for Bionic, this is sufficient */ 68 | + return 0; 69 | +} 70 | +#endif 71 | -- 72 | 2.31.1 73 | 74 | -------------------------------------------------------------------------------- /patches/024-c-glob.patch: -------------------------------------------------------------------------------- 1 | From: John Wu 2 | Date: Sun, 12 Aug 2018 18:31:26 +0800 3 | Subject: [PATCH] glob: minor adjustments to support unified headers 4 | 5 | --- 6 | shell/glob.h | 6 +++--- 7 | 1 file changed, 3 insertions(+), 3 deletions(-) 8 | 9 | diff --git a/shell/glob.h b/shell/glob.h 10 | index e8e65786d..c274a8f6a 100644 11 | --- a/shell/glob.h 12 | +++ b/shell/glob.h 13 | @@ -47,7 +47,7 @@ 14 | #include 15 | //#include 16 | 17 | -#ifndef _SIZE_T_DECLARED 18 | +#if !defined(_SIZE_T_DECLARED) && !defined(__ANDROID__) 19 | typedef __size_t size_t; 20 | #define _SIZE_T_DECLARED 21 | #endif 22 | @@ -74,7 +74,7 @@ typedef struct { 23 | int (*gl_stat)(const char *, struct stat *); 24 | } glob_t; 25 | 26 | -#if __POSIX_VISIBLE >= 199209 27 | +#if __POSIX_VISIBLE >= 199209 || defined(__ANDROID__) 28 | /* Believed to have been introduced in 1003.2-1992 */ 29 | #define GLOB_APPEND 0x0001 /* Append to output from previous call. */ 30 | #define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ 31 | @@ -91,7 +91,7 @@ typedef struct { 32 | #define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ 33 | #endif /* __POSIX_VISIBLE >= 199209 */ 34 | 35 | -#if __BSD_VISIBLE 36 | +#if __BSD_VISIBLE || defined(__ANDROID__) 37 | #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ 38 | #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ 39 | #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ 40 | -------------------------------------------------------------------------------- /patches/026-modinfo-modprobe-without-utsrel.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Thu, 6 May 2021 16:30:26 -0300 3 | Subject: [PATCH] modinfo/modprobe: use ifdef block for android without-utsrel 4 | modules path 5 | 6 | and fixes the modules.dep requirement, it is now optional... 7 | 8 | Patch by Tanguy Pruvot 9 | Change-Id: Ifccb530fa23b021fd12e2395f5d0c66600b25c04 10 | from https://github.com/tpruvot/android_external_busybox 11 | 12 | and commit 2df42d3971f1e260e67c3fa4831cb9195fb276c4 13 | from https://github.com/tpruvot/android_external_busybox 14 | 15 | Rebased for busybox 1.33.1 by Chris Renshaw 16 | --- 17 | modutils/modinfo.c | 33 +++++++++++++++++++++++++++++---- 18 | modutils/modprobe.c | 18 +++++++++++++++++- 19 | 2 files changed, 46 insertions(+), 5 deletions(-) 20 | 21 | diff --git a/modutils/modinfo.c b/modutils/modinfo.c 22 | index d15772f0d..0b6a89329 100644 23 | --- a/modutils/modinfo.c 24 | +++ b/modutils/modinfo.c 25 | @@ -20,6 +20,10 @@ 26 | #include "libbb.h" 27 | #include "modutils.h" 28 | 29 | +#if defined(ANDROID) || defined(__ANDROID__) 30 | +#define DONT_USE_UTS_REL_FOLDER 31 | +#endif 32 | + 33 | static const char *const shortcuts[] ALIGN_PTR = { 34 | "filename", // -n 35 | "author", // -a 36 | @@ -63,7 +67,7 @@ static void modinfo(const char *path, const char *version, 37 | { 38 | size_t len; 39 | int j; 40 | - char *ptr, *the_module; 41 | + char *ptr, *fullpath, *the_module; 42 | char *allocated; 43 | int tags = option_mask32; 44 | 45 | @@ -74,8 +78,14 @@ static void modinfo(const char *path, const char *version, 46 | if (path[0] == '/') 47 | return; 48 | /* Newer depmod puts relative paths in modules.dep */ 49 | - path = allocated = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path); 50 | - the_module = xmalloc_open_zipped_read_close(path, &len); 51 | + fullpath = allocated = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path); 52 | + the_module = xmalloc_open_zipped_read_close(fullpath, &len); 53 | +#ifdef DONT_USE_UTS_REL_FOLDER 54 | + if (!the_module) { 55 | + fullpath = allocated = xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, path); 56 | + the_module = xmalloc_open_zipped_read_close(fullpath, &len); 57 | + } 58 | +#endif 59 | if (!the_module) { 60 | bb_error_msg("module '%s' not found", path); 61 | goto ret; 62 | @@ -156,9 +166,23 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) 63 | uname(&uts); 64 | parser = config_open2( 65 | xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE), 66 | - xfopen_for_read 67 | + fopen_for_read 68 | ); 69 | 70 | +#ifdef DONT_USE_UTS_REL_FOLDER 71 | + if (!parser) { 72 | + parser = config_open2( 73 | + xasprintf("%s/%s", CONFIG_DEFAULT_MODULES_DIR, CONFIG_DEFAULT_DEPMOD_FILE), 74 | + fopen_for_read 75 | + ); 76 | + } 77 | + 78 | + if (!parser) { 79 | + strcpy(uts.release,""); 80 | + goto no_modules_dep; 81 | + } 82 | +#endif 83 | + 84 | while (config_read(parser, tokens, 2, 1, "# \t", PARSE_NORMAL)) { 85 | colon = last_char_is(tokens[0], ':'); 86 | if (colon == NULL) 87 | @@ -175,6 +199,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) 88 | if (ENABLE_FEATURE_CLEAN_UP) 89 | config_close(parser); 90 | 91 | +no_modules_dep: 92 | for (i = 0; argv[i]; i++) { 93 | if (argv[i][0]) { 94 | modinfo(argv[i], uts.release, field); 95 | diff --git a/modutils/modprobe.c b/modutils/modprobe.c 96 | index c334186b8..eecccac1b 100644 97 | --- a/modutils/modprobe.c 98 | +++ b/modutils/modprobe.c 99 | @@ -172,6 +172,10 @@ static const char modprobe_longopts[] ALIGN1 = 100 | #define MODULE_FLAG_BLACKLISTED 0x0008 101 | #define MODULE_FLAG_BUILTIN 0x0010 102 | 103 | +#if defined(ANDROID) || defined(__ANDROID__) 104 | +#define DONT_USE_UTS_REL_FOLDER 105 | +#endif 106 | + 107 | struct globals { 108 | llist_t *probes; /* MEs of module(s) requested on cmdline */ 109 | #if ENABLE_FEATURE_CMDLINE_MODULE_OPTIONS 110 | @@ -474,10 +478,17 @@ static int do_modprobe(struct module_entry *m) 111 | #endif 112 | 113 | if (option_mask32 & OPT_SHOW_DEPS) { 114 | +#ifndef DONT_USE_UTS_REL_FOLDER 115 | printf(options ? "insmod %s/%s/%s %s\n" 116 | : "insmod %s/%s/%s\n", 117 | CONFIG_DEFAULT_MODULES_DIR, G.uts.release, fn, 118 | options); 119 | +#else 120 | + printf(options ? "insmod %s/%s %s\n" 121 | + : "insmod %s/%s\n", 122 | + CONFIG_DEFAULT_MODULES_DIR, fn, 123 | + options); 124 | +#endif 125 | free(options); 126 | continue; 127 | } 128 | @@ -559,6 +570,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) 129 | int rc; 130 | unsigned opt; 131 | struct module_entry *me; 132 | + struct stat info; 133 | 134 | INIT_G(); 135 | 136 | @@ -570,8 +582,12 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) 137 | 138 | /* Goto modules location */ 139 | xchdir(CONFIG_DEFAULT_MODULES_DIR); 140 | +#ifndef DONT_USE_UTS_REL_FOLDER 141 | uname(&G.uts); 142 | - xchdir(G.uts.release); 143 | + if (stat(G.uts.release, &info) == 0) { 144 | + xchdir(G.uts.release); 145 | + } 146 | +#endif 147 | 148 | if (opt & OPT_LIST_ONLY) { 149 | int i; 150 | -- 151 | 2.31.1 152 | 153 | -------------------------------------------------------------------------------- /patches/027-depmod-parameter.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 12 Sep 2016 16:55:01 -0300 3 | Subject: [PATCH] depmod: fix syntax with modules in parameter 4 | 5 | Patch by Tanguy Pruvot 6 | Change-Id: I21b8664db01cf0132db82f8d6caa1a0e77e71004 7 | from https://github.com/tpruvot/android_external_busybox 8 | Rebased for busybox 1.25.0 by Chris Renshaw 9 | --- 10 | modutils/depmod.c | 5 ++++- 11 | 1 file changed, 4 insertions(+), 1 deletion(-) 12 | 13 | diff --git a/modutils/depmod.c b/modutils/depmod.c 14 | index 9713aef..4050494 100644 15 | --- a/modutils/depmod.c 16 | +++ b/modutils/depmod.c 17 | @@ -37,7 +37,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA 18 | image = xmalloc_open_zipped_read_close(fname, &len); 19 | 20 | e = moddb_get_or_create(modules, bb_get_last_path_component_nostrip(fname)); 21 | - e->name = xstrdup(fname + 2); /* skip "./" */ 22 | + if (strncmp(fname, "./", 2) == 0) 23 | + e->name = xstrdup(fname + 2); 24 | + else 25 | + e->name = xstrdup(fname); 26 | 27 | for (ptr = image; ptr < image + len - 10; ptr++) { 28 | if (is_prefixed_with(ptr, "depends=")) { 29 | -- 30 | 2.8.3 31 | 32 | -------------------------------------------------------------------------------- /patches/028-reboot-poweroff.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 26 Jun 2017 23:53:06 -0300 3 | Subject: [PATCH] fix reboot+poweroff: hack android_reboot support 4 | 5 | based on 'reboot.c' and 'halt.c' patches from CyanogenMod: 6 | https://github.com/CyanogenMod/android_external_busybox/commit/8aeb3719294721f744239ced474d159f073eef55#diff-51036c2b1c4282b63402a0e0286a066a 7 | https://github.com/CyanogenMod/android_external_busybox/commit/8aeb3719294721f744239ced474d159f073eef55#diff-fa7fd08ce03ea9138df81c149792b371 8 | https://github.com/CyanogenMod/android_external_busybox/commit/d0b802581eb4f83e81b652f0b59b8b9b98105e66 9 | 10 | then updated and simplified using: 11 | https://github.com/android/platform_system_core/blob/master/libcutils/android_reboot.c 12 | https://github.com/android/platform_system_core/blob/master/libcutils/include/cutils/android_reboot.h 13 | 14 | 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 15 | --- 16 | init/halt.c | 27 +++++++++++++++++++++++++++ 17 | init/reboot.c | 33 +++++++++++++++++++++++++++++++++ 18 | 2 files changed, 60 insertions(+) 19 | create mode 100644 init/reboot.c 20 | 21 | diff --git a/init/halt.c b/init/halt.c 22 | index b7fb10869..5287be470 100644 23 | --- a/init/halt.c 24 | +++ b/init/halt.c 25 | @@ -83,6 +83,10 @@ 26 | #include "libbb.h" 27 | #include "reboot.h" 28 | 29 | +#ifdef __BIONIC__ 30 | +#include "reboot.c" 31 | +#endif 32 | + 33 | #if ENABLE_FEATURE_WTMP 34 | #include 35 | 36 | @@ -152,6 +156,29 @@ int halt_main(int argc UNUSED_PARAM, char **argv) 37 | if (!(flags & 2)) /* no -n */ 38 | sync(); 39 | 40 | +#ifdef __BIONIC__ 41 | + char *mode[4]; 42 | + int c = 1; 43 | + mode[0] = strdup("reboot"); 44 | + mode[1] = mode[2] = mode[3] = NULL; 45 | + switch (which) { 46 | + case 0: 47 | + case 1: 48 | + //-p for halt 49 | + mode[1] = strdup("-p"); 50 | + c = 2; 51 | + break; 52 | + case 2: 53 | + //reboot 54 | + if (argc > 1) { 55 | + mode[1] = strdup(argv[1]); 56 | + c = 2; 57 | + } 58 | + break; 59 | + } 60 | + return reboot_android(c, mode); 61 | +#endif 62 | + 63 | /* Perform action. */ 64 | rc = 1; 65 | if (!(flags & 4)) { /* no -f */ 66 | diff --git a/init/reboot.c b/init/reboot.c 67 | new file mode 100644 68 | index 000000000..97fe523a7 69 | --- /dev/null 70 | +++ b/init/reboot.c 71 | @@ -0,0 +1,33 @@ 72 | +#include 73 | +#include 74 | +#include 75 | + 76 | +int reboot_android(int argc, char *argv[]) 77 | +{ 78 | + int ret; 79 | + 80 | + const char* restart_cmd = NULL; 81 | + char* prop_value; 82 | + char* prop_cmd; 83 | + 84 | + restart_cmd = "reboot"; 85 | + while (true) { 86 | + int c = getopt(argc, argv, "p"); 87 | + if (c == EOF) 88 | + break; 89 | + switch (c) { 90 | + case 'p': 91 | + restart_cmd = "shutdown"; 92 | + break; 93 | + } 94 | + } 95 | + 96 | + if (argc > optind) 97 | + asprintf(&prop_value, "%s,%s", restart_cmd, argv[optind]); 98 | + else 99 | + asprintf(&prop_value, "%s", restart_cmd); 100 | + 101 | + asprintf(&prop_cmd, "setprop sys.powerctl %s", prop_value); 102 | + ret = execlp("sh", "sh", "-c", prop_cmd, NULL); 103 | + return ret; 104 | +} 105 | -- 106 | 2.12.3 107 | 108 | -------------------------------------------------------------------------------- /patches/050-b-xconnect-dietlibc.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Wed, 30 Oct 2019 02:47:24 -0300 3 | Subject: [PATCH] hack: use dietlibc's resolver to avoid static compiliation 4 | issues with bionic's getaddrinfo() returning only null instead of opening the 5 | expected connection to /dev/socket/dnsproxyd 6 | 7 | --- 8 | libbb/xconnect.c | 6 ++++-- 9 | 1 file changed, 4 insertions(+), 2 deletions(-) 10 | 11 | diff --git a/libbb/xconnect.c b/libbb/xconnect.c 12 | index 3a0dc26..52e5e19 100644 13 | --- a/libbb/xconnect.c 14 | +++ b/libbb/xconnect.c 15 | @@ -12,6 +12,8 @@ 16 | #include 17 | #include 18 | #include 19 | +#include 20 | +#include "../libres/dietdns.h" 21 | #if ENABLE_IFPLUGD || ENABLE_FEATURE_MDEV_DAEMON || ENABLE_UEVENT 22 | # include 23 | #endif 24 | @@ -282,7 +284,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) 25 | * for each possible socket type (tcp,udp,raw...): */ 26 | hint.ai_socktype = SOCK_STREAM; 27 | hint.ai_flags = ai_flags & ~DIE_ON_ERROR; 28 | - rc = getaddrinfo(host, NULL, &hint, &result); 29 | + rc = diet_getaddrinfo(host, NULL, &hint, &result); /* hack to use dietlibc's resolver to work around static compile issue */ 30 | if (rc || !result) { 31 | bb_error_msg("bad address '%s'", org_host); 32 | if (ai_flags & DIE_ON_ERROR) 33 | @@ -309,7 +311,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;) 34 | set_nport(&r->u.sa, htons(port)); 35 | ret: 36 | if (result) 37 | - freeaddrinfo(result); 38 | + diet_freeaddrinfo(result); /* hack to use dietlibc's resolver to work around static compile issue */ 39 | return r; 40 | } 41 | #if !ENABLE_FEATURE_IPV6 42 | -- 43 | 2.8.3 44 | 45 | -------------------------------------------------------------------------------- /patches/050-c-dietlibc-dnscruft.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Mon, 3 Jul 2017 03:17:06 -0300 3 | Subject: [PATCH] dietlibc/dnscruft: try to get dns server via command if __sys_property_get fails 4 | 5 | - bionic libc's property_get and __sys_property_get fail for statically compiled binaries 6 | - fallback to a default known dns server if all else fails 7 | --- 8 | libres/dnscruft.c | 17 ++++++++++++++++- 9 | 1 file changed, 16 insertions(+), 1 deletion(-) 10 | 11 | diff --git a/libres/dnscruft.c b/libres/dnscruft.c 12 | index 142ffecd1..7804765b9 100644 13 | --- a/libres/dnscruft.c 14 | +++ b/libres/dnscruft.c 15 | @@ -61,6 +61,9 @@ void __dns_readstartfiles(void) { 16 | #ifdef __BIONIC__ 17 | char propvalue[PROP_VALUE_MAX]; 18 | char propname[PROP_NAME_MAX]; 19 | + char propcmd[PROP_NAME_MAX+8]; 20 | + char pbuf[256]; 21 | + FILE *fp; 22 | int i; 23 | #endif 24 | 25 | @@ -73,7 +76,19 @@ void __dns_readstartfiles(void) { 26 | for(i = 1; i <= MAX_DNS_PROPERTIES; i++) { 27 | snprintf(propname, sizeof(propname), "%s%d", DNS_PROP_NAME_PREFIX, i); 28 | if(__system_property_get(propname, propvalue) < 1) { 29 | - break; 30 | + /* attempt to get the property via command instead since the call to Bionic libc failed */ 31 | + snprintf(propcmd, sizeof(propcmd), "getprop %s", propname); 32 | + if((fp = popen(propcmd, "r"))) { 33 | + if((fgets(pbuf, sizeof(pbuf)-1, fp) != NULL) && (strlen(pbuf) > 0)) { 34 | + if (pbuf[strlen(pbuf)-1] == '\n') 35 | + pbuf[strlen(pbuf)-1] = '\0'; /* strip trailing newline */ 36 | + strncpy(propvalue, pbuf, sizeof(propvalue)); 37 | + } 38 | + } 39 | + pclose(fp); 40 | + memset(&propname[0], 0, sizeof(propname)); /* clear propname to avoid unpredictable behavior */ 41 | + if(strlen(propvalue) < 1) 42 | + strcpy(propvalue, "8.8.8.8"); /* use a fallback nameserver since we still fail to get the property correctly */ 43 | } 44 | 45 | if (parsesockaddr(propvalue,&_diet_res.nsaddr_list[_diet_res.nscount])) 46 | -- 47 | 2.12.3 48 | 49 | -------------------------------------------------------------------------------- /patches/051-ash-history.patch: -------------------------------------------------------------------------------- 1 | From: Chris Renshaw 2 | Date: Tue, 23 May 2023 18:30:43 -0300 3 | Subject: [PATCH] ash history 4 | 5 | allows ash history to work on Android 6 | 7 | Patch modified by Tias Guns from 'busybox-android.patch' by Alexandre Courbot 8 | https://github.com/Gnurou/busybox-android 9 | Rebased for busybox 1.36.1 by Chris Renshaw 10 | --- 11 | include/libbb.h | 4 ++-- 12 | init/init.c | 2 +- 13 | libbb/get_shell_name.c | 4 ++++ 14 | shell/ash.c | 8 ++++++-- 15 | 4 files changed, 13 insertions(+), 5 deletions(-) 16 | 17 | diff --git a/include/libbb.h b/include/libbb.h 18 | index cca33a177..82e05a645 100644 19 | --- a/include/libbb.h 20 | +++ b/include/libbb.h 21 | @@ -2341,12 +2341,12 @@ void XZALLOC_CONST_PTR(const void *pptr, size_t size) FAST_FUNC; 22 | * use bb_default_login_shell and following defines. 23 | * If you change LIBBB_DEFAULT_LOGIN_SHELL, 24 | * don't forget to change increment constant. */ 25 | -#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh" 26 | +#define LIBBB_DEFAULT_LOGIN_SHELL "-/system/bin/sh" 27 | extern const char bb_default_login_shell[] ALIGN1; 28 | /* "/bin/sh" */ 29 | #define DEFAULT_SHELL (bb_default_login_shell+1) 30 | /* "sh" */ 31 | -#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6) 32 | +#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+13) 33 | 34 | /* The following devices are the same on all systems. */ 35 | #define CURRENT_TTY "/dev/tty" 36 | diff --git a/init/init.c b/init/init.c 37 | index 1e1ce833d..57129e9c2 100644 38 | --- a/init/init.c 39 | +++ b/init/init.c 40 | @@ -1106,7 +1106,7 @@ int init_main(int argc UNUSED_PARAM, char **argv) 41 | 42 | /* Make sure environs is set to something sane */ 43 | putenv((char *) bb_PATH_root_path); 44 | - putenv((char *) "SHELL=/bin/sh"); 45 | + putenv((char *) "SHELL=/system/bin/sh"); 46 | putenv((char *) "USER=root"); /* needed? why? */ 47 | /* Linux kernel sets HOME="/" when execing init, 48 | * and it can be overridden (but not unset?) on kernel's command line. 49 | diff --git a/libbb/get_shell_name.c b/libbb/get_shell_name.c 50 | index 5aebe9cdc..5af53bdda 100644 51 | --- a/libbb/get_shell_name.c 52 | +++ b/libbb/get_shell_name.c 53 | @@ -17,6 +17,10 @@ const char* FAST_FUNC get_shell_name(void) 54 | if (shell && shell[0]) 55 | return shell; 56 | 57 | +#ifdef __ANDROID__ 58 | + return DEFAULT_SHELL_SHORT_NAME; 59 | +#endif 60 | + 61 | pw = getpwuid(getuid()); 62 | if (pw && pw->pw_shell && pw->pw_shell[0]) 63 | return pw->pw_shell; 64 | diff --git a/shell/ash.c b/shell/ash.c 65 | index 9344e4de1..5dd7f80f1 100644 66 | --- a/shell/ash.c 67 | +++ b/shell/ash.c 68 | @@ -14537,7 +14537,7 @@ procargs(char **argv) 69 | int login_sh; 70 | 71 | xargv = argv; 72 | - login_sh = xargv[0] && xargv[0][0] == '-'; 73 | + login_sh = 1; /* = xargv[0] && xargv[0][0] == '-'; - make always true for Android */ 74 | #if NUM_SCRIPTS > 0 75 | if (minusc) 76 | goto setarg0; 77 | @@ -14713,7 +14713,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) 78 | const char *hp; 79 | 80 | state = 1; 81 | - read_profile("/etc/profile"); 82 | + read_profile("/system/etc/profile"); 83 | state1: 84 | state = 2; 85 | hp = lookupvar("HOME"); 86 | @@ -14758,6 +14758,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv) 87 | if (line_input_state) { 88 | const char *hp = lookupvar("HISTFILE"); 89 | if (!hp) { 90 | +#ifdef __ANDROID__ 91 | + setvar("HISTFILE", "/mnt/sdcard/ash_history", 0); 92 | +#else 93 | hp = lookupvar("HOME"); 94 | if (hp) { 95 | INT_OFF; 96 | @@ -14767,6 +14770,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) 97 | INT_ON; 98 | hp = lookupvar("HISTFILE"); 99 | } 100 | +#endif 101 | } 102 | if (hp) 103 | line_input_state->hist_file = xstrdup(hp); 104 | -- 105 | 2.34.1 106 | 107 | -------------------------------------------------------------------------------- /patches/052-install-disable-selinux.patch: -------------------------------------------------------------------------------- 1 | From: topjohnwu 2 | Date: Sat, 2 May 2020 01:48:30 -0700 3 | Subject: [PATCH] install: disable broken SELinux features 4 | 5 | matchpathcon is not usable on Android 6 | --- 7 | coreutils/install.c | 8 +++++--- 8 | 1 file changed, 5 insertions(+), 3 deletions(-) 9 | 10 | diff --git a/coreutils/install.c b/coreutils/install.c 11 | index 8270490bd..12f560451 100644 12 | --- a/coreutils/install.c 13 | +++ b/coreutils/install.c 14 | @@ -34,13 +34,15 @@ 15 | //usage: "\n -g GRP Set group ownership" 16 | //usage: "\n -m MODE Set permissions" 17 | //usage: "\n -t DIR Install to DIR" 18 | -//usage: IF_SELINUX( 19 | -//usage: "\n -Z Set security context" 20 | -//usage: ) 21 | 22 | #include "libbb.h" 23 | #include "libcoreutils/coreutils.h" 24 | 25 | +// Force disable SELinux features for this applet 26 | +#undef ENABLE_SELINUX 27 | +#undef IF_SELINUX 28 | +#define IF_SELINUX(...) 29 | + 30 | #if ENABLE_FEATURE_INSTALL_LONG_OPTIONS 31 | static const char install_longopts[] ALIGN1 = 32 | IF_FEATURE_VERBOSE( 33 | -- 34 | 2.26.0 35 | 36 | --------------------------------------------------------------------------------