aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2024-05-09 17:06:47 +0000
committerSadaf Ebrahimi <sadafebrahimi@google.com>2024-05-09 17:06:53 +0000
commit601ee22c05b5ccc15fda900d60a036a04d781c47 (patch)
tree2379b2569bd512fe44f03eea5946e2501b8d2d0f
parentc321443c7c049a7975fed7c88c84c8a046bc9ef5 (diff)
parent6800a95ef32826e753881802a2c126c59d451397 (diff)
downloadtoybox-main.tar.gz
Upgrade toybox to 6800a95ef32826e753881802a2c126c59d451397HEADmastermain
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/toybox For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I58117099abc100bd070cf3641e788b6a996a77ca
-rw-r--r--METADATA6
-rw-r--r--android/device/generated/globals.h5
-rw-r--r--android/device/generated/help.h6
-rw-r--r--android/device/generated/tags.h280
-rw-r--r--android/linux/generated/help.h6
-rw-r--r--android/linux/generated/tags.h280
-rw-r--r--android/mac/generated/help.h6
-rw-r--r--android/mac/generated/tags.h280
-rw-r--r--lib/lib.c2
-rw-r--r--mkroot/README4
-rwxr-xr-xmkroot/mkroot.sh6
-rwxr-xr-xscripts/make.sh21
-rw-r--r--scripts/mktags.c58
-rwxr-xr-xtests/find.test8
-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/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
40 files changed, 654 insertions, 697 deletions
diff --git a/METADATA b/METADATA
index 8730ee22..94fd4032 100644
--- a/METADATA
+++ b/METADATA
@@ -8,13 +8,13 @@ third_party {
license_type: UNENCUMBERED
last_upgrade_date {
year: 2024
- month: 4
- day: 22
+ month: 5
+ day: 9
}
homepage: "https://landley.net/toybox/"
identifier {
type: "Git"
value: "https://github.com/landley/toybox"
- version: "7c6aecd477a9b898df981197088c9e1d5775fe9c"
+ version: "6800a95ef32826e753881802a2c126c59d451397"
}
}
diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h
index 6b358369..43023b91 100644
--- a/android/device/generated/globals.h
+++ b/android/device/generated/globals.h
@@ -118,7 +118,7 @@ struct blkid_data {
};
struct blockdev_data {
- long setbsz, setra;
+ long setra, setbsz;
};
struct chrt_data {
@@ -598,8 +598,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..6931101c 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -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/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/help.h b/android/linux/generated/help.h
index b3c74b17..8ce794a8 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -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/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/help.h b/android/mac/generated/help.h
index b3c74b17..8ce794a8 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -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/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/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/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 227dbb3c..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=)
@@ -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/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/tests/find.test b/tests/find.test
index d57d1910..e026d7b5 100755
--- a/tests/find.test
+++ b/tests/find.test
@@ -156,4 +156,12 @@ 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
+testing 'strlower edge case' \
+ 'touch aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ; find . -iname aaaaaȺȺȺȺȺȺȺȺȺ' './aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ\n' \
+ '' ''
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/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..c8e68683 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) &&
+ ((new->st.st_mode & S_IFMT) == S_IFREG);
} 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