aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp6
-rw-r--r--METADATA6
-rw-r--r--Makefile2
-rw-r--r--android/device/generated/flags.h40
-rw-r--r--android/device/generated/globals.h10
-rw-r--r--android/device/generated/help.h8
-rw-r--r--android/device/generated/newtoys.h4
-rw-r--r--android/device/generated/tags.h280
-rw-r--r--android/linux/generated/config.h12
-rw-r--r--android/linux/generated/flags.h106
-rw-r--r--android/linux/generated/globals.h23
-rw-r--r--android/linux/generated/help.h8
-rw-r--r--android/linux/generated/newtoys.h4
-rw-r--r--android/linux/generated/tags.h280
-rw-r--r--android/mac/generated/flags.h40
-rw-r--r--android/mac/generated/help.h8
-rw-r--r--android/mac/generated/newtoys.h4
-rw-r--r--android/mac/generated/tags.h280
-rw-r--r--config-linux6
-rw-r--r--kconfig/freebsd_miniconfig1
-rw-r--r--lib/lib.c2
-rw-r--r--lib/lib.h6
-rw-r--r--lib/net.c6
-rw-r--r--lib/portability.c2
-rw-r--r--lib/toyflags.h1
-rw-r--r--lib/tty.c40
-rw-r--r--main.c11
-rw-r--r--mkroot/README4
-rwxr-xr-xmkroot/mkroot.sh8
-rwxr-xr-xmkroot/record-commands22
-rwxr-xr-xpost_update.sh5
-rwxr-xr-xscripts/make.sh21
-rw-r--r--scripts/mktags.c58
-rw-r--r--scripts/prereq/generated/config.h2
-rwxr-xr-xtests/find.test9
-rwxr-xr-xtests/timeout.test8
-rw-r--r--toys.h2
-rw-r--r--toys/lsb/mknod.c7
-rw-r--r--toys/lsb/umount.c22
-rw-r--r--toys/net/ftpget.c30
-rw-r--r--toys/net/microcom.c7
-rw-r--r--toys/net/netcat.c89
-rw-r--r--toys/net/tunctl.c4
-rw-r--r--toys/other/blockdev.c13
-rw-r--r--toys/other/chcon.c6
-rw-r--r--toys/other/chrt.c9
-rw-r--r--toys/other/hwclock.c81
-rw-r--r--toys/other/mix.c8
-rw-r--r--toys/other/setfattr.c9
-rw-r--r--toys/other/swapon.c8
-rw-r--r--toys/other/sysctl.c30
-rw-r--r--toys/other/xxd.c6
-rw-r--r--toys/pending/dhcp6.c4
-rw-r--r--toys/pending/diff.c54
-rw-r--r--toys/pending/syslogd.c38
-rw-r--r--toys/posix/cat.c2
-rw-r--r--toys/posix/du.c3
-rw-r--r--toys/posix/find.c3
-rw-r--r--toys/posix/getconf.c6
-rw-r--r--toys/posix/mkdir.c2
-rw-r--r--toys/posix/mkfifo.c7
-rw-r--r--toys/posix/paste.c8
-rw-r--r--toys/posix/rm.c2
-rw-r--r--toys/posix/touch.c5
-rw-r--r--www/design.html16
-rw-r--r--www/header.html2
-rw-r--r--www/news.html298
67 files changed, 1245 insertions, 869 deletions
diff --git a/Android.bp b/Android.bp
index 5d9ec2eb..c93935f9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -133,8 +133,11 @@ all_srcs = [
]
linux_srcs = [
+ "toys/lsb/mount.c",
+ "toys/lsb/umount.c",
"toys/posix/ps.c",
"toys/other/flock.c",
+ "toys/other/nsenter.c",
"toys/other/taskset.c",
]
@@ -149,10 +152,8 @@ device_srcs = [
"toys/lsb/dmesg.c",
"toys/lsb/killall.c",
"toys/lsb/mknod.c",
- "toys/lsb/mount.c",
"toys/lsb/pidof.c",
"toys/lsb/sync.c",
- "toys/lsb/umount.c",
"toys/net/ifconfig.c",
"toys/net/netcat.c",
"toys/net/netstat.c",
@@ -192,7 +193,6 @@ device_srcs = [
"toys/other/modinfo.c",
"toys/other/mountpoint.c",
"toys/other/nbd_client.c",
- "toys/other/nsenter.c",
"toys/other/partprobe.c",
"toys/other/pivot_root.c",
"toys/other/pmap.c",
diff --git a/METADATA b/METADATA
index 513ea30c..ecef7a3b 100644
--- a/METADATA
+++ b/METADATA
@@ -8,13 +8,13 @@ third_party {
license_type: UNENCUMBERED
last_upgrade_date {
year: 2024
- month: 4
- day: 8
+ month: 5
+ day: 20
}
homepage: "https://landley.net/toybox/"
identifier {
type: "Git"
value: "https://github.com/landley/toybox"
- version: "96d9f66127d84fba2f56f4754fc302e826968751"
+ version: "3ad2a87991aae26f4041031c27dbbf63d5ec1ca7"
}
}
diff --git a/Makefile b/Makefile
index 100fd30e..09fed076 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ root_clean:
@echo root cleaned
clean::
- @chmod -fR 700 generated || true
+ @chmod -fR 700 generated 2>/dev/null || true
@rm -rf toybox generated change install .singleconfig*
@echo cleaned
diff --git a/android/device/generated/flags.h b/android/device/generated/flags.h
index 5d873312..906e3f63 100644
--- a/android/device/generated/flags.h
+++ b/android/device/generated/flags.h
@@ -2228,14 +2228,13 @@
#undef FLAG_r
#endif
-// netcat ^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U] ^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]
+// netcat ^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO] ^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]
#undef OPTSTR_netcat
-#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]"
+#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]"
#ifdef CLEANUP_netcat
#undef CLEANUP_netcat
#undef FOR_netcat
#undef FLAG_z
-#undef FLAG_v
#undef FLAG_n
#undef FLAG_U
#undef FLAG_u
@@ -2243,6 +2242,8 @@
#undef FLAG_4
#undef FLAG_f
#undef FLAG_s
+#undef FLAG_o
+#undef FLAG_O
#undef FLAG_q
#undef FLAG_p
#undef FLAG_W
@@ -5975,22 +5976,23 @@
#define TT this.netcat
#endif
#define FLAG_z (1LL<<0)
-#define FLAG_v (1LL<<1)
-#define FLAG_n (1LL<<2)
-#define FLAG_U (1LL<<3)
-#define FLAG_u (1LL<<4)
-#define FLAG_6 (1LL<<5)
-#define FLAG_4 (1LL<<6)
-#define FLAG_f (1LL<<7)
-#define FLAG_s (1LL<<8)
-#define FLAG_q (1LL<<9)
-#define FLAG_p (1LL<<10)
-#define FLAG_W (1LL<<11)
-#define FLAG_w (1LL<<12)
-#define FLAG_L (1LL<<13)
-#define FLAG_l (1LL<<14)
-#define FLAG_E (1LL<<15)
-#define FLAG_t (1LL<<16)
+#define FLAG_n (1LL<<1)
+#define FLAG_U (1LL<<2)
+#define FLAG_u (1LL<<3)
+#define FLAG_6 (1LL<<4)
+#define FLAG_4 (1LL<<5)
+#define FLAG_f (1LL<<6)
+#define FLAG_s (1LL<<7)
+#define FLAG_o (1LL<<8)
+#define FLAG_O (1LL<<9)
+#define FLAG_q (1LL<<10)
+#define FLAG_p (1LL<<11)
+#define FLAG_W (1LL<<12)
+#define FLAG_w (1LL<<13)
+#define FLAG_L (1LL<<14)
+#define FLAG_l (1LL<<15)
+#define FLAG_E (1LL<<16)
+#define FLAG_t (1LL<<17)
#endif
#ifdef FOR_netstat
diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h
index 6b358369..dc1bc35e 100644
--- a/android/device/generated/globals.h
+++ b/android/device/generated/globals.h
@@ -78,8 +78,11 @@ struct microcom_data {
};
struct netcat_data {
- char *f, *s;
+ char *f, *s, *o, *O;
long q, p, W, w;
+
+ unsigned ofd, olast, opos, ocount[2];
+ char obuf[16];
};
struct netstat_data {
@@ -118,7 +121,7 @@ struct blkid_data {
};
struct blockdev_data {
- long setbsz, setra;
+ long setra, setbsz;
};
struct chrt_data {
@@ -598,8 +601,7 @@ struct mkdir_data {
};
struct mkfifo_data {
- char *m;
- char *Z;
+ char *m, *Z;
mode_t mode;
};
diff --git a/android/device/generated/help.h b/android/device/generated/help.h
index 74661d3d..1c00091b 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -124,7 +124,7 @@
#define HELP_netstat "usage: netstat [-pWrxwutneal]\n\nDisplay networking information. Default is netstat -tuwx\n\n-r Routing table\n-a All sockets (not just connected)\n-l Listening server sockets\n-t TCP sockets\n-u UDP sockets\n-w Raw sockets\n-x Unix sockets\n-e Extended info\n-n Don't resolve names\n-W Wide display\n-p Show PID/program name of sockets"
-#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-v Verbose\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
+#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] [-o FILE] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-o Hex dump to FILE (-o- writes hex only to stdout)\n-O Hex dump to FILE (collated)\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
#define HELP_microcom "usage: microcom [-s SPEED] [-X] DEVICE\n\nSimple serial console. Hit CTRL-] for menu.\n\n-s Set baud rate to SPEED (default 115200)\n-X Ignore ^] menu escape"
@@ -174,7 +174,7 @@
#define HELP_tac "usage: tac [FILE...]\n\nOutput lines in reverse order."
-#define HELP_sysctl "usage: sysctl [-aAeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a,A Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
+#define HELP_sysctl "usage: sysctl [-aeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
#define HELP_switch_root "usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT...\n\nUse from PID 1 under initramfs to free initramfs, chroot to NEW_ROOT,\nand exec NEW_INIT.\n\n-c Redirect console to device in NEW_ROOT\n-h Hang instead of exiting on failure (avoids kernel panic)"
@@ -290,7 +290,7 @@
#define HELP_i2cdetect "usage: i2cdetect [-aqry] BUS [FIRST LAST]\nusage: i2cdetect -F BUS\nusage: i2cdetect -l\n\nDetect i2c devices.\n\n-a All addresses (0x00-0x7f rather than 0x03-0x77 or FIRST-LAST)\n-F Show functionality\n-l List available buses\n-q Probe with SMBus Quick Write (default)\n-r Probe with SMBus Read Byte\n-y Skip confirmation prompts (yes to all)"
-#define HELP_hwclock "usage: hwclock [-rswtluf]\n\nGet/set the hardware clock.\n\n-f FILE Use specified device file instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Set the system time based on the current timezone (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
+#define HELP_hwclock "usage: hwclock [-rswtlu] [-f FILE]\n\nGet/set the hardware clock. Default is hwclock -ruf /dev/rtc0\n\n-f Use specified device FILE instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Inform kernel of non-UTC clock's timezone so it returns UTC (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
#define HELP_hexedit "usage: hexedit [-r] FILE\n\nHexadecimal file editor/viewer. All changes are written to disk immediately.\n\n-r Read only (display but don't edit)\n\nKeys:\nArrows Move left/right/up/down by one line/column\nPgUp/PgDn Move up/down by one page\nHome/End Start/end of line (start/end of file with ctrl)\n0-9, a-f Change current half-byte to hexadecimal value\n^J or : Jump (+/- for relative offset, otherwise absolute address)\n^F or / Find string (^G/n: next, ^D/p: previous match)\nu Undo\nx Toggle bw/color display\nq/^C/^Q/Esc Quit"
@@ -494,7 +494,7 @@
#define HELP_dhcpd "usage: dhcpd [-46fS] [-i IFACE] [-P N] [CONFFILE]\n\n -f Run in foreground\n -i Interface to use\n -S Log to syslog too\n -P N Use port N (default ipv4 67, ipv6 547)\n -4, -6 Run as a DHCPv4 or DHCPv6 server"
-#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events\n -t Send up to N Solicit packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -r Request this IP address\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
+#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\nConfigure network dynamically using DHCP.\n\n-i Interface to use (default eth0)\n-p Create pidfile\n-s Run PROG at DHCP events\n-t Send up to N Solicit packets\n-T Pause between packets (default 3 seconds)\n-A Wait N seconds after failure (default 20)\n-f Run in foreground\n-b Background if lease is not obtained\n-n Exit if lease is not obtained\n-q Exit after obtaining lease\n-R Release IP on exit\n-S Log to syslog too\n-r Request this IP address\n-v Verbose\n\nSignals:\nUSR1 Renew current lease\nUSR2 Release current lease"
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
diff --git a/android/device/generated/newtoys.h b/android/device/generated/newtoys.h
index 92814854..0873071c 100644
--- a/android/device/generated/newtoys.h
+++ b/android/device/generated/newtoys.h
@@ -184,7 +184,7 @@ USE_MCOOKIE(NEWTOY(mcookie, "v(verbose)V(version)", TOYFLAG_USR|TOYFLAG_BIN))
USE_MD5SUM(NEWTOY(md5sum, "bc(check)s(status)[!bc]", TOYFLAG_USR|TOYFLAG_BIN))
USE_MDEV(NEWTOY(mdev, "s", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MEMEATER(NEWTOY(memeater, "<1>1M", TOYFLAG_USR|TOYFLAG_BIN))
-USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN))
+USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NOBUF))
USE_MIX(NEWTOY(mix, "c:d:l#r#", TOYFLAG_USR|TOYFLAG_BIN))
USE_MKDIR(NEWTOY(mkdir, "<1"USE_MKDIR_Z("Z:")"vp(parent)(parents)m:", TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MKE2FS(NEWTOY(mke2fs, "<1>2g:Fnqm#N#i#b#", TOYFLAG_SBIN))
@@ -204,7 +204,7 @@ USE_NBD_SERVER(OLDTOY(nbd-server, nbd_server, TOYFLAG_USR|TOYFLAG_BIN))
USE_NBD_CLIENT(NEWTOY(nbd_client, "<3>3b#<1>4294967295=4096ns", 0))
USE_NBD_SERVER(NEWTOY(nbd_server, "<1>1r", 0))
USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
-USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
+USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]", TOYFLAG_BIN))
USE_NETSTAT(NEWTOY(netstat, "pWrxwutneal", TOYFLAG_BIN))
USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_BIN))
USE_NL(NEWTOY(nl, "v#=1l#w#<0=6b:n:s:E", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/device/generated/tags.h b/android/device/generated/tags.h
index 463e8d2c..d47e3a58 100644
--- a/android/device/generated/tags.h
+++ b/android/device/generated/tags.h
@@ -1,140 +1,140 @@
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
-#define DD_conv_fsync 0
-#define _DD_conv_fsync (1<<0)
-#define DD_conv_noerror 1
-#define _DD_conv_noerror (1<<1)
-#define DD_conv_notrunc 2
-#define _DD_conv_notrunc (1<<2)
-#define DD_conv_sync 3
-#define _DD_conv_sync (1<<3)
-#define DD_iflag_count_bytes 0
-#define _DD_iflag_count_bytes (1<<0)
-#define DD_iflag_skip_bytes 1
-#define _DD_iflag_skip_bytes (1<<1)
-#define DD_oflag_seek_bytes 0
-#define _DD_oflag_seek_bytes (1<<0)
-#define PS_PID 0
-#define _PS_PID (1<<0)
-#define PS_PPID 1
-#define _PS_PPID (1<<1)
-#define PS_PRI 2
-#define _PS_PRI (1<<2)
-#define PS_NI 3
-#define _PS_NI (1<<3)
-#define PS_ADDR 4
-#define _PS_ADDR (1<<4)
-#define PS_SZ 5
-#define _PS_SZ (1<<5)
-#define PS_RSS 6
-#define _PS_RSS (1<<6)
-#define PS_PGID 7
-#define _PS_PGID (1<<7)
-#define PS_VSZ 8
-#define _PS_VSZ (1<<8)
-#define PS_MAJFL 9
-#define _PS_MAJFL (1<<9)
-#define PS_MINFL 10
-#define _PS_MINFL (1<<10)
-#define PS_PR 11
-#define _PS_PR (1<<11)
-#define PS_PSR 12
-#define _PS_PSR (1<<12)
-#define PS_RTPRIO 13
-#define _PS_RTPRIO (1<<13)
-#define PS_SCH 14
-#define _PS_SCH (1<<14)
-#define PS_CPU 15
-#define _PS_CPU (1<<15)
-#define PS_TID 16
-#define _PS_TID (1<<16)
-#define PS_TCNT 17
-#define _PS_TCNT (1<<17)
-#define PS_BIT 18
-#define _PS_BIT (1<<18)
-#define PS_TTY 19
-#define _PS_TTY (1<<19)
-#define PS_WCHAN 20
-#define _PS_WCHAN (1<<20)
-#define PS_LABEL 21
-#define _PS_LABEL (1<<21)
-#define PS_COMM 22
-#define _PS_COMM (1<<22)
-#define PS_NAME 23
-#define _PS_NAME (1<<23)
-#define PS_COMMAND 24
-#define _PS_COMMAND (1<<24)
-#define PS_CMDLINE 25
-#define _PS_CMDLINE (1<<25)
-#define PS_ARGS 26
-#define _PS_ARGS (1<<26)
-#define PS_CMD 27
-#define _PS_CMD (1<<27)
-#define PS_UID 28
-#define _PS_UID (1<<28)
-#define PS_USER 29
-#define _PS_USER (1<<29)
-#define PS_RUID 30
-#define _PS_RUID (1<<30)
-#define PS_RUSER 31
-#define _PS_RUSER (1<<31)
-#define PS_GID 32
-#define _PS_GID (1LL<<32)
-#define PS_GROUP 33
-#define _PS_GROUP (1LL<<33)
-#define PS_RGID 34
-#define _PS_RGID (1LL<<34)
-#define PS_RGROUP 35
-#define _PS_RGROUP (1LL<<35)
-#define PS_TIME 36
-#define _PS_TIME (1LL<<36)
-#define PS_ELAPSED 37
-#define _PS_ELAPSED (1LL<<37)
-#define PS_TIME_ 38
-#define _PS_TIME_ (1LL<<38)
-#define PS_C 39
-#define _PS_C (1LL<<39)
-#define PS__VSZ 40
-#define _PS__VSZ (1LL<<40)
-#define PS__MEM 41
-#define _PS__MEM (1LL<<41)
-#define PS__CPU 42
-#define _PS__CPU (1LL<<42)
-#define PS_VIRT 43
-#define _PS_VIRT (1LL<<43)
-#define PS_RES 44
-#define _PS_RES (1LL<<44)
-#define PS_SHR 45
-#define _PS_SHR (1LL<<45)
-#define PS_READ 46
-#define _PS_READ (1LL<<46)
-#define PS_WRITE 47
-#define _PS_WRITE (1LL<<47)
-#define PS_IO 48
-#define _PS_IO (1LL<<48)
-#define PS_DREAD 49
-#define _PS_DREAD (1LL<<49)
-#define PS_DWRITE 50
-#define _PS_DWRITE (1LL<<50)
-#define PS_SWAP 51
-#define _PS_SWAP (1LL<<51)
-#define PS_DIO 52
-#define _PS_DIO (1LL<<52)
-#define PS_STIME 53
-#define _PS_STIME (1LL<<53)
-#define PS_F 54
-#define _PS_F (1LL<<54)
-#define PS_S 55
-#define _PS_S (1LL<<55)
-#define PS_STAT 56
-#define _PS_STAT (1LL<<56)
-#define PS_PCY 57
-#define _PS_PCY (1LL<<57)
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
+#define DD_conv_fsync 0
+#define _DD_conv_fsync (1<<0)
+#define DD_conv_noerror 1
+#define _DD_conv_noerror (1<<1)
+#define DD_conv_notrunc 2
+#define _DD_conv_notrunc (1<<2)
+#define DD_conv_sync 3
+#define _DD_conv_sync (1<<3)
+#define DD_iflag_count_bytes 0
+#define _DD_iflag_count_bytes (1<<0)
+#define DD_iflag_skip_bytes 1
+#define _DD_iflag_skip_bytes (1<<1)
+#define DD_oflag_seek_bytes 0
+#define _DD_oflag_seek_bytes (1<<0)
+#define PS_PID 0
+#define _PS_PID (1<<0)
+#define PS_PPID 1
+#define _PS_PPID (1<<1)
+#define PS_PRI 2
+#define _PS_PRI (1<<2)
+#define PS_NI 3
+#define _PS_NI (1<<3)
+#define PS_ADDR 4
+#define _PS_ADDR (1<<4)
+#define PS_SZ 5
+#define _PS_SZ (1<<5)
+#define PS_RSS 6
+#define _PS_RSS (1<<6)
+#define PS_PGID 7
+#define _PS_PGID (1<<7)
+#define PS_VSZ 8
+#define _PS_VSZ (1<<8)
+#define PS_MAJFL 9
+#define _PS_MAJFL (1<<9)
+#define PS_MINFL 10
+#define _PS_MINFL (1<<10)
+#define PS_PR 11
+#define _PS_PR (1<<11)
+#define PS_PSR 12
+#define _PS_PSR (1<<12)
+#define PS_RTPRIO 13
+#define _PS_RTPRIO (1<<13)
+#define PS_SCH 14
+#define _PS_SCH (1<<14)
+#define PS_CPU 15
+#define _PS_CPU (1<<15)
+#define PS_TID 16
+#define _PS_TID (1<<16)
+#define PS_TCNT 17
+#define _PS_TCNT (1<<17)
+#define PS_BIT 18
+#define _PS_BIT (1<<18)
+#define PS_TTY 19
+#define _PS_TTY (1<<19)
+#define PS_WCHAN 20
+#define _PS_WCHAN (1<<20)
+#define PS_LABEL 21
+#define _PS_LABEL (1<<21)
+#define PS_COMM 22
+#define _PS_COMM (1<<22)
+#define PS_NAME 23
+#define _PS_NAME (1<<23)
+#define PS_COMMAND 24
+#define _PS_COMMAND (1<<24)
+#define PS_CMDLINE 25
+#define _PS_CMDLINE (1<<25)
+#define PS_ARGS 26
+#define _PS_ARGS (1<<26)
+#define PS_CMD 27
+#define _PS_CMD (1<<27)
+#define PS_UID 28
+#define _PS_UID (1<<28)
+#define PS_USER 29
+#define _PS_USER (1<<29)
+#define PS_RUID 30
+#define _PS_RUID (1<<30)
+#define PS_RUSER 31
+#define _PS_RUSER (1<<31)
+#define PS_GID 32
+#define _PS_GID (1LL<<32)
+#define PS_GROUP 33
+#define _PS_GROUP (1LL<<33)
+#define PS_RGID 34
+#define _PS_RGID (1LL<<34)
+#define PS_RGROUP 35
+#define _PS_RGROUP (1LL<<35)
+#define PS_TIME 36
+#define _PS_TIME (1LL<<36)
+#define PS_ELAPSED 37
+#define _PS_ELAPSED (1LL<<37)
+#define PS_TIME_ 38
+#define _PS_TIME_ (1LL<<38)
+#define PS_C 39
+#define _PS_C (1LL<<39)
+#define PS__VSZ 40
+#define _PS__VSZ (1LL<<40)
+#define PS__MEM 41
+#define _PS__MEM (1LL<<41)
+#define PS__CPU 42
+#define _PS__CPU (1LL<<42)
+#define PS_VIRT 43
+#define _PS_VIRT (1LL<<43)
+#define PS_RES 44
+#define _PS_RES (1LL<<44)
+#define PS_SHR 45
+#define _PS_SHR (1LL<<45)
+#define PS_READ 46
+#define _PS_READ (1LL<<46)
+#define PS_WRITE 47
+#define _PS_WRITE (1LL<<47)
+#define PS_IO 48
+#define _PS_IO (1LL<<48)
+#define PS_DREAD 49
+#define _PS_DREAD (1LL<<49)
+#define PS_DWRITE 50
+#define _PS_DWRITE (1LL<<50)
+#define PS_SWAP 51
+#define _PS_SWAP (1LL<<51)
+#define PS_DIO 52
+#define _PS_DIO (1LL<<52)
+#define PS_STIME 53
+#define _PS_STIME (1LL<<53)
+#define PS_F 54
+#define _PS_F (1LL<<54)
+#define PS_S 55
+#define _PS_S (1LL<<55)
+#define PS_STAT 56
+#define _PS_STAT (1LL<<56)
+#define PS_PCY 57
+#define _PS_PCY (1LL<<57)
diff --git a/android/linux/generated/config.h b/android/linux/generated/config.h
index 3e2afb23..330982dd 100644
--- a/android/linux/generated/config.h
+++ b/android/linux/generated/config.h
@@ -402,8 +402,8 @@
#define USE_MODPROBE(...)
#define CFG_MORE 0
#define USE_MORE(...)
-#define CFG_MOUNT 0
-#define USE_MOUNT(...)
+#define CFG_MOUNT 1
+#define USE_MOUNT(...) __VA_ARGS__
#define CFG_MOUNTPOINT 0
#define USE_MOUNTPOINT(...)
#define CFG_MV 1
@@ -618,8 +618,8 @@
#define USE_UCLAMPSET(...)
#define CFG_ULIMIT 0
#define USE_ULIMIT(...)
-#define CFG_UMOUNT 0
-#define USE_UMOUNT(...)
+#define CFG_UMOUNT 1
+#define USE_UMOUNT(...) __VA_ARGS__
#define CFG_UNAME 1
#define USE_UNAME(...) __VA_ARGS__
#define CFG_UNICODE 0
@@ -630,8 +630,8 @@
#define USE_UNIX2DOS(...) __VA_ARGS__
#define CFG_UNLINK 0
#define USE_UNLINK(...)
-#define CFG_UNSHARE 0
-#define USE_UNSHARE(...)
+#define CFG_UNSHARE 1
+#define USE_UNSHARE(...) __VA_ARGS__
#define CFG_UPTIME 0
#define USE_UPTIME(...)
#define CFG_USERADD 0
diff --git a/android/linux/generated/flags.h b/android/linux/generated/flags.h
index 125b74d0..7a6ad283 100644
--- a/android/linux/generated/flags.h
+++ b/android/linux/generated/flags.h
@@ -2163,7 +2163,7 @@
#undef FOR_more
#endif
-// mount ?RO:afnrvwt:o*[-rw]
+// mount ?RO:afnrvwt:o*[-rw] ?RO:afnrvwt:o*[-rw]
#undef OPTSTR_mount
#define OPTSTR_mount "?RO:afnrvwt:o*[-rw]"
#ifdef CLEANUP_mount
@@ -2228,14 +2228,13 @@
#undef FLAG_r
#endif
-// netcat ^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]
+// netcat ^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]
#undef OPTSTR_netcat
-#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]"
+#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]"
#ifdef CLEANUP_netcat
#undef CLEANUP_netcat
#undef FOR_netcat
#undef FLAG_z
-#undef FLAG_v
#undef FLAG_n
#undef FLAG_U
#undef FLAG_u
@@ -2243,6 +2242,8 @@
#undef FLAG_4
#undef FLAG_f
#undef FLAG_s
+#undef FLAG_o
+#undef FLAG_O
#undef FLAG_q
#undef FLAG_p
#undef FLAG_W
@@ -3570,7 +3571,7 @@
#undef FLAG_P
#endif
-// umount cndDflrat*v[!na]
+// umount cndDflrat*v[!na] cndDflrat*v[!na]
#undef OPTSTR_umount
#define OPTSTR_umount "cndDflrat*v[!na]"
#ifdef CLEANUP_umount
@@ -3655,7 +3656,7 @@
#undef FLAG_f
#endif
-// unshare <1^a(all)f(fork)r(map-root-user)C(cgroup):; i(ipc):; m(mount):; n(net):; p(pid):; u(uts):; U(user):;
+// unshare <1^a(all)f(fork)r(map-root-user)C(cgroup):; i(ipc):; m(mount):; n(net):; p(pid):; u(uts):; U(user):; <1^a(all)f(fork)r(map-root-user)C(cgroup):; i(ipc):; m(mount):; n(net):; p(pid):; u(uts):; U(user):;
#undef OPTSTR_unshare
#define OPTSTR_unshare "<1^a(all)f(fork)r(map-root-user)C(cgroup):; i(ipc):; m(mount):; n(net):; p(pid):; u(uts):; U(user):; "
#ifdef CLEANUP_unshare
@@ -5914,16 +5915,16 @@
#ifndef TT
#define TT this.mount
#endif
-#define FLAG_o (FORCED_FLAG<<0)
-#define FLAG_t (FORCED_FLAG<<1)
-#define FLAG_w (FORCED_FLAG<<2)
-#define FLAG_v (FORCED_FLAG<<3)
-#define FLAG_r (FORCED_FLAG<<4)
-#define FLAG_n (FORCED_FLAG<<5)
-#define FLAG_f (FORCED_FLAG<<6)
-#define FLAG_a (FORCED_FLAG<<7)
-#define FLAG_O (FORCED_FLAG<<8)
-#define FLAG_R (FORCED_FLAG<<9)
+#define FLAG_o (1LL<<0)
+#define FLAG_t (1LL<<1)
+#define FLAG_w (1LL<<2)
+#define FLAG_v (1LL<<3)
+#define FLAG_r (1LL<<4)
+#define FLAG_n (1LL<<5)
+#define FLAG_f (1LL<<6)
+#define FLAG_a (1LL<<7)
+#define FLAG_O (1LL<<8)
+#define FLAG_R (1LL<<9)
#endif
#ifdef FOR_mountpoint
@@ -5975,22 +5976,23 @@
#define TT this.netcat
#endif
#define FLAG_z (FORCED_FLAG<<0)
-#define FLAG_v (FORCED_FLAG<<1)
-#define FLAG_n (FORCED_FLAG<<2)
-#define FLAG_U (FORCED_FLAG<<3)
-#define FLAG_u (FORCED_FLAG<<4)
-#define FLAG_6 (FORCED_FLAG<<5)
-#define FLAG_4 (FORCED_FLAG<<6)
-#define FLAG_f (FORCED_FLAG<<7)
-#define FLAG_s (FORCED_FLAG<<8)
-#define FLAG_q (FORCED_FLAG<<9)
-#define FLAG_p (FORCED_FLAG<<10)
-#define FLAG_W (FORCED_FLAG<<11)
-#define FLAG_w (FORCED_FLAG<<12)
-#define FLAG_L (FORCED_FLAG<<13)
-#define FLAG_l (FORCED_FLAG<<14)
-#define FLAG_E (FORCED_FLAG<<15)
-#define FLAG_t (FORCED_FLAG<<16)
+#define FLAG_n (FORCED_FLAG<<1)
+#define FLAG_U (FORCED_FLAG<<2)
+#define FLAG_u (FORCED_FLAG<<3)
+#define FLAG_6 (FORCED_FLAG<<4)
+#define FLAG_4 (FORCED_FLAG<<5)
+#define FLAG_f (FORCED_FLAG<<6)
+#define FLAG_s (FORCED_FLAG<<7)
+#define FLAG_o (FORCED_FLAG<<8)
+#define FLAG_O (FORCED_FLAG<<9)
+#define FLAG_q (FORCED_FLAG<<10)
+#define FLAG_p (FORCED_FLAG<<11)
+#define FLAG_W (FORCED_FLAG<<12)
+#define FLAG_w (FORCED_FLAG<<13)
+#define FLAG_L (FORCED_FLAG<<14)
+#define FLAG_l (FORCED_FLAG<<15)
+#define FLAG_E (FORCED_FLAG<<16)
+#define FLAG_t (FORCED_FLAG<<17)
#endif
#ifdef FOR_netstat
@@ -7217,16 +7219,16 @@
#ifndef TT
#define TT this.umount
#endif
-#define FLAG_v (FORCED_FLAG<<0)
-#define FLAG_t (FORCED_FLAG<<1)
-#define FLAG_a (FORCED_FLAG<<2)
-#define FLAG_r (FORCED_FLAG<<3)
-#define FLAG_l (FORCED_FLAG<<4)
-#define FLAG_f (FORCED_FLAG<<5)
-#define FLAG_D (FORCED_FLAG<<6)
-#define FLAG_d (FORCED_FLAG<<7)
-#define FLAG_n (FORCED_FLAG<<8)
-#define FLAG_c (FORCED_FLAG<<9)
+#define FLAG_v (1LL<<0)
+#define FLAG_t (1LL<<1)
+#define FLAG_a (1LL<<2)
+#define FLAG_r (1LL<<3)
+#define FLAG_l (1LL<<4)
+#define FLAG_f (1LL<<5)
+#define FLAG_D (1LL<<6)
+#define FLAG_d (1LL<<7)
+#define FLAG_n (1LL<<8)
+#define FLAG_c (1LL<<9)
#endif
#ifdef FOR_uname
@@ -7295,16 +7297,16 @@
#ifndef TT
#define TT this.unshare
#endif
-#define FLAG_U (FORCED_FLAG<<0)
-#define FLAG_u (FORCED_FLAG<<1)
-#define FLAG_p (FORCED_FLAG<<2)
-#define FLAG_n (FORCED_FLAG<<3)
-#define FLAG_m (FORCED_FLAG<<4)
-#define FLAG_i (FORCED_FLAG<<5)
-#define FLAG_C (FORCED_FLAG<<6)
-#define FLAG_r (FORCED_FLAG<<7)
-#define FLAG_f (FORCED_FLAG<<8)
-#define FLAG_a (FORCED_FLAG<<9)
+#define FLAG_U (1LL<<0)
+#define FLAG_u (1LL<<1)
+#define FLAG_p (1LL<<2)
+#define FLAG_n (1LL<<3)
+#define FLAG_m (1LL<<4)
+#define FLAG_i (1LL<<5)
+#define FLAG_C (1LL<<6)
+#define FLAG_r (1LL<<7)
+#define FLAG_f (1LL<<8)
+#define FLAG_a (1LL<<9)
#endif
#ifdef FOR_uptime
diff --git a/android/linux/generated/globals.h b/android/linux/generated/globals.h
index 362a97bc..37bdea6b 100644
--- a/android/linux/generated/globals.h
+++ b/android/linux/generated/globals.h
@@ -14,12 +14,27 @@ struct mktemp_data {
char *p, *tmpdir;
};
+struct mount_data {
+ struct arg_list *o;
+ char *t, *O;
+
+ unsigned long flags;
+ char *opts;
+ int okuser;
+};
+
struct seq_data {
char *s, *f;
int precision, buflen;
};
+struct umount_data {
+ struct arg_list *t;
+
+ char *types;
+};
+
struct microcom_data {
long s;
@@ -36,6 +51,11 @@ struct getopt_data {
char *o, *n;
};
+struct nsenter_data {
+ char *UupnmiC[7];
+ long t;
+};
+
struct realpath_data {
char *R, *relative_base;
};
@@ -399,10 +419,13 @@ extern union global_union {
struct hostname_data hostname;
struct md5sum_data md5sum;
struct mktemp_data mktemp;
+ struct mount_data mount;
struct seq_data seq;
+ struct umount_data umount;
struct microcom_data microcom;
struct dos2unix_data dos2unix;
struct getopt_data getopt;
+ struct nsenter_data nsenter;
struct realpath_data realpath;
struct setsid_data setsid;
struct stat_data stat;
diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h
index b3c74b17..02095c14 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -126,7 +126,7 @@
#define HELP_netstat "usage: netstat [-pWrxwutneal]\n\nDisplay networking information. Default is netstat -tuwx\n\n-r Routing table\n-a All sockets (not just connected)\n-l Listening server sockets\n-t TCP sockets\n-u UDP sockets\n-w Raw sockets\n-x Unix sockets\n-e Extended info\n-n Don't resolve names\n-W Wide display\n-p Show PID/program name of sockets"
-#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-v Verbose\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
+#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] [-o FILE] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-o Hex dump to FILE (-o- writes hex only to stdout)\n-O Hex dump to FILE (collated)\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
#define HELP_microcom "usage: microcom [-s SPEED] [-X] DEVICE\n\nSimple serial console. Hit CTRL-] for menu.\n\n-s Set baud rate to SPEED (default 115200)\n-X Ignore ^] menu escape"
@@ -176,7 +176,7 @@
#define HELP_tac "usage: tac [FILE...]\n\nOutput lines in reverse order."
-#define HELP_sysctl "usage: sysctl [-aAeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a,A Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
+#define HELP_sysctl "usage: sysctl [-aeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
#define HELP_switch_root "usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT...\n\nUse from PID 1 under initramfs to free initramfs, chroot to NEW_ROOT,\nand exec NEW_INIT.\n\n-c Redirect console to device in NEW_ROOT\n-h Hang instead of exiting on failure (avoids kernel panic)"
@@ -292,7 +292,7 @@
#define HELP_i2cdetect "usage: i2cdetect [-aqry] BUS [FIRST LAST]\nusage: i2cdetect -F BUS\nusage: i2cdetect -l\n\nDetect i2c devices.\n\n-a All addresses (0x00-0x7f rather than 0x03-0x77 or FIRST-LAST)\n-F Show functionality\n-l List available buses\n-q Probe with SMBus Quick Write (default)\n-r Probe with SMBus Read Byte\n-y Skip confirmation prompts (yes to all)"
-#define HELP_hwclock "usage: hwclock [-rswtluf]\n\nGet/set the hardware clock.\n\n-f FILE Use specified device file instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Set the system time based on the current timezone (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
+#define HELP_hwclock "usage: hwclock [-rswtlu] [-f FILE]\n\nGet/set the hardware clock. Default is hwclock -ruf /dev/rtc0\n\n-f Use specified device FILE instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Inform kernel of non-UTC clock's timezone so it returns UTC (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
#define HELP_hexedit "usage: hexedit [-r] FILE\n\nHexadecimal file editor/viewer. All changes are written to disk immediately.\n\n-r Read only (display but don't edit)\n\nKeys:\nArrows Move left/right/up/down by one line/column\nPgUp/PgDn Move up/down by one page\nHome/End Start/end of line (start/end of file with ctrl)\n0-9, a-f Change current half-byte to hexadecimal value\n^J or : Jump (+/- for relative offset, otherwise absolute address)\n^F or / Find string (^G/n: next, ^D/p: previous match)\nu Undo\nx Toggle bw/color display\nq/^C/^Q/Esc Quit"
@@ -496,7 +496,7 @@
#define HELP_dhcpd "usage: dhcpd [-46fS] [-i IFACE] [-P N] [CONFFILE]\n\n -f Run in foreground\n -i Interface to use\n -S Log to syslog too\n -P N Use port N (default ipv4 67, ipv6 547)\n -4, -6 Run as a DHCPv4 or DHCPv6 server"
-#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events\n -t Send up to N Solicit packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -r Request this IP address\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
+#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\nConfigure network dynamically using DHCP.\n\n-i Interface to use (default eth0)\n-p Create pidfile\n-s Run PROG at DHCP events\n-t Send up to N Solicit packets\n-T Pause between packets (default 3 seconds)\n-A Wait N seconds after failure (default 20)\n-f Run in foreground\n-b Background if lease is not obtained\n-n Exit if lease is not obtained\n-q Exit after obtaining lease\n-R Release IP on exit\n-S Log to syslog too\n-r Request this IP address\n-v Verbose\n\nSignals:\nUSR1 Renew current lease\nUSR2 Release current lease"
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
diff --git a/android/linux/generated/newtoys.h b/android/linux/generated/newtoys.h
index 92814854..0873071c 100644
--- a/android/linux/generated/newtoys.h
+++ b/android/linux/generated/newtoys.h
@@ -184,7 +184,7 @@ USE_MCOOKIE(NEWTOY(mcookie, "v(verbose)V(version)", TOYFLAG_USR|TOYFLAG_BIN))
USE_MD5SUM(NEWTOY(md5sum, "bc(check)s(status)[!bc]", TOYFLAG_USR|TOYFLAG_BIN))
USE_MDEV(NEWTOY(mdev, "s", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MEMEATER(NEWTOY(memeater, "<1>1M", TOYFLAG_USR|TOYFLAG_BIN))
-USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN))
+USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NOBUF))
USE_MIX(NEWTOY(mix, "c:d:l#r#", TOYFLAG_USR|TOYFLAG_BIN))
USE_MKDIR(NEWTOY(mkdir, "<1"USE_MKDIR_Z("Z:")"vp(parent)(parents)m:", TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MKE2FS(NEWTOY(mke2fs, "<1>2g:Fnqm#N#i#b#", TOYFLAG_SBIN))
@@ -204,7 +204,7 @@ USE_NBD_SERVER(OLDTOY(nbd-server, nbd_server, TOYFLAG_USR|TOYFLAG_BIN))
USE_NBD_CLIENT(NEWTOY(nbd_client, "<3>3b#<1>4294967295=4096ns", 0))
USE_NBD_SERVER(NEWTOY(nbd_server, "<1>1r", 0))
USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
-USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
+USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]", TOYFLAG_BIN))
USE_NETSTAT(NEWTOY(netstat, "pWrxwutneal", TOYFLAG_BIN))
USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_BIN))
USE_NL(NEWTOY(nl, "v#=1l#w#<0=6b:n:s:E", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/linux/generated/tags.h b/android/linux/generated/tags.h
index 463e8d2c..d47e3a58 100644
--- a/android/linux/generated/tags.h
+++ b/android/linux/generated/tags.h
@@ -1,140 +1,140 @@
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
-#define DD_conv_fsync 0
-#define _DD_conv_fsync (1<<0)
-#define DD_conv_noerror 1
-#define _DD_conv_noerror (1<<1)
-#define DD_conv_notrunc 2
-#define _DD_conv_notrunc (1<<2)
-#define DD_conv_sync 3
-#define _DD_conv_sync (1<<3)
-#define DD_iflag_count_bytes 0
-#define _DD_iflag_count_bytes (1<<0)
-#define DD_iflag_skip_bytes 1
-#define _DD_iflag_skip_bytes (1<<1)
-#define DD_oflag_seek_bytes 0
-#define _DD_oflag_seek_bytes (1<<0)
-#define PS_PID 0
-#define _PS_PID (1<<0)
-#define PS_PPID 1
-#define _PS_PPID (1<<1)
-#define PS_PRI 2
-#define _PS_PRI (1<<2)
-#define PS_NI 3
-#define _PS_NI (1<<3)
-#define PS_ADDR 4
-#define _PS_ADDR (1<<4)
-#define PS_SZ 5
-#define _PS_SZ (1<<5)
-#define PS_RSS 6
-#define _PS_RSS (1<<6)
-#define PS_PGID 7
-#define _PS_PGID (1<<7)
-#define PS_VSZ 8
-#define _PS_VSZ (1<<8)
-#define PS_MAJFL 9
-#define _PS_MAJFL (1<<9)
-#define PS_MINFL 10
-#define _PS_MINFL (1<<10)
-#define PS_PR 11
-#define _PS_PR (1<<11)
-#define PS_PSR 12
-#define _PS_PSR (1<<12)
-#define PS_RTPRIO 13
-#define _PS_RTPRIO (1<<13)
-#define PS_SCH 14
-#define _PS_SCH (1<<14)
-#define PS_CPU 15
-#define _PS_CPU (1<<15)
-#define PS_TID 16
-#define _PS_TID (1<<16)
-#define PS_TCNT 17
-#define _PS_TCNT (1<<17)
-#define PS_BIT 18
-#define _PS_BIT (1<<18)
-#define PS_TTY 19
-#define _PS_TTY (1<<19)
-#define PS_WCHAN 20
-#define _PS_WCHAN (1<<20)
-#define PS_LABEL 21
-#define _PS_LABEL (1<<21)
-#define PS_COMM 22
-#define _PS_COMM (1<<22)
-#define PS_NAME 23
-#define _PS_NAME (1<<23)
-#define PS_COMMAND 24
-#define _PS_COMMAND (1<<24)
-#define PS_CMDLINE 25
-#define _PS_CMDLINE (1<<25)
-#define PS_ARGS 26
-#define _PS_ARGS (1<<26)
-#define PS_CMD 27
-#define _PS_CMD (1<<27)
-#define PS_UID 28
-#define _PS_UID (1<<28)
-#define PS_USER 29
-#define _PS_USER (1<<29)
-#define PS_RUID 30
-#define _PS_RUID (1<<30)
-#define PS_RUSER 31
-#define _PS_RUSER (1<<31)
-#define PS_GID 32
-#define _PS_GID (1LL<<32)
-#define PS_GROUP 33
-#define _PS_GROUP (1LL<<33)
-#define PS_RGID 34
-#define _PS_RGID (1LL<<34)
-#define PS_RGROUP 35
-#define _PS_RGROUP (1LL<<35)
-#define PS_TIME 36
-#define _PS_TIME (1LL<<36)
-#define PS_ELAPSED 37
-#define _PS_ELAPSED (1LL<<37)
-#define PS_TIME_ 38
-#define _PS_TIME_ (1LL<<38)
-#define PS_C 39
-#define _PS_C (1LL<<39)
-#define PS__VSZ 40
-#define _PS__VSZ (1LL<<40)
-#define PS__MEM 41
-#define _PS__MEM (1LL<<41)
-#define PS__CPU 42
-#define _PS__CPU (1LL<<42)
-#define PS_VIRT 43
-#define _PS_VIRT (1LL<<43)
-#define PS_RES 44
-#define _PS_RES (1LL<<44)
-#define PS_SHR 45
-#define _PS_SHR (1LL<<45)
-#define PS_READ 46
-#define _PS_READ (1LL<<46)
-#define PS_WRITE 47
-#define _PS_WRITE (1LL<<47)
-#define PS_IO 48
-#define _PS_IO (1LL<<48)
-#define PS_DREAD 49
-#define _PS_DREAD (1LL<<49)
-#define PS_DWRITE 50
-#define _PS_DWRITE (1LL<<50)
-#define PS_SWAP 51
-#define _PS_SWAP (1LL<<51)
-#define PS_DIO 52
-#define _PS_DIO (1LL<<52)
-#define PS_STIME 53
-#define _PS_STIME (1LL<<53)
-#define PS_F 54
-#define _PS_F (1LL<<54)
-#define PS_S 55
-#define _PS_S (1LL<<55)
-#define PS_STAT 56
-#define _PS_STAT (1LL<<56)
-#define PS_PCY 57
-#define _PS_PCY (1LL<<57)
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
+#define DD_conv_fsync 0
+#define _DD_conv_fsync (1<<0)
+#define DD_conv_noerror 1
+#define _DD_conv_noerror (1<<1)
+#define DD_conv_notrunc 2
+#define _DD_conv_notrunc (1<<2)
+#define DD_conv_sync 3
+#define _DD_conv_sync (1<<3)
+#define DD_iflag_count_bytes 0
+#define _DD_iflag_count_bytes (1<<0)
+#define DD_iflag_skip_bytes 1
+#define _DD_iflag_skip_bytes (1<<1)
+#define DD_oflag_seek_bytes 0
+#define _DD_oflag_seek_bytes (1<<0)
+#define PS_PID 0
+#define _PS_PID (1<<0)
+#define PS_PPID 1
+#define _PS_PPID (1<<1)
+#define PS_PRI 2
+#define _PS_PRI (1<<2)
+#define PS_NI 3
+#define _PS_NI (1<<3)
+#define PS_ADDR 4
+#define _PS_ADDR (1<<4)
+#define PS_SZ 5
+#define _PS_SZ (1<<5)
+#define PS_RSS 6
+#define _PS_RSS (1<<6)
+#define PS_PGID 7
+#define _PS_PGID (1<<7)
+#define PS_VSZ 8
+#define _PS_VSZ (1<<8)
+#define PS_MAJFL 9
+#define _PS_MAJFL (1<<9)
+#define PS_MINFL 10
+#define _PS_MINFL (1<<10)
+#define PS_PR 11
+#define _PS_PR (1<<11)
+#define PS_PSR 12
+#define _PS_PSR (1<<12)
+#define PS_RTPRIO 13
+#define _PS_RTPRIO (1<<13)
+#define PS_SCH 14
+#define _PS_SCH (1<<14)
+#define PS_CPU 15
+#define _PS_CPU (1<<15)
+#define PS_TID 16
+#define _PS_TID (1<<16)
+#define PS_TCNT 17
+#define _PS_TCNT (1<<17)
+#define PS_BIT 18
+#define _PS_BIT (1<<18)
+#define PS_TTY 19
+#define _PS_TTY (1<<19)
+#define PS_WCHAN 20
+#define _PS_WCHAN (1<<20)
+#define PS_LABEL 21
+#define _PS_LABEL (1<<21)
+#define PS_COMM 22
+#define _PS_COMM (1<<22)
+#define PS_NAME 23
+#define _PS_NAME (1<<23)
+#define PS_COMMAND 24
+#define _PS_COMMAND (1<<24)
+#define PS_CMDLINE 25
+#define _PS_CMDLINE (1<<25)
+#define PS_ARGS 26
+#define _PS_ARGS (1<<26)
+#define PS_CMD 27
+#define _PS_CMD (1<<27)
+#define PS_UID 28
+#define _PS_UID (1<<28)
+#define PS_USER 29
+#define _PS_USER (1<<29)
+#define PS_RUID 30
+#define _PS_RUID (1<<30)
+#define PS_RUSER 31
+#define _PS_RUSER (1<<31)
+#define PS_GID 32
+#define _PS_GID (1LL<<32)
+#define PS_GROUP 33
+#define _PS_GROUP (1LL<<33)
+#define PS_RGID 34
+#define _PS_RGID (1LL<<34)
+#define PS_RGROUP 35
+#define _PS_RGROUP (1LL<<35)
+#define PS_TIME 36
+#define _PS_TIME (1LL<<36)
+#define PS_ELAPSED 37
+#define _PS_ELAPSED (1LL<<37)
+#define PS_TIME_ 38
+#define _PS_TIME_ (1LL<<38)
+#define PS_C 39
+#define _PS_C (1LL<<39)
+#define PS__VSZ 40
+#define _PS__VSZ (1LL<<40)
+#define PS__MEM 41
+#define _PS__MEM (1LL<<41)
+#define PS__CPU 42
+#define _PS__CPU (1LL<<42)
+#define PS_VIRT 43
+#define _PS_VIRT (1LL<<43)
+#define PS_RES 44
+#define _PS_RES (1LL<<44)
+#define PS_SHR 45
+#define _PS_SHR (1LL<<45)
+#define PS_READ 46
+#define _PS_READ (1LL<<46)
+#define PS_WRITE 47
+#define _PS_WRITE (1LL<<47)
+#define PS_IO 48
+#define _PS_IO (1LL<<48)
+#define PS_DREAD 49
+#define _PS_DREAD (1LL<<49)
+#define PS_DWRITE 50
+#define _PS_DWRITE (1LL<<50)
+#define PS_SWAP 51
+#define _PS_SWAP (1LL<<51)
+#define PS_DIO 52
+#define _PS_DIO (1LL<<52)
+#define PS_STIME 53
+#define _PS_STIME (1LL<<53)
+#define PS_F 54
+#define _PS_F (1LL<<54)
+#define PS_S 55
+#define _PS_S (1LL<<55)
+#define PS_STAT 56
+#define _PS_STAT (1LL<<56)
+#define PS_PCY 57
+#define _PS_PCY (1LL<<57)
diff --git a/android/mac/generated/flags.h b/android/mac/generated/flags.h
index 11ac529e..1183c4ed 100644
--- a/android/mac/generated/flags.h
+++ b/android/mac/generated/flags.h
@@ -2228,14 +2228,13 @@
#undef FLAG_r
#endif
-// netcat ^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]
+// netcat ^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]
#undef OPTSTR_netcat
-#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]"
+#define OPTSTR_netcat "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]"
#ifdef CLEANUP_netcat
#undef CLEANUP_netcat
#undef FOR_netcat
#undef FLAG_z
-#undef FLAG_v
#undef FLAG_n
#undef FLAG_U
#undef FLAG_u
@@ -2243,6 +2242,8 @@
#undef FLAG_4
#undef FLAG_f
#undef FLAG_s
+#undef FLAG_o
+#undef FLAG_O
#undef FLAG_q
#undef FLAG_p
#undef FLAG_W
@@ -5975,22 +5976,23 @@
#define TT this.netcat
#endif
#define FLAG_z (FORCED_FLAG<<0)
-#define FLAG_v (FORCED_FLAG<<1)
-#define FLAG_n (FORCED_FLAG<<2)
-#define FLAG_U (FORCED_FLAG<<3)
-#define FLAG_u (FORCED_FLAG<<4)
-#define FLAG_6 (FORCED_FLAG<<5)
-#define FLAG_4 (FORCED_FLAG<<6)
-#define FLAG_f (FORCED_FLAG<<7)
-#define FLAG_s (FORCED_FLAG<<8)
-#define FLAG_q (FORCED_FLAG<<9)
-#define FLAG_p (FORCED_FLAG<<10)
-#define FLAG_W (FORCED_FLAG<<11)
-#define FLAG_w (FORCED_FLAG<<12)
-#define FLAG_L (FORCED_FLAG<<13)
-#define FLAG_l (FORCED_FLAG<<14)
-#define FLAG_E (FORCED_FLAG<<15)
-#define FLAG_t (FORCED_FLAG<<16)
+#define FLAG_n (FORCED_FLAG<<1)
+#define FLAG_U (FORCED_FLAG<<2)
+#define FLAG_u (FORCED_FLAG<<3)
+#define FLAG_6 (FORCED_FLAG<<4)
+#define FLAG_4 (FORCED_FLAG<<5)
+#define FLAG_f (FORCED_FLAG<<6)
+#define FLAG_s (FORCED_FLAG<<7)
+#define FLAG_o (FORCED_FLAG<<8)
+#define FLAG_O (FORCED_FLAG<<9)
+#define FLAG_q (FORCED_FLAG<<10)
+#define FLAG_p (FORCED_FLAG<<11)
+#define FLAG_W (FORCED_FLAG<<12)
+#define FLAG_w (FORCED_FLAG<<13)
+#define FLAG_L (FORCED_FLAG<<14)
+#define FLAG_l (FORCED_FLAG<<15)
+#define FLAG_E (FORCED_FLAG<<16)
+#define FLAG_t (FORCED_FLAG<<17)
#endif
#ifdef FOR_netstat
diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h
index b3c74b17..02095c14 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -126,7 +126,7 @@
#define HELP_netstat "usage: netstat [-pWrxwutneal]\n\nDisplay networking information. Default is netstat -tuwx\n\n-r Routing table\n-a All sockets (not just connected)\n-l Listening server sockets\n-t TCP sockets\n-u UDP sockets\n-w Raw sockets\n-x Unix sockets\n-e Extended info\n-n Don't resolve names\n-W Wide display\n-p Show PID/program name of sockets"
-#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-v Verbose\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
+#define HELP_netcat "usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] [-o FILE] {IPADDR PORTNUM|-f FILENAME|COMMAND...}\n\nForward stdin/stdout to a file or network connection.\n\n-4 Force IPv4\n-6 Force IPv6\n-E Forward stderr\n-f Use FILENAME (ala /dev/ttyS0) instead of network\n-L Listen and background each incoming connection (server mode)\n-l Listen for one incoming connection, then exit\n-n No DNS lookup\n-o Hex dump to FILE (-o- writes hex only to stdout)\n-O Hex dump to FILE (collated)\n-p Local port number\n-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet\n-s Local source address\n-t Allocate tty\n-u Use UDP\n-U Use a UNIX domain socket\n-W SECONDS timeout for more data on an idle connection\n-w SECONDS timeout to establish connection\n-z zero-I/O mode [used for scanning]\n\nWhen listening the COMMAND line is executed as a child process to handle\nan incoming connection. With no COMMAND -l forwards the connection\nto stdin/stdout. If no -p specified, -l prints the port it bound to and\nbackgrounds itself (returning immediately).\n\nFor a quick-and-dirty server, try something like:\nnetcat -s 127.0.0.1 -p 1234 -tL sh -l\n\nOr use \"stty 115200 -F /dev/ttyS0 && stty raw -echo -ctlecho\" with\nnetcat -f to connect to a serial port."
#define HELP_microcom "usage: microcom [-s SPEED] [-X] DEVICE\n\nSimple serial console. Hit CTRL-] for menu.\n\n-s Set baud rate to SPEED (default 115200)\n-X Ignore ^] menu escape"
@@ -176,7 +176,7 @@
#define HELP_tac "usage: tac [FILE...]\n\nOutput lines in reverse order."
-#define HELP_sysctl "usage: sysctl [-aAeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a,A Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
+#define HELP_sysctl "usage: sysctl [-aeNnqw] [-p [FILE] | KEY[=VALUE]...]\n\nRead/write system control data (under /proc/sys).\n\n-a Show all values\n-e Don't warn about unknown keys\n-N Don't print key values\n-n Don't print key names\n-p Read values from FILE (default /etc/sysctl.conf)\n-q Don't show value after write\n-w Only write values (object to reading)"
#define HELP_switch_root "usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT...\n\nUse from PID 1 under initramfs to free initramfs, chroot to NEW_ROOT,\nand exec NEW_INIT.\n\n-c Redirect console to device in NEW_ROOT\n-h Hang instead of exiting on failure (avoids kernel panic)"
@@ -292,7 +292,7 @@
#define HELP_i2cdetect "usage: i2cdetect [-aqry] BUS [FIRST LAST]\nusage: i2cdetect -F BUS\nusage: i2cdetect -l\n\nDetect i2c devices.\n\n-a All addresses (0x00-0x7f rather than 0x03-0x77 or FIRST-LAST)\n-F Show functionality\n-l List available buses\n-q Probe with SMBus Quick Write (default)\n-r Probe with SMBus Read Byte\n-y Skip confirmation prompts (yes to all)"
-#define HELP_hwclock "usage: hwclock [-rswtluf]\n\nGet/set the hardware clock.\n\n-f FILE Use specified device file instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Set the system time based on the current timezone (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
+#define HELP_hwclock "usage: hwclock [-rswtlu] [-f FILE]\n\nGet/set the hardware clock. Default is hwclock -ruf /dev/rtc0\n\n-f Use specified device FILE instead of /dev/rtc0 (--rtc)\n-l Hardware clock uses localtime (--localtime)\n-r Show hardware clock time (--show)\n-s Set system time from hardware clock (--hctosys)\n-t Inform kernel of non-UTC clock's timezone so it returns UTC (--systz)\n-u Hardware clock uses UTC (--utc)\n-w Set hardware clock from system time (--systohc)"
#define HELP_hexedit "usage: hexedit [-r] FILE\n\nHexadecimal file editor/viewer. All changes are written to disk immediately.\n\n-r Read only (display but don't edit)\n\nKeys:\nArrows Move left/right/up/down by one line/column\nPgUp/PgDn Move up/down by one page\nHome/End Start/end of line (start/end of file with ctrl)\n0-9, a-f Change current half-byte to hexadecimal value\n^J or : Jump (+/- for relative offset, otherwise absolute address)\n^F or / Find string (^G/n: next, ^D/p: previous match)\nu Undo\nx Toggle bw/color display\nq/^C/^Q/Esc Quit"
@@ -496,7 +496,7 @@
#define HELP_dhcpd "usage: dhcpd [-46fS] [-i IFACE] [-P N] [CONFFILE]\n\n -f Run in foreground\n -i Interface to use\n -S Log to syslog too\n -P N Use port N (default ipv4 67, ipv6 547)\n -4, -6 Run as a DHCPv4 or DHCPv6 server"
-#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events\n -t Send up to N Solicit packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -r Request this IP address\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
+#define HELP_dhcp6 "usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n\nConfigure network dynamically using DHCP.\n\n-i Interface to use (default eth0)\n-p Create pidfile\n-s Run PROG at DHCP events\n-t Send up to N Solicit packets\n-T Pause between packets (default 3 seconds)\n-A Wait N seconds after failure (default 20)\n-f Run in foreground\n-b Background if lease is not obtained\n-n Exit if lease is not obtained\n-q Exit after obtaining lease\n-R Release IP on exit\n-S Log to syslog too\n-r Request this IP address\n-v Verbose\n\nSignals:\nUSR1 Renew current lease\nUSR2 Release current lease"
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
diff --git a/android/mac/generated/newtoys.h b/android/mac/generated/newtoys.h
index 92814854..0873071c 100644
--- a/android/mac/generated/newtoys.h
+++ b/android/mac/generated/newtoys.h
@@ -184,7 +184,7 @@ USE_MCOOKIE(NEWTOY(mcookie, "v(verbose)V(version)", TOYFLAG_USR|TOYFLAG_BIN))
USE_MD5SUM(NEWTOY(md5sum, "bc(check)s(status)[!bc]", TOYFLAG_USR|TOYFLAG_BIN))
USE_MDEV(NEWTOY(mdev, "s", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MEMEATER(NEWTOY(memeater, "<1>1M", TOYFLAG_USR|TOYFLAG_BIN))
-USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN))
+USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NOBUF))
USE_MIX(NEWTOY(mix, "c:d:l#r#", TOYFLAG_USR|TOYFLAG_BIN))
USE_MKDIR(NEWTOY(mkdir, "<1"USE_MKDIR_Z("Z:")"vp(parent)(parents)m:", TOYFLAG_BIN|TOYFLAG_UMASK))
USE_MKE2FS(NEWTOY(mke2fs, "<1>2g:Fnqm#N#i#b#", TOYFLAG_SBIN))
@@ -204,7 +204,7 @@ USE_NBD_SERVER(OLDTOY(nbd-server, nbd_server, TOYFLAG_USR|TOYFLAG_BIN))
USE_NBD_CLIENT(NEWTOY(nbd_client, "<3>3b#<1>4294967295=4096ns", 0))
USE_NBD_SERVER(NEWTOY(nbd_server, "<1>1r", 0))
USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
-USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
+USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]", TOYFLAG_BIN))
USE_NETSTAT(NEWTOY(netstat, "pWrxwutneal", TOYFLAG_BIN))
USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_BIN))
USE_NL(NEWTOY(nl, "v#=1l#w#<0=6b:n:s:E", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/mac/generated/tags.h b/android/mac/generated/tags.h
index 463e8d2c..d47e3a58 100644
--- a/android/mac/generated/tags.h
+++ b/android/mac/generated/tags.h
@@ -1,140 +1,140 @@
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
-#define DD_conv_fsync 0
-#define _DD_conv_fsync (1<<0)
-#define DD_conv_noerror 1
-#define _DD_conv_noerror (1<<1)
-#define DD_conv_notrunc 2
-#define _DD_conv_notrunc (1<<2)
-#define DD_conv_sync 3
-#define _DD_conv_sync (1<<3)
-#define DD_iflag_count_bytes 0
-#define _DD_iflag_count_bytes (1<<0)
-#define DD_iflag_skip_bytes 1
-#define _DD_iflag_skip_bytes (1<<1)
-#define DD_oflag_seek_bytes 0
-#define _DD_oflag_seek_bytes (1<<0)
-#define PS_PID 0
-#define _PS_PID (1<<0)
-#define PS_PPID 1
-#define _PS_PPID (1<<1)
-#define PS_PRI 2
-#define _PS_PRI (1<<2)
-#define PS_NI 3
-#define _PS_NI (1<<3)
-#define PS_ADDR 4
-#define _PS_ADDR (1<<4)
-#define PS_SZ 5
-#define _PS_SZ (1<<5)
-#define PS_RSS 6
-#define _PS_RSS (1<<6)
-#define PS_PGID 7
-#define _PS_PGID (1<<7)
-#define PS_VSZ 8
-#define _PS_VSZ (1<<8)
-#define PS_MAJFL 9
-#define _PS_MAJFL (1<<9)
-#define PS_MINFL 10
-#define _PS_MINFL (1<<10)
-#define PS_PR 11
-#define _PS_PR (1<<11)
-#define PS_PSR 12
-#define _PS_PSR (1<<12)
-#define PS_RTPRIO 13
-#define _PS_RTPRIO (1<<13)
-#define PS_SCH 14
-#define _PS_SCH (1<<14)
-#define PS_CPU 15
-#define _PS_CPU (1<<15)
-#define PS_TID 16
-#define _PS_TID (1<<16)
-#define PS_TCNT 17
-#define _PS_TCNT (1<<17)
-#define PS_BIT 18
-#define _PS_BIT (1<<18)
-#define PS_TTY 19
-#define _PS_TTY (1<<19)
-#define PS_WCHAN 20
-#define _PS_WCHAN (1<<20)
-#define PS_LABEL 21
-#define _PS_LABEL (1<<21)
-#define PS_COMM 22
-#define _PS_COMM (1<<22)
-#define PS_NAME 23
-#define _PS_NAME (1<<23)
-#define PS_COMMAND 24
-#define _PS_COMMAND (1<<24)
-#define PS_CMDLINE 25
-#define _PS_CMDLINE (1<<25)
-#define PS_ARGS 26
-#define _PS_ARGS (1<<26)
-#define PS_CMD 27
-#define _PS_CMD (1<<27)
-#define PS_UID 28
-#define _PS_UID (1<<28)
-#define PS_USER 29
-#define _PS_USER (1<<29)
-#define PS_RUID 30
-#define _PS_RUID (1<<30)
-#define PS_RUSER 31
-#define _PS_RUSER (1<<31)
-#define PS_GID 32
-#define _PS_GID (1LL<<32)
-#define PS_GROUP 33
-#define _PS_GROUP (1LL<<33)
-#define PS_RGID 34
-#define _PS_RGID (1LL<<34)
-#define PS_RGROUP 35
-#define _PS_RGROUP (1LL<<35)
-#define PS_TIME 36
-#define _PS_TIME (1LL<<36)
-#define PS_ELAPSED 37
-#define _PS_ELAPSED (1LL<<37)
-#define PS_TIME_ 38
-#define _PS_TIME_ (1LL<<38)
-#define PS_C 39
-#define _PS_C (1LL<<39)
-#define PS__VSZ 40
-#define _PS__VSZ (1LL<<40)
-#define PS__MEM 41
-#define _PS__MEM (1LL<<41)
-#define PS__CPU 42
-#define _PS__CPU (1LL<<42)
-#define PS_VIRT 43
-#define _PS_VIRT (1LL<<43)
-#define PS_RES 44
-#define _PS_RES (1LL<<44)
-#define PS_SHR 45
-#define _PS_SHR (1LL<<45)
-#define PS_READ 46
-#define _PS_READ (1LL<<46)
-#define PS_WRITE 47
-#define _PS_WRITE (1LL<<47)
-#define PS_IO 48
-#define _PS_IO (1LL<<48)
-#define PS_DREAD 49
-#define _PS_DREAD (1LL<<49)
-#define PS_DWRITE 50
-#define _PS_DWRITE (1LL<<50)
-#define PS_SWAP 51
-#define _PS_SWAP (1LL<<51)
-#define PS_DIO 52
-#define _PS_DIO (1LL<<52)
-#define PS_STIME 53
-#define _PS_STIME (1LL<<53)
-#define PS_F 54
-#define _PS_F (1LL<<54)
-#define PS_S 55
-#define _PS_S (1LL<<55)
-#define PS_STAT 56
-#define _PS_STAT (1LL<<56)
-#define PS_PCY 57
-#define _PS_PCY (1LL<<57)
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
+#define DD_conv_fsync 0
+#define _DD_conv_fsync (1<<0)
+#define DD_conv_noerror 1
+#define _DD_conv_noerror (1<<1)
+#define DD_conv_notrunc 2
+#define _DD_conv_notrunc (1<<2)
+#define DD_conv_sync 3
+#define _DD_conv_sync (1<<3)
+#define DD_iflag_count_bytes 0
+#define _DD_iflag_count_bytes (1<<0)
+#define DD_iflag_skip_bytes 1
+#define _DD_iflag_skip_bytes (1<<1)
+#define DD_oflag_seek_bytes 0
+#define _DD_oflag_seek_bytes (1<<0)
+#define PS_PID 0
+#define _PS_PID (1<<0)
+#define PS_PPID 1
+#define _PS_PPID (1<<1)
+#define PS_PRI 2
+#define _PS_PRI (1<<2)
+#define PS_NI 3
+#define _PS_NI (1<<3)
+#define PS_ADDR 4
+#define _PS_ADDR (1<<4)
+#define PS_SZ 5
+#define _PS_SZ (1<<5)
+#define PS_RSS 6
+#define _PS_RSS (1<<6)
+#define PS_PGID 7
+#define _PS_PGID (1<<7)
+#define PS_VSZ 8
+#define _PS_VSZ (1<<8)
+#define PS_MAJFL 9
+#define _PS_MAJFL (1<<9)
+#define PS_MINFL 10
+#define _PS_MINFL (1<<10)
+#define PS_PR 11
+#define _PS_PR (1<<11)
+#define PS_PSR 12
+#define _PS_PSR (1<<12)
+#define PS_RTPRIO 13
+#define _PS_RTPRIO (1<<13)
+#define PS_SCH 14
+#define _PS_SCH (1<<14)
+#define PS_CPU 15
+#define _PS_CPU (1<<15)
+#define PS_TID 16
+#define _PS_TID (1<<16)
+#define PS_TCNT 17
+#define _PS_TCNT (1<<17)
+#define PS_BIT 18
+#define _PS_BIT (1<<18)
+#define PS_TTY 19
+#define _PS_TTY (1<<19)
+#define PS_WCHAN 20
+#define _PS_WCHAN (1<<20)
+#define PS_LABEL 21
+#define _PS_LABEL (1<<21)
+#define PS_COMM 22
+#define _PS_COMM (1<<22)
+#define PS_NAME 23
+#define _PS_NAME (1<<23)
+#define PS_COMMAND 24
+#define _PS_COMMAND (1<<24)
+#define PS_CMDLINE 25
+#define _PS_CMDLINE (1<<25)
+#define PS_ARGS 26
+#define _PS_ARGS (1<<26)
+#define PS_CMD 27
+#define _PS_CMD (1<<27)
+#define PS_UID 28
+#define _PS_UID (1<<28)
+#define PS_USER 29
+#define _PS_USER (1<<29)
+#define PS_RUID 30
+#define _PS_RUID (1<<30)
+#define PS_RUSER 31
+#define _PS_RUSER (1<<31)
+#define PS_GID 32
+#define _PS_GID (1LL<<32)
+#define PS_GROUP 33
+#define _PS_GROUP (1LL<<33)
+#define PS_RGID 34
+#define _PS_RGID (1LL<<34)
+#define PS_RGROUP 35
+#define _PS_RGROUP (1LL<<35)
+#define PS_TIME 36
+#define _PS_TIME (1LL<<36)
+#define PS_ELAPSED 37
+#define _PS_ELAPSED (1LL<<37)
+#define PS_TIME_ 38
+#define _PS_TIME_ (1LL<<38)
+#define PS_C 39
+#define _PS_C (1LL<<39)
+#define PS__VSZ 40
+#define _PS__VSZ (1LL<<40)
+#define PS__MEM 41
+#define _PS__MEM (1LL<<41)
+#define PS__CPU 42
+#define _PS__CPU (1LL<<42)
+#define PS_VIRT 43
+#define _PS_VIRT (1LL<<43)
+#define PS_RES 44
+#define _PS_RES (1LL<<44)
+#define PS_SHR 45
+#define _PS_SHR (1LL<<45)
+#define PS_READ 46
+#define _PS_READ (1LL<<46)
+#define PS_WRITE 47
+#define _PS_WRITE (1LL<<47)
+#define PS_IO 48
+#define _PS_IO (1LL<<48)
+#define PS_DREAD 49
+#define _PS_DREAD (1LL<<49)
+#define PS_DWRITE 50
+#define _PS_DWRITE (1LL<<50)
+#define PS_SWAP 51
+#define _PS_SWAP (1LL<<51)
+#define PS_DIO 52
+#define _PS_DIO (1LL<<52)
+#define PS_STIME 53
+#define _PS_STIME (1LL<<53)
+#define PS_F 54
+#define _PS_F (1LL<<54)
+#define PS_S 55
+#define _PS_S (1LL<<55)
+#define PS_STAT 56
+#define _PS_STAT (1LL<<56)
+#define PS_PCY 57
+#define _PS_PCY (1LL<<57)
diff --git a/config-linux b/config-linux
index 59b5745a..24132c62 100644
--- a/config-linux
+++ b/config-linux
@@ -214,7 +214,7 @@ CONFIG_MKTEMP=y
# CONFIG_MODINFO is not set
# CONFIG_MODPROBE is not set
# CONFIG_MORE is not set
-# CONFIG_MOUNT is not set
+CONFIG_MOUNT=y
# CONFIG_MOUNTPOINT is not set
CONFIG_MV=y
# CONFIG_NBD_CLIENT is not set
@@ -322,13 +322,13 @@ CONFIG_TR=y
# CONFIG_TUNCTL is not set
# CONFIG_UCLAMPSET is not set
# CONFIG_ULIMIT is not set
-# CONFIG_UMOUNT is not set
+CONFIG_UMOUNT=y
CONFIG_UNAME=y
# CONFIG_UNICODE is not set
CONFIG_UNIQ=y
CONFIG_UNIX2DOS=y
# CONFIG_UNLINK is not set
-# CONFIG_UNSHARE is not set
+CONFIG_UNSHARE=y
# CONFIG_UPTIME is not set
# CONFIG_USERADD is not set
# CONFIG_USERDEL is not set
diff --git a/kconfig/freebsd_miniconfig b/kconfig/freebsd_miniconfig
index e82e3f95..0ca16d89 100644
--- a/kconfig/freebsd_miniconfig
+++ b/kconfig/freebsd_miniconfig
@@ -61,6 +61,7 @@ CONFIG_TOUCH=y
CONFIG_TRUE=y
CONFIG_TSORT=y
CONFIG_TTY=y
+CONFIG_UNAME=y
CONFIG_UNIQ=y
CONFIG_UNLINK=y
CONFIG_UUDECODE=y
diff --git a/lib/lib.c b/lib/lib.c
index 6a4a77dd..9561848a 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -432,7 +432,7 @@ char *strlower(char *s)
// Case conversion can expand utf8 representation, but with extra mlen
// space above we should basically never need to realloc
- if (mlen+4 > (len = new-try)) continue;
+ if (mlen > (len = new-try)+4) continue;
try = xrealloc(try, mlen = len+16);
new = try+len;
}
diff --git a/lib/lib.h b/lib/lib.h
index da20dd10..5bc21f01 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -333,6 +333,8 @@ int terminal_probesize(unsigned *xx, unsigned *yy);
#define KEY_ALT (1<<18)
int scan_key(char *scratch, int timeout_ms);
int scan_key_getsize(char *scratch, int timeout_ms, unsigned *xx, unsigned *yy);
+unsigned cfspeed2bps(unsigned speed);
+unsigned bps2cfspeed(unsigned baud);
void xsetspeed(struct termios *tio, int speed);
int set_terminal(int fd, int raw, int speed, struct termios *old);
void xset_terminal(int fd, int raw, int speed, struct termios *old);
@@ -357,7 +359,9 @@ void xconnect(int fd, const struct sockaddr *sa, socklen_t len);
int xconnectany(struct addrinfo *ai);
int xbindany(struct addrinfo *ai);
int xpoll(struct pollfd *fds, int nfds, int timeout);
-int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_timeout);
+int pollinate(int in1, int in2, int out1, int out2,
+ void (*callback)(int fd, void *buf, size_t len),
+ int timeout, int shutdown_timeout);
char *ntop(struct sockaddr *sa);
void xsendto(int sockfd, void *buf, size_t len, struct sockaddr *dest);
int xrecvwait(int fd, char *buf, int len, union socksaddr *sa, int timeout);
diff --git a/lib/net.c b/lib/net.c
index 16a110e3..8fe006b6 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -96,7 +96,9 @@ int xpoll(struct pollfd *fds, int nfds, int timeout)
// Loop forwarding data from in1 to out1 and in2 to out2, handling
// half-connection shutdown. timeouts return if no data for X ms.
// Returns 0: both closed, 1 shutdown_timeout, 2 timeout
-int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_timeout)
+int pollinate(int in1, int in2, int out1, int out2,
+ void (*callback)(int fd, void *buf, size_t len),
+ int timeout, int shutdown_timeout)
{
struct pollfd pollfds[2];
int i, pollcount = 2;
@@ -115,7 +117,7 @@ int pollinate(int in1, int in2, int out1, int out2, int timeout, int shutdown_ti
int len = read(pollfds[i].fd, libbuf, sizeof(libbuf));
if (len<1) pollfds[i].revents = POLLHUP;
else {
- xwrite(i ? out2 : out1, libbuf, len);
+ callback(i ? out2 : out1, libbuf, len);
continue;
}
}
diff --git a/lib/portability.c b/lib/portability.c
index 83382d1d..abcecc80 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -65,7 +65,7 @@ struct mtab_list *xgetmountlist(char *path)
int i, count;
if (path) error_exit("xgetmountlist");
- if ((count = getmntinfo(&entries, 0)) == 0) perror_exit("getmntinfo");
+ if (!(count = getmntinfo(&entries, MNT_WAIT))) perror_exit("getmntinfo");
// The "test" part of the loop is done before the first time through and
// again after each "increment", so putting the actual load there avoids
diff --git a/lib/toyflags.h b/lib/toyflags.h
index ab8e4f5b..928fe0bb 100644
--- a/lib/toyflags.h
+++ b/lib/toyflags.h
@@ -30,6 +30,7 @@
// Line buffered stdout
#define TOYFLAG_LINEBUF (1<<10)
+#define TOYFLAG_NOBUF (1<<11)
// Error code to return if argument parsing fails (default 1)
#define TOYFLAG_ARGFAIL(x) (x<<24)
diff --git a/lib/tty.c b/lib/tty.c
index 543006fb..7c249fcc 100644
--- a/lib/tty.c
+++ b/lib/tty.c
@@ -16,6 +16,7 @@
#include "toys.h"
+// Check stdout, stderr, stdin (in that order) and if none open /dev/tty
int tty_fd(void)
{
int i, j;
@@ -72,19 +73,38 @@ int terminal_probesize(unsigned *xx, unsigned *yy)
return 0;
}
-void xsetspeed(struct termios *tio, int speed)
+// This table skips both B0 and BOTHER
+static const int speeds[] = {50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800,
+ 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000,
+ 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000,3500000,4000000};
+
+// Show bits per second for cfspeed value. Assumes we have a valid speed
+unsigned cfspeed2bps(unsigned speed)
{
- int i, speeds[] = {50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
- 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,
- 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
- 2500000, 3000000, 3500000, 4000000};
-
- // Find speed in table, adjust to constant
- for (i = 0; i < ARRAY_LEN(speeds); i++) if (speeds[i] == speed) break;
- if (i == ARRAY_LEN(speeds)) error_exit("unknown speed: %d", speed);
- cfsetspeed(tio, i+1+4081*(i>15));
+ if (!(speed&15)) return 0;
+ if (speed>15) speed = (speed&15)+15;
+
+ return speeds[--speed];
}
+// Convert bits per second to cfspeed value. Returns 0 for unknown bps
+unsigned bps2cfspeed(unsigned baud)
+{
+ int i = 0;
+
+ while (i<ARRAY_LEN(speeds))
+ if (speeds[i++]==baud) return i+(i>15)*(4096-16+1);
+
+ return 0;
+}
+
+void xsetspeed(struct termios *tio, int bps)
+{
+ int i = bps2cfspeed(bps);
+
+ if (!i) error_exit("unknown speed: %d", bps);
+ cfsetspeed(tio, i);
+}
// Reset terminal to known state, saving copy of old state if old != NULL.
int set_terminal(int fd, int raw, int speed, struct termios *old)
diff --git a/main.c b/main.c
index 93cf768e..2cbaf172 100644
--- a/main.c
+++ b/main.c
@@ -154,8 +154,6 @@ void check_help(char **arg)
// Setup toybox global state for this command.
void toy_singleinit(struct toy_list *which, char *argv[])
{
- char *buf;
-
toys.which = which;
toys.argv = argv;
toys.toycount = ARRAY_LEN(toy_list);
@@ -168,6 +166,9 @@ void toy_singleinit(struct toy_list *which, char *argv[])
// Setup we only want to do once: skip for multiplexer or NOFORK reentry
if (!(CFG_TOYBOX && which == toy_list) && !(which->flags & TOYFLAG_NOFORK)) {
+ char *buf = 0;
+ int btype = _IOFBF;
+
toys.old_umask = umask(0);
if (!(which->flags & TOYFLAG_UMASK)) umask(toys.old_umask);
@@ -178,8 +179,10 @@ void toy_singleinit(struct toy_list *which, char *argv[])
uselocale(newlocale(LC_CTYPE_MASK, "C.UTF-8", 0) ? :
newlocale(LC_CTYPE_MASK, "en_US.UTF-8", 0));
- buf = (which->flags & TOYFLAG_LINEBUF) ? 0 : xmalloc(4096);
- setvbuf(stdout, buf, buf ? _IOFBF : _IOLBF, buf ? 4096 : 0);
+ if (which->flags & TOYFLAG_LINEBUF) btype = _IOLBF;
+ else if (which->flags & TOYFLAG_NOBUF) btype = _IONBF;
+ else buf = xmalloc(4096);
+ setvbuf(stdout, buf, btype, buf ? 4096 : 0);
}
}
diff --git a/mkroot/README b/mkroot/README
index 6b499ba8..b7e64114 100644
--- a/mkroot/README
+++ b/mkroot/README
@@ -18,7 +18,7 @@ and one or more musl cross compiler toolchain(s) in the "ccc" directory:
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
$ wget https://landley.net/bin/toolchains/latest/i686-linux-musl-cross.tar.xz
$ mkdir ccc
- $ tar xvJCf ccc i686-linux-musl-cross-tar.xz
+ $ tar xvJCf ccc i686-linux-musl-cross.tar.xz
Then invoke mkroot like:
@@ -128,7 +128,7 @@ support.
--- Environment variables
Any "name=value" argument provided on the mkroot.sh command line will set
-an environment variable, and any string that without an = indicates a package
+an environment variable, and any string without an = indicates a package
script to run before building toybox (explained below). This is why CROSS=
CROSS_COMPILE= and LINUX= were all set on the command line above.
diff --git a/mkroot/mkroot.sh b/mkroot/mkroot.sh
index cb6a78f9..3a422c78 100755
--- a/mkroot/mkroot.sh
+++ b/mkroot/mkroot.sh
@@ -17,7 +17,7 @@ done
: ${TOP:=$PWD/root} ${BUILD:=$TOP/build} ${LOG:=$BUILD/log}
: ${AIRLOCK:=$BUILD/airlock} ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/mkroot/packages}
-announce() { printf "\033]2;$CROSS $*\007" >/dev/tty; printf "\n=== $*\n";}
+announce() { printf "\033]2;$CROSS $*\007" 2>/dev/null >/dev/tty; printf "\n=== $*\n";}
die() { echo "$@" >&2; exit 1; }
# ----- Are we cross compiling (via CROSS_COMPILE= or CROSS=)
@@ -82,7 +82,7 @@ if [ -z "$NOLOGPATH" ]; then
CROSS_COMPILE=${CROSS_COMPILE##*/}
export WRAPDIR="$BUILD/record-commands" LOGPATH="$LOG"-commands.txt
rm -rf "$WRAPDIR" "$LOGPATH" generated/obj &&
- WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 source mkroot/record-commands ||
+ eval "$(WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 mkroot/record-commands)"||
exit 1
fi
@@ -154,7 +154,9 @@ guest:x:500:500:guest:/home/guest:/bin/sh
nobody:x:65534:65534:nobody:/proc/self:/dev/null
EOF
echo -e 'root:x:0:\nguest:x:500:\nnobody:x:65534:' > "$ROOT"/etc/group &&
-: ${VERSION:=$(toybox --version)} &&
+# Grab toybox version git or toys.h
+: ${VERSION:=$(git describe --tags --abbrev=12 2>/dev/null)} &&
+: ${VERSION:=$(sed -n 's/.*TOYBOX_VERSION "\([^"]*\)".*/\1/p' toys.h)} &&
# Optional file, basically a comment
echo $'NAME="mkroot"\nVERSION="'${VERSION#* }$'"\nHOME_URL="https://landley.net/toybox"' > "$ROOT"/etc/os-release || exit 1
diff --git a/mkroot/record-commands b/mkroot/record-commands
index 32557a3e..71f2c4ef 100755
--- a/mkroot/record-commands
+++ b/mkroot/record-commands
@@ -5,20 +5,15 @@
[ -z "$WRAPDIR" ] && WRAPDIR="$PWD"/record-commands && RM=$(which rm)
[ -z "$LOGPATH" ] && export LOGPATH="$PWD"/log.txt
-if [ ${#BASH_SOURCE[@]} -lt 2 ] && [ $# -eq 0 ]
-then
- echo "usage: WRAPDIR=dir LOGPATH=log.txt record-commands COMMAND..."
- echo 'Then examine log.txt. "record-commands echo" to just setup $WRAPDIR'
- exit 1
-fi
-
if [ ! -x "$WRAPDIR/logpath" ]
then
+ LOG="$(which logpath)"
mkdir -p "$WRAPDIR" || exit 1
- [ -e "$(which logpath)" ] && cp -H "$(which logpath)" "$WRAPDIR/logpath" ||
- PREFIX="$WRAPDIR/" scripts/single.sh logpath || exit 1
+ [ -e "$LOG" ] && cp -H "$LOG" "$WRAPDIR/logpath" || { cd "$(dirname $0)/.." &&
+ PREFIX="$WRAPDIR/" scripts/single.sh logpath >/dev/null &&
+ LOG="$PWD/logpath" || exit 1; }
tr : '\n' <<< "$PATH" | while read i; do
- find "$i" -type f,l -maxdepth 1 -executable -exec basename {} \; | \
+ find "$i" \( -type f -o -type l \) -maxdepth 1 -executable -exec basename {} \; | \
while read FILE; do ln -s logpath "$WRAPDIR/$FILE" 2>/dev/null; done
done
fi
@@ -27,13 +22,14 @@ fi
rm -f "$LOGPATH"
# When sourced, set up wrapper for current context.
-export PATH="$WRAPDIR:$PATH"
-if [ ${#BASH_SOURCE[@]} -lt 2 ]
+if [ $# -gt 0 ]
then
- "$@"
+ PATH="$WRAPDIR:$PATH" "$@"
X=$?
[ -n "$RM" ] && "$RM" -rf "$WRAPDIR"
exit $X
+else
+ echo export LOGPATH=${LOGPATH@Q} PATH=${WRAPDIR@Q}:${PATH@Q}
fi
diff --git a/post_update.sh b/post_update.sh
index c07d65ae..2b42dba9 100755
--- a/post_update.sh
+++ b/post_update.sh
@@ -1,8 +1,13 @@
#!/bin/bash
+# external-updater provides:
# $1 Path to the new version.
# $2 Path to the old version.
+if [ "$#" -lt 1 ]; then
+ echo 'need at least the path to the current version!'
+ exit 1
+fi
cd $1
set -e
diff --git a/scripts/make.sh b/scripts/make.sh
index 512fdc75..ff677d5d 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -69,6 +69,9 @@ LIBRARIES=$(
echo -l$i &
done | sort | xargs
)
+# Actually resolve dangling dependencies in extra libraries when static linking
+[ -n "$LIBRARIES" ] && [ "$LDFLAGS" != "${LDFLAGS/-static/}" ] &&
+ LIBRARIES="-Wl,--start-group $LIBRARIES -Wl,--end-group"
[ -z "$VERSION" ] && [ -d ".git" ] && [ -n "$(which git 2>/dev/null)" ] &&
VERSION="$(git describe --tags --abbrev=12 2>/dev/null)"
@@ -209,12 +212,18 @@ fi
echo "} this;"
} > "$GENDIR"/globals.h || exit 1
-hostcomp mktags
-if isnewer tags.h toys
-then
- $SED -n '/TAGGED_ARRAY(/,/^)/{s/.*TAGGED_ARRAY[(]\([^,]*\),/\1/;p}' \
- toys/*/*.c lib/*.c | "$UNSTRIPPED"/mktags > "$GENDIR"/tags.h
-fi
+# Recreate tags.h
+$SED -ne '/TAGGED_ARRAY(/,/^)/{s/.*TAGGED_ARRAY[(]\([^,]*\),/\1/p' \
+ -e 's/[^{]*{"\([^"]*\)"[^{]*/ _\1/gp}' toys/*/*.c | tr '[:punct:]' _ | \
+while read i; do
+ [ "$i" = "${i#_}" ] && { HEAD="$i"; X=0; LL=; continue;}
+ for j in $i; do
+ [ $X -eq 32 ] && LL=LL
+ NAME="$HEAD$j"
+ printf "#define $NAME %*s%s\n#define _$NAME %*s%s\n" \
+ $((32-${#NAME})) "" "$X" $((31-${#NAME})) "" "(1$LL<<$((X++)))" || exit 1
+ done
+done > "$GENDIR"/tags.h || exit 1
# Create help.h, and zhelp.h if zcat enabled
hostcomp config2help
diff --git a/scripts/mktags.c b/scripts/mktags.c
deleted file mode 100644
index 05494b2a..00000000
--- a/scripts/mktags.c
+++ /dev/null
@@ -1,58 +0,0 @@
-// Process TAGGED_ARRAY() macros to emit TAG_STRING index macros.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-int main(int argc, char *argv[])
-{
- char *tag = 0;
- int idx = 0;
-
- for (;;) {
- char *line = 0, *s;
- ssize_t len;
-
- len = getline(&line, (void *)&len, stdin);
- if (len<0) break;
- while (len && isspace(line[len-1])) line[--len]=0;
-
- // Very simple parser: If we haven't got a TAG then first line is TAG.
- // Then look for { followed by "str" (must be on same line, may have
- // more than one per line), for each one emit #define. Current TAG ended
- // by ) at start of line.
-
- if (!tag) {
- if (!isalpha(*line)) {
- fprintf(stderr, "bad tag %s\n", line);
- exit(1);
- }
- tag = strdup(line);
- idx = 0;
-
- continue;
- }
-
- for (s = line; isspace(*s); s++);
- if (*s == ')') tag = 0;
- else for (;;) {
- char *start;
-
- while (*s && *s != '{') s++;
- while (*s && *s != '"') s++;
- if (!*s) break;
-
- start = ++s;
- while (*s && *s != '"') {
- if (!isalpha(*s) && !isdigit(*s)) *s = '_';
- s++;
- }
- printf("#define %s_%*.*s %d\n", tag, -40, (int)(s-start), start, idx);
- printf("#define _%s_%*.*s (1%s<<%d)\n", tag, -39, (int)(s-start), start,
- idx>31 ? "LL": "", idx);
- idx++;
- }
- free(line);
- }
-}
diff --git a/scripts/prereq/generated/config.h b/scripts/prereq/generated/config.h
index f46eed9b..60c87b5b 100644
--- a/scripts/prereq/generated/config.h
+++ b/scripts/prereq/generated/config.h
@@ -700,5 +700,7 @@
#define USE_TOYBOX_NORECURSE(...)
#define CFG_TOYBOX_DEBUG 0
#define USE_TOYBOX_DEBUG(...)
+#define CFG_TOYBOX_UID_SYS 100
+#define CFG_TOYBOX_UID_USR 500
#define CFG_TOYBOX_FORCE_NOMMU 0
#define USE_TOYBOX_FORCE_NOMMU(...)
diff --git a/tests/find.test b/tests/find.test
index d57d1910..e4a161c4 100755
--- a/tests/find.test
+++ b/tests/find.test
@@ -156,4 +156,13 @@ touch -d @12345 dir/one
touch -d @12346 dir/two
testing 'newerat' 'find dir -type f -newerat @12345' 'dir/two\n' '' ''
testing 'newer nano' 'find dir -type f -newerat @12345.67890' 'dir/two\n' '' ''
+ln -s one dir/three
+testing '-size implies -type f' 'find dir -size -1M | sort' \
+ 'dir/one\ndir/two\n' '' ''
rm -rf dir
+
+utf8locale
+skipnot [ "$(uname)" != "Darwin" ] # Darwin's towlower() is broken.
+testing 'strlower edge case' \
+ 'touch aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ; find . -iname aaaaaȺȺȺȺȺȺȺȺȺ' './aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ\n' \
+ '' ''
diff --git a/tests/timeout.test b/tests/timeout.test
index 694540ae..624f3650 100755
--- a/tests/timeout.test
+++ b/tests/timeout.test
@@ -8,13 +8,13 @@
testcmd "times out" '.1 sleep 100 ; echo $?' '124\n' '' ''
testcmd "failure" '-s MONKEY .1 sleep 100 2>/dev/null ; echo $?' '125\n' '' ''
testcmd "early failure" '2>/dev/null ; echo $?' '125\n' '' ''
-testcmd "can't execute" '.1 / 2>/dev/null ; echo $?' '126\n' '' ''
-testcmd "can't find" '.1 /does/not/exist 2>/dev/null ; echo $?' '127\n' '' ''
+testcmd "can't execute" '1 / 2>/dev/null ; echo $?' '126\n' '' ''
+testcmd "can't find" '1 /does/not/exist 2>/dev/null ; echo $?' '127\n' '' ''
testcmd "custom signal" '-s 3 .1 sleep 100; echo $?' '124\n' '' ''
testcmd "killed" '-s 9 .1 sleep 100; echo $?' '137\n' '' ''
testcmd "TERM" '-s TERM .1 sleep 100; echo $?' '124\n' '' ''
-testcmd "exit 0" '.1 true ; echo $?' '0\n' '' ''
-testcmd "exit 1" '.1 false ; echo $?' '1\n' '' ''
+testcmd "exit 0" '1 true ; echo $?' '0\n' '' ''
+testcmd "exit 1" '1 false ; echo $?' '1\n' '' ''
testcmd "--preserve-status" '--preserve-status .1 sleep 100 ; echo $?' '143\n' '' ''
testcmd "--preserve-status killed" '--preserve-status -s 9 .1 sleep 100 ; echo $?' '137\n' '' ''
diff --git a/toys.h b/toys.h
index 88b7a837..94d0c4b5 100644
--- a/toys.h
+++ b/toys.h
@@ -141,5 +141,5 @@ extern char **environ, *toybox_version, toybuf[4096], libbuf[4096];
#ifndef TOYBOX_VENDOR
#define TOYBOX_VENDOR ""
#endif
-#define TOYBOX_VERSION "0.8.10"TOYBOX_VENDOR
+#define TOYBOX_VERSION "0.8.11"TOYBOX_VENDOR
#endif
diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c
index f8c33183..cbc33980 100644
--- a/toys/lsb/mknod.c
+++ b/toys/lsb/mknod.c
@@ -37,7 +37,7 @@ GLOBALS(
void mknod_main(void)
{
mode_t modes[] = {S_IFIFO, S_IFCHR, S_IFCHR, S_IFBLK};
- int major=0, minor=0, type;
+ int major = 0, minor = 0, type;
int mode = TT.m ? string_to_mode(TT.m, 0777) : 0660;
type = stridx("pcub", *toys.optargs[1]);
@@ -49,9 +49,8 @@ void mknod_main(void)
minor = atoi(toys.optargs[3]);
}
- if (toys.optflags & FLAG_Z)
- if (-1 == lsm_set_create(TT.Z))
- perror_exit("-Z '%s' failed", TT.Z);
+ if (FLAG(Z) && lsm_set_create(TT.Z)==-1)
+ perror_exit("-Z '%s' failed", TT.Z);
if (mknod(*toys.optargs, mode|modes[type], dev_makedev(major, minor)))
perror_exit_raw(*toys.optargs);
}
diff --git a/toys/lsb/umount.c b/toys/lsb/umount.c
index 19fd5274..464b02b5 100644
--- a/toys/lsb/umount.c
+++ b/toys/lsb/umount.c
@@ -76,17 +76,16 @@ static void do_umount(char *dir, char *dev, int flags)
}
if (!umount2(dir, flags)) {
- if (toys.optflags & FLAG_v) xprintf("%s unmounted\n", dir);
+ if (FLAG(v)) xprintf("%s unmounted\n", dir);
// Attempt to disassociate loopback device. This ioctl should be ignored
// for anything else, because lanana allocated ioctl range 'L' to loopback
- if (dev && !(toys.optflags & FLAG_D)) {
+ if (dev && !FLAG(D)) {
int lfd = open(dev, O_RDONLY);
if (lfd != -1) {
// This is LOOP_CLR_FD, fetching it from headers is awkward
- if (!ioctl(lfd, 0x4C01) && (toys.optflags & FLAG_v))
- xprintf("%s cleared\n", dev);
+ if (!ioctl(lfd, 0x4C01) && FLAG(v)) xprintf("%s cleared\n", dev);
close(lfd);
}
}
@@ -94,9 +93,9 @@ static void do_umount(char *dir, char *dev, int flags)
return;
}
- if (toys.optflags & FLAG_r) {
+ if (FLAG(r)) {
if (!mount("", dir, "", MS_REMOUNT|MS_RDONLY, "")) {
- if (toys.optflags & FLAG_v) xprintf("%s remounted ro\n", dir);
+ if (FLAG(v)) xprintf("%s remounted ro\n", dir);
return;
}
}
@@ -110,19 +109,18 @@ void umount_main(void)
struct mtab_list *mlsave = 0, *mlrev = 0, *ml;
int flags=0;
- if (!toys.optc && !(toys.optflags & FLAG_a))
- error_exit("Need 1 arg or -a");
+ if (!toys.optc && !FLAG(a)) error_exit("Need 1 arg or -a");
- if (toys.optflags & FLAG_f) flags |= MNT_FORCE;
- if (toys.optflags & FLAG_l) flags |= MNT_DETACH;
+ if (FLAG(f)) flags |= MNT_FORCE;
+ if (FLAG(l)) flags |= MNT_DETACH;
// Load /proc/mounts and get a reversed list (newest first)
// We use the list both for -a, and to umount /dev/name or do losetup -d
- if (!(toys.optflags & FLAG_n) && !access(pm, R_OK))
+ if (!FLAG(n) && !access(pm, R_OK))
mlrev = dlist_terminate(mlsave = xgetmountlist(pm));
// Unmount all: loop through mounted filesystems, skip -t, unmount the rest
- if (toys.optflags & FLAG_a) {
+ if (FLAG(a)) {
char *typestr = 0;
struct arg_list *tal;
diff --git a/toys/net/ftpget.c b/toys/net/ftpget.c
index 27ea6db6..8c72d97c 100644
--- a/toys/net/ftpget.c
+++ b/toys/net/ftpget.c
@@ -65,7 +65,7 @@ static int xread2line(int fd, char *buf, int len)
while (total--)
if (buf[total]=='\r' || buf[total]=='\n') buf[total] = 0;
else break;
- if (toys.optflags & FLAG_v) fprintf(stderr, "%s\n", toybuf);
+ if (FLAG(v)) fprintf(stderr, "%s\n", toybuf);
return total+1;
}
@@ -76,7 +76,7 @@ static int ftp_line(char *cmd, char *arg, int must)
if (cmd) {
char *s = "%s %s\r\n"+3*(!arg);
- if (toys.optflags & FLAG_v) fprintf(stderr, s, cmd, arg);
+ if (FLAG(v)) fprintf(stderr, s, cmd, arg);
dprintf(TT.fd, s, cmd, arg);
}
if (must>=0) {
@@ -115,15 +115,15 @@ void ftpget_main(void)
if (rc == 331) rc = ftp_line("PASS", TT.P, 0);
if (rc != 230) error_exit_raw(toybuf);
- if (toys.optflags & FLAG_m) {
+ if (FLAG(m)) {
if (toys.optc != 3) error_exit("-m FROM TO");
ftp_line("RNFR", toys.optargs[1], 350);
ftp_line("RNTO", toys.optargs[2], 250);
- } else if (toys.optflags & FLAG_M) ftp_line("MKD", toys.optargs[1], 257);
- else if (toys.optflags & FLAG_d) ftp_line("DELE", toys.optargs[1], 250);
- else if (toys.optflags & FLAG_D) ftp_line("RMD", toys.optargs[1], 250);
+ } else if (FLAG(M)) ftp_line("MKD", toys.optargs[1], 257);
+ else if (FLAG(d)) ftp_line("DELE", toys.optargs[1], 250);
+ else if (FLAG(D)) ftp_line("RMD", toys.optargs[1], 250);
else {
- int get = !(toys.optflags&FLAG_s), cnt = toys.optflags&FLAG_c;
+ int get = !FLAG(s), cnt = FLAG(c);
char *cmd;
// Only do passive binary transfers
@@ -152,14 +152,12 @@ void ftpget_main(void)
// RETR blocks until file data read from data port, so use SIZE to check
// if file exists before creating local copy
lenr = 0;
- if (toys.optflags&(FLAG_s|FLAG_g)) {
+ if (FLAG(s)|FLAG(g)) {
if (ftp_line("SIZE", remote, 0) == 213)
sscanf(toybuf, "%*u %llu", &lenr);
else if (get) error_exit("no %s", remote);
- }
- // Open file for reading or writing
- if (toys.optflags & (FLAG_g|FLAG_s)) {
+ // Open file for reading or writing
if (strcmp(toys.optargs[1], "-"))
ii = xcreate(toys.optargs[1],
get ? (cnt ? O_APPEND : O_TRUNC)|O_CREAT|O_WRONLY : O_RDONLY, 0666);
@@ -167,8 +165,8 @@ void ftpget_main(void)
}
if (get) {
cmd = "RETR";
- if (toys.optflags&FLAG_l) cmd = "LIST";
- if (toys.optflags&FLAG_L) cmd = "NLST";
+ if (FLAG(l)) cmd = "LIST";
+ if (FLAG(L)) cmd = "NLST";
if (cnt) {
char buf[32];
@@ -179,8 +177,8 @@ void ftpget_main(void)
ftp_line(cmd, remote, -1);
lenl += xsendfile(port, ii);
- ftp_line(0, 0, (toys.optflags&FLAG_g) ? 226 : 150);
- } else if (toys.optflags & FLAG_s) {
+ ftp_line(0, 0, FLAG(g) ? 226 : 150);
+ } else if (FLAG(s)) {
cmd = "STOR";
if (cnt && lenr) {
cmd = "APPE";
@@ -190,7 +188,7 @@ void ftpget_main(void)
lenr += xsendfile(ii, port);
close(port);
}
- if (toys.optflags&(FLAG_g|FLAG_s))
+ if (FLAG(s)|FLAG(g))
if (lenl != lenr) error_exit("short %lld/%lld", lenl, lenr);
}
ftp_line("QUIT", 0, 0);
diff --git a/toys/net/microcom.c b/toys/net/microcom.c
index d805a062..1ee9204e 100644
--- a/toys/net/microcom.c
+++ b/toys/net/microcom.c
@@ -2,7 +2,7 @@
*
* Copyright 2017 The Android Open Source Project.
-USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN))
+USE_MICROCOM(NEWTOY(microcom, "<1>1s#=115200X", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_NOBUF))
config MICROCOM
bool "microcom"
@@ -79,9 +79,8 @@ static void handle_esc(void)
}
free(filename);
close(fd);
- } else {
- xprintf("Ignoring unknown command.");
- }
+ } else xprintf("Ignoring unknown command.");
+
xprintf("\r\n");
}
diff --git a/toys/net/netcat.c b/toys/net/netcat.c
index 4e76fa7f..65eeea74 100644
--- a/toys/net/netcat.c
+++ b/toys/net/netcat.c
@@ -2,16 +2,16 @@
*
* Copyright 2007 Rob Landley <rob@landley.net>
*
- * TODO: genericize for telnet/microcom/tail-f, fix -t
+ * TODO: genericize for telnet/microcom/tail-f, fix -t with login_tty()
-USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
+USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1O:o:s:f:46uUnz[!tlL][!Lw][!Lu][!46U][!oO]", TOYFLAG_BIN))
USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
config NETCAT
bool "netcat"
default y
help
- usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] {IPADDR PORTNUM|-f FILENAME|COMMAND...}
+ usage: netcat [-46ELlntUu] [-pqWw #] [-s addr] [-o FILE] {IPADDR PORTNUM|-f FILENAME|COMMAND...}
Forward stdin/stdout to a file or network connection.
@@ -22,11 +22,12 @@ config NETCAT
-L Listen and background each incoming connection (server mode)
-l Listen for one incoming connection, then exit
-n No DNS lookup
+ -o Hex dump to FILE (-o- writes hex only to stdout)
+ -O Hex dump to FILE (collated)
-p Local port number
-q Quit SECONDS after EOF on stdin, even if stdout hasn't closed yet
-s Local source address
-t Allocate tty
- -v Verbose
-u Use UDP
-U Use a UNIX domain socket
-W SECONDS timeout for more data on an idle connection
@@ -49,8 +50,11 @@ config NETCAT
#include "toys.h"
GLOBALS(
- char *f, *s;
+ char *f, *s, *o, *O;
long q, p, W, w;
+
+ unsigned ofd, olast, opos, ocount[2];
+ char obuf[16];
)
static void timeout(int signum)
@@ -78,6 +82,49 @@ static int usock(char *name, int type, int out)
return sockfd;
}
+// Hex dump accumulated buffer data
+void oflush(void)
+{
+ char *s = toybuf;
+ unsigned *oc = TT.ocount+(TT.olast==1), uu;
+
+ if (!TT.opos) return;
+ s += sprintf(toybuf, "%c %08x", 60+2*(TT.olast==1), *oc);
+ for (uu = 0; uu<16; uu++) {
+ s += sprintf(s, uu<TT.opos ? " %02x" : " ", TT.obuf[uu]);
+ if (TT.obuf[uu]-32u>95) TT.obuf[uu] = '.';
+ }
+ dprintf(TT.ofd, "%s # %.*s\n", toybuf, TT.opos, TT.obuf);
+ *oc += TT.opos;
+ TT.opos = 0;
+}
+
+// Write data to output, and hex dump to -o if enabled.
+void ohexwrite(int fd, void *buf, size_t len)
+{
+ // Hex dump if -o specified. Output is always to fd 1, input != 1.
+ if (TT.ofd) {
+ int i = 0, j;
+
+ if (TT.olast != fd) oflush();
+ TT.olast = fd;
+
+ while (i<len) {
+ j = minof(16-TT.opos, len-i);
+ memcpy(TT.obuf+TT.opos, buf+i, j);
+ TT.opos += j;
+ i += j;
+ if (TT.opos==16 || !TT.O) oflush();
+ }
+
+ // Don't write data to stdout when -o goes to stdout.
+ if (TT.ofd==1 && fd==1) return;
+ }
+
+ // Pass along raw data
+ xwrite(fd, buf, len);
+}
+
void netcat_main(void)
{
int sockfd = -1, in1 = 0, in2 = 0, out1 = 1, out2 = 1, family = AF_UNSPEC,
@@ -85,7 +132,15 @@ void netcat_main(void)
socklen_t len;
pid_t child;
- // Addjust idle and quit_delay to ms or -1 for no timeout
+ // -o - disables normal writes to stdout, just gives hex dump.
+ if (TT.O) TT.o = TT.O;
+ if (TT.o) {
+ if (!strcmp(TT.o, "-")) TT.ofd = 1;
+ else TT.ofd = xcreate(TT.o, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ sigatexit(oflush);
+ }
+
+ // Adjust idle and quit_delay to ms or -1 for no timeout
TT.W = TT.W ? TT.W*1000 : -1;
TT.q = TT.q ? TT.q*1000 : -1;
@@ -104,16 +159,16 @@ void netcat_main(void)
else if (FLAG(6)) family = AF_INET6;
else if (FLAG(U)) family = AF_UNIX;
- if (TT.f) in1 = out2 = xopen(TT.f, O_RDWR);
- else {
+ if (TT.f) {
+ in1 = out2 = xopen(TT.f, O_RDWR);
+ alarm(0);
+ pollinate(in1, in2, out1, out2, ohexwrite, TT.W, TT.q);
+ } else {
// Setup socket
if (!FLAG(l) && !FLAG(L)) {
- char *host = toys.optargs[0];
- char *port = toys.optargs[1];
- if (FLAG(U)) sockfd = usock(host, type, 1);
- else sockfd = xconnectany(xgetaddrinfo(host, port, family, type, 0, AI_NUMERICHOST*FLAG(n)));
-
- if (FLAG(v)) printf("%s:%s [open]\n", host, port);
+ if (FLAG(U)) sockfd = usock(toys.optargs[0], type, 1);
+ else sockfd = xconnectany(xgetaddrinfo(toys.optargs[0], toys.optargs[1],
+ family, type, 0, AI_NUMERICHOST*FLAG(n)));
// Do not perform any I/O in zero mode
if (FLAG(z)) goto cleanup;
@@ -121,7 +176,7 @@ void netcat_main(void)
// We have a connection. Disarm timeout and start poll/send loop.
alarm(0);
in1 = out2 = sockfd;
- pollinate(in1, in2, out1, out2, TT.W, TT.q);
+ pollinate(in1, in2, out1, out2, ohexwrite, TT.W, TT.q);
} else {
// Listen for incoming connections
if (FLAG(U)) {
@@ -152,7 +207,7 @@ void netcat_main(void)
}
do {
- len = sizeof(struct sockaddr_storage);
+ len = sizeof(struct sockaddr_storage);
if (FLAG(u)) {
if (-1 == recvfrom(in1 = dup(sockfd), &child, 1, MSG_PEEK,
(void *)toybuf, &len)) perror_exit("recvfrom");
@@ -188,7 +243,7 @@ void netcat_main(void)
// Copy stdin/out
} else {
- pollinate(in1, in2, out1, out2, TT.W, TT.q);
+ pollinate(in1, in2, out1, out2, ohexwrite, TT.W, TT.q);
close(in1);
}
} while (FLAG(L));
diff --git a/toys/net/tunctl.c b/toys/net/tunctl.c
index b18306f0..21dcd0dd 100644
--- a/toys/net/tunctl.c
+++ b/toys/net/tunctl.c
@@ -42,11 +42,11 @@ void tunctl_main(void)
int fd = xopen("/dev/net/tun", O_RDWR);
// Associate filehandle with device
- ifr->ifr_flags = ((toys.optflags&FLAG_T) ? IFF_TUN : IFF_TAP)|IFF_NO_PI;
+ ifr->ifr_flags = (FLAG(T) ? IFF_TUN : IFF_TAP)|IFF_NO_PI;
strncpy(ifr->ifr_name, *toys.optargs, sizeof(ifr->ifr_name));
xioctl(fd, TUNSETIFF, toybuf);
- if (toys.optflags&FLAG_t) {
+ if (FLAG(t)) {
xioctl(fd, TUNSETPERSIST, (void *)1);
xioctl(fd, TUNSETOWNER, (void *)(long)u);
} else xioctl(fd, TUNSETPERSIST, (void *)0);
diff --git a/toys/other/blockdev.c b/toys/other/blockdev.c
index 9f169453..25553e99 100644
--- a/toys/other/blockdev.c
+++ b/toys/other/blockdev.c
@@ -34,7 +34,7 @@ config BLOCKDEV
#include <linux/fs.h>
GLOBALS(
- long setbsz, setra;
+ long setra, setbsz;
)
void blockdev_main(void)
@@ -50,20 +50,19 @@ void blockdev_main(void)
int fd = xopenro(*ss), i;
// Command line order discarded so perform multiple operations in flag order
- for (i = 0; i < 32; i++) {
+ for (i = 0; i<32; i++) {
long flag = toys.optflags & (1<<i);
if (!flag) continue;
- if (flag & FLAG_setbsz) val = TT.setbsz;
- else val = !!(flag & FLAG_setro);
-
- if (flag & FLAG_setra) val = TT.setra;
+ if (FLAG(setbsz)) val = TT.setbsz;
+ else if (FLAG(setra)) val = TT.setra;
+ else val = FLAG(setro);
xioctl(fd, cmds[i], &val);
flag &= FLAG_setbsz|FLAG_setro|FLAG_flushbufs|FLAG_rereadpt|FLAG_setrw|FLAG_setbsz;
- if (!flag) printf("%lld\n", (toys.optflags & FLAG_getsz) ? val >> 9: val);
+ if (!flag) printf("%lld\n", val>>(9*FLAG(getsz)));
}
xclose(fd);
}
diff --git a/toys/other/chcon.c b/toys/other/chcon.c
index cdbabf76..ff1c850d 100644
--- a/toys/other/chcon.c
+++ b/toys/other/chcon.c
@@ -28,12 +28,12 @@ static int do_chcon(struct dirtree *try)
if (!dirtree_notdotdot(try)) return 0;
path = dirtree_path(try, 0);
- if (toys.optflags & FLAG_v) printf("chcon '%s' to %s\n", path, con);
- if (-1 == ((toys.optflags & FLAG_h) ? lsetfilecon : setfilecon)(path, con))
+ if (FLAG(v)) printf("chcon '%s' to %s\n", path, con);
+ if (-1 == (FLAG(h) ? lsetfilecon : setfilecon)(path, con))
perror_msg("'%s' to %s", path, con);
free(path);
- return (toys.optflags & FLAG_R)*DIRTREE_RECURSE;
+ return FLAG(R)*DIRTREE_RECURSE;
}
void chcon_main(void)
diff --git a/toys/other/chrt.c b/toys/other/chrt.c
index 1a8222fa..e2331c91 100644
--- a/toys/other/chrt.c
+++ b/toys/other/chrt.c
@@ -57,7 +57,7 @@ void chrt_main(void)
int pol, pri;
// Show min/maxes?
- if (toys.optflags&FLAG_m) {
+ if (FLAG(m)) {
for (pol = 0; pol<ARRAY_LEN(polnames); pol++) if (polnames[pol])
printf("%s min/max priority\t: %d/%d\n", polnames[pol],
sched_get_priority_min(pol), sched_get_priority_max(pol));
@@ -81,14 +81,13 @@ void chrt_main(void)
}
if (!*toys.optargs) help_exit("no PRIORITY");
- if (!toys.optargs[1] == !(toys.optflags&FLAG_p))
- help_exit("need 1 of -p or COMMAND");
+ if (!toys.optargs[1] == !FLAG(p)) help_exit("need 1 of -p or COMMAND");
// Set policy and priority
- if (-1==(pol = highest_bit(toys.optflags&0x2f))) pol = SCHED_RR;
+ if (-1==(pol = highest_bit(toys.optflags&(FLAG_p-1)))) pol = SCHED_RR;
pri = atolx_range(*toys.optargs, sched_get_priority_min(pol),
sched_get_priority_max(pol));
- if (toys.optflags&FLAG_R) pol |= SCHED_RESET_ON_FORK;
+ if (FLAG(R)) pol |= SCHED_RESET_ON_FORK;
if (sched_setscheduler(TT.p, pol, (void *)&pri))
perror_exit("sched_setscheduler");
diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c
index 4087ec93..5186a2d1 100644
--- a/toys/other/hwclock.c
+++ b/toys/other/hwclock.c
@@ -2,27 +2,35 @@
*
* Copyright 2014 Bilal Qureshi <bilal.jmi@gmail.com>
*
- * No standard, but see Documentation/rtc.txt in the linux kernel source..
+ * No standard, but see Documentation/rtc.txt in the linux kernel source.
*
+ * TODO: get/set subsecond time
USE_HWCLOCK(NEWTOY(hwclock, ">0(fast)f(rtc):u(utc)l(localtime)t(systz)s(hctosys)r(show)w(systohc)[-ul][!rtsw]", TOYFLAG_SBIN))
config HWCLOCK
bool "hwclock"
default y
help
- usage: hwclock [-rswtluf]
+ usage: hwclock [-rswtlu] [-f FILE]
- Get/set the hardware clock.
+ Get/set the hardware clock. Default is hwclock -ruf /dev/rtc0
- -f FILE Use specified device file instead of /dev/rtc0 (--rtc)
+ -f Use specified device FILE instead of /dev/rtc0 (--rtc)
-l Hardware clock uses localtime (--localtime)
-r Show hardware clock time (--show)
-s Set system time from hardware clock (--hctosys)
- -t Set the system time based on the current timezone (--systz)
+ -t Inform kernel of non-UTC clock's timezone so it returns UTC (--systz)
-u Hardware clock uses UTC (--utc)
-w Set hardware clock from system time (--systohc)
*/
+
+// Bug workaround for musl commit 5a105f19b5aa which removed a symbol the
+// kernel headers have. (Can't copy it here, varies wildly by architecture.)
+#if __has_include(<asm/unistd.h>)
+#include <asm/unistd.h>
+#endif
+
#define FOR_hwclock
#include "toys.h"
#include <linux/rtc.h>
@@ -31,58 +39,51 @@ GLOBALS(
char *f;
)
+// Bug workaround for musl commit 2c2c3605d3b3 which rewrote the syscall
+// wrapper to not use the syscall, which is the only way to set kernel's sys_tz
+#define settimeofday(x, tz) syscall(__NR_settimeofday, (void *)0, (void *)tz)
+
void hwclock_main()
{
- struct timezone tzone;
- struct timeval timeval;
+ struct timezone tz = {0};
+ struct timespec ts = {0};
struct tm tm;
- int fd = -1, utc;
+ int fd = -1;
- if (FLAG(u)) utc = 1;
- else if (FLAG(l)) utc = 0;
- else utc = !readfile("/etc/adjtime", toybuf, sizeof(toybuf)) ||
- !!strstr(toybuf, "UTC");
+ // -t without -u implies -l
+ if (FLAG(t)&&!FLAG(u)) toys.optflags |= FLAG_l;
+ if (FLAG(l)) {
+ // sets globals timezone and daylight from sys/time.h
+ // Handle dst adjustment ourselves. (Rebooting during dst transition is
+ // just conceptually unpleasant, linux uses UTC for a reason.)
+ tzset();
+ tz.tz_minuteswest = timezone/60 - 60*daylight;
+ }
if (!FLAG(t)) {
- if (!TT.f) TT.f = "/dev/rtc0";
- fd = xopen(TT.f, O_WRONLY*FLAG(w));
+ fd = xopen(TT.f ? : "/dev/rtc0", O_WRONLY*FLAG(w));
- // Get current time in seconds from rtc device. TODO: get subsecond time
+ // Get current time in seconds from rtc device.
if (!FLAG(w)) {
xioctl(fd, RTC_RD_TIME, &tm);
- timeval.tv_sec = xmktime(&tm, utc);
- timeval.tv_usec = 0; // TODO: fixit
+ ts.tv_sec = xmktime(&tm, !FLAG(l));
}
}
if (FLAG(w) || FLAG(t)) {
- if (gettimeofday(&timeval, 0)) perror_exit("gettimeofday failed");
- if (!(utc ? gmtime_r : localtime_r)(&timeval.tv_sec, &tm))
- error_exit(utc ? "gmtime_r failed" : "localtime_r failed");
- }
-
- if (FLAG(w)) {
- /* The value of tm_isdst is positive if daylight saving time is in effect,
- * zero if it is not and negative if the information is not available.
- * TODO: so why isn't this negative...? */
- tm.tm_isdst = 0;
- xioctl(fd, RTC_SET_TIME, &tm);
+ if (FLAG(w)) {
+ if (clock_gettime(CLOCK_REALTIME, &ts)) perror_exit("clock_gettime");
+ if (!(FLAG(l) ? localtime_r : gmtime_r)(&ts.tv_sec, &tm))
+ error_exit("%s failed", FLAG(l) ? "localtime_r" : "gmtime_r");
+ xioctl(fd, RTC_SET_TIME, &tm);
+ }
+ if (settimeofday(0, &tz)) perror_exit("settimeofday");
} else if (FLAG(s)) {
- tzone.tz_minuteswest = timezone / 60 - 60 * daylight;
- } else if (FLAG(t)) {
- // Adjust seconds for timezone and daylight saving time
- // extern long timezone is defined in header sys/time.h
- tzone.tz_minuteswest = timezone / 60;
- if (tm.tm_isdst) tzone.tz_minuteswest -= 60;
- if (!utc) timeval.tv_sec += tzone.tz_minuteswest * 60;
+ if (clock_settime(CLOCK_REALTIME, &ts)) perror_exit("clock_settime");
} else {
strftime(toybuf, sizeof(toybuf), "%F %T%z", &tm);
xputs(toybuf);
}
- if (FLAG(t) || FLAG(s)) {
- tzone.tz_dsttime = 0;
- if (settimeofday(&timeval, &tzone)) perror_exit("settimeofday failed");
- }
- xclose(fd);
+ if (CFG_TOYBOX_FREE) xclose(fd);
}
diff --git a/toys/other/mix.c b/toys/other/mix.c
index d0f65618..a5e3ea1d 100644
--- a/toys/other/mix.c
+++ b/toys/other/mix.c
@@ -41,15 +41,15 @@ void mix_main(void)
if ((1<<channel) & mask) {
if (TT.c) {
if (!strcmp(channels[channel], TT.c)) break;
- } else if (toys.optflags & FLAG_l) break;
+ } else if (FLAG(l)) break;
else printf("%s\n", channels[channel]);
}
}
- if (!(toys.optflags & (FLAG_c|FLAG_l))) return;
+ if (!FLAG(c) && !FLAG(l)) return;
else if (channel == SOUND_MIXER_NRDEVICES) error_exit("bad -c '%s'", TT.c);
- if (!(toys.optflags & FLAG_l)) {
+ if (!FLAG(l)) {
xioctl(fd, MIXER_READ(channel), &level);
if (level > 0xFF)
xprintf("%s:%s = left:%d\t right:%d\n",
@@ -57,7 +57,7 @@ void mix_main(void)
else xprintf("%s:%s = %d\n", TT.d, channels[channel], level);
} else {
level = TT.l;
- if (!(toys.optflags & FLAG_r)) level = TT.r | (level<<8);
+ if (!FLAG(r)) level = TT.r | (level<<8);
xioctl(fd, MIXER_WRITE(channel), &level);
}
diff --git a/toys/other/setfattr.c b/toys/other/setfattr.c
index 0aea225a..c6ff2ab5 100644
--- a/toys/other/setfattr.c
+++ b/toys/other/setfattr.c
@@ -29,13 +29,12 @@ GLOBALS(
void setfattr_main(void)
{
- int h = toys.optflags & FLAG_h, rc;
+ int h = FLAG(h), rc;
char **s;
- for (s=toys.optargs; *s; s++) {
- if (TT.x) rc = (h?lremovexattr:removexattr)(*s, TT.x);
- else rc = (h?lsetxattr:setxattr)(*s, TT.n, TT.v, TT.v?strlen(TT.v):0, 0);
-
+ for (s = toys.optargs; *s; s++) {
+ if (TT.x) rc = (h ? lremovexattr : removexattr)(*s, TT.x);
+ else rc = (h ? lsetxattr : setxattr)(*s, TT.n, TT.v, TT.v ? strlen(TT.v) : 0, 0);
if (rc) perror_msg_raw(*s);
}
}
diff --git a/toys/other/swapon.c b/toys/other/swapon.c
index 2eb5b93c..e27517de 100644
--- a/toys/other/swapon.c
+++ b/toys/other/swapon.c
@@ -25,12 +25,10 @@ GLOBALS(
void swapon_main(void)
{
- // 0x70000 = SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE|SWAP_FLAG_DISCARD_PAGES
- int flags = (toys.optflags&FLAG_d)*0x70000;
-
- if (toys.optflags)
- flags |= SWAP_FLAG_PREFER | (TT.p << SWAP_FLAG_PRIO_SHIFT);
+ // SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE|SWAP_FLAG_DISCARD_PAGES
+ int flags = FLAG(d)*0x70000;
+ if (FLAG(p)) flags |= SWAP_FLAG_PREFER | (TT.p << SWAP_FLAG_PRIO_SHIFT);
if (swapon(*toys.optargs, flags))
perror_exit("Couldn't swapon '%s'", *toys.optargs);
}
diff --git a/toys/other/sysctl.c b/toys/other/sysctl.c
index 2d79176f..7a2cba62 100644
--- a/toys/other/sysctl.c
+++ b/toys/other/sysctl.c
@@ -11,11 +11,11 @@ config SYSCTL
bool "sysctl"
default y
help
- usage: sysctl [-aAeNnqw] [-p [FILE] | KEY[=VALUE]...]
+ usage: sysctl [-aeNnqw] [-p [FILE] | KEY[=VALUE]...]
Read/write system control data (under /proc/sys).
- -a,A Show all values
+ -a Show all values
-e Don't warn about unknown keys
-N Don't print key values
-n Don't print key names
@@ -43,9 +43,8 @@ static void replace_char(char *str, char old, char new)
static void key_error(char *key)
{
- if (errno == ENOENT) {
- if (!(toys.optflags & FLAG_e)) error_msg("unknown key '%s'", key);
- } else perror_msg("key '%s'", key);
+ if (errno != ENOENT) perror_msg("key '%s'", key);
+ else if (!FLAG(e)) error_msg("unknown key '%s'", key);
}
static int write_key(char *path, char *key, char *value)
@@ -77,11 +76,11 @@ static int do_show_keys(struct dirtree *dt)
if (!data) key_error(key);
else {
// Print the parts that aren't switched off by flags.
- if (!(toys.optflags & FLAG_n)) xprintf("%s", key);
- if (!(toys.optflags & (FLAG_N|FLAG_n))) xprintf(" = ");
+ if (!FLAG(n)) xprintf("%s", key);
+ if (!FLAG(N) && !FLAG(n)) xprintf(" = ");
for (key = data+strlen(data); key > data && isspace(*--key); *key = 0);
- if (!(toys.optflags & FLAG_N)) xprintf("%s", data);
- if ((toys.optflags & (FLAG_N|FLAG_n)) != (FLAG_N|FLAG_n)) xputc('\n');
+ if (!FLAG(N)) xprintf("%s", data);
+ if (!FLAG(N) || !FLAG(n)) xputc('\n');
}
free(data);
@@ -96,16 +95,11 @@ static void process_key(char *key, char *value)
char *path;
if (!value) value = split_key(key);
- if ((toys.optflags & FLAG_w) && !value) {
- error_msg("'%s' not key=value", key);
-
- return;
- }
-
+ if (FLAG(w) && !value) return error_msg("'%s' not key=value", key);
path = xmprintf("/proc/sys/%s", key);
replace_char(path, '.', '/');
// Note: failure to assign to a non-leaf node suppresses the display.
- if (!(value && (!write_key(path, key, value) || (toys.optflags & FLAG_q)))) {
+ if (!(value && (!write_key(path, key, value) || FLAG(q)))) {
if (!access(path, R_OK)) dirtree_read(path, do_show_keys);
else key_error(key);
}
@@ -117,10 +111,10 @@ void sysctl_main()
char **args = 0;
// Display all keys
- if (toys.optflags & FLAG_a) dirtree_read("/proc/sys", do_show_keys);
+ if (FLAG(a)) dirtree_read("/proc/sys", do_show_keys);
// read file
- else if (toys.optflags & FLAG_p) {
+ else if (FLAG(p)) {
FILE *fp = xfopen(*toys.optargs ? *toys.optargs : "/etc/sysctl.conf", "r");
size_t len;
diff --git a/toys/other/xxd.c b/toys/other/xxd.c
index 2afa5298..2a82d63f 100644
--- a/toys/other/xxd.c
+++ b/toys/other/xxd.c
@@ -41,17 +41,18 @@ GLOBALS(
static void do_xxd(int fd, char *name)
{
+ FILE *fp = xfdopen(xdup(fd), "r");
long long pos = 0;
long long limit = TT.l;
int i, j, k, len, space, c = TT.c ? : sizeof(toybuf);
if (FLAG(s)) {
- xlseek(fd, TT.s, SEEK_SET);
+ if (fseek(fp, TT.s, SEEK_SET)) perror_exit("seek %ld", TT.s);
pos = TT.s;
if (limit) limit += TT.s;
}
- while (0<(len = readall(fd, toybuf, (limit && limit-pos<c) ? limit-pos : c))){
+ while ((len=fread(toybuf, 1, (limit && limit-pos<c) ? limit-pos : c, fp))>0){
if (!FLAG(p)) printf("%08llx: ", TT.o + pos);
pos += len;
space = 2*TT.c;
@@ -84,6 +85,7 @@ static void do_xxd(int fd, char *name)
}
if (!TT.c && FLAG(p)) putchar('\n');
if (len<0) perror_exit("read");
+ fclose(fp);
}
static void do_xxd_include(int fd, char *name)
diff --git a/toys/pending/dhcp6.c b/toys/pending/dhcp6.c
index 72affff6..c186b480 100644
--- a/toys/pending/dhcp6.c
+++ b/toys/pending/dhcp6.c
@@ -9,9 +9,9 @@ config DHCP6
bool "dhcp6"
default n
help
- usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]
+ usage: dhcp6 [-fbnqvR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]
- Configure network dynamically using DHCP.
+ Configure network dynamically using DHCP.
-i Interface to use (default eth0)
-p Create pidfile
diff --git a/toys/pending/diff.c b/toys/pending/diff.c
index 5d5ea3d6..27873cfd 100644
--- a/toys/pending/diff.c
+++ b/toys/pending/diff.c
@@ -14,33 +14,33 @@ config DIFF
bool "diff"
default n
help
- usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] [-F REGEX ] FILE1 FILE2
-
- -a Treat all files as text
- -b Ignore changes in the amount of whitespace
- -B Ignore changes whose lines are all blank
- -d Try hard to find a smaller set of changes
- -F Show the most recent line matching the regex
- -i Ignore case differences
- -L Use LABEL instead of the filename in the unified header
- -N Treat absent files as empty
- -q Output only whether files differ
- -r Recurse
- -S Start with FILE when comparing directories
- -s Report when two files are the same
- -T Make tabs line up by prefixing a tab when necessary
- -t Expand tabs to spaces in output
- -u Unified diff
- -U Output LINES lines of context
- -w Ignore all whitespace
-
- --color Color output --strip-trailing-cr Strip '\r' from input lines
- --TYPE-line-format=FORMAT Display TYPE (unchanged/old/new) lines using FORMAT
- FORMAT uses printf integer escapes (ala %-2.4x) followed by LETTER: FELMNn
- Supported format specifiers are:
- * %l, the contents of the line, without the trailing newline
- * %L, the contents of the line, including the trailing newline
- * %%, the character '%'
+ usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] [-F REGEX ] FILE1 FILE2
+
+ -a Treat all files as text
+ -b Ignore changes in the amount of whitespace
+ -B Ignore changes whose lines are all blank
+ -d Try hard to find a smaller set of changes
+ -F Show the most recent line matching the regex
+ -i Ignore case differences
+ -L Use LABEL instead of the filename in the unified header
+ -N Treat absent files as empty
+ -q Output only whether files differ
+ -r Recurse
+ -S Start with FILE when comparing directories
+ -s Report when two files are the same
+ -T Make tabs line up by prefixing a tab when necessary
+ -t Expand tabs to spaces in output
+ -u Unified diff
+ -U Output LINES lines of context
+ -w Ignore all whitespace
+
+ --color Color output --strip-trailing-cr Strip '\r' from input lines
+ --TYPE-line-format=FORMAT Display TYPE (unchanged/old/new) lines using FORMAT
+ FORMAT uses printf integer escapes (ala %-2.4x) followed by LETTER: FELMNn
+ Supported format specifiers are:
+ * %l, the contents of the line, without the trailing newline
+ * %L, the contents of the line, including the trailing newline
+ * %%, the character '%'
*/
#define FOR_diff
diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c
index d80bea0e..43ccd9b2 100644
--- a/toys/pending/syslogd.c
+++ b/toys/pending/syslogd.c
@@ -11,25 +11,25 @@ config SYSLOGD
bool "syslogd"
default n
help
- usage: syslogd [-a socket] [-O logfile] [-f config file] [-m interval]
- [-p socket] [-s SIZE] [-b N] [-R HOST] [-l N] [-nSLKD]
-
- System logging utility
-
- -a Extra unix socket for listen
- -O FILE Default log file <DEFAULT: /var/log/messages>
- -f FILE Config file <DEFAULT: /etc/syslog.conf>
- -p Alternative unix domain socket <DEFAULT : /dev/log>
- -n Avoid auto-backgrounding
- -S Smaller output
- -m MARK interval <DEFAULT: 20 minutes> (RANGE: 0 to 71582787)
- -R HOST Log to IP or hostname on PORT (default PORT=514/UDP)"
- -L Log locally and via network (default is network only if -R)"
- -s SIZE Max size (KB) before rotation (default:200KB, 0=off)
- -b N rotated logs to keep (default:1, max=99, 0=purge)
- -K Log to kernel printk buffer (use dmesg to read it)
- -l N Log only messages more urgent than prio(default:8 max:8 min:1)
- -D Drop duplicates
+ usage: syslogd [-a socket] [-O logfile] [-f config file] [-m interval]
+ [-p socket] [-s SIZE] [-b N] [-R HOST] [-l N] [-nSLKD]
+
+ System logging utility
+
+ -a Extra unix socket for listen
+ -O FILE Default log file <DEFAULT: /var/log/messages>
+ -f FILE Config file <DEFAULT: /etc/syslog.conf>
+ -p Alternative unix domain socket <DEFAULT : /dev/log>
+ -n Avoid auto-backgrounding
+ -S Smaller output
+ -m MARK interval <DEFAULT: 20 minutes> (RANGE: 0 to 71582787)
+ -R HOST Log to IP or hostname on PORT (default PORT=514/UDP)"
+ -L Log locally and via network (default is network only if -R)"
+ -s SIZE Max size (KB) before rotation (default:200KB, 0=off)
+ -b N rotated logs to keep (default:1, max=99, 0=purge)
+ -K Log to kernel printk buffer (use dmesg to read it)
+ -l N Log only messages more urgent than prio(default:8 max:8 min:1)
+ -D Drop duplicates
*/
#define FOR_syslogd
diff --git a/toys/posix/cat.c b/toys/posix/cat.c
index 1eb15d49..1226651f 100644
--- a/toys/posix/cat.c
+++ b/toys/posix/cat.c
@@ -51,7 +51,7 @@ static void do_cat(int fd, char *name)
if (c<32) {
if (c == 10) {
if (FLAG(e)) xputc('$');
- } else if (toys.optflags & (c==9 ? FLAG_t : FLAG_v)) {
+ } else if (c==9 ? FLAG(t) : FLAG(v)) {
printf("^%c", c+'@');
continue;
}
diff --git a/toys/posix/du.c b/toys/posix/du.c
index 0544aeee..a51dfc11 100644
--- a/toys/posix/du.c
+++ b/toys/posix/du.c
@@ -158,8 +158,7 @@ void du_main(void)
// Loop over command line arguments, recursing through children
for (args = toys.optc ? toys.optargs : noargs; *args; args++)
- dirtree_flagread(*args, DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)),
- do_du);
+ dirtree_flagread(*args, DIRTREE_SYMFOLLOW*(FLAG(H)|FLAG(L)), do_du);
if (FLAG(c)) print(FLAG(b) ? TT.total : TT.total*512, 0);
if (CFG_TOYBOX_FREE) seen_inode(TT.inodes, 0);
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 0fde9c9e..ac148816 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -438,7 +438,8 @@ static int do_find(struct dirtree *new)
if (*ss != arg) free(arg);
}
} else if (!strcmp(s, "size")) {
- if (check) test = compare_numsign(new->st.st_size, 512, arg);
+ if (check) test = compare_numsign(new->st.st_size, -512, arg) &&
+ S_ISREG(new->st.st_mode);
} else if (!strcmp(s, "links")) {
if (check) test = compare_numsign(new->st.st_nlink, 0, arg);
} else if (!strcmp(s, "inum")) {
diff --git a/toys/posix/getconf.c b/toys/posix/getconf.c
index 7c2e588f..c553d258 100644
--- a/toys/posix/getconf.c
+++ b/toys/posix/getconf.c
@@ -200,14 +200,14 @@ static void show_conf(int i, struct config *c, const char *path)
void getconf_main(void)
{
struct config *configs[] = {sysconfs, pathconfs, confstrs, limits, others},
- *c = NULL;
+ *c = 0;
int i, j, lens[] = {ARRAY_LEN(sysconfs), ARRAY_LEN(pathconfs),
ARRAY_LEN(confstrs), ARRAY_LEN(limits), ARRAY_LEN(others)};
char *name, *path = (toys.optc==2) ? toys.optargs[1] : "/",
*config_names[] = {"sysconf(3)", "pathconf(3)", "confstr(3)",
"<limits.h>", "Misc"};
- if (toys.optflags&FLAG_a) {
+ if (FLAG(a)) {
for (i = 0; i<5; i++) {
for (j = 0; j<lens[i]; j++) {
c = &configs[i][j];
@@ -218,7 +218,7 @@ void getconf_main(void)
return;
}
- if (toys.optflags&FLAG_l) {
+ if (FLAG(l)) {
for (i = 0; i<5; i++) {
printf("%s\n", config_names[i]);
for (j = 0; j<lens[i]; j++) printf(" %s\n", configs[i][j].name);
diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c
index 932635a6..df9061d7 100644
--- a/toys/posix/mkdir.c
+++ b/toys/posix/mkdir.c
@@ -40,7 +40,7 @@ void mkdir_main(void)
char **s;
mode_t mode = (0777&~toys.old_umask);
- if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z))
+ if (CFG_MKDIR_Z && FLAG(Z))
if (0>lsm_set_create(TT.Z))
perror_exit("-Z '%s' failed", TT.Z);
diff --git a/toys/posix/mkfifo.c b/toys/posix/mkfifo.c
index 8639ebd8..366ac436 100644
--- a/toys/posix/mkfifo.c
+++ b/toys/posix/mkfifo.c
@@ -28,8 +28,7 @@ config MKFIFO_Z
#include "toys.h"
GLOBALS(
- char *m;
- char *Z;
+ char *m, *Z;
mode_t mode;
)
@@ -39,9 +38,9 @@ void mkfifo_main(void)
char **s;
TT.mode = 0666;
- if (toys.optflags & FLAG_m) TT.mode = string_to_mode(TT.m, 0);
+ if (FLAG(m)) TT.mode = string_to_mode(TT.m, 0);
- if (CFG_MKFIFO_Z && (toys.optflags&FLAG_Z))
+ if (CFG_MKFIFO_Z && FLAG(Z))
if (0>lsm_set_create(TT.Z))
perror_exit("-Z '%s' failed", TT.Z);
diff --git a/toys/posix/paste.c b/toys/posix/paste.c
index 5c1b234c..e685c506 100644
--- a/toys/posix/paste.c
+++ b/toys/posix/paste.c
@@ -35,7 +35,7 @@ static void paste_files(void)
{
FILE **fps = (void *)toybuf;
char *dpos, *dstr, *buf, c;
- int i, any, dcount, dlen, len, seq = toys.optflags&FLAG_s;
+ int i, any, dcount, dlen, len, seq = FLAG(s);
// Loop through lines until no input left
for (;;) {
@@ -114,7 +114,7 @@ static void do_paste(int fd, char *name)
if (!(fps[TT.files++] = (fd ? fdopen(fd, "r") : stdin))) perror_exit(0);
if (TT.files >= sizeof(toybuf)/sizeof(FILE *)) perror_exit("tilt");
- if (toys.optflags&FLAG_s) {
+ if (FLAG(s)) {
paste_files();
xputc('\n');
TT.files = 0;
@@ -123,8 +123,8 @@ static void do_paste(int fd, char *name)
void paste_main(void)
{
- if (!(toys.optflags&FLAG_d)) TT.d = "\t";
+ if (!FLAG(d)) TT.d = "\t";
loopfiles_rw(toys.optargs, O_RDONLY, 0, do_paste);
- if (!(toys.optflags&FLAG_s)) paste_files();
+ if (!FLAG(s)) paste_files();
}
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index cfe282f7..27a461ff 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -32,7 +32,7 @@ static int do_rm(struct dirtree *try)
// Intentionally fail non-recursive attempts to remove even an empty dir
// (via wrong flags to unlinkat) because POSIX says to.
- if (dir && !(toys.optflags & (FLAG_r|FLAG_R))) goto skip;
+ if (dir && !FLAG(r) && !FLAG(R)) goto skip;
// This is either the posix section 2(b) prompt or the section 3 prompt.
if (!FLAG(f)
diff --git a/toys/posix/touch.c b/toys/posix/touch.c
index e687ff81..0196b305 100644
--- a/toys/posix/touch.c
+++ b/toys/posix/touch.c
@@ -37,7 +37,7 @@ void touch_main(void)
{
struct timespec ts[2];
char **ss;
- int fd, i;
+ int fd;
// use current time if no -t or -d
ts[0].tv_nsec = UTIME_NOW;
@@ -61,8 +61,7 @@ void touch_main(void)
}
// Which time(s) should we actually change?
- i = toys.optflags & (FLAG_a|FLAG_m);
- if (i && i!=(FLAG_a|FLAG_m)) ts[i!=FLAG_m].tv_nsec = UTIME_OMIT;
+ if (FLAG(a)^FLAG(m)) ts[!FLAG(m)].tv_nsec = UTIME_OMIT;
// Loop through files on command line
for (ss = toys.optargs; *ss;) {
diff --git a/www/design.html b/www/design.html
index 7d59f661..f5ca6787 100644
--- a/www/design.html
+++ b/www/design.html
@@ -436,7 +436,7 @@ you can't fix a bug in the old system if you can't build in the old
environment.</p>
<p>Partly because toybox's maintainer has his own corollary to Moore's law:
-50% of what you know about programming the hardware is obsolete every 18
+50% of what you know about programming is obsolete every 18
months, but the advantage of C &amp; Unix it's usually the same 50% cycling
out over and over.</p>
@@ -563,7 +563,7 @@ feeding the compiler -funsigned-char.</p>
<p>The reason to pick "unsigned" is that way char strings are 8-bit clean by
default, which makes UTF-8 support easier.</p>
-<p><h3>Error messages and internationalization:</h3></p>
+<p><h3>Error messages and internationalization</h3></p>
<p>Error messages are extremely terse not just to save bytes, but because we
don't use any sort of _("string") translation infrastructure. (We're not
@@ -602,6 +602,18 @@ of it.)</p>
<p>Someday we should probably have translated --help text, but that's a
post-1.0 issue.</p>
+<p><h3>Help text</h3></p>
+
+<p>Each command's help text tries to briefly answer the questions "what does
+this command do" and "how do I use it". There's a usage: line, basic
+description, list of command line options (mostly in alphabetical order),
+and sometimes additional explanation at the end. Default values and --longopts
+are usually in parentheses on the end of an option's explanation line.</p>
+
+<p>Toybox silently accepts a lot of compatibility flags like <b>patch -u</b>
+that aren't in the help text to work with existing scripts, but may not
+mention options that don't help write new scripts (mostly synonyms and NOPs).</p>
+
<p><h3>Shared Libraries</h3></p>
<p>Toybox's policy on shared libraries is that they should never be
diff --git a/www/header.html b/www/header.html
index e72481f4..ec0d2969 100644
--- a/www/header.html
+++ b/www/header.html
@@ -55,5 +55,5 @@
</td>
<td valign=top>
-<h2>Current release <a href=https://landley.net/toybox/news.html>0.8.10</a> (July 30, 2023)</a></h2>
+<h2>Current release <a href=https://landley.net/toybox/news.html>0.8.11</a> (April 8, 2024)</a></h2>
<hr>
diff --git a/www/news.html b/www/news.html
index f983d6f3..8054c635 100644
--- a/www/news.html
+++ b/www/news.html
@@ -37,6 +37,304 @@ bootable under QEMU (built using a <a href=https://github.com/landley/linux/tree
<u>Build</u>:
-->
+<a name="08-04-2024" /><a href="#08-04-2024"><hr><h2><b>April 8, 2024</b></h2></a>
+<blockquote>
+<p>Another thing that got forgotten was the fact that against all probability a
+sperm whale had suddenly been called into existence several miles above the
+surface of an alien planet. And since this is not a naturally tenable position
+for a whale, this poor innocent creature had very little time to come to terms
+with its identity as a whale before it then had to come to terms with not being
+a whale any more.</p>
+<p>- The Hitchhiker's Guide to the Galaxy</p>
+</blockquote>
+
+<p><a href=downloads/toybox-0.8.11.tar.gz>Toybox 0.8.11</a>
+(<a href=https://github.com/landley/toybox/releases/tag/0.8.11>git commit</a>)
+is out, with prebuilt <a href=/bin/toybox/0.8.11>static binaries</a> and
+<a href=/bin/mkroot/0.8.11>mkroot images</a>
+bootable under QEMU (built using a <a href=/bin/mkroot/0.8.11/linux-patches>lightly patched</a> linux-6.8).</p>
+
+<p>Highlights include a new <a href=quickstart.html>quickstart</a>
+web page, shorter <a href=/bin>/bin</a> links to prebuilt binaries,
+lots of work on mkroot, and a new "canned" toybox build to reduce
+dependencies.</p>
+
+<p><u>New commands</u>:
+Rob added <b>tsort</b>, and promoted <b>fold</b> and <b>getopt</b>.
+Oliver Webb added <b>ts</b> and <b>csplit</b>, and
+Elliott added <b>memeater</b>.</p>
+
+<p>And one command got temporarily de-promoted: <b>passwd</b> is "default n"
+(disabled in defconfig) this release due to the ongoing lib/passwd.c
+infrastructure rewrite that isn't quite done yet. (See the Library section.)</p>
+
+<u>Features</u>:
+The new "<a href=https://github.com/landley/toybox/commit/d1acc6e88be5>canned</a>"
+toybox build in <b>scripts/prereq/build.sh</b> lets toybox provide its own
+build prerequisites by compiling a minimal toybox against saved headers (ala
+"cc -I scripts/prereq/generated file1.c file2.c..."). This provides
+most of the commands toybox needs to configure and build itself (except make,
+bash, and the compiler toolchain). This may help <a href=https://github.com/landley/toybox/commit/3bbc31c78b41>bootstrap</a> toybox on systems
+that don't provide a modern Linux command line out of the box: install
+toybox-prereq at the start of the $PATH, add
+a .config file, and run <b>scripts/make.sh</b>.</p>
+
+<p>New <b>mv -x</b> option to atomically swap two files,
+<b>env -e FILE</b> executes a different command than argv[0] on the command
+line, the <b>reset</b> command now puts raw terminals back into "cooked" mode,
+negative offsets in <b>sort -k</b> count right to left,
+<b>setsid</b> grabs the tty more forcefully (removing the need for getty)
+and the -cc option will try to steal it,
+<b>mount</b> now shows file= when displaying loopback mounts,
+<b>wc -L</b> shows longest line length,
+<b>tar -h</b> now detects a lot more hardlinks,
+<b>cp</b> now copies xattrs for directories (not just files).</p>
+
+<p>Elliott taught <b>file</b> to recognize wasm binary modules and
+display JPEG width/height, added the LOWER_UP, DORMANT, and ECHO
+flags to <b>ifconfig</b>, added PAC and BTI decoding to <b>readelf</b>,
+cache size querying to <b>sysconf</b> (supported by glibc and bionic but
+not musl-libc), and added a "paste" menu to <b>microcom</b>. Kalesh Singh
+taught <b>readelf</b> to decode a new note type (NT_ANDROID_TYPE_PAD_SEGMENT).
+Christopher Ferris improved <b>readelf</b> section flags handling,
+with test. Oliver Webb suggested <b>count -l</b>.
+Aditya submitted <b>netcat -z</b>.</p>
+
+<u>Bugfixes</u>:
+Fixed <b>printf \0</b> and <b>grep -w</b> (which never quite worked right),
+<b>ls -k</b> now switches off --block-size,
+<b>install -dm 02750</b> works (sticky bit support for -d),
+<b>tar</b> is better at following symlinks and extracting records with broken
+metadata, <b>gzip</b> now knows
+knows how to rename between "tgz/tar" extensions,
+<b>mkpasswd -m sha*</b> salt length can now range from 8-16, not just 16,
+<b>ps</b> can now handle an session ID of 0 (which is what PID 1 starts with
+before the first call to setsid()),
+<b>pwgen</b> can now use ~ in output,
+<b>xargs</b> now stops when a child exits with 255,
+<b>iconv</b> now exits with error if any characters failed to convert with -c,
+things like <b>truncate -s 1e2</b> were saying "too large" and now correctly
+say "not integer" (it's not scientific notation, it's exabyte suffix with
+trailing garbage),
+<b>timeout</b> now takes its exit code from SIGCHLD instead of wait()
+to fix a race condition (SIGCHLD can happen before calling wait and the
+kernel won't deliver status twice, so you can't wait AND have the
+signal handler). The usual round of gcc warnings got tracked down, confirmed
+to be useless, and removed, but despite gcc constantly warning "variable is
+not actually used uninitialized" there were some uninitialized variables in
+<b>dd</b> it DIDN'T warn about: found and fixed.</p>
+
+<p>Elliott added an error message to catch <b>xxd -r</b> receiving -p format
+input without -p,
+fixed <b>readelf -n</b> for x86-64 ibt/shstk notes
+(<a href=https://github.com/landley/toybox/commit/6c23ff0168c1>whatever those
+are</a>),
+and fixed <b>blkid</b> not to check filesystem signatures that would continue
+past the end of the loaded buffer.
+Michael Shavit pointed out that <b>devmem</b> command line number parsing
+wasn't unsigned (although fixing that means it no longer parses the kmg unit
+suffixes).
+Peter Collingbourne fixed <b>inotifyd</b> skipping the first mask character.
+Taisuke Matsushiro fixed a fencepost error preventing <b>stty</b> from
+setting serial baud rate to 57600.
+Askar Safin fixed a typo in mkroot/packages/busybox.</p>
+
+<u>Library</u>:
+The in-progress rewrite of <b>lib/password.c</b> no longer uses shadow.h
+(which lets it build against bionic),
+and a new <b>lib/hash.c</b> where toybox implements its own crypt() using
+the md5/sha1/sha3 etc hash functions we've already got (to work around glibc's
+ongoing deprecation of posix features), but neither are quite finished yet.
+New <b>lib/elf.c</b> with plumbing shared by <b>file</b> and <b>readelf</b>, with
+additional arm and riscv flag decoding,
+the <b>peek()</b> family of functions now return long long instead of
+int64_t so the base types are consistent on 32/64 bit,
+<b>lib/args.c</b> now handles the high bit octal escape sequences in trailing
+[-abc] blocks, so you can have punctuation participate in option groups,
+switching off an option via grouping now sets it back to its default
+value (not to zero), and numeric and date parsing report out of range numeric
+or millisecond values.</p>
+
+<u>Mkroot</u>:
+There's a <b>README</b> in the mkroot directory now. (Microsoft Github was
+picking up the README.root file used by the tar-for-web.sh script
+and showing that instead.)
+Extended <b>run-qemu.sh</b> so it can be run from other directories
+(prepending $(dirname $0)/ to linux-kernel and initramfs.cpio.gz when
+loading them into qemu).
+The initramfs now has <b>/etc/os-release</b> with the toybox $VERSION.
+The big if/else staircase of linux kernel target configurations
+moved into its own <b>get_target_config()</b> shell function, with
+a big comment block right before it explaining what all the variables
+it sets mean, and the generic kconfig symbol list got moved out to
+a <b>GENERIC_KCONF</b> variable assignment right after that function.
+The <b>microconfig</b> format got compressed slightly more
+by use of bash brace expansion, decoded to comma separated values by
+the be2csv function ala KCONF="$(be2csv SPI{,_BITBANG} IOMMU_SUPPORT)" .
+The init script no longer calls <b>oneit</b>, instead doing the work in the
+init script. (Redirect stdin/out/err to the "real" console device on
+the last line of /sys/class/tty/console/active, call setsid, trap SIGCHLD,
+reboot when the shell exits. This (and the setsid tty stealing upgrades) also
+fixed <b>ps</b> not showing any processes in mkroot because stdin/stdout weren't
+properly claimed as the controlling tty.
+The base kernel config now uses <b>CONFIG_PANIC_TIMEOUT=1</b> so
+we don't have to say panic=1 on the kernel command line anymore.
+The baseconfig now automatically adds CONFIG_MODULES and
+CONFIG_MODULES_UNLOAD when any <b>$MODULES</b> are listed.
+Moved the kernel modules archive into the "docs" directory.
+New <b>$NOTOYBOX</b> variable skips the toybox build if set.
+The <b>$DTB</b> files no longer have a path, instead using "find"
+to install them.
+The build now creates the externally loadable cpio.gz file even when
+building initramfs into the kernel, but sticks it in the docs/ subdirectory
+when it's not used.</p>
+
+<p>Several new <b>mcm-buildall.sh</b> targets (or1k, riscv32, riscv64, sh4eb)
+taking advantage of upstream musl-cross-make updating itself to use
+musl-1.2.5. The target list in mcm-buildall.sh moved into a <b>TARGETS=()</b>
+array with a big comment before it explaining the format, and the script
+is better about building host toolchains
+to build other cross compilers with: it tries to autodetect the host
+type (moving the relevant one to the front of the build list), and
+will also build a missing host toolchain when given targets on the
+command line. Added microblaze and or1k kernel configs, neither of which
+know how to exit qemu yet. (If Linux has got a reboot mechanism it knows
+how to poke that qemu is listening for on either virtual board, I haven't
+found it yet.) Also added sh4eb with FDPIC support (see kernel patch, which
+allows qemu-system-sh4eb to run the sh2eb nommu root filesystem), and armv4l
+(the 486 of arm).</p>
+
+<u>Pending</u>:
+Elliott fixed and improved <b>strace</b>, translating more system calls.
+Rob enabled command recursion in <b>toysh</b> (so it can call non-builtins as
+builtins), fixed calling "exec" on NOFORK commands (which MUST run
+in the shell's process context), redid the code to handle trailing
+backslashes gluing lines together, and it no longer leaks script
+filehandles into child processes.
+Oliver Webb noticed that OLDTOY(MAYFORK) aliases didn't become shell
+builtins, added <b>tr -t</b>, in <b>vi</b> added line gotos in ex mode,
+'g', 'v', 'j' commands, and backwards search, cleaned up stuff in
+<b>xzcat</b>, <b>getopt</b>, <b>bc</b>, and removed a bunch of useless autogenerated
+<b>bc</b> tests. Jarno Mäkipää added the list of supported commands to <b>vi</b>'s
+help text.
+Mathieu Anquetin fixed <b>ip link set</b> parsing, and NUL byte handling
+in <b>hexdump</b>.
+General cleanup passes on <b>expr</b> (which now uses 64 bit comparisons),
+<b>tr</b>, and <b>dhcpd</b>.</p>
+
+<u>Cleanup</u>:
+pass over <b>lsattr</b>, <b>getconf</b>, <b>acpi</b>, and <b>blkid</b>.
+Use FLAG() macros in <b>ifconfig</b> and <b>restorecon</b>. Removed TODO block
+from <b>nbd-client</b>.
+More error_msg("%s", str) converted to error_msg_raw(str).
+Trimmed the GLOBALS() sizes (using <b>scripts/probes/GLOBALS</b>):
+removed 1k of global data from <b>cksum</b> and switched a 2k global
+in <b>grep</b> to a malloc. Simplified scripts/probes/bloatcheck and
+mkroot/record-commands.</p>
+
+<u>Portability</u>:
+Fixed <b>truncate -s 8g</b> on 32 bit hosts,
+updated <b>mcm-buildall.sh</b> to autodetect host type and automatically
+select newer package versions,
+and moved the <b>linux32</b> command to its own file because BSD can't
+build it.
+MacOS had a use-after-free with the getpwuid() return value being recycled
+a more aggressively than Linux.
+Elliott fixed diff.test to work with mksh, and posix_fallocate()
+to work with MacOS.
+More commands enabled in <b>make bsd_defconfig</b> and <b>make
+macos_defconfig</b>.
+Added some (void) typecasts to netstat, oneit, and watchdog to try to
+shut up compilers that insist on responding to uncorrectable failures.
+(Such as fgets() reading known /proc data from the kernel, writes to
+the watchdog timer that will reboot the system if they fail, or PID 1 calling
+dup() on stdin to create stdout and stderr after closing the old ones.
+If any of that goes wrong, what are we supposed to do about it?)</p>
+
+<u>Documentation</u>:
+The website now has a <a href=quick.html>quickstart</a> page,
+and the site now defaults to the about page (updated index.html symlink).
+The "current release" is now in the common header displayed by most pages.
+The mkroot dir has a
+<a href=https://github.com/landley/toybox/blob/0.8.11/mkroot/README>README</a>, and its <a href=faq.html#mkroot>faq entry</a>
+has been updated.
+New option to compress help text with <b>gzip</b>, and help text size now shows
+up in <b>make bloatcheck</b>.
+Fix <b>sed --help</b> to show full help, <b>patch -F</b> is now mentioned
+in the help text, tweaks to help text in <b>cut</b>, <b>grep</b>,
+<b>blkdiscard</b>.
+Elliott did a cleanup pass over "usage:" lines and alphabetized more help text
+options.
+Christian Koestlin fixed a typo in the <b>dmesg</b> docs.
+The <a href=release.txt>release
+procedure checklist</a> has been updated, and the README generated
+by <b>mkroot/tar-for-web.sh</b> got updated.
+New faq entry explaining why toybox doesn't have (or need) cttyhack,
+and the architecture list got updated to match mcm-buildall.sh.
+The usual roadmap updates.</p>
+
+<p>New <b>scripts/probes/cmd2dpkg</b> script shows what
+debian package (if any) each toybox command lives in, but only checks
+installed packages (dpkg-query -S "$(which $COMMAND)") and debian breaks
+up source packages strangely, so did not used it to redo the roadmap section
+listing packages (created using Linux From Scratch's list of commands
+installed by each source package).</p>
+
+<u>Plumbing</u>:
+The <b>yes</b> command now uses writev() to go way faster, mostly to
+prove it can.
+The default <b>stdout</b> buffer type switched to block buffering to make
+Elliott happy, which is a rich source of bugs (many of which Elliott
+has already whack-a-moled) and means among other things
+that mixing write() and fwrite() calls now requires manual flushing.
+Meanwhile xflush() became xferror() because it usually
+wasn't flushing anyway, and now that's more noticeable.
+Removed <b>TOYFLAG_LOCALE</b> and just set utf8 locale for all commands.
+The dirtree code now sets <b>DIRTREE_SYMFOLLOW</b> in "again" when we followed
+a symlink to get to this node, callers checking <b>DIRTREE_COMEAGAIN</b> need
+to mask out the bit they're interested in.
+Improved <b>scripts/probes/findglobals</b> output to be more legible.</p>
+
+<u>Test suite</u>:
+Added <b>make test_help test_install</b> targets. (The standalone
+command targets conflict with the help/install make targets, but you
+can still build them via scripts/single.sh and there's no reason not
+to be able to individually test them.)
+New <b>utf8locale</b> shell function attempts to enable a UTF8 locale for
+TEST_HOST, which was used to fix <b>wc.test</b>.
+Colin Cross fixed <b>pidof.test</b> when stdout is a socket.
+Something called "ecryptfs" has a maximum filename length of 143 bytes,
+so our <b>tar.test</b> for long filenames support needs to be skipped there
+because the filesystem can't handle it. Similarly, our <b>truncate.test</b>
+was failing because storing nothing on ecryptfs wasts more space than expected.
+The <b>tar</b> tests now fetch user/group names with "stat" because
+between Linux, Android, FreeBSD, and MacOS, there aren't really consistent
+user and group names for any existing files. Added nbd-client.test
+Thiébaud Weksteen fixed the <b>getfattr</b>/<b>setfattr</b> tests on
+filesystems using selinux. Oliver Webb added <b>sha3sum</b> tests.
+Elliott stabilized another slightly racy <b>ifconfig</b> test (big test
+farm, hits the weird corner cases).</p>
+
+<u>Build</u>:
+Lots of changes to <b>scripts/make.sh</b> and friends to speed up and parallelize
+header generation. The build now figures out which toys/*/*.c files
+to compile by searching for unindented USE() macros wrapping NEW(commandname),
+which among other things fixes enabling the builtins when selecting just
+CONFIG_SH in menuconfig (instead of doing a "make sh" single command build).
+It also probes for optional shared libraries in parallel.
+New <b>scripts/probes</b> directory to collect scripts that aren't actually
+used by the build, with a README in it.
+Updated .gitignore so it doesn't complain about spurious name collisions in
+subdirectories. Elliott shut up a
+<a href=https://github.com/landley/toybox/commit/2c36636377e1>truly sad</a>
+warning where despite sizeof(ptrdiff_t) always being sizeof(long), gcc
+nevertheless warns if you printf("%ld", ptr-ptr) and wants a magic invented
+"%td" type on 32 bit systems (but is just fine on 64 bit). (Or we could add a
+literally NOP typecast to long.) And silenced a spurious gcc 13.2 warning
+in date.c. And Rob shut up <a href=https://github.com/landley/toybox/commit/a17fee778851>more broken gcc warnings</a>.
+Updated .gitignore so it doesn't complain about spurious name collisions in
+subdirectories.</p>
+
<a name="30-07-2023" /><a href="#30-07-2023"><hr><h2><b>July 30, 2023</b></h2></a>
<blockquote>
<p>The way it functioned was very interesting. When the Drink button was