diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-28 21:12:48 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-28 21:12:48 +0000 |
commit | 85e05bb783bf18b84a71354dd688864fcd4e031c (patch) | |
tree | 5c37a9adc3617aafb184deac4bfe2e6819fd91c9 | |
parent | 36b233719dc13f995b4d8794cd85b21ea032b1c0 (diff) | |
parent | 6511f674cf96a62172cf24639febb6a11b14939c (diff) | |
download | toybox-simpleperf-release.tar.gz |
Snap for 11510257 from 6511f674cf96a62172cf24639febb6a11b14939c to simpleperf-releasesimpleperf-release
Change-Id: I74d7e50aaa3935a44bec09880de65791cc3ff774
102 files changed, 670 insertions, 4696 deletions
@@ -293,6 +293,7 @@ toybox_symlinks = [ "fsync", "getconf", "getenforce", + "getfattr", "gpiodetect", "gpiofind", "gpioget", @@ -378,6 +379,7 @@ toybox_symlinks = [ "sendevent", "seq", "setenforce", + "setfattr", "setsid", "sha1sum", "sha224sum", @@ -9,12 +9,12 @@ third_party { last_upgrade_date { year: 2024 month: 2 - day: 7 + day: 21 } homepage: "https://landley.net/toybox/" identifier { type: "Git" value: "https://github.com/landley/toybox" - version: "a57e42a386b04f27aa9c000d6425f13bb644c70c" + version: "b89c8914513ea055fdb686a765aaf4c65eaf706d" } } diff --git a/android/device/generated/config.h b/android/device/generated/config.h index a76ea6c2..903901ee 100644 --- a/android/device/generated/config.h +++ b/android/device/generated/config.h @@ -1,39 +1,29 @@ #define CFG_TOYBOX 1 #define USE_TOYBOX(...) __VA_ARGS__ - #define CFG_TOYBOX_DEBUG 0 #define USE_TOYBOX_DEBUG(...) #define CFG_TOYBOX_FLOAT 1 #define USE_TOYBOX_FLOAT(...) __VA_ARGS__ - #define CFG_TOYBOX_FORK 1 #define USE_TOYBOX_FORK(...) __VA_ARGS__ - #define CFG_TOYBOX_FREE 0 #define USE_TOYBOX_FREE(...) #define CFG_TOYBOX_HELP_DASHDASH 1 #define USE_TOYBOX_HELP_DASHDASH(...) __VA_ARGS__ - #define CFG_TOYBOX_HELP 1 #define USE_TOYBOX_HELP(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBCRYPTO 1 #define USE_TOYBOX_LIBCRYPTO(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBZ 1 #define USE_TOYBOX_LIBZ(...) __VA_ARGS__ - #define CFG_TOYBOX_LSM_NONE 0 #define USE_TOYBOX_LSM_NONE(...) #define CFG_TOYBOX_NORECURSE 1 #define USE_TOYBOX_NORECURSE(...) __VA_ARGS__ - #define CFG_TOYBOX_ON_ANDROID 1 #define USE_TOYBOX_ON_ANDROID(...) __VA_ARGS__ - #define CFG_TOYBOX_SELINUX 1 #define USE_TOYBOX_SELINUX(...) __VA_ARGS__ - #define CFG_TOYBOX_SMACK 0 #define USE_TOYBOX_SMACK(...) #define CFG_TOYBOX_SUID 0 @@ -42,7 +32,6 @@ #define USE_TOYBOX_ZHELP(...) #define CFG_ACPI 1 #define USE_ACPI(...) __VA_ARGS__ - #define CFG_ARCH 0 #define USE_ARCH(...) #define CFG_ARPING 0 @@ -55,83 +44,62 @@ #define USE_BASE32(...) #define CFG_BASE64 1 #define USE_BASE64(...) __VA_ARGS__ - #define CFG_BASENAME 1 #define USE_BASENAME(...) __VA_ARGS__ - #define CFG_BC 0 #define USE_BC(...) #define CFG_BLKDISCARD 1 #define USE_BLKDISCARD(...) __VA_ARGS__ - #define CFG_BLKID 1 #define USE_BLKID(...) __VA_ARGS__ - #define CFG_BLOCKDEV 1 #define USE_BLOCKDEV(...) __VA_ARGS__ - #define CFG_BOOTCHARTD 0 #define USE_BOOTCHARTD(...) #define CFG_BRCTL 1 #define USE_BRCTL(...) __VA_ARGS__ - #define CFG_BUNZIP2 0 #define USE_BUNZIP2(...) #define CFG_BZCAT 0 #define USE_BZCAT(...) #define CFG_CAL 1 #define USE_CAL(...) __VA_ARGS__ - #define CFG_CAT 1 #define USE_CAT(...) __VA_ARGS__ - #define CFG_CD 0 #define USE_CD(...) #define CFG_CHATTR 1 #define USE_CHATTR(...) __VA_ARGS__ - #define CFG_CHCON 1 #define USE_CHCON(...) __VA_ARGS__ - #define CFG_CHGRP 1 #define USE_CHGRP(...) __VA_ARGS__ - #define CFG_CHMOD 1 #define USE_CHMOD(...) __VA_ARGS__ - #define CFG_CHOWN 1 #define USE_CHOWN(...) __VA_ARGS__ - #define CFG_CHROOT 1 #define USE_CHROOT(...) __VA_ARGS__ - #define CFG_CHRT 1 #define USE_CHRT(...) __VA_ARGS__ - #define CFG_CHSH 0 #define USE_CHSH(...) #define CFG_CHVT 0 #define USE_CHVT(...) #define CFG_CKSUM 1 #define USE_CKSUM(...) __VA_ARGS__ - #define CFG_CLEAR 1 #define USE_CLEAR(...) __VA_ARGS__ - #define CFG_CMP 1 #define USE_CMP(...) __VA_ARGS__ - #define CFG_COMM 1 #define USE_COMM(...) __VA_ARGS__ - #define CFG_COUNT 0 #define USE_COUNT(...) #define CFG_CPIO 1 #define USE_CPIO(...) __VA_ARGS__ - #define CFG_CP 1 #define USE_CP(...) __VA_ARGS__ - #define CFG_CRC32 0 #define USE_CRC32(...) #define CFG_CROND 0 @@ -142,13 +110,10 @@ #define USE_CSPLIT(...) #define CFG_CUT 1 #define USE_CUT(...) __VA_ARGS__ - #define CFG_DATE 1 #define USE_DATE(...) __VA_ARGS__ - #define CFG_DD 1 #define USE_DD(...) __VA_ARGS__ - #define CFG_DEALLOCVT 0 #define USE_DEALLOCVT(...) #define CFG_DEBUG_DHCP 0 @@ -163,10 +128,8 @@ #define USE_DEMO_UTF8TOWC(...) #define CFG_DEVMEM 1 #define USE_DEVMEM(...) __VA_ARGS__ - #define CFG_DF 1 #define USE_DF(...) __VA_ARGS__ - #define CFG_DHCP6 0 #define USE_DHCP6(...) #define CFG_DHCPD 0 @@ -175,101 +138,76 @@ #define USE_DHCP(...) #define CFG_DIFF 1 #define USE_DIFF(...) __VA_ARGS__ - #define CFG_DIRNAME 1 #define USE_DIRNAME(...) __VA_ARGS__ - #define CFG_DMESG 1 #define USE_DMESG(...) __VA_ARGS__ - #define CFG_DNSDOMAINNAME 0 #define USE_DNSDOMAINNAME(...) #define CFG_DOS2UNIX 1 #define USE_DOS2UNIX(...) __VA_ARGS__ - #define CFG_DUMPLEASES 0 #define USE_DUMPLEASES(...) #define CFG_DU 1 #define USE_DU(...) __VA_ARGS__ - #define CFG_ECHO 1 #define USE_ECHO(...) __VA_ARGS__ - #define CFG_EGREP 1 #define USE_EGREP(...) __VA_ARGS__ - #define CFG_EJECT 0 #define USE_EJECT(...) #define CFG_ENV 1 #define USE_ENV(...) __VA_ARGS__ - #define CFG_EXIT 0 #define USE_EXIT(...) #define CFG_EXPAND 1 #define USE_EXPAND(...) __VA_ARGS__ - #define CFG_EXPR 1 #define USE_EXPR(...) __VA_ARGS__ - #define CFG_FACTOR 0 #define USE_FACTOR(...) #define CFG_FALLOCATE 1 #define USE_FALLOCATE(...) __VA_ARGS__ - #define CFG_FALSE 1 #define USE_FALSE(...) __VA_ARGS__ - #define CFG_FDISK 0 #define USE_FDISK(...) #define CFG_FGREP 1 #define USE_FGREP(...) __VA_ARGS__ - #define CFG_FILE 1 #define USE_FILE(...) __VA_ARGS__ - #define CFG_FIND 1 #define USE_FIND(...) __VA_ARGS__ - #define CFG_FLOCK 1 #define USE_FLOCK(...) __VA_ARGS__ - #define CFG_FMT 1 #define USE_FMT(...) __VA_ARGS__ - #define CFG_FOLD 0 #define USE_FOLD(...) #define CFG_FREERAMDISK 1 #define USE_FREERAMDISK(...) __VA_ARGS__ - #define CFG_FREE 1 #define USE_FREE(...) __VA_ARGS__ - #define CFG_FSCK 0 #define USE_FSCK(...) #define CFG_FSFREEZE 1 #define USE_FSFREEZE(...) __VA_ARGS__ - #define CFG_FSTYPE 0 #define USE_FSTYPE(...) #define CFG_FSYNC 1 #define USE_FSYNC(...) __VA_ARGS__ - #define CFG_FTPGET 0 #define USE_FTPGET(...) #define CFG_FTPPUT 0 #define USE_FTPPUT(...) #define CFG_GETCONF 1 #define USE_GETCONF(...) __VA_ARGS__ - #define CFG_GETENFORCE 1 #define USE_GETENFORCE(...) __VA_ARGS__ - #define CFG_GETFATTR 1 #define USE_GETFATTR(...) __VA_ARGS__ - #define CFG_GETOPT 1 #define USE_GETOPT(...) __VA_ARGS__ - #define CFG_GETTY 0 #define USE_GETTY(...) #define CFG_GITCHECKOUT 0 @@ -286,43 +224,32 @@ #define USE_GITREMOTE(...) #define CFG_GPIODETECT 1 #define USE_GPIODETECT(...) __VA_ARGS__ - #define CFG_GPIOFIND 1 #define USE_GPIOFIND(...) __VA_ARGS__ - #define CFG_GPIOGET 1 #define USE_GPIOGET(...) __VA_ARGS__ - #define CFG_GPIOINFO 1 #define USE_GPIOINFO(...) __VA_ARGS__ - #define CFG_GPIOSET 1 #define USE_GPIOSET(...) __VA_ARGS__ - #define CFG_GREP 1 #define USE_GREP(...) __VA_ARGS__ - #define CFG_GROUPADD 0 #define USE_GROUPADD(...) #define CFG_GROUPDEL 0 #define USE_GROUPDEL(...) #define CFG_GROUPS 1 #define USE_GROUPS(...) __VA_ARGS__ - #define CFG_GUNZIP 1 #define USE_GUNZIP(...) __VA_ARGS__ - #define CFG_GZIP 1 #define USE_GZIP(...) __VA_ARGS__ - #define CFG_HEAD 1 #define USE_HEAD(...) __VA_ARGS__ - #define CFG_HELLO 0 #define USE_HELLO(...) #define CFG_HELP 1 #define USE_HELP(...) __VA_ARGS__ - #define CFG_HEXDUMP 0 #define USE_HEXDUMP(...) #define CFG_HEXEDIT 0 @@ -335,59 +262,42 @@ #define USE_HOST(...) #define CFG_HOSTNAME 1 #define USE_HOSTNAME(...) __VA_ARGS__ - #define CFG_HTTPD 0 #define USE_HTTPD(...) #define CFG_HWCLOCK 1 #define USE_HWCLOCK(...) __VA_ARGS__ - #define CFG_I2CDETECT 1 #define USE_I2CDETECT(...) __VA_ARGS__ - #define CFG_I2CDUMP 1 #define USE_I2CDUMP(...) __VA_ARGS__ - #define CFG_I2CGET 1 #define USE_I2CGET(...) __VA_ARGS__ - #define CFG_I2CSET 1 #define USE_I2CSET(...) __VA_ARGS__ - #define CFG_I2CTRANSFER 1 #define USE_I2CTRANSFER(...) __VA_ARGS__ - #define CFG_ICONV 1 #define USE_ICONV(...) __VA_ARGS__ - #define CFG_ID 1 #define USE_ID(...) __VA_ARGS__ - #define CFG_ID_Z 1 #define USE_ID_Z(...) __VA_ARGS__ - #define CFG_IFCONFIG 1 #define USE_IFCONFIG(...) __VA_ARGS__ - #define CFG_INIT 0 #define USE_INIT(...) #define CFG_INOTIFYD 1 #define USE_INOTIFYD(...) __VA_ARGS__ - #define CFG_INSMOD 1 #define USE_INSMOD(...) __VA_ARGS__ - #define CFG_INSTALL 1 #define USE_INSTALL(...) __VA_ARGS__ - #define CFG_IONICE 1 #define USE_IONICE(...) __VA_ARGS__ - #define CFG_IORENICE 1 #define USE_IORENICE(...) __VA_ARGS__ - #define CFG_IOTOP 1 #define USE_IOTOP(...) __VA_ARGS__ - #define CFG_IPCRM 0 #define USE_IPCRM(...) #define CFG_IPCS 0 @@ -398,10 +308,8 @@ #define USE_KILLALL5(...) #define CFG_KILLALL 1 #define USE_KILLALL(...) __VA_ARGS__ - #define CFG_KILL 1 #define USE_KILL(...) __VA_ARGS__ - #define CFG_KLOGD 0 #define USE_KLOGD(...) #define CFG_KLOGD_SOURCE_RING_BUFFER 0 @@ -414,72 +322,54 @@ #define USE_LINUX32(...) #define CFG_LN 1 #define USE_LN(...) __VA_ARGS__ - #define CFG_LOAD_POLICY 1 #define USE_LOAD_POLICY(...) __VA_ARGS__ - #define CFG_LOGGER 1 #define USE_LOGGER(...) __VA_ARGS__ - #define CFG_LOGIN 0 #define USE_LOGIN(...) #define CFG_LOGNAME 1 #define USE_LOGNAME(...) __VA_ARGS__ - #define CFG_LOGPATH 0 #define USE_LOGPATH(...) #define CFG_LOG 1 #define USE_LOG(...) __VA_ARGS__ - #define CFG_LOSETUP 1 #define USE_LOSETUP(...) __VA_ARGS__ - #define CFG_LSATTR 1 #define USE_LSATTR(...) __VA_ARGS__ - #define CFG_LSMOD 1 #define USE_LSMOD(...) __VA_ARGS__ - #define CFG_LSOF 1 #define USE_LSOF(...) __VA_ARGS__ - #define CFG_LSPCI 1 #define USE_LSPCI(...) __VA_ARGS__ - #define CFG_LSUSB 1 #define USE_LSUSB(...) __VA_ARGS__ - #define CFG_LS 1 #define USE_LS(...) __VA_ARGS__ - #define CFG_MAKEDEVS 1 #define USE_MAKEDEVS(...) __VA_ARGS__ - #define CFG_MAN 0 #define USE_MAN(...) #define CFG_MCOOKIE 0 #define USE_MCOOKIE(...) #define CFG_MD5SUM 1 #define USE_MD5SUM(...) __VA_ARGS__ - #define CFG_MDEV_CONF 0 #define USE_MDEV_CONF(...) #define CFG_MDEV 0 #define USE_MDEV(...) #define CFG_MEMEATER 1 #define USE_MEMEATER(...) __VA_ARGS__ - #define CFG_MICROCOM 1 #define USE_MICROCOM(...) __VA_ARGS__ - #define CFG_MIX 0 #define USE_MIX(...) #define CFG_MKDIR 1 #define USE_MKDIR(...) __VA_ARGS__ - #define CFG_MKDIR_Z 1 #define USE_MKDIR_Z(...) __VA_ARGS__ - #define CFG_MKE2FS_EXTENDED 0 #define USE_MKE2FS_EXTENDED(...) #define CFG_MKE2FS_GEN 0 @@ -492,200 +382,142 @@ #define USE_MKE2FS_LABEL(...) #define CFG_MKFIFO 1 #define USE_MKFIFO(...) __VA_ARGS__ - #define CFG_MKFIFO_Z 1 #define USE_MKFIFO_Z(...) __VA_ARGS__ - #define CFG_MKNOD 1 #define USE_MKNOD(...) __VA_ARGS__ - #define CFG_MKNOD_Z 1 #define USE_MKNOD_Z(...) __VA_ARGS__ - #define CFG_MKPASSWD 0 #define USE_MKPASSWD(...) #define CFG_MKSWAP 1 #define USE_MKSWAP(...) __VA_ARGS__ - #define CFG_MKTEMP 1 #define USE_MKTEMP(...) __VA_ARGS__ - #define CFG_MODINFO 1 #define USE_MODINFO(...) __VA_ARGS__ - #define CFG_MODPROBE 1 #define USE_MODPROBE(...) __VA_ARGS__ - #define CFG_MORE 1 #define USE_MORE(...) __VA_ARGS__ - #define CFG_MOUNTPOINT 1 #define USE_MOUNTPOINT(...) __VA_ARGS__ - #define CFG_MOUNT 1 #define USE_MOUNT(...) __VA_ARGS__ - #define CFG_MV 1 #define USE_MV(...) __VA_ARGS__ - #define CFG_NBD_CLIENT 1 #define USE_NBD_CLIENT(...) __VA_ARGS__ - #define CFG_NBD_SERVER 0 #define USE_NBD_SERVER(...) #define CFG_NETCAT 1 #define USE_NETCAT(...) __VA_ARGS__ - #define CFG_NETSTAT 1 #define USE_NETSTAT(...) __VA_ARGS__ - #define CFG_NICE 1 #define USE_NICE(...) __VA_ARGS__ - #define CFG_NL 1 #define USE_NL(...) __VA_ARGS__ - #define CFG_NOHUP 1 #define USE_NOHUP(...) __VA_ARGS__ - #define CFG_NPROC 1 #define USE_NPROC(...) __VA_ARGS__ - #define CFG_NSENTER 1 #define USE_NSENTER(...) __VA_ARGS__ - #define CFG_OD 1 #define USE_OD(...) __VA_ARGS__ - #define CFG_ONEIT 0 #define USE_ONEIT(...) #define CFG_OPENVT 0 #define USE_OPENVT(...) #define CFG_PARTPROBE 1 #define USE_PARTPROBE(...) __VA_ARGS__ - #define CFG_PASSWD 0 #define USE_PASSWD(...) #define CFG_PASTE 1 #define USE_PASTE(...) __VA_ARGS__ - #define CFG_PATCH 1 #define USE_PATCH(...) __VA_ARGS__ - #define CFG_PGREP 1 #define USE_PGREP(...) __VA_ARGS__ - #define CFG_PIDOF 1 #define USE_PIDOF(...) __VA_ARGS__ - #define CFG_PING 1 #define USE_PING(...) __VA_ARGS__ - #define CFG_PIVOT_ROOT 1 #define USE_PIVOT_ROOT(...) __VA_ARGS__ - #define CFG_PKILL 1 #define USE_PKILL(...) __VA_ARGS__ - #define CFG_PMAP 1 #define USE_PMAP(...) __VA_ARGS__ - #define CFG_PRINTENV 1 #define USE_PRINTENV(...) __VA_ARGS__ - #define CFG_PRINTF 1 #define USE_PRINTF(...) __VA_ARGS__ - #define CFG_PS 1 #define USE_PS(...) __VA_ARGS__ - #define CFG_PWDX 1 #define USE_PWDX(...) __VA_ARGS__ - #define CFG_PWD 1 #define USE_PWD(...) __VA_ARGS__ - #define CFG_PWGEN 0 #define USE_PWGEN(...) #define CFG_READAHEAD 0 #define USE_READAHEAD(...) #define CFG_READELF 1 #define USE_READELF(...) __VA_ARGS__ - #define CFG_READLINK 1 #define USE_READLINK(...) __VA_ARGS__ - #define CFG_REALPATH 1 #define USE_REALPATH(...) __VA_ARGS__ - #define CFG_REBOOT 0 #define USE_REBOOT(...) #define CFG_RENICE 1 #define USE_RENICE(...) __VA_ARGS__ - #define CFG_RESET 0 #define USE_RESET(...) #define CFG_RESTORECON 1 #define USE_RESTORECON(...) __VA_ARGS__ - #define CFG_REV 1 #define USE_REV(...) __VA_ARGS__ - #define CFG_RFKILL 1 #define USE_RFKILL(...) __VA_ARGS__ - #define CFG_RMDIR 1 #define USE_RMDIR(...) __VA_ARGS__ - #define CFG_RMMOD 1 #define USE_RMMOD(...) __VA_ARGS__ - #define CFG_RM 1 #define USE_RM(...) __VA_ARGS__ - #define CFG_ROUTE 0 #define USE_ROUTE(...) #define CFG_RTCWAKE 1 #define USE_RTCWAKE(...) __VA_ARGS__ - #define CFG_RUNCON 1 #define USE_RUNCON(...) __VA_ARGS__ - #define CFG_SED 1 #define USE_SED(...) __VA_ARGS__ - #define CFG_SENDEVENT 1 #define USE_SENDEVENT(...) __VA_ARGS__ - #define CFG_SEQ 1 #define USE_SEQ(...) __VA_ARGS__ - #define CFG_SETENFORCE 1 #define USE_SETENFORCE(...) __VA_ARGS__ - #define CFG_SETFATTR 1 #define USE_SETFATTR(...) __VA_ARGS__ - #define CFG_SETSID 1 #define USE_SETSID(...) __VA_ARGS__ - #define CFG_SHA1SUM 1 #define USE_SHA1SUM(...) __VA_ARGS__ - #define CFG_SHA224SUM 1 #define USE_SHA224SUM(...) __VA_ARGS__ - #define CFG_SHA256SUM 1 #define USE_SHA256SUM(...) __VA_ARGS__ - #define CFG_SHA3SUM 0 #define USE_SHA3SUM(...) #define CFG_SHA384SUM 1 #define USE_SHA384SUM(...) __VA_ARGS__ - #define CFG_SHA512SUM 1 #define USE_SHA512SUM(...) __VA_ARGS__ - #define CFG_SH 0 #define USE_SH(...) #define CFG_SHRED 0 @@ -698,199 +530,147 @@ #define USE_SKELETON(...) #define CFG_SLEEP 1 #define USE_SLEEP(...) __VA_ARGS__ - #define CFG_SNTP 0 #define USE_SNTP(...) #define CFG_SORT_FLOAT 1 #define USE_SORT_FLOAT(...) __VA_ARGS__ - #define CFG_SORT 1 #define USE_SORT(...) __VA_ARGS__ - #define CFG_SPLIT 1 #define USE_SPLIT(...) __VA_ARGS__ - #define CFG_STAT 1 #define USE_STAT(...) __VA_ARGS__ - #define CFG_STRACE 0 #define USE_STRACE(...) #define CFG_STRINGS 1 #define USE_STRINGS(...) __VA_ARGS__ - #define CFG_STTY 1 #define USE_STTY(...) __VA_ARGS__ - #define CFG_SU 0 #define USE_SU(...) #define CFG_SULOGIN 0 #define USE_SULOGIN(...) #define CFG_SWAPOFF 1 #define USE_SWAPOFF(...) __VA_ARGS__ - #define CFG_SWAPON 1 #define USE_SWAPON(...) __VA_ARGS__ - #define CFG_SWITCH_ROOT 0 #define USE_SWITCH_ROOT(...) #define CFG_SYNC 1 #define USE_SYNC(...) __VA_ARGS__ - #define CFG_SYSCTL 1 #define USE_SYSCTL(...) __VA_ARGS__ - #define CFG_SYSLOGD 0 #define USE_SYSLOGD(...) #define CFG_TAC 1 #define USE_TAC(...) __VA_ARGS__ - #define CFG_TAIL 1 #define USE_TAIL(...) __VA_ARGS__ - #define CFG_TAR 1 #define USE_TAR(...) __VA_ARGS__ - #define CFG_TASKSET 1 #define USE_TASKSET(...) __VA_ARGS__ - #define CFG_TCPSVD 0 #define USE_TCPSVD(...) #define CFG_TEE 1 #define USE_TEE(...) __VA_ARGS__ - #define CFG_TELNETD 0 #define USE_TELNETD(...) #define CFG_TELNET 0 #define USE_TELNET(...) #define CFG_TEST 1 #define USE_TEST(...) __VA_ARGS__ - #define CFG_TEST_GLUE 1 #define USE_TEST_GLUE(...) __VA_ARGS__ - #define CFG_TFTPD 0 #define USE_TFTPD(...) #define CFG_TFTP 0 #define USE_TFTP(...) #define CFG_TIMEOUT 1 #define USE_TIMEOUT(...) __VA_ARGS__ - #define CFG_TIME 1 #define USE_TIME(...) __VA_ARGS__ - #define CFG_TOP 1 #define USE_TOP(...) __VA_ARGS__ - #define CFG_TOUCH 1 #define USE_TOUCH(...) __VA_ARGS__ - #define CFG_TRACEROUTE 1 #define USE_TRACEROUTE(...) __VA_ARGS__ - #define CFG_TRUE 1 #define USE_TRUE(...) __VA_ARGS__ - #define CFG_TRUNCATE 1 #define USE_TRUNCATE(...) __VA_ARGS__ - #define CFG_TR 1 #define USE_TR(...) __VA_ARGS__ - #define CFG_TS 0 #define USE_TS(...) #define CFG_TSORT 0 #define USE_TSORT(...) #define CFG_TTY 1 #define USE_TTY(...) __VA_ARGS__ - #define CFG_TUNCTL 1 #define USE_TUNCTL(...) __VA_ARGS__ - #define CFG_UCLAMPSET 1 #define USE_UCLAMPSET(...) __VA_ARGS__ - #define CFG_ULIMIT 1 #define USE_ULIMIT(...) __VA_ARGS__ - #define CFG_UMOUNT 1 #define USE_UMOUNT(...) __VA_ARGS__ - #define CFG_UNAME 1 #define USE_UNAME(...) __VA_ARGS__ - #define CFG_UNICODE 0 #define USE_UNICODE(...) #define CFG_UNIQ 1 #define USE_UNIQ(...) __VA_ARGS__ - #define CFG_UNIX2DOS 1 #define USE_UNIX2DOS(...) __VA_ARGS__ - #define CFG_UNLINK 1 #define USE_UNLINK(...) __VA_ARGS__ - #define CFG_UNSHARE 1 #define USE_UNSHARE(...) __VA_ARGS__ - #define CFG_UPTIME 1 #define USE_UPTIME(...) __VA_ARGS__ - #define CFG_USERADD 0 #define USE_USERADD(...) #define CFG_USERDEL 0 #define USE_USERDEL(...) #define CFG_USLEEP 1 #define USE_USLEEP(...) __VA_ARGS__ - #define CFG_UUDECODE 1 #define USE_UUDECODE(...) __VA_ARGS__ - #define CFG_UUENCODE 1 #define USE_UUENCODE(...) __VA_ARGS__ - #define CFG_UUIDGEN 1 #define USE_UUIDGEN(...) __VA_ARGS__ - #define CFG_VCONFIG 1 #define USE_VCONFIG(...) __VA_ARGS__ - #define CFG_VI 1 #define USE_VI(...) __VA_ARGS__ - #define CFG_VMSTAT 1 #define USE_VMSTAT(...) __VA_ARGS__ - #define CFG_WATCH 1 #define USE_WATCH(...) __VA_ARGS__ - #define CFG_WATCHDOG 0 #define USE_WATCHDOG(...) #define CFG_WC 1 #define USE_WC(...) __VA_ARGS__ - #define CFG_WGET 0 #define USE_WGET(...) #define CFG_WHICH 1 #define USE_WHICH(...) __VA_ARGS__ - #define CFG_WHOAMI 1 #define USE_WHOAMI(...) __VA_ARGS__ - #define CFG_WHO 0 #define USE_WHO(...) #define CFG_W 0 #define USE_W(...) #define CFG_XARGS 1 #define USE_XARGS(...) __VA_ARGS__ - #define CFG_XXD 1 #define USE_XXD(...) __VA_ARGS__ - #define CFG_XZCAT 0 #define USE_XZCAT(...) #define CFG_YES 1 #define USE_YES(...) __VA_ARGS__ - #define CFG_ZCAT 1 #define USE_ZCAT(...) __VA_ARGS__ - diff --git a/android/device/generated/flags.h b/android/device/generated/flags.h index d2edadc5..1bf39ce2 100644 --- a/android/device/generated/flags.h +++ b/android/device/generated/flags.h @@ -3808,16 +3808,17 @@ #undef FLAG_F #endif -// wc mcwl mcwl +// wc Lcmwl Lcmwl #undef OPTSTR_wc -#define OPTSTR_wc "mcwl" +#define OPTSTR_wc "Lcmwl" #ifdef CLEANUP_wc #undef CLEANUP_wc #undef FOR_wc #undef FLAG_l #undef FLAG_w -#undef FLAG_c #undef FLAG_m +#undef FLAG_c +#undef FLAG_L #endif // wget <1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data): @@ -7432,8 +7433,9 @@ #endif #define FLAG_l (1LL<<0) #define FLAG_w (1LL<<1) -#define FLAG_c (1LL<<2) -#define FLAG_m (1LL<<3) +#define FLAG_m (1LL<<2) +#define FLAG_c (1LL<<3) +#define FLAG_L (1LL<<4) #endif #ifdef FOR_wget diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h index 60cd358e..c72c29bc 100644 --- a/android/device/generated/globals.h +++ b/android/device/generated/globals.h @@ -1,44 +1,9 @@ -// toys/android/log.c - struct log_data { char *t, *p; int pri; }; -// toys/example/demo_number.c - -struct demo_number_data { - long M, D; -}; - -// toys/example/hello.c - -struct hello_data { - int unused; -}; - -// toys/example/skeleton.c - -struct skeleton_data { - union { - struct { - char *b; - long c; - struct arg_list *d; - long e; - char *f, *g, *h, *also, *blubber; - } s; - struct { - long b; - } a; - }; - - int more_globals; -}; - -// toys/lsb/dmesg.c - struct dmesg_data { long n, s; @@ -46,20 +11,14 @@ struct dmesg_data { time_t tea; }; -// toys/lsb/gzip.c - struct gzip_data { int level; }; -// toys/lsb/hostname.c - struct hostname_data { char *F; }; -// toys/lsb/killall.c - struct killall_data { char *s; @@ -70,26 +29,18 @@ struct killall_data { struct int_list { struct int_list *next; int val; } *pids; }; -// toys/lsb/md5sum.c - struct md5sum_data { int sawline; }; -// toys/lsb/mknod.c - struct mknod_data { char *Z, *m; }; -// toys/lsb/mktemp.c - struct mktemp_data { char *p, *tmpdir; }; -// toys/lsb/mount.c - struct mount_data { struct arg_list *o; char *t, *O; @@ -99,65 +50,26 @@ struct mount_data { int okuser; }; -// toys/lsb/passwd.c - -struct passwd_data { - char *a; -}; - -// toys/lsb/pidof.c - struct pidof_data { char *o; }; -// toys/lsb/seq.c - struct seq_data { char *s, *f; int precision, buflen; }; -// toys/lsb/su.c - -struct su_data { - char *s, *c; -}; - -// toys/lsb/umount.c - struct umount_data { struct arg_list *t; char *types; }; -// toys/net/ftpget.c - -struct ftpget_data { - char *u, *p, *P; - - int fd; -}; - -// toys/net/host.c - -struct host_data { - char *t; - - char **nsname; - unsigned nslen; -}; - -// toys/net/ifconfig.c - struct ifconfig_data { int sockfd; }; -// toys/net/microcom.c - struct microcom_data { long s; @@ -165,22 +77,16 @@ struct microcom_data { struct termios old_stdin, old_fd; }; -// toys/net/netcat.c - struct netcat_data { char *f, *s; long q, p, W, w; }; -// toys/net/netstat.c - struct netstat_data { struct num_cache *inodes; int wpad; }; -// toys/net/ping.c - struct ping_data { char *I; long w, W, i, s, c, t, m; @@ -190,37 +96,10 @@ struct ping_data { unsigned long sent, recv, fugit, min, max; }; -// toys/net/sntp.c - -struct sntp_data { - long r, t; - char *p, *m, *M; -}; - -// toys/net/tunctl.c - struct tunctl_data { char *u; }; -// toys/net/wget.c - -struct wget_data { - char *p, *O; - long max_redirect; - - int sock, https; - char *url; -#if CFG_WGET_LIBTLS - struct tls *tls; -#elif CFG_TOYBOX_LIBCRYPTO - struct ssl_ctx_st *ctx; - struct ssl_st *ssl; -#endif -}; - -// toys/other/base64.c - struct base64_data { long w; @@ -229,110 +108,60 @@ struct base64_data { unsigned align; // number of bits to align to }; -// toys/other/blkdiscard.c - struct blkdiscard_data { long o, l; }; -// toys/other/blkid.c - struct blkid_data { struct arg_list *s; char *o; }; -// toys/other/blockdev.c - struct blockdev_data { long setbsz, setra; }; -// toys/other/chrt.c - struct chrt_data { long p; }; -// toys/other/count.c - -struct count_data { - unsigned long long size, start; - unsigned tick, *slice; -}; - -// toys/other/dos2unix.c - struct dos2unix_data { char *tempfile; }; -// toys/other/fallocate.c - struct fallocate_data { long o, l; }; -// toys/other/fmt.c - struct fmt_data { long width; int level, pos; }; -// toys/other/free.c - struct free_data { unsigned bits; unsigned long long units; char *buf; }; -// toys/other/gpiod.c - -struct gpiod_data { +struct gpiodetect_data { struct double_list *chips; int chip_count; }; -// toys/other/hexedit.c - -struct hexedit_data { - char *data, *search, keybuf[16], input[80]; - long long len, base, pos; - int numlen, undo, undolen, mode; - unsigned rows, cols; -}; - -// toys/other/hwclock.c - struct hwclock_data { char *f; }; -// toys/other/i2ctools.c - -struct i2ctools_data { +struct i2cdetect_data { long F; }; -// toys/other/ionice.c - struct ionice_data { long p, n, c; }; -// toys/other/login.c - -struct login_data { - char *h, *f; - - int login_timeout, login_fail_timeout; -}; - -// toys/other/losetup.c - struct losetup_data { char *j; long o, S; @@ -343,8 +172,6 @@ struct losetup_data { char *dir; }; -// toys/other/lsattr.c - struct lsattr_data { long v, p; @@ -353,8 +180,6 @@ struct lsattr_data { int have_set; }; -// toys/other/lsusb.c - struct lsusb_data { char *i; long x, n; @@ -363,34 +188,14 @@ struct lsusb_data { int count; }; -// toys/other/makedevs.c - struct makedevs_data { char *d; }; -// toys/other/mix.c - -struct mix_data { - long r, l; - char *d, *c; -}; - -// toys/other/mkpasswd.c - -struct mkpasswd_data { - long P; - char *m, *S; -}; - -// toys/other/mkswap.c - struct mkswap_data { char *L; }; -// toys/other/modinfo.c - struct modinfo_data { char *F, *k, *b; @@ -398,41 +203,17 @@ struct modinfo_data { int count; }; -// toys/other/nbd_client.c - struct nbd_client_data { long b; int nbd; }; -// toys/other/nsenter.c - struct nsenter_data { char *UupnmiC[7]; long t; }; -// toys/other/oneit.c - -struct oneit_data { - char *c; -}; - -// toys/other/openvt.c - -struct openvt_data { - long c; -}; - -// toys/other/pwgen.c - -struct pwgen_data { - char *r; -}; - -// toys/other/readelf.c - struct readelf_data { char *x, *p; @@ -441,61 +222,23 @@ struct readelf_data { int bits, endian, shnum, shentsize, phentsize; }; -// toys/other/readlink.c - -struct readlink_data { +struct realpath_data { char *R, *relative_base; }; -// toys/other/reboot.c - -struct reboot_data { - char *d; -}; - -// toys/other/rtcwake.c - struct rtcwake_data { long t, s; char *m, *d; }; -// toys/other/setfattr.c - struct setfattr_data { char *x, *v, *n; }; -// toys/other/setsid.c - struct setsid_data { long c; }; -// toys/other/sha3sum.c - -struct sha3sum_data { - long a; - unsigned long long rc[24]; -}; - -// toys/other/shred.c - -struct shred_data { - long o, n, s; -}; - -// toys/other/shuf.c - -struct shuf_data { - long n; - - char **lines; - long count; -}; - -// toys/other/stat.c - struct stat_data { char *c; @@ -507,29 +250,14 @@ struct stat_data { int patlen; }; -// toys/other/swapon.c - struct swapon_data { long p; }; -// toys/other/switch_root.c - -struct switch_root_data { - char *c; - - struct stat new; - dev_t rootdev; -}; - -// toys/other/tac.c - struct tac_data { struct double_list *dl; }; -// toys/other/timeout.c - struct timeout_data { char *s, *k; @@ -538,8 +266,6 @@ struct timeout_data { int fds[2], pid, rc; }; -// toys/other/truncate.c - struct truncate_data { char *s; @@ -547,164 +273,24 @@ struct truncate_data { int type; }; -// toys/other/uclampset.c - struct uclampset_data { long M, m, p; }; -// toys/other/watch.c - struct watch_data { int n; pid_t pid, oldpid; }; -// toys/other/watchdog.c - -struct watchdog_data { - long T, t; - - int fd; -}; - -// toys/other/xxd.c - struct xxd_data { long s, g, o, l, c; }; -// toys/pending/arp.c - -struct arp_data { - char *hw_type; - char *af_type_A; - char *af_type_p; - char *interface; - - int sockfd; - char *device; -}; - -// toys/pending/arping.c - -struct arping_data { - long count; - unsigned long time_out; - char *iface; - char *src_ip; - - int sockfd; - unsigned long start, end; - unsigned sent_at, sent_nr, rcvd_nr, brd_sent, rcvd_req, brd_rcv, - unicast_flag; -}; - -// toys/pending/bc.c - -struct bc_data { - // This actually needs to be a BcVm*, but the toybox build - // system complains if I make it so. Instead, we'll just cast. - char *vm; - - size_t nchars; - char *file, sig, max_ibase; - uint16_t line_len; -}; - -// toys/pending/bootchartd.c - -struct bootchartd_data { - char timestamp[32]; - long msec; - int proc_accounting; - - pid_t pid; -}; - -// toys/pending/brctl.c - struct brctl_data { int sockfd; }; -// toys/pending/chsh.c - -struct chsh_data { - char *s, *R; -}; - -// toys/pending/crond.c - -struct crond_data { - char *crontabs_dir; - char *logfile; - int loglevel_d; - int loglevel; - - time_t crontabs_dir_mtime; - uint8_t flagd; -}; - -// toys/pending/crontab.c - -struct crontab_data { - char *user; - char *cdir; -}; - -// toys/pending/csplit.c - -struct csplit_data { - long n; - char *f; - - size_t indx, findx, lineno; - char *filefmt, *prefix; - // Variables the context checker need to track between lines - size_t btc, tmp; - int offset, withld, inf; -}; - -// toys/pending/dhcp.c - -struct dhcp_data { - char *iface; - char *pidfile; - char *script; - long retries; - long timeout; - long tryagain; - struct arg_list *req_opt; - char *req_ip; - struct arg_list *pkt_opt; - char *fdn_name; - char *hostname; - char *vendor_cls; -}; - -// toys/pending/dhcp6.c - -struct dhcp6_data { - char *interface_name, *pidfile, *script; - long retry, timeout, errortimeout; - char *req_ip; - int length, state, request_length, sock, sock1, status, retval, retries; - struct timeval tv; - uint8_t transction_id[3]; - struct sockaddr_in6 input_socket6; -}; - -// toys/pending/dhcpd.c - -struct dhcpd_data { - char *i; - long p; -}; - -// toys/pending/diff.c - struct diff_data { long U; struct arg_list *L; @@ -722,137 +308,19 @@ struct diff_data { } file[2]; }; -// toys/pending/dumpleases.c - -struct dumpleases_data { - char *file; -}; - -// toys/pending/expr.c - struct expr_data { char **tok, *delete; }; -// toys/pending/fdisk.c - -struct fdisk_data { - long sect_sz; - long sectors; - long heads; - long cylinders; -}; - -// toys/pending/fsck.c - -struct fsck_data { - int fd_num; - char *t_list; - - struct double_list *devices; - char *arr_flag; - char **arr_type; - int negate; - int sum_status; - int nr_run; - int sig_num; - long max_nr_run; -}; - -// toys/pending/getfattr.c - struct getfattr_data { char *n; }; -// toys/pending/getopt.c - struct getopt_data { struct arg_list *l; char *o, *n; }; -// toys/pending/getty.c - -struct getty_data { - char *f, *l, *I, *H; - long t; - - char *tty_name, buff[128]; - int speeds[20], sc; - struct termios termios; -}; - -// toys/pending/git.c - -struct git_data { - char *url, *name; //git repo remote url and init directory name - struct IndexV2 *i; //git creates a index for each pack file, git clone just needs one index for the received pack file -}; - -// toys/pending/groupadd.c - -struct groupadd_data { - long g; - char *R; -}; - -// toys/pending/hexdump.c - -struct hexdump_data { - long s, n; - - long long len, pos, ppos; - const char *fmt; - unsigned int fn, bc; // file number and byte count - char linebuf[16]; // line buffer - serves double duty for sqeezing repeat - // lines and for accumulating full lines accross file - // boundaries if necessesary. -}; - -// toys/pending/ip.c - -struct ip_data { - char stats, singleline, flush, *filter_dev, gbuf[8192]; - int sockfd, connected, from_ok, route_cmd; - int8_t addressfamily, is_addr; -}; - -// toys/pending/ipcrm.c - -struct ipcrm_data { - struct arg_list *qkey; - struct arg_list *qid; - struct arg_list *skey; - struct arg_list *sid; - struct arg_list *mkey; - struct arg_list *mid; -}; - -// toys/pending/ipcs.c - -struct ipcs_data { - int id; -}; - -// toys/pending/klogd.c - -struct klogd_data { - long level; - - int fd; -}; - -// toys/pending/last.c - -struct last_data { - char *file; - - struct arg_list *list; -}; - -// toys/pending/lsof.c - struct lsof_data { struct arg_list *p; @@ -861,44 +329,6 @@ struct lsof_data { int last_shown_pid, shown_header; }; -// toys/pending/man.c - -struct man_data { - char *M, *k; - - char any, cell, ex, *f, k_done, *line, *m, **sct, **scts, **sufs; - regex_t reg; -}; - -// toys/pending/mke2fs.c - -struct mke2fs_data { - // Command line arguments. - long blocksize; - long bytes_per_inode; - long inodes; // Total inodes in filesystem. - long reserved_percent; // Integer precent of space to reserve for root. - char *gendir; // Where to read dirtree from. - - // Internal data. - struct dirtree *dt; // Tree of files to copy into the new filesystem. - unsigned treeblocks; // Blocks used by dt - unsigned treeinodes; // Inodes used by dt - - unsigned blocks; // Total blocks in the filesystem. - unsigned freeblocks; // Free blocks in the filesystem. - unsigned inodespg; // Inodes per group - unsigned groups; // Total number of block groups. - unsigned blockbits; // Bits per block. (Also blocks per group.) - - // For gene2fs - unsigned nextblock; // Next data block to allocate - unsigned nextgroup; // Next group we'll be allocating from - int fsfd; // File descriptor of filesystem (to output to). -}; - -// toys/pending/modprobe.c - struct modprobe_data { struct arg_list *dirs; @@ -907,108 +337,11 @@ struct modprobe_data { int nudeps, symreq; }; -// toys/pending/more.c - struct more_data { struct termios inf; int cin_fd; }; -// toys/pending/route.c - -struct route_data { - char *A; -}; - -// toys/pending/sh.c - -struct sh_data { - union { - struct { - char *c; - } sh; - struct { - char *a; - } exec; - }; - - // keep SECONDS here: used to work around compiler limitation in run_command() - long long SECONDS; - char *isexec, *wcpat; - unsigned options, jobcnt, LINENO; - int hfd, pid, bangpid, srclvl, recursion, recfile[50+200*CFG_TOYBOX_FORK]; - - // Callable function array - struct sh_function { - char *name; - struct sh_pipeline { // pipeline segments: linked list of arg w/metadata - struct sh_pipeline *next, *prev, *end; - int count, here, type, lineno; - struct sh_arg { - char **v; - int c; - } arg[1]; - } *pipeline; - unsigned long refcount; - } **functions; - long funcslen; - - // runtime function call stack - struct sh_fcall { - struct sh_fcall *next, *prev; - - // This dlist in reverse order: TT.ff current function, TT.ff->prev globals - struct sh_vars { - long flags; - char *str; - } *vars; - long varslen, varscap, shift, oldlineno; - - struct sh_function *func; // TODO wire this up - struct sh_pipeline *pl; - char *ifs, *omnom; - struct sh_arg arg; - struct arg_list *delete; - - // Runtime stack of nested if/else/fi and for/do/done contexts. - struct sh_blockstack { - struct sh_blockstack *next; - struct sh_pipeline *start, *middle; - struct sh_process *pp; // list of processes piping in to us - int run, loop, *urd, pout, pipe; - struct sh_arg farg; // for/select arg stack, case wildcard deck - struct arg_list *fdelete; // farg's cleanup list - char *fvar; // for/select's iteration variable name - } *blk; - } *ff; - -// TODO ctrl-Z suspend should stop script - struct sh_process { - struct sh_process *next, *prev; // | && || - struct arg_list *delete; // expanded strings - // undo redirects, a=b at start, child PID, exit status, has !, job # - int *urd, envlen, pid, exit, flags, job, dash; - long long when; // when job backgrounded/suspended - struct sh_arg *raw, arg; - } *pp; // currently running process - - // job list, command line for $*, scratch space for do_wildcard_files() - struct sh_arg jobs, *wcdeck; -}; - -// toys/pending/strace.c - -struct strace_data { - long s, p; - - char ioctl[32], *fmt; - long regs[256/sizeof(long)], syscall; - pid_t pid; - int arg; -}; - -// toys/pending/stty.c - struct stty_data { char *F; @@ -1016,96 +349,11 @@ struct stty_data { unsigned output_cols; }; -// toys/pending/sulogin.c - -struct sulogin_data { - long timeout; - struct termios crntio; -}; - -// toys/pending/syslogd.c - -struct syslogd_data { - char *socket; - char *config_file; - char *unix_socket; - char *logfile; - long interval; - long rot_size; - long rot_count; - char *remote_log; - long log_prio; - - struct unsocks *lsocks; // list of listen sockets - struct logfile *lfiles; // list of write logfiles - int sigfd[2]; -}; - -// toys/pending/tcpsvd.c - -struct tcpsvd_data { - char *l, *u, *C; - long b, c; - - int maxc; - int count_all; - int udp; -}; - -// toys/pending/telnet.c - -struct telnet_data { - int sock; - char buf[2048]; // Half sizeof(toybuf) allows a buffer full of IACs. - struct termios old_term; - struct termios raw_term; - uint8_t mode; - int echo, sga; - int state, request; -}; - -// toys/pending/telnetd.c - -struct telnetd_data { - char *login_path; - char *issue_path; - int port; - char *host_addr; - long w_sec; - - int gmax_fd; - pid_t fork_pid; -}; - -// toys/pending/tftp.c - -struct tftp_data { - char *local_file; - char *remote_file; - long block_size; - - struct sockaddr_storage inaddr; - int af; -}; - -// toys/pending/tftpd.c - -struct tftpd_data { - char *user; - - long sfd; - struct passwd *pw; -}; - -// toys/pending/tr.c - struct tr_data { short *map; int len1, len2; }; -// toys/pending/traceroute.c - struct traceroute_data { long max_ttl; long port; @@ -1127,20 +375,6 @@ struct traceroute_data { int istraceroute6; }; -// toys/pending/useradd.c - -struct useradd_data { - char *dir; - char *gecos; - char *shell; - char *u_grp; - long uid; - - long gid; -}; - -// toys/pending/vi.c - struct vi_data { char *s; @@ -1197,20 +431,14 @@ struct vi_data { } *slices; }; -// toys/posix/basename.c - struct basename_data { char *s; }; -// toys/posix/cal.c - struct cal_data { struct tm *now; }; -// toys/posix/chgrp.c - struct chgrp_data { uid_t owner; gid_t group; @@ -1218,14 +446,10 @@ struct chgrp_data { int symfollow; }; -// toys/posix/chmod.c - struct chmod_data { char *mode; }; -// toys/posix/cmp.c - struct cmp_data { long n; @@ -1233,8 +457,6 @@ struct cmp_data { char *name; }; -// toys/posix/cp.c - struct cp_data { union { // install's options @@ -1255,14 +477,10 @@ struct cp_data { int pflags; }; -// toys/posix/cpio.c - struct cpio_data { char *F, *H, *R; }; -// toys/posix/cut.c - struct cut_data { char *d, *O; struct arg_list *select[5]; // we treat them the same, so loop through @@ -1272,32 +490,24 @@ struct cut_data { regex_t reg; }; -// toys/posix/date.c - struct date_data { char *s, *r, *I, *D, *d; unsigned nano; }; -// toys/posix/dd.c - struct dd_data { // Display fields int show_xfer, show_records; unsigned long long bytes, in_full, in_part, out_full, out_part, start; }; -// toys/posix/df.c - struct df_data { struct arg_list *t; int units, width[6]; }; -// toys/posix/du.c - struct du_data { long d; @@ -1306,29 +516,21 @@ struct du_data { void *inodes; }; -// toys/posix/env.c - struct env_data { struct arg_list *u; }; -// toys/posix/expand.c - struct expand_data { struct arg_list *t; unsigned tabcount, *tab; }; -// toys/posix/file.c - struct file_data { int max_name_len; off_t len; }; -// toys/posix/find.c - struct find_data { char **filter; struct double_list *argdata; @@ -1338,14 +540,6 @@ struct find_data { char *start; }; -// toys/posix/fold.c - -struct fold_data { - long w; -}; - -// toys/posix/grep.c - struct grep_data { long m, A, B, C; struct arg_list *f, *e, *M, *S, *exclude_dir; @@ -1357,51 +551,37 @@ struct grep_data { struct arg_list **fixed; }; -// toys/posix/head.c - struct head_data { long c, n; int file_no; }; -// toys/posix/iconv.c - struct iconv_data { char *f, *t; void *ic; }; -// toys/posix/id.c - struct id_data { int is_groups; }; -// toys/posix/kill.c - struct kill_data { char *s; struct arg_list *o; }; -// toys/posix/ln.c - struct ln_data { char *t; }; -// toys/posix/logger.c - struct logger_data { char *p, *t; int priority; }; -// toys/posix/ls.c - struct ls_data { long w, l, block_size; char *color, *sort; @@ -1412,14 +592,10 @@ struct ls_data { char *escmore; }; -// toys/posix/mkdir.c - struct mkdir_data { char *m, *Z; }; -// toys/posix/mkfifo.c - struct mkfifo_data { char *m; char *Z; @@ -1427,14 +603,10 @@ struct mkfifo_data { mode_t mode; }; -// toys/posix/nice.c - struct nice_data { long n; }; -// toys/posix/nl.c - struct nl_data { char *s, *n, *b; long w, l, v; @@ -1443,8 +615,6 @@ struct nl_data { long lcount, slen; }; -// toys/posix/od.c - struct od_data { struct arg_list *t; char *A; @@ -1457,16 +627,12 @@ struct od_data { off_t pos; }; -// toys/posix/paste.c - struct paste_data { char *d; int files; }; -// toys/posix/patch.c - struct patch_data { char *i, *d; long v, p, g, F; @@ -1477,8 +643,6 @@ struct patch_data { char *tempname; }; -// toys/posix/ps.c - struct ps_data { union { struct { @@ -1513,14 +677,10 @@ struct ps_data { void (*show_process)(void *tb); }; -// toys/posix/renice.c - struct renice_data { long n; }; -// toys/posix/sed.c - struct sed_data { char *i; struct arg_list *f, *e; @@ -1536,8 +696,6 @@ struct sed_data { char delim, xftype; }; -// toys/posix/sort.c - struct sort_data { char *t; struct arg_list *k; @@ -1548,23 +706,17 @@ struct sort_data { char **lines, *name; }; -// toys/posix/split.c - struct split_data { long n, l, b, a; char *outfile; }; -// toys/posix/strings.c - struct strings_data { long n; char *t; }; -// toys/posix/tail.c - struct tail_data { long n, c; char *s; @@ -1578,8 +730,6 @@ struct tail_data { } *F; }; -// toys/posix/tar.c - struct tar_data { char *f, *C, *I; struct arg_list *T, *X, *xform; @@ -1613,47 +763,33 @@ struct tar_data { } hdr; }; -// toys/posix/tee.c - struct tee_data { void *outputs; int out; }; -// toys/posix/touch.c - struct touch_data { char *t, *r, *d; }; -// toys/posix/ulimit.c - struct ulimit_data { long P; }; -// toys/posix/uniq.c - struct uniq_data { long w, s, f; long repeats; }; -// toys/posix/uudecode.c - struct uudecode_data { char *o; }; -// toys/posix/wc.c - struct wc_data { - unsigned long totals[4]; + unsigned long totals[5]; }; -// toys/posix/xargs.c - struct xargs_data { long s, n, P; char *E; @@ -1662,12 +798,8 @@ struct xargs_data { char delim; FILE *tty; }; - extern union global_union { struct log_data log; - struct demo_number_data demo_number; - struct hello_data hello; - struct skeleton_data skeleton; struct dmesg_data dmesg; struct gzip_data gzip; struct hostname_data hostname; @@ -1676,116 +808,60 @@ extern union global_union { struct mknod_data mknod; struct mktemp_data mktemp; struct mount_data mount; - struct passwd_data passwd; struct pidof_data pidof; struct seq_data seq; - struct su_data su; struct umount_data umount; - struct ftpget_data ftpget; - struct host_data host; struct ifconfig_data ifconfig; struct microcom_data microcom; struct netcat_data netcat; struct netstat_data netstat; struct ping_data ping; - struct sntp_data sntp; struct tunctl_data tunctl; - struct wget_data wget; struct base64_data base64; struct blkdiscard_data blkdiscard; struct blkid_data blkid; struct blockdev_data blockdev; struct chrt_data chrt; - struct count_data count; struct dos2unix_data dos2unix; struct fallocate_data fallocate; struct fmt_data fmt; struct free_data free; - struct gpiod_data gpiod; - struct hexedit_data hexedit; + struct gpiodetect_data gpiodetect; struct hwclock_data hwclock; - struct i2ctools_data i2ctools; + struct i2cdetect_data i2cdetect; struct ionice_data ionice; - struct login_data login; struct losetup_data losetup; struct lsattr_data lsattr; struct lsusb_data lsusb; struct makedevs_data makedevs; - struct mix_data mix; - struct mkpasswd_data mkpasswd; struct mkswap_data mkswap; struct modinfo_data modinfo; struct nbd_client_data nbd_client; struct nsenter_data nsenter; - struct oneit_data oneit; - struct openvt_data openvt; - struct pwgen_data pwgen; struct readelf_data readelf; - struct readlink_data readlink; - struct reboot_data reboot; + struct realpath_data realpath; struct rtcwake_data rtcwake; struct setfattr_data setfattr; struct setsid_data setsid; - struct sha3sum_data sha3sum; - struct shred_data shred; - struct shuf_data shuf; struct stat_data stat; struct swapon_data swapon; - struct switch_root_data switch_root; struct tac_data tac; struct timeout_data timeout; struct truncate_data truncate; struct uclampset_data uclampset; struct watch_data watch; - struct watchdog_data watchdog; struct xxd_data xxd; - struct arp_data arp; - struct arping_data arping; - struct bc_data bc; - struct bootchartd_data bootchartd; struct brctl_data brctl; - struct chsh_data chsh; - struct crond_data crond; - struct crontab_data crontab; - struct csplit_data csplit; - struct dhcp_data dhcp; - struct dhcp6_data dhcp6; - struct dhcpd_data dhcpd; struct diff_data diff; - struct dumpleases_data dumpleases; struct expr_data expr; - struct fdisk_data fdisk; - struct fsck_data fsck; struct getfattr_data getfattr; struct getopt_data getopt; - struct getty_data getty; - struct git_data git; - struct groupadd_data groupadd; - struct hexdump_data hexdump; - struct ip_data ip; - struct ipcrm_data ipcrm; - struct ipcs_data ipcs; - struct klogd_data klogd; - struct last_data last; struct lsof_data lsof; - struct man_data man; - struct mke2fs_data mke2fs; struct modprobe_data modprobe; struct more_data more; - struct route_data route; - struct sh_data sh; - struct strace_data strace; struct stty_data stty; - struct sulogin_data sulogin; - struct syslogd_data syslogd; - struct tcpsvd_data tcpsvd; - struct telnet_data telnet; - struct telnetd_data telnetd; - struct tftp_data tftp; - struct tftpd_data tftpd; struct tr_data tr; struct traceroute_data traceroute; - struct useradd_data useradd; struct vi_data vi; struct basename_data basename; struct cal_data cal; @@ -1803,7 +879,6 @@ extern union global_union { struct expand_data expand; struct file_data file; struct find_data find; - struct fold_data fold; struct grep_data grep; struct head_data head; struct iconv_data iconv; diff --git a/android/device/generated/help.h b/android/device/generated/help.h index d3a500a1..a7eab297 100644 --- a/android/device/generated/help.h +++ b/android/device/generated/help.h @@ -520,7 +520,7 @@ #define HELP_who "usage: who\n\nPrint information about logged in users." -#define HELP_wc "usage: wc [-lwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." +#define HELP_wc "usage: wc [-Llwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-L Show max line length\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." #define HELP_uuencode "usage: uuencode [-m] [INFILE] ENCODE_FILENAME\n\nUuencode stdin (or INFILE) to stdout, with ENCODE_FILENAME in the output.\n\n-m Base64" diff --git a/android/device/generated/newtoys.h b/android/device/generated/newtoys.h index a4bf4c24..fa6fa62b 100644 --- a/android/device/generated/newtoys.h +++ b/android/device/generated/newtoys.h @@ -335,7 +335,7 @@ USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) USE_SH(NEWTOY(wait, "n", TOYFLAG_NOFORK)) USE_WATCH(NEWTOY(watch, "^<1n%<100=2000tebx", TOYFLAG_USR|TOYFLAG_BIN)) USE_WATCHDOG(NEWTOY(watchdog, "<1>1Ft#=4<1T#=60<1", TOYFLAG_NEEDROOT|TOYFLAG_SBIN)) -USE_WC(NEWTOY(wc, "mcwl", TOYFLAG_USR|TOYFLAG_BIN)) +USE_WC(NEWTOY(wc, "Lcmwl", TOYFLAG_USR|TOYFLAG_BIN)) USE_WGET(NEWTOY(wget, "<1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data):", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHICH(NEWTOY(which, "<1a", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHO(NEWTOY(who, "a", TOYFLAG_USR|TOYFLAG_BIN)) diff --git a/android/linux/generated/config.h b/android/linux/generated/config.h index f2f73439..737e2dc2 100644 --- a/android/linux/generated/config.h +++ b/android/linux/generated/config.h @@ -1,34 +1,25 @@ #define CFG_TOYBOX 1 #define USE_TOYBOX(...) __VA_ARGS__ - #define CFG_TOYBOX_DEBUG 0 #define USE_TOYBOX_DEBUG(...) #define CFG_TOYBOX_FLOAT 1 #define USE_TOYBOX_FLOAT(...) __VA_ARGS__ - #define CFG_TOYBOX_FORK 1 #define USE_TOYBOX_FORK(...) __VA_ARGS__ - #define CFG_TOYBOX_FREE 0 #define USE_TOYBOX_FREE(...) #define CFG_TOYBOX_HELP_DASHDASH 1 #define USE_TOYBOX_HELP_DASHDASH(...) __VA_ARGS__ - #define CFG_TOYBOX_HELP 1 #define USE_TOYBOX_HELP(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBCRYPTO 1 #define USE_TOYBOX_LIBCRYPTO(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBZ 1 #define USE_TOYBOX_LIBZ(...) __VA_ARGS__ - #define CFG_TOYBOX_LSM_NONE 1 #define USE_TOYBOX_LSM_NONE(...) __VA_ARGS__ - #define CFG_TOYBOX_NORECURSE 1 #define USE_TOYBOX_NORECURSE(...) __VA_ARGS__ - #define CFG_TOYBOX_ON_ANDROID 0 #define USE_TOYBOX_ON_ANDROID(...) #define CFG_TOYBOX_SELINUX 0 @@ -55,7 +46,6 @@ #define USE_BASE64(...) #define CFG_BASENAME 1 #define USE_BASENAME(...) __VA_ARGS__ - #define CFG_BC 0 #define USE_BC(...) #define CFG_BLKDISCARD 0 @@ -76,7 +66,6 @@ #define USE_CAL(...) #define CFG_CAT 1 #define USE_CAT(...) __VA_ARGS__ - #define CFG_CD 0 #define USE_CD(...) #define CFG_CHATTR 0 @@ -87,7 +76,6 @@ #define USE_CHGRP(...) #define CFG_CHMOD 1 #define USE_CHMOD(...) __VA_ARGS__ - #define CFG_CHOWN 0 #define USE_CHOWN(...) #define CFG_CHROOT 0 @@ -104,18 +92,14 @@ #define USE_CLEAR(...) #define CFG_CMP 1 #define USE_CMP(...) __VA_ARGS__ - #define CFG_COMM 1 #define USE_COMM(...) __VA_ARGS__ - #define CFG_COUNT 0 #define USE_COUNT(...) #define CFG_CPIO 1 #define USE_CPIO(...) __VA_ARGS__ - #define CFG_CP 1 #define USE_CP(...) __VA_ARGS__ - #define CFG_CRC32 0 #define USE_CRC32(...) #define CFG_CROND 0 @@ -126,13 +110,10 @@ #define USE_CSPLIT(...) #define CFG_CUT 1 #define USE_CUT(...) __VA_ARGS__ - #define CFG_DATE 1 #define USE_DATE(...) __VA_ARGS__ - #define CFG_DD 1 #define USE_DD(...) __VA_ARGS__ - #define CFG_DEALLOCVT 0 #define USE_DEALLOCVT(...) #define CFG_DEBUG_DHCP 0 @@ -157,40 +138,32 @@ #define USE_DHCP(...) #define CFG_DIFF 1 #define USE_DIFF(...) __VA_ARGS__ - #define CFG_DIRNAME 1 #define USE_DIRNAME(...) __VA_ARGS__ - #define CFG_DMESG 0 #define USE_DMESG(...) #define CFG_DNSDOMAINNAME 0 #define USE_DNSDOMAINNAME(...) #define CFG_DOS2UNIX 1 #define USE_DOS2UNIX(...) __VA_ARGS__ - #define CFG_DUMPLEASES 0 #define USE_DUMPLEASES(...) #define CFG_DU 1 #define USE_DU(...) __VA_ARGS__ - #define CFG_ECHO 1 #define USE_ECHO(...) __VA_ARGS__ - #define CFG_EGREP 1 #define USE_EGREP(...) __VA_ARGS__ - #define CFG_EJECT 0 #define USE_EJECT(...) #define CFG_ENV 1 #define USE_ENV(...) __VA_ARGS__ - #define CFG_EXIT 0 #define USE_EXIT(...) #define CFG_EXPAND 0 #define USE_EXPAND(...) #define CFG_EXPR 1 #define USE_EXPR(...) __VA_ARGS__ - #define CFG_FACTOR 0 #define USE_FACTOR(...) #define CFG_FALLOCATE 0 @@ -201,16 +174,12 @@ #define USE_FDISK(...) #define CFG_FGREP 1 #define USE_FGREP(...) __VA_ARGS__ - #define CFG_FILE 1 #define USE_FILE(...) __VA_ARGS__ - #define CFG_FIND 1 #define USE_FIND(...) __VA_ARGS__ - #define CFG_FLOCK 1 #define USE_FLOCK(...) __VA_ARGS__ - #define CFG_FMT 0 #define USE_FMT(...) #define CFG_FOLD 0 @@ -233,14 +202,12 @@ #define USE_FTPPUT(...) #define CFG_GETCONF 1 #define USE_GETCONF(...) __VA_ARGS__ - #define CFG_GETENFORCE 0 #define USE_GETENFORCE(...) #define CFG_GETFATTR 0 #define USE_GETFATTR(...) #define CFG_GETOPT 1 #define USE_GETOPT(...) __VA_ARGS__ - #define CFG_GETTY 0 #define USE_GETTY(...) #define CFG_GITCHECKOUT 0 @@ -267,7 +234,6 @@ #define USE_GPIOSET(...) #define CFG_GREP 1 #define USE_GREP(...) __VA_ARGS__ - #define CFG_GROUPADD 0 #define USE_GROUPADD(...) #define CFG_GROUPDEL 0 @@ -278,10 +244,8 @@ #define USE_GUNZIP(...) #define CFG_GZIP 1 #define USE_GZIP(...) __VA_ARGS__ - #define CFG_HEAD 1 #define USE_HEAD(...) __VA_ARGS__ - #define CFG_HELLO 0 #define USE_HELLO(...) #define CFG_HELP 0 @@ -298,7 +262,6 @@ #define USE_HOST(...) #define CFG_HOSTNAME 1 #define USE_HOSTNAME(...) __VA_ARGS__ - #define CFG_HTTPD 0 #define USE_HTTPD(...) #define CFG_HWCLOCK 0 @@ -317,7 +280,6 @@ #define USE_ICONV(...) #define CFG_ID 1 #define USE_ID(...) __VA_ARGS__ - #define CFG_ID_Z 0 #define USE_ID_Z(...) #define CFG_IFCONFIG 0 @@ -330,7 +292,6 @@ #define USE_INSMOD(...) #define CFG_INSTALL 1 #define USE_INSTALL(...) __VA_ARGS__ - #define CFG_IONICE 0 #define USE_IONICE(...) #define CFG_IORENICE 0 @@ -361,7 +322,6 @@ #define USE_LINUX32(...) #define CFG_LN 1 #define USE_LN(...) __VA_ARGS__ - #define CFG_LOAD_POLICY 0 #define USE_LOAD_POLICY(...) #define CFG_LOGGER 0 @@ -388,7 +348,6 @@ #define USE_LSUSB(...) #define CFG_LS 1 #define USE_LS(...) __VA_ARGS__ - #define CFG_MAKEDEVS 0 #define USE_MAKEDEVS(...) #define CFG_MAN 0 @@ -397,7 +356,6 @@ #define USE_MCOOKIE(...) #define CFG_MD5SUM 1 #define USE_MD5SUM(...) __VA_ARGS__ - #define CFG_MDEV_CONF 0 #define USE_MDEV_CONF(...) #define CFG_MDEV 0 @@ -406,12 +364,10 @@ #define USE_MEMEATER(...) #define CFG_MICROCOM 1 #define USE_MICROCOM(...) __VA_ARGS__ - #define CFG_MIX 0 #define USE_MIX(...) #define CFG_MKDIR 1 #define USE_MKDIR(...) __VA_ARGS__ - #define CFG_MKDIR_Z 0 #define USE_MKDIR_Z(...) #define CFG_MKE2FS_EXTENDED 0 @@ -438,7 +394,6 @@ #define USE_MKSWAP(...) #define CFG_MKTEMP 1 #define USE_MKTEMP(...) __VA_ARGS__ - #define CFG_MODINFO 0 #define USE_MODINFO(...) #define CFG_MODPROBE 0 @@ -451,7 +406,6 @@ #define USE_MOUNTPOINT(...) #define CFG_MV 1 #define USE_MV(...) __VA_ARGS__ - #define CFG_NBD_CLIENT 0 #define USE_NBD_CLIENT(...) #define CFG_NBD_SERVER 0 @@ -464,17 +418,14 @@ #define USE_NICE(...) #define CFG_NL 1 #define USE_NL(...) __VA_ARGS__ - #define CFG_NOHUP 0 #define USE_NOHUP(...) #define CFG_NPROC 1 #define USE_NPROC(...) __VA_ARGS__ - #define CFG_NSENTER 0 #define USE_NSENTER(...) #define CFG_OD 1 #define USE_OD(...) __VA_ARGS__ - #define CFG_ONEIT 0 #define USE_ONEIT(...) #define CFG_OPENVT 0 @@ -487,13 +438,10 @@ #define USE_PASSWD_SAD(...) #define CFG_PASTE 1 #define USE_PASTE(...) __VA_ARGS__ - #define CFG_PATCH 1 #define USE_PATCH(...) __VA_ARGS__ - #define CFG_PGREP 1 #define USE_PGREP(...) __VA_ARGS__ - #define CFG_PIDOF 0 #define USE_PIDOF(...) #define CFG_PING 0 @@ -502,22 +450,18 @@ #define USE_PIVOT_ROOT(...) #define CFG_PKILL 1 #define USE_PKILL(...) __VA_ARGS__ - #define CFG_PMAP 0 #define USE_PMAP(...) #define CFG_PRINTENV 0 #define USE_PRINTENV(...) #define CFG_PRINTF 1 #define USE_PRINTF(...) __VA_ARGS__ - #define CFG_PS 1 #define USE_PS(...) __VA_ARGS__ - #define CFG_PWDX 0 #define USE_PWDX(...) #define CFG_PWD 1 #define USE_PWD(...) __VA_ARGS__ - #define CFG_PWGEN 0 #define USE_PWGEN(...) #define CFG_READAHEAD 0 @@ -526,10 +470,8 @@ #define USE_READELF(...) #define CFG_READLINK 1 #define USE_READLINK(...) __VA_ARGS__ - #define CFG_REALPATH 1 #define USE_REALPATH(...) __VA_ARGS__ - #define CFG_REBOOT 0 #define USE_REBOOT(...) #define CFG_RENICE 0 @@ -544,12 +486,10 @@ #define USE_RFKILL(...) #define CFG_RMDIR 1 #define USE_RMDIR(...) __VA_ARGS__ - #define CFG_RMMOD 0 #define USE_RMMOD(...) #define CFG_RM 1 #define USE_RM(...) __VA_ARGS__ - #define CFG_ROUTE 0 #define USE_ROUTE(...) #define CFG_RTCWAKE 0 @@ -558,34 +498,28 @@ #define USE_RUNCON(...) #define CFG_SED 1 #define USE_SED(...) __VA_ARGS__ - #define CFG_SENDEVENT 0 #define USE_SENDEVENT(...) #define CFG_SEQ 1 #define USE_SEQ(...) __VA_ARGS__ - #define CFG_SETENFORCE 0 #define USE_SETENFORCE(...) #define CFG_SETFATTR 0 #define USE_SETFATTR(...) #define CFG_SETSID 1 #define USE_SETSID(...) __VA_ARGS__ - #define CFG_SHA1SUM 1 #define USE_SHA1SUM(...) __VA_ARGS__ - #define CFG_SHA224SUM 0 #define USE_SHA224SUM(...) #define CFG_SHA256SUM 1 #define USE_SHA256SUM(...) __VA_ARGS__ - #define CFG_SHA3SUM 0 #define USE_SHA3SUM(...) #define CFG_SHA384SUM 0 #define USE_SHA384SUM(...) #define CFG_SHA512SUM 1 #define USE_SHA512SUM(...) __VA_ARGS__ - #define CFG_SH 0 #define USE_SH(...) #define CFG_SHRED 0 @@ -598,20 +532,16 @@ #define USE_SKELETON(...) #define CFG_SLEEP 1 #define USE_SLEEP(...) __VA_ARGS__ - #define CFG_SNTP 0 #define USE_SNTP(...) #define CFG_SORT_FLOAT 1 #define USE_SORT_FLOAT(...) __VA_ARGS__ - #define CFG_SORT 1 #define USE_SORT(...) __VA_ARGS__ - #define CFG_SPLIT 0 #define USE_SPLIT(...) #define CFG_STAT 1 #define USE_STAT(...) __VA_ARGS__ - #define CFG_STRACE 0 #define USE_STRACE(...) #define CFG_STRINGS 0 @@ -638,27 +568,22 @@ #define USE_TAC(...) #define CFG_TAIL 1 #define USE_TAIL(...) __VA_ARGS__ - #define CFG_TAR 1 #define USE_TAR(...) __VA_ARGS__ - #define CFG_TASKSET 0 #define USE_TASKSET(...) #define CFG_TCPSVD 0 #define USE_TCPSVD(...) #define CFG_TEE 1 #define USE_TEE(...) __VA_ARGS__ - #define CFG_TELNETD 0 #define USE_TELNETD(...) #define CFG_TELNET 0 #define USE_TELNET(...) #define CFG_TEST 1 #define USE_TEST(...) __VA_ARGS__ - #define CFG_TEST_GLUE 1 #define USE_TEST_GLUE(...) __VA_ARGS__ - #define CFG_TFTPD 0 #define USE_TFTPD(...) #define CFG_TFTP 0 @@ -667,23 +592,18 @@ #define USE_TIME(...) #define CFG_TIMEOUT 1 #define USE_TIMEOUT(...) __VA_ARGS__ - #define CFG_TOP 0 #define USE_TOP(...) #define CFG_TOUCH 1 #define USE_TOUCH(...) __VA_ARGS__ - #define CFG_TRACEROUTE 0 #define USE_TRACEROUTE(...) #define CFG_TRUE 1 #define USE_TRUE(...) __VA_ARGS__ - #define CFG_TRUNCATE 1 #define USE_TRUNCATE(...) __VA_ARGS__ - #define CFG_TR 1 #define USE_TR(...) __VA_ARGS__ - #define CFG_TS 0 #define USE_TS(...) #define CFG_TSORT 0 @@ -700,15 +620,12 @@ #define USE_UMOUNT(...) #define CFG_UNAME 1 #define USE_UNAME(...) __VA_ARGS__ - #define CFG_UNICODE 0 #define USE_UNICODE(...) #define CFG_UNIQ 1 #define USE_UNIQ(...) __VA_ARGS__ - #define CFG_UNIX2DOS 1 #define USE_UNIX2DOS(...) __VA_ARGS__ - #define CFG_UNLINK 0 #define USE_UNLINK(...) #define CFG_UNSHARE 0 @@ -739,29 +656,23 @@ #define USE_WATCHDOG(...) #define CFG_WC 1 #define USE_WC(...) __VA_ARGS__ - #define CFG_WGET 0 #define USE_WGET(...) #define CFG_WHICH 1 #define USE_WHICH(...) __VA_ARGS__ - #define CFG_WHOAMI 1 #define USE_WHOAMI(...) __VA_ARGS__ - #define CFG_WHO 0 #define USE_WHO(...) #define CFG_W 0 #define USE_W(...) #define CFG_XARGS 1 #define USE_XARGS(...) __VA_ARGS__ - #define CFG_XXD 1 #define USE_XXD(...) __VA_ARGS__ - #define CFG_XZCAT 0 #define USE_XZCAT(...) #define CFG_YES 0 #define USE_YES(...) #define CFG_ZCAT 1 #define USE_ZCAT(...) __VA_ARGS__ - diff --git a/android/linux/generated/flags.h b/android/linux/generated/flags.h index a732398b..045104ce 100644 --- a/android/linux/generated/flags.h +++ b/android/linux/generated/flags.h @@ -3808,16 +3808,17 @@ #undef FLAG_F #endif -// wc mcwl mcwl +// wc Lcmwl Lcmwl #undef OPTSTR_wc -#define OPTSTR_wc "mcwl" +#define OPTSTR_wc "Lcmwl" #ifdef CLEANUP_wc #undef CLEANUP_wc #undef FOR_wc #undef FLAG_l #undef FLAG_w -#undef FLAG_c #undef FLAG_m +#undef FLAG_c +#undef FLAG_L #endif // wget <1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data): @@ -7432,8 +7433,9 @@ #endif #define FLAG_l (1LL<<0) #define FLAG_w (1LL<<1) -#define FLAG_c (1LL<<2) -#define FLAG_m (1LL<<3) +#define FLAG_m (1LL<<2) +#define FLAG_c (1LL<<3) +#define FLAG_L (1LL<<4) #endif #ifdef FOR_wget diff --git a/android/linux/generated/globals.h b/android/linux/generated/globals.h index 60cd358e..07e504ef 100644 --- a/android/linux/generated/globals.h +++ b/android/linux/generated/globals.h @@ -1,163 +1,25 @@ -// toys/android/log.c - -struct log_data { - char *t, *p; - - int pri; -}; - -// toys/example/demo_number.c - -struct demo_number_data { - long M, D; -}; - -// toys/example/hello.c - -struct hello_data { - int unused; -}; - -// toys/example/skeleton.c - -struct skeleton_data { - union { - struct { - char *b; - long c; - struct arg_list *d; - long e; - char *f, *g, *h, *also, *blubber; - } s; - struct { - long b; - } a; - }; - - int more_globals; -}; - -// toys/lsb/dmesg.c - -struct dmesg_data { - long n, s; - - int use_color; - time_t tea; -}; - -// toys/lsb/gzip.c - struct gzip_data { int level; }; -// toys/lsb/hostname.c - struct hostname_data { char *F; }; -// toys/lsb/killall.c - -struct killall_data { - char *s; - - int signum; - pid_t cur_pid; - char **names; - short *err; - struct int_list { struct int_list *next; int val; } *pids; -}; - -// toys/lsb/md5sum.c - struct md5sum_data { int sawline; }; -// toys/lsb/mknod.c - -struct mknod_data { - char *Z, *m; -}; - -// toys/lsb/mktemp.c - struct mktemp_data { char *p, *tmpdir; }; -// toys/lsb/mount.c - -struct mount_data { - struct arg_list *o; - char *t, *O; - - unsigned long flags; - char *opts; - int okuser; -}; - -// toys/lsb/passwd.c - -struct passwd_data { - char *a; -}; - -// toys/lsb/pidof.c - -struct pidof_data { - char *o; -}; - -// toys/lsb/seq.c - struct seq_data { char *s, *f; int precision, buflen; }; -// toys/lsb/su.c - -struct su_data { - char *s, *c; -}; - -// toys/lsb/umount.c - -struct umount_data { - struct arg_list *t; - - char *types; -}; - -// toys/net/ftpget.c - -struct ftpget_data { - char *u, *p, *P; - - int fd; -}; - -// toys/net/host.c - -struct host_data { - char *t; - - char **nsname; - unsigned nslen; -}; - -// toys/net/ifconfig.c - -struct ifconfig_data { - int sockfd; -}; - -// toys/net/microcom.c - struct microcom_data { long s; @@ -165,337 +27,18 @@ struct microcom_data { struct termios old_stdin, old_fd; }; -// toys/net/netcat.c - -struct netcat_data { - char *f, *s; - long q, p, W, w; -}; - -// toys/net/netstat.c - -struct netstat_data { - struct num_cache *inodes; - int wpad; -}; - -// toys/net/ping.c - -struct ping_data { - char *I; - long w, W, i, s, c, t, m; - - struct sockaddr *sa; - int sock; - unsigned long sent, recv, fugit, min, max; -}; - -// toys/net/sntp.c - -struct sntp_data { - long r, t; - char *p, *m, *M; -}; - -// toys/net/tunctl.c - -struct tunctl_data { - char *u; -}; - -// toys/net/wget.c - -struct wget_data { - char *p, *O; - long max_redirect; - - int sock, https; - char *url; -#if CFG_WGET_LIBTLS - struct tls *tls; -#elif CFG_TOYBOX_LIBCRYPTO - struct ssl_ctx_st *ctx; - struct ssl_st *ssl; -#endif -}; - -// toys/other/base64.c - -struct base64_data { - long w; - - unsigned total; - unsigned n; // number of bits used in encoding. 5 for base32, 6 for base64 - unsigned align; // number of bits to align to -}; - -// toys/other/blkdiscard.c - -struct blkdiscard_data { - long o, l; -}; - -// toys/other/blkid.c - -struct blkid_data { - struct arg_list *s; - char *o; -}; - -// toys/other/blockdev.c - -struct blockdev_data { - long setbsz, setra; -}; - -// toys/other/chrt.c - -struct chrt_data { - long p; -}; - -// toys/other/count.c - -struct count_data { - unsigned long long size, start; - unsigned tick, *slice; -}; - -// toys/other/dos2unix.c - struct dos2unix_data { char *tempfile; }; -// toys/other/fallocate.c - -struct fallocate_data { - long o, l; -}; - -// toys/other/fmt.c - -struct fmt_data { - long width; - - int level, pos; -}; - -// toys/other/free.c - -struct free_data { - unsigned bits; - unsigned long long units; - char *buf; -}; - -// toys/other/gpiod.c - -struct gpiod_data { - struct double_list *chips; - int chip_count; -}; - -// toys/other/hexedit.c - -struct hexedit_data { - char *data, *search, keybuf[16], input[80]; - long long len, base, pos; - int numlen, undo, undolen, mode; - unsigned rows, cols; -}; - -// toys/other/hwclock.c - -struct hwclock_data { - char *f; -}; - -// toys/other/i2ctools.c - -struct i2ctools_data { - long F; -}; - -// toys/other/ionice.c - -struct ionice_data { - long p, n, c; -}; - -// toys/other/login.c - -struct login_data { - char *h, *f; - - int login_timeout, login_fail_timeout; -}; - -// toys/other/losetup.c - -struct losetup_data { - char *j; - long o, S; - - int openflags; - dev_t jdev; - ino_t jino; - char *dir; -}; - -// toys/other/lsattr.c - -struct lsattr_data { - long v, p; - - unsigned add, rm, set; - // !add and !rm tell us whether they were used, but `chattr =` is meaningful. - int have_set; -}; - -// toys/other/lsusb.c - -struct lsusb_data { - char *i; - long x, n; - - void *ids, *class; - int count; -}; - -// toys/other/makedevs.c - -struct makedevs_data { - char *d; -}; - -// toys/other/mix.c - -struct mix_data { - long r, l; - char *d, *c; -}; - -// toys/other/mkpasswd.c - -struct mkpasswd_data { - long P; - char *m, *S; -}; - -// toys/other/mkswap.c - -struct mkswap_data { - char *L; -}; - -// toys/other/modinfo.c - -struct modinfo_data { - char *F, *k, *b; - - long mod; - int count; -}; - -// toys/other/nbd_client.c - -struct nbd_client_data { - long b; - - int nbd; -}; - -// toys/other/nsenter.c - -struct nsenter_data { - char *UupnmiC[7]; - long t; -}; - -// toys/other/oneit.c - -struct oneit_data { - char *c; -}; - -// toys/other/openvt.c - -struct openvt_data { - long c; -}; - -// toys/other/pwgen.c - -struct pwgen_data { - char *r; -}; - -// toys/other/readelf.c - -struct readelf_data { - char *x, *p; - - char *elf, *shstrtab, *f; - unsigned long long shoff, phoff, size, shstrtabsz; - int bits, endian, shnum, shentsize, phentsize; -}; - -// toys/other/readlink.c - -struct readlink_data { +struct realpath_data { char *R, *relative_base; }; -// toys/other/reboot.c - -struct reboot_data { - char *d; -}; - -// toys/other/rtcwake.c - -struct rtcwake_data { - long t, s; - char *m, *d; -}; - -// toys/other/setfattr.c - -struct setfattr_data { - char *x, *v, *n; -}; - -// toys/other/setsid.c - struct setsid_data { long c; }; -// toys/other/sha3sum.c - -struct sha3sum_data { - long a; - unsigned long long rc[24]; -}; - -// toys/other/shred.c - -struct shred_data { - long o, n, s; -}; - -// toys/other/shuf.c - -struct shuf_data { - long n; - - char **lines; - long count; -}; - -// toys/other/stat.c - struct stat_data { char *c; @@ -507,29 +50,6 @@ struct stat_data { int patlen; }; -// toys/other/swapon.c - -struct swapon_data { - long p; -}; - -// toys/other/switch_root.c - -struct switch_root_data { - char *c; - - struct stat new; - dev_t rootdev; -}; - -// toys/other/tac.c - -struct tac_data { - struct double_list *dl; -}; - -// toys/other/timeout.c - struct timeout_data { char *s, *k; @@ -538,8 +58,6 @@ struct timeout_data { int fds[2], pid, rc; }; -// toys/other/truncate.c - struct truncate_data { char *s; @@ -547,164 +65,10 @@ struct truncate_data { int type; }; -// toys/other/uclampset.c - -struct uclampset_data { - long M, m, p; -}; - -// toys/other/watch.c - -struct watch_data { - int n; - - pid_t pid, oldpid; -}; - -// toys/other/watchdog.c - -struct watchdog_data { - long T, t; - - int fd; -}; - -// toys/other/xxd.c - struct xxd_data { long s, g, o, l, c; }; -// toys/pending/arp.c - -struct arp_data { - char *hw_type; - char *af_type_A; - char *af_type_p; - char *interface; - - int sockfd; - char *device; -}; - -// toys/pending/arping.c - -struct arping_data { - long count; - unsigned long time_out; - char *iface; - char *src_ip; - - int sockfd; - unsigned long start, end; - unsigned sent_at, sent_nr, rcvd_nr, brd_sent, rcvd_req, brd_rcv, - unicast_flag; -}; - -// toys/pending/bc.c - -struct bc_data { - // This actually needs to be a BcVm*, but the toybox build - // system complains if I make it so. Instead, we'll just cast. - char *vm; - - size_t nchars; - char *file, sig, max_ibase; - uint16_t line_len; -}; - -// toys/pending/bootchartd.c - -struct bootchartd_data { - char timestamp[32]; - long msec; - int proc_accounting; - - pid_t pid; -}; - -// toys/pending/brctl.c - -struct brctl_data { - int sockfd; -}; - -// toys/pending/chsh.c - -struct chsh_data { - char *s, *R; -}; - -// toys/pending/crond.c - -struct crond_data { - char *crontabs_dir; - char *logfile; - int loglevel_d; - int loglevel; - - time_t crontabs_dir_mtime; - uint8_t flagd; -}; - -// toys/pending/crontab.c - -struct crontab_data { - char *user; - char *cdir; -}; - -// toys/pending/csplit.c - -struct csplit_data { - long n; - char *f; - - size_t indx, findx, lineno; - char *filefmt, *prefix; - // Variables the context checker need to track between lines - size_t btc, tmp; - int offset, withld, inf; -}; - -// toys/pending/dhcp.c - -struct dhcp_data { - char *iface; - char *pidfile; - char *script; - long retries; - long timeout; - long tryagain; - struct arg_list *req_opt; - char *req_ip; - struct arg_list *pkt_opt; - char *fdn_name; - char *hostname; - char *vendor_cls; -}; - -// toys/pending/dhcp6.c - -struct dhcp6_data { - char *interface_name, *pidfile, *script; - long retry, timeout, errortimeout; - char *req_ip; - int length, state, request_length, sock, sock1, status, retval, retries; - struct timeval tv; - uint8_t transction_id[3]; - struct sockaddr_in6 input_socket6; -}; - -// toys/pending/dhcpd.c - -struct dhcpd_data { - char *i; - long p; -}; - -// toys/pending/diff.c - struct diff_data { long U; struct arg_list *L; @@ -722,510 +86,28 @@ struct diff_data { } file[2]; }; -// toys/pending/dumpleases.c - -struct dumpleases_data { - char *file; -}; - -// toys/pending/expr.c - struct expr_data { char **tok, *delete; }; -// toys/pending/fdisk.c - -struct fdisk_data { - long sect_sz; - long sectors; - long heads; - long cylinders; -}; - -// toys/pending/fsck.c - -struct fsck_data { - int fd_num; - char *t_list; - - struct double_list *devices; - char *arr_flag; - char **arr_type; - int negate; - int sum_status; - int nr_run; - int sig_num; - long max_nr_run; -}; - -// toys/pending/getfattr.c - -struct getfattr_data { - char *n; -}; - -// toys/pending/getopt.c - struct getopt_data { struct arg_list *l; char *o, *n; }; -// toys/pending/getty.c - -struct getty_data { - char *f, *l, *I, *H; - long t; - - char *tty_name, buff[128]; - int speeds[20], sc; - struct termios termios; -}; - -// toys/pending/git.c - -struct git_data { - char *url, *name; //git repo remote url and init directory name - struct IndexV2 *i; //git creates a index for each pack file, git clone just needs one index for the received pack file -}; - -// toys/pending/groupadd.c - -struct groupadd_data { - long g; - char *R; -}; - -// toys/pending/hexdump.c - -struct hexdump_data { - long s, n; - - long long len, pos, ppos; - const char *fmt; - unsigned int fn, bc; // file number and byte count - char linebuf[16]; // line buffer - serves double duty for sqeezing repeat - // lines and for accumulating full lines accross file - // boundaries if necessesary. -}; - -// toys/pending/ip.c - -struct ip_data { - char stats, singleline, flush, *filter_dev, gbuf[8192]; - int sockfd, connected, from_ok, route_cmd; - int8_t addressfamily, is_addr; -}; - -// toys/pending/ipcrm.c - -struct ipcrm_data { - struct arg_list *qkey; - struct arg_list *qid; - struct arg_list *skey; - struct arg_list *sid; - struct arg_list *mkey; - struct arg_list *mid; -}; - -// toys/pending/ipcs.c - -struct ipcs_data { - int id; -}; - -// toys/pending/klogd.c - -struct klogd_data { - long level; - - int fd; -}; - -// toys/pending/last.c - -struct last_data { - char *file; - - struct arg_list *list; -}; - -// toys/pending/lsof.c - -struct lsof_data { - struct arg_list *p; - - struct stat *sought_files; - struct double_list *all_sockets, *files; - int last_shown_pid, shown_header; -}; - -// toys/pending/man.c - -struct man_data { - char *M, *k; - - char any, cell, ex, *f, k_done, *line, *m, **sct, **scts, **sufs; - regex_t reg; -}; - -// toys/pending/mke2fs.c - -struct mke2fs_data { - // Command line arguments. - long blocksize; - long bytes_per_inode; - long inodes; // Total inodes in filesystem. - long reserved_percent; // Integer precent of space to reserve for root. - char *gendir; // Where to read dirtree from. - - // Internal data. - struct dirtree *dt; // Tree of files to copy into the new filesystem. - unsigned treeblocks; // Blocks used by dt - unsigned treeinodes; // Inodes used by dt - - unsigned blocks; // Total blocks in the filesystem. - unsigned freeblocks; // Free blocks in the filesystem. - unsigned inodespg; // Inodes per group - unsigned groups; // Total number of block groups. - unsigned blockbits; // Bits per block. (Also blocks per group.) - - // For gene2fs - unsigned nextblock; // Next data block to allocate - unsigned nextgroup; // Next group we'll be allocating from - int fsfd; // File descriptor of filesystem (to output to). -}; - -// toys/pending/modprobe.c - -struct modprobe_data { - struct arg_list *dirs; - - struct arg_list *probes, *dbase[256]; - char *cmdopts; - int nudeps, symreq; -}; - -// toys/pending/more.c - -struct more_data { - struct termios inf; - int cin_fd; -}; - -// toys/pending/route.c - -struct route_data { - char *A; -}; - -// toys/pending/sh.c - -struct sh_data { - union { - struct { - char *c; - } sh; - struct { - char *a; - } exec; - }; - - // keep SECONDS here: used to work around compiler limitation in run_command() - long long SECONDS; - char *isexec, *wcpat; - unsigned options, jobcnt, LINENO; - int hfd, pid, bangpid, srclvl, recursion, recfile[50+200*CFG_TOYBOX_FORK]; - - // Callable function array - struct sh_function { - char *name; - struct sh_pipeline { // pipeline segments: linked list of arg w/metadata - struct sh_pipeline *next, *prev, *end; - int count, here, type, lineno; - struct sh_arg { - char **v; - int c; - } arg[1]; - } *pipeline; - unsigned long refcount; - } **functions; - long funcslen; - - // runtime function call stack - struct sh_fcall { - struct sh_fcall *next, *prev; - - // This dlist in reverse order: TT.ff current function, TT.ff->prev globals - struct sh_vars { - long flags; - char *str; - } *vars; - long varslen, varscap, shift, oldlineno; - - struct sh_function *func; // TODO wire this up - struct sh_pipeline *pl; - char *ifs, *omnom; - struct sh_arg arg; - struct arg_list *delete; - - // Runtime stack of nested if/else/fi and for/do/done contexts. - struct sh_blockstack { - struct sh_blockstack *next; - struct sh_pipeline *start, *middle; - struct sh_process *pp; // list of processes piping in to us - int run, loop, *urd, pout, pipe; - struct sh_arg farg; // for/select arg stack, case wildcard deck - struct arg_list *fdelete; // farg's cleanup list - char *fvar; // for/select's iteration variable name - } *blk; - } *ff; - -// TODO ctrl-Z suspend should stop script - struct sh_process { - struct sh_process *next, *prev; // | && || - struct arg_list *delete; // expanded strings - // undo redirects, a=b at start, child PID, exit status, has !, job # - int *urd, envlen, pid, exit, flags, job, dash; - long long when; // when job backgrounded/suspended - struct sh_arg *raw, arg; - } *pp; // currently running process - - // job list, command line for $*, scratch space for do_wildcard_files() - struct sh_arg jobs, *wcdeck; -}; - -// toys/pending/strace.c - -struct strace_data { - long s, p; - - char ioctl[32], *fmt; - long regs[256/sizeof(long)], syscall; - pid_t pid; - int arg; -}; - -// toys/pending/stty.c - -struct stty_data { - char *F; - - int fd, col; - unsigned output_cols; -}; - -// toys/pending/sulogin.c - -struct sulogin_data { - long timeout; - struct termios crntio; -}; - -// toys/pending/syslogd.c - -struct syslogd_data { - char *socket; - char *config_file; - char *unix_socket; - char *logfile; - long interval; - long rot_size; - long rot_count; - char *remote_log; - long log_prio; - - struct unsocks *lsocks; // list of listen sockets - struct logfile *lfiles; // list of write logfiles - int sigfd[2]; -}; - -// toys/pending/tcpsvd.c - -struct tcpsvd_data { - char *l, *u, *C; - long b, c; - - int maxc; - int count_all; - int udp; -}; - -// toys/pending/telnet.c - -struct telnet_data { - int sock; - char buf[2048]; // Half sizeof(toybuf) allows a buffer full of IACs. - struct termios old_term; - struct termios raw_term; - uint8_t mode; - int echo, sga; - int state, request; -}; - -// toys/pending/telnetd.c - -struct telnetd_data { - char *login_path; - char *issue_path; - int port; - char *host_addr; - long w_sec; - - int gmax_fd; - pid_t fork_pid; -}; - -// toys/pending/tftp.c - -struct tftp_data { - char *local_file; - char *remote_file; - long block_size; - - struct sockaddr_storage inaddr; - int af; -}; - -// toys/pending/tftpd.c - -struct tftpd_data { - char *user; - - long sfd; - struct passwd *pw; -}; - -// toys/pending/tr.c - struct tr_data { short *map; int len1, len2; }; -// toys/pending/traceroute.c - -struct traceroute_data { - long max_ttl; - long port; - long ttl_probes; - char *src_ip; - long tos; - long wait_time; - struct arg_list *loose_source; - long pause_time; - long first_ttl; - char *iface; - - uint32_t gw_list[9]; - int recv_sock; - int snd_sock; - unsigned msg_len; - char *packet; - uint32_t ident; - int istraceroute6; -}; - -// toys/pending/useradd.c - -struct useradd_data { - char *dir; - char *gecos; - char *shell; - char *u_grp; - long uid; - - long gid; -}; - -// toys/pending/vi.c - -struct vi_data { - char *s; - - char *filename; - int vi_mode, tabstop, list; - int cur_col, cur_row, scr_row; - int drawn_row, drawn_col; - int count0, count1, vi_mov_flag; - unsigned screen_height, screen_width; - char vi_reg, *last_search; - struct str_line { - int alloc; - int len; - char *data; - } *il; - size_t screen, cursor; //offsets - //yank buffer - struct yank_buf { - char reg; - int alloc; - char* data; - } yank; - - size_t filesize; -// mem_block contains RO data that is either original file as mmap -// or heap allocated inserted data - struct block_list { - struct block_list *next, *prev; - struct mem_block { - size_t size; - size_t len; - enum alloc_flag { - MMAP, //can be munmap() before exit() - HEAP, //can be free() before exit() - STACK, //global or stack perhaps toybuf - } alloc; - const char *data; - } *node; - } *text; - -// slices do not contain actual allocated data but slices of data in mem_block -// when file is first opened it has only one slice. -// after inserting data into middle new mem_block is allocated for insert data -// and 3 slices are created, where first and last slice are pointing to original -// mem_block with offsets, and middle slice is pointing to newly allocated block -// When deleting, data is not freed but mem_blocks are sliced more such way that -// deleted data left between 2 slices - struct slice_list { - struct slice_list *next, *prev; - struct slice { - size_t len; - const char *data; - } *node; - } *slices; -}; - -// toys/posix/basename.c - struct basename_data { char *s; }; -// toys/posix/cal.c - -struct cal_data { - struct tm *now; -}; - -// toys/posix/chgrp.c - -struct chgrp_data { - uid_t owner; - gid_t group; - char *owner_name, *group_name; - int symfollow; -}; - -// toys/posix/chmod.c - struct chmod_data { char *mode; }; -// toys/posix/cmp.c - struct cmp_data { long n; @@ -1233,8 +115,6 @@ struct cmp_data { char *name; }; -// toys/posix/cp.c - struct cp_data { union { // install's options @@ -1255,14 +135,10 @@ struct cp_data { int pflags; }; -// toys/posix/cpio.c - struct cpio_data { char *F, *H, *R; }; -// toys/posix/cut.c - struct cut_data { char *d, *O; struct arg_list *select[5]; // we treat them the same, so loop through @@ -1272,32 +148,18 @@ struct cut_data { regex_t reg; }; -// toys/posix/date.c - struct date_data { char *s, *r, *I, *D, *d; unsigned nano; }; -// toys/posix/dd.c - struct dd_data { // Display fields int show_xfer, show_records; unsigned long long bytes, in_full, in_part, out_full, out_part, start; }; -// toys/posix/df.c - -struct df_data { - struct arg_list *t; - - int units, width[6]; -}; - -// toys/posix/du.c - struct du_data { long d; @@ -1306,29 +168,15 @@ struct du_data { void *inodes; }; -// toys/posix/env.c - struct env_data { struct arg_list *u; }; -// toys/posix/expand.c - -struct expand_data { - struct arg_list *t; - - unsigned tabcount, *tab; -}; - -// toys/posix/file.c - struct file_data { int max_name_len; off_t len; }; -// toys/posix/find.c - struct find_data { char **filter; struct double_list *argdata; @@ -1338,14 +186,6 @@ struct find_data { char *start; }; -// toys/posix/fold.c - -struct fold_data { - long w; -}; - -// toys/posix/grep.c - struct grep_data { long m, A, B, C; struct arg_list *f, *e, *M, *S, *exclude_dir; @@ -1357,51 +197,20 @@ struct grep_data { struct arg_list **fixed; }; -// toys/posix/head.c - struct head_data { long c, n; int file_no; }; -// toys/posix/iconv.c - -struct iconv_data { - char *f, *t; - - void *ic; -}; - -// toys/posix/id.c - struct id_data { int is_groups; }; -// toys/posix/kill.c - -struct kill_data { - char *s; - struct arg_list *o; -}; - -// toys/posix/ln.c - struct ln_data { char *t; }; -// toys/posix/logger.c - -struct logger_data { - char *p, *t; - - int priority; -}; - -// toys/posix/ls.c - struct ls_data { long w, l, block_size; char *color, *sort; @@ -1412,29 +221,10 @@ struct ls_data { char *escmore; }; -// toys/posix/mkdir.c - struct mkdir_data { char *m, *Z; }; -// toys/posix/mkfifo.c - -struct mkfifo_data { - char *m; - char *Z; - - mode_t mode; -}; - -// toys/posix/nice.c - -struct nice_data { - long n; -}; - -// toys/posix/nl.c - struct nl_data { char *s, *n, *b; long w, l, v; @@ -1443,8 +233,6 @@ struct nl_data { long lcount, slen; }; -// toys/posix/od.c - struct od_data { struct arg_list *t; char *A; @@ -1457,16 +245,12 @@ struct od_data { off_t pos; }; -// toys/posix/paste.c - struct paste_data { char *d; int files; }; -// toys/posix/patch.c - struct patch_data { char *i, *d; long v, p, g, F; @@ -1477,8 +261,6 @@ struct patch_data { char *tempname; }; -// toys/posix/ps.c - struct ps_data { union { struct { @@ -1513,14 +295,6 @@ struct ps_data { void (*show_process)(void *tb); }; -// toys/posix/renice.c - -struct renice_data { - long n; -}; - -// toys/posix/sed.c - struct sed_data { char *i; struct arg_list *f, *e; @@ -1536,8 +310,6 @@ struct sed_data { char delim, xftype; }; -// toys/posix/sort.c - struct sort_data { char *t; struct arg_list *k; @@ -1548,23 +320,6 @@ struct sort_data { char **lines, *name; }; -// toys/posix/split.c - -struct split_data { - long n, l, b, a; - - char *outfile; -}; - -// toys/posix/strings.c - -struct strings_data { - long n; - char *t; -}; - -// toys/posix/tail.c - struct tail_data { long n, c; char *s; @@ -1578,8 +333,6 @@ struct tail_data { } *F; }; -// toys/posix/tar.c - struct tar_data { char *f, *C, *I; struct arg_list *T, *X, *xform; @@ -1613,47 +366,25 @@ struct tar_data { } hdr; }; -// toys/posix/tee.c - struct tee_data { void *outputs; int out; }; -// toys/posix/touch.c - struct touch_data { char *t, *r, *d; }; -// toys/posix/ulimit.c - -struct ulimit_data { - long P; -}; - -// toys/posix/uniq.c - struct uniq_data { long w, s, f; long repeats; }; -// toys/posix/uudecode.c - -struct uudecode_data { - char *o; -}; - -// toys/posix/wc.c - struct wc_data { - unsigned long totals[4]; + unsigned long totals[5]; }; -// toys/posix/xargs.c - struct xargs_data { long s, n, P; char *E; @@ -1662,134 +393,25 @@ struct xargs_data { char delim; FILE *tty; }; - extern union global_union { - struct log_data log; - struct demo_number_data demo_number; - struct hello_data hello; - struct skeleton_data skeleton; - struct dmesg_data dmesg; struct gzip_data gzip; struct hostname_data hostname; - struct killall_data killall; struct md5sum_data md5sum; - struct mknod_data mknod; struct mktemp_data mktemp; - struct mount_data mount; - struct passwd_data passwd; - struct pidof_data pidof; struct seq_data seq; - struct su_data su; - struct umount_data umount; - struct ftpget_data ftpget; - struct host_data host; - struct ifconfig_data ifconfig; struct microcom_data microcom; - struct netcat_data netcat; - struct netstat_data netstat; - struct ping_data ping; - struct sntp_data sntp; - struct tunctl_data tunctl; - struct wget_data wget; - struct base64_data base64; - struct blkdiscard_data blkdiscard; - struct blkid_data blkid; - struct blockdev_data blockdev; - struct chrt_data chrt; - struct count_data count; struct dos2unix_data dos2unix; - struct fallocate_data fallocate; - struct fmt_data fmt; - struct free_data free; - struct gpiod_data gpiod; - struct hexedit_data hexedit; - struct hwclock_data hwclock; - struct i2ctools_data i2ctools; - struct ionice_data ionice; - struct login_data login; - struct losetup_data losetup; - struct lsattr_data lsattr; - struct lsusb_data lsusb; - struct makedevs_data makedevs; - struct mix_data mix; - struct mkpasswd_data mkpasswd; - struct mkswap_data mkswap; - struct modinfo_data modinfo; - struct nbd_client_data nbd_client; - struct nsenter_data nsenter; - struct oneit_data oneit; - struct openvt_data openvt; - struct pwgen_data pwgen; - struct readelf_data readelf; - struct readlink_data readlink; - struct reboot_data reboot; - struct rtcwake_data rtcwake; - struct setfattr_data setfattr; + struct realpath_data realpath; struct setsid_data setsid; - struct sha3sum_data sha3sum; - struct shred_data shred; - struct shuf_data shuf; struct stat_data stat; - struct swapon_data swapon; - struct switch_root_data switch_root; - struct tac_data tac; struct timeout_data timeout; struct truncate_data truncate; - struct uclampset_data uclampset; - struct watch_data watch; - struct watchdog_data watchdog; struct xxd_data xxd; - struct arp_data arp; - struct arping_data arping; - struct bc_data bc; - struct bootchartd_data bootchartd; - struct brctl_data brctl; - struct chsh_data chsh; - struct crond_data crond; - struct crontab_data crontab; - struct csplit_data csplit; - struct dhcp_data dhcp; - struct dhcp6_data dhcp6; - struct dhcpd_data dhcpd; struct diff_data diff; - struct dumpleases_data dumpleases; struct expr_data expr; - struct fdisk_data fdisk; - struct fsck_data fsck; - struct getfattr_data getfattr; struct getopt_data getopt; - struct getty_data getty; - struct git_data git; - struct groupadd_data groupadd; - struct hexdump_data hexdump; - struct ip_data ip; - struct ipcrm_data ipcrm; - struct ipcs_data ipcs; - struct klogd_data klogd; - struct last_data last; - struct lsof_data lsof; - struct man_data man; - struct mke2fs_data mke2fs; - struct modprobe_data modprobe; - struct more_data more; - struct route_data route; - struct sh_data sh; - struct strace_data strace; - struct stty_data stty; - struct sulogin_data sulogin; - struct syslogd_data syslogd; - struct tcpsvd_data tcpsvd; - struct telnet_data telnet; - struct telnetd_data telnetd; - struct tftp_data tftp; - struct tftpd_data tftpd; struct tr_data tr; - struct traceroute_data traceroute; - struct useradd_data useradd; - struct vi_data vi; struct basename_data basename; - struct cal_data cal; - struct chgrp_data chgrp; struct chmod_data chmod; struct cmp_data cmp; struct cp_data cp; @@ -1797,41 +419,28 @@ extern union global_union { struct cut_data cut; struct date_data date; struct dd_data dd; - struct df_data df; struct du_data du; struct env_data env; - struct expand_data expand; struct file_data file; struct find_data find; - struct fold_data fold; struct grep_data grep; struct head_data head; - struct iconv_data iconv; struct id_data id; - struct kill_data kill; struct ln_data ln; - struct logger_data logger; struct ls_data ls; struct mkdir_data mkdir; - struct mkfifo_data mkfifo; - struct nice_data nice; struct nl_data nl; struct od_data od; struct paste_data paste; struct patch_data patch; struct ps_data ps; - struct renice_data renice; struct sed_data sed; struct sort_data sort; - struct split_data split; - struct strings_data strings; struct tail_data tail; struct tar_data tar; struct tee_data tee; struct touch_data touch; - struct ulimit_data ulimit; struct uniq_data uniq; - struct uudecode_data uudecode; struct wc_data wc; struct xargs_data xargs; } this; diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h index 2274125a..319227d0 100644 --- a/android/linux/generated/help.h +++ b/android/linux/generated/help.h @@ -522,7 +522,7 @@ #define HELP_who "usage: who\n\nPrint information about logged in users." -#define HELP_wc "usage: wc [-lwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." +#define HELP_wc "usage: wc [-Llwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-L Show max line length\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." #define HELP_uuencode "usage: uuencode [-m] [INFILE] ENCODE_FILENAME\n\nUuencode stdin (or INFILE) to stdout, with ENCODE_FILENAME in the output.\n\n-m Base64" diff --git a/android/linux/generated/newtoys.h b/android/linux/generated/newtoys.h index a4bf4c24..fa6fa62b 100644 --- a/android/linux/generated/newtoys.h +++ b/android/linux/generated/newtoys.h @@ -335,7 +335,7 @@ USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) USE_SH(NEWTOY(wait, "n", TOYFLAG_NOFORK)) USE_WATCH(NEWTOY(watch, "^<1n%<100=2000tebx", TOYFLAG_USR|TOYFLAG_BIN)) USE_WATCHDOG(NEWTOY(watchdog, "<1>1Ft#=4<1T#=60<1", TOYFLAG_NEEDROOT|TOYFLAG_SBIN)) -USE_WC(NEWTOY(wc, "mcwl", TOYFLAG_USR|TOYFLAG_BIN)) +USE_WC(NEWTOY(wc, "Lcmwl", TOYFLAG_USR|TOYFLAG_BIN)) USE_WGET(NEWTOY(wget, "<1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data):", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHICH(NEWTOY(which, "<1a", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHO(NEWTOY(who, "a", TOYFLAG_USR|TOYFLAG_BIN)) diff --git a/android/mac/generated/config.h b/android/mac/generated/config.h index 746abf46..b06bd580 100644 --- a/android/mac/generated/config.h +++ b/android/mac/generated/config.h @@ -1,34 +1,25 @@ #define CFG_TOYBOX 1 #define USE_TOYBOX(...) __VA_ARGS__ - #define CFG_TOYBOX_DEBUG 0 #define USE_TOYBOX_DEBUG(...) #define CFG_TOYBOX_FLOAT 1 #define USE_TOYBOX_FLOAT(...) __VA_ARGS__ - #define CFG_TOYBOX_FORK 1 #define USE_TOYBOX_FORK(...) __VA_ARGS__ - #define CFG_TOYBOX_FREE 0 #define USE_TOYBOX_FREE(...) #define CFG_TOYBOX_HELP_DASHDASH 1 #define USE_TOYBOX_HELP_DASHDASH(...) __VA_ARGS__ - #define CFG_TOYBOX_HELP 1 #define USE_TOYBOX_HELP(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBCRYPTO 1 #define USE_TOYBOX_LIBCRYPTO(...) __VA_ARGS__ - #define CFG_TOYBOX_LIBZ 1 #define USE_TOYBOX_LIBZ(...) __VA_ARGS__ - #define CFG_TOYBOX_LSM_NONE 1 #define USE_TOYBOX_LSM_NONE(...) __VA_ARGS__ - #define CFG_TOYBOX_NORECURSE 1 #define USE_TOYBOX_NORECURSE(...) __VA_ARGS__ - #define CFG_TOYBOX_ON_ANDROID 0 #define USE_TOYBOX_ON_ANDROID(...) #define CFG_TOYBOX_SELINUX 0 @@ -55,7 +46,6 @@ #define USE_BASE64(...) #define CFG_BASENAME 1 #define USE_BASENAME(...) __VA_ARGS__ - #define CFG_BC 0 #define USE_BC(...) #define CFG_BLKDISCARD 0 @@ -76,7 +66,6 @@ #define USE_CAL(...) #define CFG_CAT 1 #define USE_CAT(...) __VA_ARGS__ - #define CFG_CD 0 #define USE_CD(...) #define CFG_CHATTR 0 @@ -87,7 +76,6 @@ #define USE_CHGRP(...) #define CFG_CHMOD 1 #define USE_CHMOD(...) __VA_ARGS__ - #define CFG_CHOWN 0 #define USE_CHOWN(...) #define CFG_CHROOT 0 @@ -104,18 +92,14 @@ #define USE_CLEAR(...) #define CFG_CMP 1 #define USE_CMP(...) __VA_ARGS__ - #define CFG_COMM 1 #define USE_COMM(...) __VA_ARGS__ - #define CFG_COUNT 0 #define USE_COUNT(...) #define CFG_CPIO 1 #define USE_CPIO(...) __VA_ARGS__ - #define CFG_CP 1 #define USE_CP(...) __VA_ARGS__ - #define CFG_CRC32 0 #define USE_CRC32(...) #define CFG_CROND 0 @@ -126,13 +110,10 @@ #define USE_CSPLIT(...) #define CFG_CUT 1 #define USE_CUT(...) __VA_ARGS__ - #define CFG_DATE 1 #define USE_DATE(...) __VA_ARGS__ - #define CFG_DD 1 #define USE_DD(...) __VA_ARGS__ - #define CFG_DEALLOCVT 0 #define USE_DEALLOCVT(...) #define CFG_DEBUG_DHCP 0 @@ -157,40 +138,32 @@ #define USE_DHCP(...) #define CFG_DIFF 1 #define USE_DIFF(...) __VA_ARGS__ - #define CFG_DIRNAME 1 #define USE_DIRNAME(...) __VA_ARGS__ - #define CFG_DMESG 0 #define USE_DMESG(...) #define CFG_DNSDOMAINNAME 0 #define USE_DNSDOMAINNAME(...) #define CFG_DOS2UNIX 1 #define USE_DOS2UNIX(...) __VA_ARGS__ - #define CFG_DUMPLEASES 0 #define USE_DUMPLEASES(...) #define CFG_DU 1 #define USE_DU(...) __VA_ARGS__ - #define CFG_ECHO 1 #define USE_ECHO(...) __VA_ARGS__ - #define CFG_EGREP 1 #define USE_EGREP(...) __VA_ARGS__ - #define CFG_EJECT 0 #define USE_EJECT(...) #define CFG_ENV 1 #define USE_ENV(...) __VA_ARGS__ - #define CFG_EXIT 0 #define USE_EXIT(...) #define CFG_EXPAND 0 #define USE_EXPAND(...) #define CFG_EXPR 1 #define USE_EXPR(...) __VA_ARGS__ - #define CFG_FACTOR 0 #define USE_FACTOR(...) #define CFG_FALLOCATE 0 @@ -201,13 +174,10 @@ #define USE_FDISK(...) #define CFG_FGREP 1 #define USE_FGREP(...) __VA_ARGS__ - #define CFG_FILE 1 #define USE_FILE(...) __VA_ARGS__ - #define CFG_FIND 1 #define USE_FIND(...) __VA_ARGS__ - #define CFG_FLOCK 0 #define USE_FLOCK(...) #define CFG_FMT 0 @@ -232,14 +202,12 @@ #define USE_FTPPUT(...) #define CFG_GETCONF 1 #define USE_GETCONF(...) __VA_ARGS__ - #define CFG_GETENFORCE 0 #define USE_GETENFORCE(...) #define CFG_GETFATTR 0 #define USE_GETFATTR(...) #define CFG_GETOPT 1 #define USE_GETOPT(...) __VA_ARGS__ - #define CFG_GETTY 0 #define USE_GETTY(...) #define CFG_GITCHECKOUT 0 @@ -266,7 +234,6 @@ #define USE_GPIOSET(...) #define CFG_GREP 1 #define USE_GREP(...) __VA_ARGS__ - #define CFG_GROUPADD 0 #define USE_GROUPADD(...) #define CFG_GROUPDEL 0 @@ -277,10 +244,8 @@ #define USE_GUNZIP(...) #define CFG_GZIP 1 #define USE_GZIP(...) __VA_ARGS__ - #define CFG_HEAD 1 #define USE_HEAD(...) __VA_ARGS__ - #define CFG_HELLO 0 #define USE_HELLO(...) #define CFG_HELP 0 @@ -297,7 +262,6 @@ #define USE_HOST(...) #define CFG_HOSTNAME 1 #define USE_HOSTNAME(...) __VA_ARGS__ - #define CFG_HTTPD 0 #define USE_HTTPD(...) #define CFG_HWCLOCK 0 @@ -316,7 +280,6 @@ #define USE_ICONV(...) #define CFG_ID 1 #define USE_ID(...) __VA_ARGS__ - #define CFG_ID_Z 0 #define USE_ID_Z(...) #define CFG_IFCONFIG 0 @@ -329,7 +292,6 @@ #define USE_INSMOD(...) #define CFG_INSTALL 1 #define USE_INSTALL(...) __VA_ARGS__ - #define CFG_IONICE 0 #define USE_IONICE(...) #define CFG_IORENICE 0 @@ -360,7 +322,6 @@ #define USE_LINUX32(...) #define CFG_LN 1 #define USE_LN(...) __VA_ARGS__ - #define CFG_LOAD_POLICY 0 #define USE_LOAD_POLICY(...) #define CFG_LOGGER 0 @@ -387,7 +348,6 @@ #define USE_LSUSB(...) #define CFG_LS 1 #define USE_LS(...) __VA_ARGS__ - #define CFG_MAKEDEVS 0 #define USE_MAKEDEVS(...) #define CFG_MAN 0 @@ -396,7 +356,6 @@ #define USE_MCOOKIE(...) #define CFG_MD5SUM 1 #define USE_MD5SUM(...) __VA_ARGS__ - #define CFG_MDEV_CONF 0 #define USE_MDEV_CONF(...) #define CFG_MDEV 0 @@ -405,12 +364,10 @@ #define USE_MEMEATER(...) #define CFG_MICROCOM 1 #define USE_MICROCOM(...) __VA_ARGS__ - #define CFG_MIX 0 #define USE_MIX(...) #define CFG_MKDIR 1 #define USE_MKDIR(...) __VA_ARGS__ - #define CFG_MKDIR_Z 0 #define USE_MKDIR_Z(...) #define CFG_MKE2FS_EXTENDED 0 @@ -437,7 +394,6 @@ #define USE_MKSWAP(...) #define CFG_MKTEMP 1 #define USE_MKTEMP(...) __VA_ARGS__ - #define CFG_MODINFO 0 #define USE_MODINFO(...) #define CFG_MODPROBE 0 @@ -450,7 +406,6 @@ #define USE_MOUNTPOINT(...) #define CFG_MV 1 #define USE_MV(...) __VA_ARGS__ - #define CFG_NBD_CLIENT 0 #define USE_NBD_CLIENT(...) #define CFG_NBD_SERVER 0 @@ -463,7 +418,6 @@ #define USE_NICE(...) #define CFG_NL 1 #define USE_NL(...) __VA_ARGS__ - #define CFG_NOHUP 0 #define USE_NOHUP(...) #define CFG_NPROC 0 @@ -472,7 +426,6 @@ #define USE_NSENTER(...) #define CFG_OD 1 #define USE_OD(...) __VA_ARGS__ - #define CFG_ONEIT 0 #define USE_ONEIT(...) #define CFG_OPENVT 0 @@ -485,10 +438,8 @@ #define USE_PASSWD_SAD(...) #define CFG_PASTE 1 #define USE_PASTE(...) __VA_ARGS__ - #define CFG_PATCH 1 #define USE_PATCH(...) __VA_ARGS__ - #define CFG_PGREP 0 #define USE_PGREP(...) #define CFG_PIDOF 0 @@ -505,14 +456,12 @@ #define USE_PRINTENV(...) #define CFG_PRINTF 1 #define USE_PRINTF(...) __VA_ARGS__ - #define CFG_PS 0 #define USE_PS(...) #define CFG_PWDX 0 #define USE_PWDX(...) #define CFG_PWD 1 #define USE_PWD(...) __VA_ARGS__ - #define CFG_PWGEN 0 #define USE_PWGEN(...) #define CFG_READAHEAD 0 @@ -521,10 +470,8 @@ #define USE_READELF(...) #define CFG_READLINK 1 #define USE_READLINK(...) __VA_ARGS__ - #define CFG_REALPATH 1 #define USE_REALPATH(...) __VA_ARGS__ - #define CFG_REBOOT 0 #define USE_REBOOT(...) #define CFG_RENICE 0 @@ -539,12 +486,10 @@ #define USE_RFKILL(...) #define CFG_RMDIR 1 #define USE_RMDIR(...) __VA_ARGS__ - #define CFG_RMMOD 0 #define USE_RMMOD(...) #define CFG_RM 1 #define USE_RM(...) __VA_ARGS__ - #define CFG_ROUTE 0 #define USE_ROUTE(...) #define CFG_RTCWAKE 0 @@ -553,34 +498,28 @@ #define USE_RUNCON(...) #define CFG_SED 1 #define USE_SED(...) __VA_ARGS__ - #define CFG_SENDEVENT 0 #define USE_SENDEVENT(...) #define CFG_SEQ 1 #define USE_SEQ(...) __VA_ARGS__ - #define CFG_SETENFORCE 0 #define USE_SETENFORCE(...) #define CFG_SETFATTR 0 #define USE_SETFATTR(...) #define CFG_SETSID 1 #define USE_SETSID(...) __VA_ARGS__ - #define CFG_SHA1SUM 1 #define USE_SHA1SUM(...) __VA_ARGS__ - #define CFG_SHA224SUM 0 #define USE_SHA224SUM(...) #define CFG_SHA256SUM 1 #define USE_SHA256SUM(...) __VA_ARGS__ - #define CFG_SHA3SUM 0 #define USE_SHA3SUM(...) #define CFG_SHA384SUM 0 #define USE_SHA384SUM(...) #define CFG_SHA512SUM 1 #define USE_SHA512SUM(...) __VA_ARGS__ - #define CFG_SH 0 #define USE_SH(...) #define CFG_SHRED 0 @@ -593,20 +532,16 @@ #define USE_SKELETON(...) #define CFG_SLEEP 1 #define USE_SLEEP(...) __VA_ARGS__ - #define CFG_SNTP 0 #define USE_SNTP(...) #define CFG_SORT_FLOAT 1 #define USE_SORT_FLOAT(...) __VA_ARGS__ - #define CFG_SORT 1 #define USE_SORT(...) __VA_ARGS__ - #define CFG_SPLIT 0 #define USE_SPLIT(...) #define CFG_STAT 1 #define USE_STAT(...) __VA_ARGS__ - #define CFG_STRACE 0 #define USE_STRACE(...) #define CFG_STRINGS 0 @@ -633,27 +568,22 @@ #define USE_TAC(...) #define CFG_TAIL 1 #define USE_TAIL(...) __VA_ARGS__ - #define CFG_TAR 1 #define USE_TAR(...) __VA_ARGS__ - #define CFG_TASKSET 0 #define USE_TASKSET(...) #define CFG_TCPSVD 0 #define USE_TCPSVD(...) #define CFG_TEE 1 #define USE_TEE(...) __VA_ARGS__ - #define CFG_TELNETD 0 #define USE_TELNETD(...) #define CFG_TELNET 0 #define USE_TELNET(...) #define CFG_TEST 1 #define USE_TEST(...) __VA_ARGS__ - #define CFG_TEST_GLUE 1 #define USE_TEST_GLUE(...) __VA_ARGS__ - #define CFG_TFTPD 0 #define USE_TFTPD(...) #define CFG_TFTP 0 @@ -662,23 +592,18 @@ #define USE_TIME(...) #define CFG_TIMEOUT 1 #define USE_TIMEOUT(...) __VA_ARGS__ - #define CFG_TOP 0 #define USE_TOP(...) #define CFG_TOUCH 1 #define USE_TOUCH(...) __VA_ARGS__ - #define CFG_TRACEROUTE 0 #define USE_TRACEROUTE(...) #define CFG_TRUE 1 #define USE_TRUE(...) __VA_ARGS__ - #define CFG_TRUNCATE 1 #define USE_TRUNCATE(...) __VA_ARGS__ - #define CFG_TR 1 #define USE_TR(...) __VA_ARGS__ - #define CFG_TS 0 #define USE_TS(...) #define CFG_TSORT 0 @@ -695,15 +620,12 @@ #define USE_UMOUNT(...) #define CFG_UNAME 1 #define USE_UNAME(...) __VA_ARGS__ - #define CFG_UNICODE 0 #define USE_UNICODE(...) #define CFG_UNIQ 1 #define USE_UNIQ(...) __VA_ARGS__ - #define CFG_UNIX2DOS 1 #define USE_UNIX2DOS(...) __VA_ARGS__ - #define CFG_UNLINK 0 #define USE_UNLINK(...) #define CFG_UNSHARE 0 @@ -734,29 +656,23 @@ #define USE_WATCHDOG(...) #define CFG_WC 1 #define USE_WC(...) __VA_ARGS__ - #define CFG_WGET 0 #define USE_WGET(...) #define CFG_WHICH 1 #define USE_WHICH(...) __VA_ARGS__ - #define CFG_WHOAMI 1 #define USE_WHOAMI(...) __VA_ARGS__ - #define CFG_WHO 0 #define USE_WHO(...) #define CFG_W 0 #define USE_W(...) #define CFG_XARGS 1 #define USE_XARGS(...) __VA_ARGS__ - #define CFG_XXD 1 #define USE_XXD(...) __VA_ARGS__ - #define CFG_XZCAT 0 #define USE_XZCAT(...) #define CFG_YES 0 #define USE_YES(...) #define CFG_ZCAT 1 #define USE_ZCAT(...) __VA_ARGS__ - diff --git a/android/mac/generated/flags.h b/android/mac/generated/flags.h index 0358fbd5..67e8ea6f 100644 --- a/android/mac/generated/flags.h +++ b/android/mac/generated/flags.h @@ -3808,16 +3808,17 @@ #undef FLAG_F #endif -// wc mcwl mcwl +// wc Lcmwl Lcmwl #undef OPTSTR_wc -#define OPTSTR_wc "mcwl" +#define OPTSTR_wc "Lcmwl" #ifdef CLEANUP_wc #undef CLEANUP_wc #undef FOR_wc #undef FLAG_l #undef FLAG_w -#undef FLAG_c #undef FLAG_m +#undef FLAG_c +#undef FLAG_L #endif // wget <1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data): @@ -7432,8 +7433,9 @@ #endif #define FLAG_l (1LL<<0) #define FLAG_w (1LL<<1) -#define FLAG_c (1LL<<2) -#define FLAG_m (1LL<<3) +#define FLAG_m (1LL<<2) +#define FLAG_c (1LL<<3) +#define FLAG_L (1LL<<4) #endif #ifdef FOR_wget diff --git a/android/mac/generated/globals.h b/android/mac/generated/globals.h index 60cd358e..ef07fd4d 100644 --- a/android/mac/generated/globals.h +++ b/android/mac/generated/globals.h @@ -1,163 +1,25 @@ -// toys/android/log.c - -struct log_data { - char *t, *p; - - int pri; -}; - -// toys/example/demo_number.c - -struct demo_number_data { - long M, D; -}; - -// toys/example/hello.c - -struct hello_data { - int unused; -}; - -// toys/example/skeleton.c - -struct skeleton_data { - union { - struct { - char *b; - long c; - struct arg_list *d; - long e; - char *f, *g, *h, *also, *blubber; - } s; - struct { - long b; - } a; - }; - - int more_globals; -}; - -// toys/lsb/dmesg.c - -struct dmesg_data { - long n, s; - - int use_color; - time_t tea; -}; - -// toys/lsb/gzip.c - struct gzip_data { int level; }; -// toys/lsb/hostname.c - struct hostname_data { char *F; }; -// toys/lsb/killall.c - -struct killall_data { - char *s; - - int signum; - pid_t cur_pid; - char **names; - short *err; - struct int_list { struct int_list *next; int val; } *pids; -}; - -// toys/lsb/md5sum.c - struct md5sum_data { int sawline; }; -// toys/lsb/mknod.c - -struct mknod_data { - char *Z, *m; -}; - -// toys/lsb/mktemp.c - struct mktemp_data { char *p, *tmpdir; }; -// toys/lsb/mount.c - -struct mount_data { - struct arg_list *o; - char *t, *O; - - unsigned long flags; - char *opts; - int okuser; -}; - -// toys/lsb/passwd.c - -struct passwd_data { - char *a; -}; - -// toys/lsb/pidof.c - -struct pidof_data { - char *o; -}; - -// toys/lsb/seq.c - struct seq_data { char *s, *f; int precision, buflen; }; -// toys/lsb/su.c - -struct su_data { - char *s, *c; -}; - -// toys/lsb/umount.c - -struct umount_data { - struct arg_list *t; - - char *types; -}; - -// toys/net/ftpget.c - -struct ftpget_data { - char *u, *p, *P; - - int fd; -}; - -// toys/net/host.c - -struct host_data { - char *t; - - char **nsname; - unsigned nslen; -}; - -// toys/net/ifconfig.c - -struct ifconfig_data { - int sockfd; -}; - -// toys/net/microcom.c - struct microcom_data { long s; @@ -165,337 +27,18 @@ struct microcom_data { struct termios old_stdin, old_fd; }; -// toys/net/netcat.c - -struct netcat_data { - char *f, *s; - long q, p, W, w; -}; - -// toys/net/netstat.c - -struct netstat_data { - struct num_cache *inodes; - int wpad; -}; - -// toys/net/ping.c - -struct ping_data { - char *I; - long w, W, i, s, c, t, m; - - struct sockaddr *sa; - int sock; - unsigned long sent, recv, fugit, min, max; -}; - -// toys/net/sntp.c - -struct sntp_data { - long r, t; - char *p, *m, *M; -}; - -// toys/net/tunctl.c - -struct tunctl_data { - char *u; -}; - -// toys/net/wget.c - -struct wget_data { - char *p, *O; - long max_redirect; - - int sock, https; - char *url; -#if CFG_WGET_LIBTLS - struct tls *tls; -#elif CFG_TOYBOX_LIBCRYPTO - struct ssl_ctx_st *ctx; - struct ssl_st *ssl; -#endif -}; - -// toys/other/base64.c - -struct base64_data { - long w; - - unsigned total; - unsigned n; // number of bits used in encoding. 5 for base32, 6 for base64 - unsigned align; // number of bits to align to -}; - -// toys/other/blkdiscard.c - -struct blkdiscard_data { - long o, l; -}; - -// toys/other/blkid.c - -struct blkid_data { - struct arg_list *s; - char *o; -}; - -// toys/other/blockdev.c - -struct blockdev_data { - long setbsz, setra; -}; - -// toys/other/chrt.c - -struct chrt_data { - long p; -}; - -// toys/other/count.c - -struct count_data { - unsigned long long size, start; - unsigned tick, *slice; -}; - -// toys/other/dos2unix.c - struct dos2unix_data { char *tempfile; }; -// toys/other/fallocate.c - -struct fallocate_data { - long o, l; -}; - -// toys/other/fmt.c - -struct fmt_data { - long width; - - int level, pos; -}; - -// toys/other/free.c - -struct free_data { - unsigned bits; - unsigned long long units; - char *buf; -}; - -// toys/other/gpiod.c - -struct gpiod_data { - struct double_list *chips; - int chip_count; -}; - -// toys/other/hexedit.c - -struct hexedit_data { - char *data, *search, keybuf[16], input[80]; - long long len, base, pos; - int numlen, undo, undolen, mode; - unsigned rows, cols; -}; - -// toys/other/hwclock.c - -struct hwclock_data { - char *f; -}; - -// toys/other/i2ctools.c - -struct i2ctools_data { - long F; -}; - -// toys/other/ionice.c - -struct ionice_data { - long p, n, c; -}; - -// toys/other/login.c - -struct login_data { - char *h, *f; - - int login_timeout, login_fail_timeout; -}; - -// toys/other/losetup.c - -struct losetup_data { - char *j; - long o, S; - - int openflags; - dev_t jdev; - ino_t jino; - char *dir; -}; - -// toys/other/lsattr.c - -struct lsattr_data { - long v, p; - - unsigned add, rm, set; - // !add and !rm tell us whether they were used, but `chattr =` is meaningful. - int have_set; -}; - -// toys/other/lsusb.c - -struct lsusb_data { - char *i; - long x, n; - - void *ids, *class; - int count; -}; - -// toys/other/makedevs.c - -struct makedevs_data { - char *d; -}; - -// toys/other/mix.c - -struct mix_data { - long r, l; - char *d, *c; -}; - -// toys/other/mkpasswd.c - -struct mkpasswd_data { - long P; - char *m, *S; -}; - -// toys/other/mkswap.c - -struct mkswap_data { - char *L; -}; - -// toys/other/modinfo.c - -struct modinfo_data { - char *F, *k, *b; - - long mod; - int count; -}; - -// toys/other/nbd_client.c - -struct nbd_client_data { - long b; - - int nbd; -}; - -// toys/other/nsenter.c - -struct nsenter_data { - char *UupnmiC[7]; - long t; -}; - -// toys/other/oneit.c - -struct oneit_data { - char *c; -}; - -// toys/other/openvt.c - -struct openvt_data { - long c; -}; - -// toys/other/pwgen.c - -struct pwgen_data { - char *r; -}; - -// toys/other/readelf.c - -struct readelf_data { - char *x, *p; - - char *elf, *shstrtab, *f; - unsigned long long shoff, phoff, size, shstrtabsz; - int bits, endian, shnum, shentsize, phentsize; -}; - -// toys/other/readlink.c - -struct readlink_data { +struct realpath_data { char *R, *relative_base; }; -// toys/other/reboot.c - -struct reboot_data { - char *d; -}; - -// toys/other/rtcwake.c - -struct rtcwake_data { - long t, s; - char *m, *d; -}; - -// toys/other/setfattr.c - -struct setfattr_data { - char *x, *v, *n; -}; - -// toys/other/setsid.c - struct setsid_data { long c; }; -// toys/other/sha3sum.c - -struct sha3sum_data { - long a; - unsigned long long rc[24]; -}; - -// toys/other/shred.c - -struct shred_data { - long o, n, s; -}; - -// toys/other/shuf.c - -struct shuf_data { - long n; - - char **lines; - long count; -}; - -// toys/other/stat.c - struct stat_data { char *c; @@ -507,29 +50,6 @@ struct stat_data { int patlen; }; -// toys/other/swapon.c - -struct swapon_data { - long p; -}; - -// toys/other/switch_root.c - -struct switch_root_data { - char *c; - - struct stat new; - dev_t rootdev; -}; - -// toys/other/tac.c - -struct tac_data { - struct double_list *dl; -}; - -// toys/other/timeout.c - struct timeout_data { char *s, *k; @@ -538,8 +58,6 @@ struct timeout_data { int fds[2], pid, rc; }; -// toys/other/truncate.c - struct truncate_data { char *s; @@ -547,164 +65,10 @@ struct truncate_data { int type; }; -// toys/other/uclampset.c - -struct uclampset_data { - long M, m, p; -}; - -// toys/other/watch.c - -struct watch_data { - int n; - - pid_t pid, oldpid; -}; - -// toys/other/watchdog.c - -struct watchdog_data { - long T, t; - - int fd; -}; - -// toys/other/xxd.c - struct xxd_data { long s, g, o, l, c; }; -// toys/pending/arp.c - -struct arp_data { - char *hw_type; - char *af_type_A; - char *af_type_p; - char *interface; - - int sockfd; - char *device; -}; - -// toys/pending/arping.c - -struct arping_data { - long count; - unsigned long time_out; - char *iface; - char *src_ip; - - int sockfd; - unsigned long start, end; - unsigned sent_at, sent_nr, rcvd_nr, brd_sent, rcvd_req, brd_rcv, - unicast_flag; -}; - -// toys/pending/bc.c - -struct bc_data { - // This actually needs to be a BcVm*, but the toybox build - // system complains if I make it so. Instead, we'll just cast. - char *vm; - - size_t nchars; - char *file, sig, max_ibase; - uint16_t line_len; -}; - -// toys/pending/bootchartd.c - -struct bootchartd_data { - char timestamp[32]; - long msec; - int proc_accounting; - - pid_t pid; -}; - -// toys/pending/brctl.c - -struct brctl_data { - int sockfd; -}; - -// toys/pending/chsh.c - -struct chsh_data { - char *s, *R; -}; - -// toys/pending/crond.c - -struct crond_data { - char *crontabs_dir; - char *logfile; - int loglevel_d; - int loglevel; - - time_t crontabs_dir_mtime; - uint8_t flagd; -}; - -// toys/pending/crontab.c - -struct crontab_data { - char *user; - char *cdir; -}; - -// toys/pending/csplit.c - -struct csplit_data { - long n; - char *f; - - size_t indx, findx, lineno; - char *filefmt, *prefix; - // Variables the context checker need to track between lines - size_t btc, tmp; - int offset, withld, inf; -}; - -// toys/pending/dhcp.c - -struct dhcp_data { - char *iface; - char *pidfile; - char *script; - long retries; - long timeout; - long tryagain; - struct arg_list *req_opt; - char *req_ip; - struct arg_list *pkt_opt; - char *fdn_name; - char *hostname; - char *vendor_cls; -}; - -// toys/pending/dhcp6.c - -struct dhcp6_data { - char *interface_name, *pidfile, *script; - long retry, timeout, errortimeout; - char *req_ip; - int length, state, request_length, sock, sock1, status, retval, retries; - struct timeval tv; - uint8_t transction_id[3]; - struct sockaddr_in6 input_socket6; -}; - -// toys/pending/dhcpd.c - -struct dhcpd_data { - char *i; - long p; -}; - -// toys/pending/diff.c - struct diff_data { long U; struct arg_list *L; @@ -722,510 +86,28 @@ struct diff_data { } file[2]; }; -// toys/pending/dumpleases.c - -struct dumpleases_data { - char *file; -}; - -// toys/pending/expr.c - struct expr_data { char **tok, *delete; }; -// toys/pending/fdisk.c - -struct fdisk_data { - long sect_sz; - long sectors; - long heads; - long cylinders; -}; - -// toys/pending/fsck.c - -struct fsck_data { - int fd_num; - char *t_list; - - struct double_list *devices; - char *arr_flag; - char **arr_type; - int negate; - int sum_status; - int nr_run; - int sig_num; - long max_nr_run; -}; - -// toys/pending/getfattr.c - -struct getfattr_data { - char *n; -}; - -// toys/pending/getopt.c - struct getopt_data { struct arg_list *l; char *o, *n; }; -// toys/pending/getty.c - -struct getty_data { - char *f, *l, *I, *H; - long t; - - char *tty_name, buff[128]; - int speeds[20], sc; - struct termios termios; -}; - -// toys/pending/git.c - -struct git_data { - char *url, *name; //git repo remote url and init directory name - struct IndexV2 *i; //git creates a index for each pack file, git clone just needs one index for the received pack file -}; - -// toys/pending/groupadd.c - -struct groupadd_data { - long g; - char *R; -}; - -// toys/pending/hexdump.c - -struct hexdump_data { - long s, n; - - long long len, pos, ppos; - const char *fmt; - unsigned int fn, bc; // file number and byte count - char linebuf[16]; // line buffer - serves double duty for sqeezing repeat - // lines and for accumulating full lines accross file - // boundaries if necessesary. -}; - -// toys/pending/ip.c - -struct ip_data { - char stats, singleline, flush, *filter_dev, gbuf[8192]; - int sockfd, connected, from_ok, route_cmd; - int8_t addressfamily, is_addr; -}; - -// toys/pending/ipcrm.c - -struct ipcrm_data { - struct arg_list *qkey; - struct arg_list *qid; - struct arg_list *skey; - struct arg_list *sid; - struct arg_list *mkey; - struct arg_list *mid; -}; - -// toys/pending/ipcs.c - -struct ipcs_data { - int id; -}; - -// toys/pending/klogd.c - -struct klogd_data { - long level; - - int fd; -}; - -// toys/pending/last.c - -struct last_data { - char *file; - - struct arg_list *list; -}; - -// toys/pending/lsof.c - -struct lsof_data { - struct arg_list *p; - - struct stat *sought_files; - struct double_list *all_sockets, *files; - int last_shown_pid, shown_header; -}; - -// toys/pending/man.c - -struct man_data { - char *M, *k; - - char any, cell, ex, *f, k_done, *line, *m, **sct, **scts, **sufs; - regex_t reg; -}; - -// toys/pending/mke2fs.c - -struct mke2fs_data { - // Command line arguments. - long blocksize; - long bytes_per_inode; - long inodes; // Total inodes in filesystem. - long reserved_percent; // Integer precent of space to reserve for root. - char *gendir; // Where to read dirtree from. - - // Internal data. - struct dirtree *dt; // Tree of files to copy into the new filesystem. - unsigned treeblocks; // Blocks used by dt - unsigned treeinodes; // Inodes used by dt - - unsigned blocks; // Total blocks in the filesystem. - unsigned freeblocks; // Free blocks in the filesystem. - unsigned inodespg; // Inodes per group - unsigned groups; // Total number of block groups. - unsigned blockbits; // Bits per block. (Also blocks per group.) - - // For gene2fs - unsigned nextblock; // Next data block to allocate - unsigned nextgroup; // Next group we'll be allocating from - int fsfd; // File descriptor of filesystem (to output to). -}; - -// toys/pending/modprobe.c - -struct modprobe_data { - struct arg_list *dirs; - - struct arg_list *probes, *dbase[256]; - char *cmdopts; - int nudeps, symreq; -}; - -// toys/pending/more.c - -struct more_data { - struct termios inf; - int cin_fd; -}; - -// toys/pending/route.c - -struct route_data { - char *A; -}; - -// toys/pending/sh.c - -struct sh_data { - union { - struct { - char *c; - } sh; - struct { - char *a; - } exec; - }; - - // keep SECONDS here: used to work around compiler limitation in run_command() - long long SECONDS; - char *isexec, *wcpat; - unsigned options, jobcnt, LINENO; - int hfd, pid, bangpid, srclvl, recursion, recfile[50+200*CFG_TOYBOX_FORK]; - - // Callable function array - struct sh_function { - char *name; - struct sh_pipeline { // pipeline segments: linked list of arg w/metadata - struct sh_pipeline *next, *prev, *end; - int count, here, type, lineno; - struct sh_arg { - char **v; - int c; - } arg[1]; - } *pipeline; - unsigned long refcount; - } **functions; - long funcslen; - - // runtime function call stack - struct sh_fcall { - struct sh_fcall *next, *prev; - - // This dlist in reverse order: TT.ff current function, TT.ff->prev globals - struct sh_vars { - long flags; - char *str; - } *vars; - long varslen, varscap, shift, oldlineno; - - struct sh_function *func; // TODO wire this up - struct sh_pipeline *pl; - char *ifs, *omnom; - struct sh_arg arg; - struct arg_list *delete; - - // Runtime stack of nested if/else/fi and for/do/done contexts. - struct sh_blockstack { - struct sh_blockstack *next; - struct sh_pipeline *start, *middle; - struct sh_process *pp; // list of processes piping in to us - int run, loop, *urd, pout, pipe; - struct sh_arg farg; // for/select arg stack, case wildcard deck - struct arg_list *fdelete; // farg's cleanup list - char *fvar; // for/select's iteration variable name - } *blk; - } *ff; - -// TODO ctrl-Z suspend should stop script - struct sh_process { - struct sh_process *next, *prev; // | && || - struct arg_list *delete; // expanded strings - // undo redirects, a=b at start, child PID, exit status, has !, job # - int *urd, envlen, pid, exit, flags, job, dash; - long long when; // when job backgrounded/suspended - struct sh_arg *raw, arg; - } *pp; // currently running process - - // job list, command line for $*, scratch space for do_wildcard_files() - struct sh_arg jobs, *wcdeck; -}; - -// toys/pending/strace.c - -struct strace_data { - long s, p; - - char ioctl[32], *fmt; - long regs[256/sizeof(long)], syscall; - pid_t pid; - int arg; -}; - -// toys/pending/stty.c - -struct stty_data { - char *F; - - int fd, col; - unsigned output_cols; -}; - -// toys/pending/sulogin.c - -struct sulogin_data { - long timeout; - struct termios crntio; -}; - -// toys/pending/syslogd.c - -struct syslogd_data { - char *socket; - char *config_file; - char *unix_socket; - char *logfile; - long interval; - long rot_size; - long rot_count; - char *remote_log; - long log_prio; - - struct unsocks *lsocks; // list of listen sockets - struct logfile *lfiles; // list of write logfiles - int sigfd[2]; -}; - -// toys/pending/tcpsvd.c - -struct tcpsvd_data { - char *l, *u, *C; - long b, c; - - int maxc; - int count_all; - int udp; -}; - -// toys/pending/telnet.c - -struct telnet_data { - int sock; - char buf[2048]; // Half sizeof(toybuf) allows a buffer full of IACs. - struct termios old_term; - struct termios raw_term; - uint8_t mode; - int echo, sga; - int state, request; -}; - -// toys/pending/telnetd.c - -struct telnetd_data { - char *login_path; - char *issue_path; - int port; - char *host_addr; - long w_sec; - - int gmax_fd; - pid_t fork_pid; -}; - -// toys/pending/tftp.c - -struct tftp_data { - char *local_file; - char *remote_file; - long block_size; - - struct sockaddr_storage inaddr; - int af; -}; - -// toys/pending/tftpd.c - -struct tftpd_data { - char *user; - - long sfd; - struct passwd *pw; -}; - -// toys/pending/tr.c - struct tr_data { short *map; int len1, len2; }; -// toys/pending/traceroute.c - -struct traceroute_data { - long max_ttl; - long port; - long ttl_probes; - char *src_ip; - long tos; - long wait_time; - struct arg_list *loose_source; - long pause_time; - long first_ttl; - char *iface; - - uint32_t gw_list[9]; - int recv_sock; - int snd_sock; - unsigned msg_len; - char *packet; - uint32_t ident; - int istraceroute6; -}; - -// toys/pending/useradd.c - -struct useradd_data { - char *dir; - char *gecos; - char *shell; - char *u_grp; - long uid; - - long gid; -}; - -// toys/pending/vi.c - -struct vi_data { - char *s; - - char *filename; - int vi_mode, tabstop, list; - int cur_col, cur_row, scr_row; - int drawn_row, drawn_col; - int count0, count1, vi_mov_flag; - unsigned screen_height, screen_width; - char vi_reg, *last_search; - struct str_line { - int alloc; - int len; - char *data; - } *il; - size_t screen, cursor; //offsets - //yank buffer - struct yank_buf { - char reg; - int alloc; - char* data; - } yank; - - size_t filesize; -// mem_block contains RO data that is either original file as mmap -// or heap allocated inserted data - struct block_list { - struct block_list *next, *prev; - struct mem_block { - size_t size; - size_t len; - enum alloc_flag { - MMAP, //can be munmap() before exit() - HEAP, //can be free() before exit() - STACK, //global or stack perhaps toybuf - } alloc; - const char *data; - } *node; - } *text; - -// slices do not contain actual allocated data but slices of data in mem_block -// when file is first opened it has only one slice. -// after inserting data into middle new mem_block is allocated for insert data -// and 3 slices are created, where first and last slice are pointing to original -// mem_block with offsets, and middle slice is pointing to newly allocated block -// When deleting, data is not freed but mem_blocks are sliced more such way that -// deleted data left between 2 slices - struct slice_list { - struct slice_list *next, *prev; - struct slice { - size_t len; - const char *data; - } *node; - } *slices; -}; - -// toys/posix/basename.c - struct basename_data { char *s; }; -// toys/posix/cal.c - -struct cal_data { - struct tm *now; -}; - -// toys/posix/chgrp.c - -struct chgrp_data { - uid_t owner; - gid_t group; - char *owner_name, *group_name; - int symfollow; -}; - -// toys/posix/chmod.c - struct chmod_data { char *mode; }; -// toys/posix/cmp.c - struct cmp_data { long n; @@ -1233,8 +115,6 @@ struct cmp_data { char *name; }; -// toys/posix/cp.c - struct cp_data { union { // install's options @@ -1255,14 +135,10 @@ struct cp_data { int pflags; }; -// toys/posix/cpio.c - struct cpio_data { char *F, *H, *R; }; -// toys/posix/cut.c - struct cut_data { char *d, *O; struct arg_list *select[5]; // we treat them the same, so loop through @@ -1272,32 +148,18 @@ struct cut_data { regex_t reg; }; -// toys/posix/date.c - struct date_data { char *s, *r, *I, *D, *d; unsigned nano; }; -// toys/posix/dd.c - struct dd_data { // Display fields int show_xfer, show_records; unsigned long long bytes, in_full, in_part, out_full, out_part, start; }; -// toys/posix/df.c - -struct df_data { - struct arg_list *t; - - int units, width[6]; -}; - -// toys/posix/du.c - struct du_data { long d; @@ -1306,29 +168,15 @@ struct du_data { void *inodes; }; -// toys/posix/env.c - struct env_data { struct arg_list *u; }; -// toys/posix/expand.c - -struct expand_data { - struct arg_list *t; - - unsigned tabcount, *tab; -}; - -// toys/posix/file.c - struct file_data { int max_name_len; off_t len; }; -// toys/posix/find.c - struct find_data { char **filter; struct double_list *argdata; @@ -1338,14 +186,6 @@ struct find_data { char *start; }; -// toys/posix/fold.c - -struct fold_data { - long w; -}; - -// toys/posix/grep.c - struct grep_data { long m, A, B, C; struct arg_list *f, *e, *M, *S, *exclude_dir; @@ -1357,51 +197,20 @@ struct grep_data { struct arg_list **fixed; }; -// toys/posix/head.c - struct head_data { long c, n; int file_no; }; -// toys/posix/iconv.c - -struct iconv_data { - char *f, *t; - - void *ic; -}; - -// toys/posix/id.c - struct id_data { int is_groups; }; -// toys/posix/kill.c - -struct kill_data { - char *s; - struct arg_list *o; -}; - -// toys/posix/ln.c - struct ln_data { char *t; }; -// toys/posix/logger.c - -struct logger_data { - char *p, *t; - - int priority; -}; - -// toys/posix/ls.c - struct ls_data { long w, l, block_size; char *color, *sort; @@ -1412,29 +221,10 @@ struct ls_data { char *escmore; }; -// toys/posix/mkdir.c - struct mkdir_data { char *m, *Z; }; -// toys/posix/mkfifo.c - -struct mkfifo_data { - char *m; - char *Z; - - mode_t mode; -}; - -// toys/posix/nice.c - -struct nice_data { - long n; -}; - -// toys/posix/nl.c - struct nl_data { char *s, *n, *b; long w, l, v; @@ -1443,8 +233,6 @@ struct nl_data { long lcount, slen; }; -// toys/posix/od.c - struct od_data { struct arg_list *t; char *A; @@ -1457,16 +245,12 @@ struct od_data { off_t pos; }; -// toys/posix/paste.c - struct paste_data { char *d; int files; }; -// toys/posix/patch.c - struct patch_data { char *i, *d; long v, p, g, F; @@ -1477,50 +261,6 @@ struct patch_data { char *tempname; }; -// toys/posix/ps.c - -struct ps_data { - union { - struct { - struct arg_list *G, *g, *U, *u, *t, *s, *p, *O, *o, *P, *k; - } ps; - struct { - long n, m, d, s; - struct arg_list *u, *p, *o, *k, *O; - } top; - struct { - char *L; - struct arg_list *G, *g, *P, *s, *t, *U, *u; - char *d; - - void *regexes, *snapshot; - int signal; - pid_t self, match; - } pgrep; - }; - - struct ps_ptr_len { - void *ptr; - long len; - } gg, GG, pp, PP, ss, tt, uu, UU; - struct dirtree *threadparent; - unsigned width, height, scroll; - dev_t tty; - void *fields, *kfields; - long long ticks, bits, time; - int kcount, forcek, sortpos, pidlen; - int (*match_process)(long long *slot); - void (*show_process)(void *tb); -}; - -// toys/posix/renice.c - -struct renice_data { - long n; -}; - -// toys/posix/sed.c - struct sed_data { char *i; struct arg_list *f, *e; @@ -1536,8 +276,6 @@ struct sed_data { char delim, xftype; }; -// toys/posix/sort.c - struct sort_data { char *t; struct arg_list *k; @@ -1548,23 +286,6 @@ struct sort_data { char **lines, *name; }; -// toys/posix/split.c - -struct split_data { - long n, l, b, a; - - char *outfile; -}; - -// toys/posix/strings.c - -struct strings_data { - long n; - char *t; -}; - -// toys/posix/tail.c - struct tail_data { long n, c; char *s; @@ -1578,8 +299,6 @@ struct tail_data { } *F; }; -// toys/posix/tar.c - struct tar_data { char *f, *C, *I; struct arg_list *T, *X, *xform; @@ -1613,47 +332,25 @@ struct tar_data { } hdr; }; -// toys/posix/tee.c - struct tee_data { void *outputs; int out; }; -// toys/posix/touch.c - struct touch_data { char *t, *r, *d; }; -// toys/posix/ulimit.c - -struct ulimit_data { - long P; -}; - -// toys/posix/uniq.c - struct uniq_data { long w, s, f; long repeats; }; -// toys/posix/uudecode.c - -struct uudecode_data { - char *o; -}; - -// toys/posix/wc.c - struct wc_data { - unsigned long totals[4]; + unsigned long totals[5]; }; -// toys/posix/xargs.c - struct xargs_data { long s, n, P; char *E; @@ -1662,134 +359,25 @@ struct xargs_data { char delim; FILE *tty; }; - extern union global_union { - struct log_data log; - struct demo_number_data demo_number; - struct hello_data hello; - struct skeleton_data skeleton; - struct dmesg_data dmesg; struct gzip_data gzip; struct hostname_data hostname; - struct killall_data killall; struct md5sum_data md5sum; - struct mknod_data mknod; struct mktemp_data mktemp; - struct mount_data mount; - struct passwd_data passwd; - struct pidof_data pidof; struct seq_data seq; - struct su_data su; - struct umount_data umount; - struct ftpget_data ftpget; - struct host_data host; - struct ifconfig_data ifconfig; struct microcom_data microcom; - struct netcat_data netcat; - struct netstat_data netstat; - struct ping_data ping; - struct sntp_data sntp; - struct tunctl_data tunctl; - struct wget_data wget; - struct base64_data base64; - struct blkdiscard_data blkdiscard; - struct blkid_data blkid; - struct blockdev_data blockdev; - struct chrt_data chrt; - struct count_data count; struct dos2unix_data dos2unix; - struct fallocate_data fallocate; - struct fmt_data fmt; - struct free_data free; - struct gpiod_data gpiod; - struct hexedit_data hexedit; - struct hwclock_data hwclock; - struct i2ctools_data i2ctools; - struct ionice_data ionice; - struct login_data login; - struct losetup_data losetup; - struct lsattr_data lsattr; - struct lsusb_data lsusb; - struct makedevs_data makedevs; - struct mix_data mix; - struct mkpasswd_data mkpasswd; - struct mkswap_data mkswap; - struct modinfo_data modinfo; - struct nbd_client_data nbd_client; - struct nsenter_data nsenter; - struct oneit_data oneit; - struct openvt_data openvt; - struct pwgen_data pwgen; - struct readelf_data readelf; - struct readlink_data readlink; - struct reboot_data reboot; - struct rtcwake_data rtcwake; - struct setfattr_data setfattr; + struct realpath_data realpath; struct setsid_data setsid; - struct sha3sum_data sha3sum; - struct shred_data shred; - struct shuf_data shuf; struct stat_data stat; - struct swapon_data swapon; - struct switch_root_data switch_root; - struct tac_data tac; struct timeout_data timeout; struct truncate_data truncate; - struct uclampset_data uclampset; - struct watch_data watch; - struct watchdog_data watchdog; struct xxd_data xxd; - struct arp_data arp; - struct arping_data arping; - struct bc_data bc; - struct bootchartd_data bootchartd; - struct brctl_data brctl; - struct chsh_data chsh; - struct crond_data crond; - struct crontab_data crontab; - struct csplit_data csplit; - struct dhcp_data dhcp; - struct dhcp6_data dhcp6; - struct dhcpd_data dhcpd; struct diff_data diff; - struct dumpleases_data dumpleases; struct expr_data expr; - struct fdisk_data fdisk; - struct fsck_data fsck; - struct getfattr_data getfattr; struct getopt_data getopt; - struct getty_data getty; - struct git_data git; - struct groupadd_data groupadd; - struct hexdump_data hexdump; - struct ip_data ip; - struct ipcrm_data ipcrm; - struct ipcs_data ipcs; - struct klogd_data klogd; - struct last_data last; - struct lsof_data lsof; - struct man_data man; - struct mke2fs_data mke2fs; - struct modprobe_data modprobe; - struct more_data more; - struct route_data route; - struct sh_data sh; - struct strace_data strace; - struct stty_data stty; - struct sulogin_data sulogin; - struct syslogd_data syslogd; - struct tcpsvd_data tcpsvd; - struct telnet_data telnet; - struct telnetd_data telnetd; - struct tftp_data tftp; - struct tftpd_data tftpd; struct tr_data tr; - struct traceroute_data traceroute; - struct useradd_data useradd; - struct vi_data vi; struct basename_data basename; - struct cal_data cal; - struct chgrp_data chgrp; struct chmod_data chmod; struct cmp_data cmp; struct cp_data cp; @@ -1797,41 +385,27 @@ extern union global_union { struct cut_data cut; struct date_data date; struct dd_data dd; - struct df_data df; struct du_data du; struct env_data env; - struct expand_data expand; struct file_data file; struct find_data find; - struct fold_data fold; struct grep_data grep; struct head_data head; - struct iconv_data iconv; struct id_data id; - struct kill_data kill; struct ln_data ln; - struct logger_data logger; struct ls_data ls; struct mkdir_data mkdir; - struct mkfifo_data mkfifo; - struct nice_data nice; struct nl_data nl; struct od_data od; struct paste_data paste; struct patch_data patch; - struct ps_data ps; - struct renice_data renice; struct sed_data sed; struct sort_data sort; - struct split_data split; - struct strings_data strings; struct tail_data tail; struct tar_data tar; struct tee_data tee; struct touch_data touch; - struct ulimit_data ulimit; struct uniq_data uniq; - struct uudecode_data uudecode; struct wc_data wc; struct xargs_data xargs; } this; diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h index 2274125a..319227d0 100644 --- a/android/mac/generated/help.h +++ b/android/mac/generated/help.h @@ -522,7 +522,7 @@ #define HELP_who "usage: who\n\nPrint information about logged in users." -#define HELP_wc "usage: wc [-lwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." +#define HELP_wc "usage: wc [-Llwcm] [FILE...]\n\nCount lines, words, and characters in input.\n\n-L Show max line length\n-l Show lines\n-w Show words\n-c Show bytes\n-m Show characters\n\nBy default outputs lines, words, bytes, and filename for each\nargument (or from stdin if none). Displays only either bytes\nor characters." #define HELP_uuencode "usage: uuencode [-m] [INFILE] ENCODE_FILENAME\n\nUuencode stdin (or INFILE) to stdout, with ENCODE_FILENAME in the output.\n\n-m Base64" diff --git a/android/mac/generated/newtoys.h b/android/mac/generated/newtoys.h index a4bf4c24..fa6fa62b 100644 --- a/android/mac/generated/newtoys.h +++ b/android/mac/generated/newtoys.h @@ -335,7 +335,7 @@ USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) USE_SH(NEWTOY(wait, "n", TOYFLAG_NOFORK)) USE_WATCH(NEWTOY(watch, "^<1n%<100=2000tebx", TOYFLAG_USR|TOYFLAG_BIN)) USE_WATCHDOG(NEWTOY(watchdog, "<1>1Ft#=4<1T#=60<1", TOYFLAG_NEEDROOT|TOYFLAG_SBIN)) -USE_WC(NEWTOY(wc, "mcwl", TOYFLAG_USR|TOYFLAG_BIN)) +USE_WC(NEWTOY(wc, "Lcmwl", TOYFLAG_USR|TOYFLAG_BIN)) USE_WGET(NEWTOY(wget, "<1>1(max-redirect)#<0=20d(debug)O(output-document):p(post-data):", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHICH(NEWTOY(which, "<1a", TOYFLAG_USR|TOYFLAG_BIN)) USE_WHO(NEWTOY(who, "a", TOYFLAG_USR|TOYFLAG_BIN)) diff --git a/lib/deflate.c b/lib/deflate.c index 12263f7a..c1800750 100644 --- a/lib/deflate.c +++ b/lib/deflate.c @@ -466,7 +466,7 @@ long long gzip_fd(int infd, int outfd) // 2 ID bytes (1F, 8b), gzip method byte (8=deflate), FLAG byte (none), // 4 byte MTIME (zeroed), Extra Flags (2=maximum compression), // Operating System (FF=unknown) - + dd->infd = infd; xwrite(bb->fd, "\x1f\x8b\x08\0\0\0\0\0\x02\xff", 10); @@ -389,6 +389,6 @@ void hash_by_name(int fd, char *name, char *result) // by looping on a volatile pointer. for (pp = (void *)hash; pp-(unsigned *)hash<sizeof(*hash)/4; pp++) *pp = 0; for (pp = (void *)libbuf; pp-(unsigned *)libbuf<sizeof(libbuf)/4; pp++) - *pp = 0; + *pp = 0; } #endif @@ -97,7 +97,7 @@ int draw_trim_esc(char *str, int padto, int width, char *escmore, if (padto>=0 && len>width) str += utf8skip(str, len-width); if (len>width) len = width; - // Left pad if right justified + // Left pad if right justified if (padto>0 && apad>len) printf("%*s", apad-len, ""); crunch_str(&str, len, stdout, 0, crunch_rev_escape); if (padto<0 && apad>len) printf("%*s", apad-len, ""); diff --git a/mkroot/packages/busybox b/mkroot/packages/busybox index b1e9e4f7..d3594d41 100755 --- a/mkroot/packages/busybox +++ b/mkroot/packages/busybox @@ -1,4 +1,4 @@ -#!/bin/echo Try "scripts/mkroot.sh dropbear" +#!/bin/echo Try "scripts/mkroot.sh busybox" download a5d40ca0201b20909f7a8a561adf57adccc8a877 \ http://www.busybox.net/downloads/busybox-1.36.1.tar.bz2 diff --git a/scripts/make.sh b/scripts/make.sh index d659e739..3a5d0826 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -154,7 +154,7 @@ fi # Rebuild config.h from .config $SED -En $KCONFIG_CONFIG > "$GENDIR"/config.h \ -e 's/^# CONFIG_(.*) is not set.*/#define CFG_\1 0\n#define USE_\1(...)/p' \ - -e 's/^CONFIG_(.*)=y.*/#define CFG_\1 1\n#define USE_\1(...) __VA_ARGS__\n/p'\ + -e 's/^CONFIG_(.*)=y.*/#define CFG_\1 1\n#define USE_\1(...) __VA_ARGS__/p'\ || exit 1 # Process config.h and newtoys.h to generate FLAG_x macros. Note we must @@ -204,30 +204,18 @@ fi # Extract global structure definitions and flag definitions from toys/*/*.c -function getglobals() { - for i in toys/*/*.c - do - NAME=${i##*/} NAME=${NAME%\.c} - DATA="$($SED -n -e '/^GLOBALS(/,/^)/b got;b;:got' \ - -e 's/^GLOBALS(/_data {/' \ - -e 's/^)/};/' -e 'p' $i)" - [ -n "$DATA" ] && echo -e "// $i\n\nstruct $NAME$DATA\n" - done -} - -if isnewer globals.h toys -then - GLOBSTRUCT="$(getglobals)" - ( - echo "$GLOBSTRUCT" - echo - echo "extern union global_union {" - echo "$GLOBSTRUCT" | \ - $SED -n 's/struct \(.*\)_data {/ struct \1_data \1;/p' - echo "} this;" - ) > "$GENDIR"/globals.h -fi + STRUX="$($SED -ne 's/^#define[ \t]*FOR_\([^ \t]*\).*/\1/;T s1;h;:s1' \ + -e '/^GLOBALS(/,/^)/{s/^GLOBALS(//;T s2;g;s/.*/struct &_data {/;:s2;s/^)/};\n/;p}' \ + $TOYFILES)" + echo "$STRUX" && + echo "extern union global_union {" && + $SED -n 's/^struct \(.*\)_data .*/\1/;T;s/.*/\tstruct &_data &;/p' \ + <<<"$STRUX" && + echo "} this;" +} > "$GENDIR"/globals.h || exit 1 +# -e 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/;H;g;s/\n/ /'\ +# -e 's/\([^ ]*\) \(.*\)/\tUSE_\2(struct \1_data \1;)/p')" hostcomp mktags if isnewer tags.h toys diff --git a/scripts/single.sh b/scripts/single.sh index f4f28be9..e2ed9880 100755 --- a/scripts/single.sh +++ b/scripts/single.sh @@ -35,10 +35,11 @@ do make allnoconfig > /dev/null || exit 1 + # For the shell pull in MAYFORK commands from other source files as builtins. unset DEPENDS MPDEL if [ "$i" == sh ] then - DEPENDS="$($SED -n 's/USE_\([^(]*\)(NEWTOY([^,]*,.*TOYFLAG_MAYFORK.*/\1/p' toys/*/*.c)" + DEPENDS="$($SED -n 's/USE_\([^(]*\)(...TOY([^,]*,.*TOYFLAG_MAYFORK.*/\1/p' toys/*/*.c)" else MPDEL='s/CONFIG_TOYBOX=y/# CONFIG_TOYBOX is not set/;t' fi diff --git a/tests/getfattr.test b/tests/getfattr.test index ae33d766..2bec8354 100644 --- a/tests/getfattr.test +++ b/tests/getfattr.test @@ -4,22 +4,27 @@ #testing "name" "command" "result" "infile" "stdin" +function clean() +{ + # The filesystem may include some extended attributes by default (for + # instance, security.selinux). Skip them. + grep -v "security\." +} + mkdir attrs touch attrs/file setfattr -n user.empty attrs/file setfattr -n user.data -v hello attrs/file setfattr -n user.more -v world attrs/file -testing "" "getfattr attrs/file" \ +testing "" "getfattr attrs/file | clean" \ "# file: attrs/file\nuser.data\nuser.empty\nuser.more\n\n" "" "" -testing "-d" "getfattr -d attrs/file" \ +testing "-d" "getfattr -d attrs/file | clean" \ "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.more=\"world\"\n\n" "" "" testing "-n" "getfattr -n user.empty attrs/file" \ "# file: attrs/file\nuser.empty\n\n" "" "" testing "-d -n" "getfattr -d -n user.data attrs/file" \ "# file: attrs/file\nuser.data=\"hello\"\n\n" "" "" -testing "--only-values" "getfattr --only-values attrs/file" \ - "helloworld" "" "" testing "--only-values -n" "getfattr --only-values -n user.data attrs/file" \ "hello" "" "" diff --git a/tests/grep.test b/tests/grep.test index 74a598ee..64ca105b 100755 --- a/tests/grep.test +++ b/tests/grep.test @@ -242,3 +242,6 @@ testcmd 'middle ^ not special' 'a^' 'a^b\n' '' 'a^b\nb^a\n' testcmd 'middle $ not special' "'\$b'" 'a$b\n' '' 'a$b\nb$a\n' testcmd 'grep -of' '-of input' 'abc\n' 'a.c\n' 'abcdef\n' + +testcmd '-A with -m' '-A1 -m2 match' 'match\n1\nmatch\n2\n' '' \ + 'match\n1\nmatch\n2\nmatch\n3\n' diff --git a/tests/nbd-client.test b/tests/nbd-client.test new file mode 100755 index 00000000..f6600c30 --- /dev/null +++ b/tests/nbd-client.test @@ -0,0 +1,65 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +if [ "$(id -u)" -ne 0 ] +then + echo "$SHOWSKIP: nbd-client (not root)" + return 2>/dev/null + exit +fi + +# Test filesystem images + +# truncate -s256k ext2.img; mke2fs ext2.img; bzip2 < ext2.img | base64 +base64 -d | bzcat > ext2.img << EOF +QlpoOTFBWSZTWbBa6EkAABn//////0BEGVhI8AFKBR1FzqBiBACiQgFgAEgAAhVAZ4QMsAEYJEFN +I0AA0AAAABoGgAGmg2ppkHMJoDQGjRhGgxGmJkxNBhGgZAMmAkiSamj0I9BMmmmEaAAAANADQGmI +Vsb7iiy5kJkdeO7Nijja84iwwpZrgb1C54RIVpgQISiSGEk87UjHU9lMEUdeBNZVp2dNZqlfPsaF +m1bufdAsy3r0SJadGCGluQKTCBABVYyGSUjCNaq4AABbuvG2UToQVhiJkSMCCV3QCADJbdvuYpjo +vsnYkYkIFnzihj/ICWNlSoOYMLqmT3wO4C5ZCEAztpmAFCV0rUUwIgcB45oB+8iI/vtvYqkkWU7T +QiPrkylDZYYRPFZQUFGmgRAFgwEygDC+o7xtv26GOcRFYzdlo2G5i0Yg1WxsQYQJJJhfrCP6DgGA +VSH+LuSKcKEhYLXQkg== +EOF + +tuncate -s360k fat.img; mkfs.fat fat.img; bzip2 < fat.img | base64 +base64 -d | bzcat > fat.img << EOF +QlpoOTFBWSZTWRzu2ngAC6j/v/C7YaDQITAEIwPHCTfv3CRAQAAUBAlAAkAABAhAC7AAu2oampqP +SMgAGmmgAAM1AaZGE8oNU8lPU2piDQBoADQAGgaHpPUaBlIjaQAaAGgA0yaaMJk0Bo0KfAsgEkgE +j8EGgCSAQSEwpVSi2ik+oAQCC0FJOUzrkxZikHndRLY4URVk3SAv4kdIUvCMR7xxaNBFDI63CTTL ++9TioH4KEDXJDB1p4/uaA4CiIOROg4eLOL5FJBAk24CR6KFRyRLEdFnt1RnVbD9PKNZduYsKfdFB +5xE1ErWAhXDDdJmXHoknmTLMhczHhSlJogGAMDGDxLOsTj+LuSKcKEgOd208AA== +EOF + + + +dd if= +testcmd " + +echo "one" > file1 +echo "two" > file2 +testing "cat" "cat && echo yes" "oneyes\n" "" "one" +testing "-" "cat - && echo yes" "oneyes\n" "" "one" +testing "file1 file2" "cat file1 file2" "one\ntwo\n" "" "" +testing "- file" "cat - file1" "zero\none\n" "" "zero\n" +testing "file -" "cat file1 -" "one\nzero\n" "" "zero\n" + +testing "file1 notfound file2" \ + "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \ + "one\ntwo\ncat: notfound: No such file or directory\n" "" "" + +testing "binary" \ + 'cat "$C" > file1 && cmp "$C" file1 && echo yes' "yes\n" "" "" + +testing "- file1" \ + "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \ + "-hello\n" "" "hello\n" + +skipnot [ -e /dev/full ] +testing "> /dev/full" \ + "cat - > /dev/full 2>/dev/null || echo failed" \ + "failed\n" "" "zero\n" + +rm file1 file2 diff --git a/tests/setfattr.test b/tests/setfattr.test index 6a044ea2..58801b0e 100644 --- a/tests/setfattr.test +++ b/tests/setfattr.test @@ -4,6 +4,13 @@ #testing "name" "command" "result" "infile" "stdin" +function clean() +{ + # The filesystem may include some extended attributes by default (for + # instance, security.selinux). Skip them. + grep -v "security\." +} + mkdir attrs touch attrs/file setfattr -n user.empty attrs/file @@ -11,11 +18,11 @@ setfattr -n user.data -v hello attrs/file setfattr -n user.delete-me -v hello attrs/file testing "-x" \ - "setfattr -x user.delete-me attrs/file && getfattr attrs/file" \ + "setfattr -x user.delete-me attrs/file && getfattr attrs/file | clean" \ "# file: attrs/file\nuser.data\nuser.empty\n\n" "" "" -testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file" \ +testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file | clean" \ "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new\n\n" "" "" -testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file" \ +testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file | clean" \ "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new=\"data\"\n\n" "" "" rm -rf attrs diff --git a/tests/wc.test b/tests/wc.test index 66cf48be..966114cf 100755 --- a/tests/wc.test +++ b/tests/wc.test @@ -13,23 +13,41 @@ some lines EOF -testing "wc" "wc >/dev/null && echo yes" "yes\n" "" "" -testing "empty file" "wc" " 0 0 0\n" "" "" -testing "standard input" "wc" " 1 3 5\n" "" "a b\nc" -testing "standard input -c" "wc -c" "5\n" "" "a b\nc" -testing "standard input -cl" "wc -cl" " 1 5\n" "" "a b\nc" -testing "-c" "wc -c file1" "26 file1\n" "" "" -testing "-l" "wc -l file1" "4 file1\n" "" "" -testing "-w" "wc -w file1" "5 file1\n" "" "" -NOSPACE=1 testing "one file" "wc file1" "4 5 26 file1\n" "" "" -testing "multiple files" "wc input - file1" \ +testcmd "wc" ">/dev/null && echo yes" "yes\n" "" "" +testcmd "empty file" "" " 0 0 0\n" "" "" +testcmd "standard input" "" " 1 3 5\n" "" "a b\nc" +testcmd "standard input -c" "-c" "5\n" "" "a b\nc" +testcmd "standard input -cl" "-cl" " 1 5\n" "" "a b\nc" +testcmd "-c" "-c file1" "26 file1\n" "" "" +testcmd "-l" "-l file1" "4 file1\n" "" "" +testcmd "-w" "-w file1" "5 file1\n" "" "" +testcmd "-L" "-L file1" "18 file1\n" "" "" +NOSPACE=1 testcmd "one file" "file1" "4 5 26 file1\n" "" "" +testcmd "multiple files" "input - file1" \ " 1 2 3 input\n 0 2 3 -\n 4 5 26 file1\n 5 9 32 total\n" "a\nb" "a b" #Tests for wc -m echo -n " " > file1 for i in $(seq 1 512); do echo -n "üüüüüüüüüüüüüüüü" >> file1; done -testing "-m" "wc -m file1" "8193 file1\n" "" "" +testcmd "-m" "-m file1" "8193 file1\n" "" "" testing "-m 2" 'cat "$FILES/utf8/test2.txt" | wc -m' "169\n" "" "" echo -n " " > file1 -NOSPACE=1 testing "-mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" "" +NOSPACE=1 testcmd "-mlw" "-mlw input" "1 2 11 input\n" "hello, 世界!\n" "" rm file1 + +# Corner cases for "line length". Not QUITE fold because \b doesn't subtract + +testcmd '-L 2' '-L' '1\n' '' 'a\n' +testcmd '-L 3' '-L' '1\n' '' 'a' +testcmd '-L 4' '-L' '6\n' '' 'first\rsecond\n' +testcmd '-L 5' '-L' '9\n' '' '\ta\n' +testcmd '-L 6' '-L' '8\n' '' '\t\b\b\b\n' +testcmd '-L 7' '-L' '9\n' '' 'abc\td\n' +testcmd '-L 8' '-L' '4\n' '' 'abc\bd\n' +testcmd '-L 9' '-L' '0\n' '' '\x01\n' +testcmd '-L 10' '-L' '1\n' '' 'w\xcc\x88\n' +NOSPACE=1 testcmd '-Lm incoherence' '-Lm' '2 0\n' '' '\x01\n' + +# 25 wide chars, also testing field order +NOSPACE=1 testcmd '-cmlLw wide' '-cmlLw' '0 1 25 75 50\n' '' \ + "$(<"$FILES"/utf8/japan.txt)" diff --git a/tests/xargs.test b/tests/xargs.test index 7566e375..20a03187 100644 --- a/tests/xargs.test +++ b/tests/xargs.test @@ -86,3 +86,7 @@ testing "parallel sleep" " #testing "-s impossible" testing "no stdin" "echo -n | xargs cat" "" "" "" + +testing "exit 255 aborts" \ + "xargs -n1 sh -c 'echo \$1; exit \$1' blah 2>/dev/null" '123\n234\n255\n' \ + '' '123\n234\n255\n42\n99\n' diff --git a/toys/android/sendevent.c b/toys/android/sendevent.c index 8e982e0b..b952d192 100644 --- a/toys/android/sendevent.c +++ b/toys/android/sendevent.c @@ -27,7 +27,7 @@ void sendevent_main(void) if (ioctl(fd, EVIOCGVERSION, &version)) perror_exit("EVIOCGVERSION failed for %s", *toys.optargs); - + memset(&ev, 0, sizeof(ev)); // TODO: error checking and support for named constants. ev.type = atoi(toys.optargs[1]); diff --git a/toys/lsb/mount.c b/toys/lsb/mount.c index 109f6e19..9fbd432c 100644 --- a/toys/lsb/mount.c +++ b/toys/lsb/mount.c @@ -349,7 +349,7 @@ void mount_main(void) for (mmm = mtl2; mmm; mmm = mmm->next) if (!strcmp(mm->dir, mmm->dir) && !strcmp(mm->device, mmm->device)) break; - + // user only counts from fstab, not opts. if (!mmm) { TT.okuser = comma_scan(mm->opts, "user", 1); diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c index b44d05c6..e73d70fc 100644 --- a/toys/lsb/seq.c +++ b/toys/lsb/seq.c @@ -55,7 +55,7 @@ static double parsef(char *s) static char *flush_toybuf(char *ss) { if (ss-toybuf<TT.buflen) return ss; - xwrite(1, toybuf, ss-toybuf); + xwrite(1, toybuf, ss-toybuf); return toybuf; } diff --git a/toys/lsb/umount.c b/toys/lsb/umount.c index fbaa8e42..19fd5274 100644 --- a/toys/lsb/umount.c +++ b/toys/lsb/umount.c @@ -61,7 +61,7 @@ static void do_umount(char *dir, char *dev, int flags) if (!strcmp(mt->dir, dir)) while ((s = comma_iterate(&mt->opts, &len))) { if (len == 4 && strncmp(s, "user", 4)) user = 1; - else if (len == 6 && strncmp(s, "nouser", 6)) user = 0; + else if (len == 6 && strncmp(s, "nouser", 6)) user = 0; } mt = mt->next; @@ -125,7 +125,7 @@ void umount_main(void) if (toys.optflags & FLAG_a) { char *typestr = 0; struct arg_list *tal; - + for (tal = TT.t; tal; tal = tal->next) comma_collate(&typestr, tal->arg); for (ml = mlrev; ml; ml = ml->prev) if (mountlist_istype(ml, typestr)) do_umount(ml->dir, ml->device, flags); diff --git a/toys/net/host.c b/toys/net/host.c index f8e54dcc..4082a8f3 100644 --- a/toys/net/host.c +++ b/toys/net/host.c @@ -142,7 +142,7 @@ void host_main(void) qlen = 0; for (sec = 0; sec<(2<<verbose); sec++) { count = peek_be(abuf+4+2*sec, 2); - if (verbose && count>0 && sec>1) + if (verbose && count>0 && sec>1) puts(sec==2 ? "For authoritative answers, see:" : "Additional information:"); @@ -162,7 +162,7 @@ void host_main(void) else if (type==2 || type==5) xdn_expand(abuf, abuf+alen, p, t2, t2len); else if (type==13 || type==16) sprintf(t2, "\"%.*s\"", minof(pllen, t2len), p); - else if (type==6) { + else if (type==6) { ss = p+xdn_expand(abuf, abuf+alen, p, t2, t2len-1); j = strlen(t2); t2[j++] = ' '; diff --git a/toys/net/ifconfig.c b/toys/net/ifconfig.c index 63e7a0ae..632d15dd 100644 --- a/toys/net/ifconfig.c +++ b/toys/net/ifconfig.c @@ -210,7 +210,7 @@ static void display_ifconfig(char *name, int always, unsigned long long val[]) char *ptr = ipv6_addr+sizeof(ipv6_addr)-1; // convert giant hex string into colon-spearated ipv6 address by - // inserting ':' every 4 characters. + // inserting ':' every 4 characters. for (i = 32; i; i--) if ((*(ptr--) = ipv6_addr[i])) if (!(i&3)) *(ptr--) = ':'; @@ -447,7 +447,7 @@ void ifconfig_main(void) if (*hw_addr == ':') hw_addr++; sscanf(hw_addr, "%2x%n", &val, &len); - if (!len || len > 2) break; // 1 nibble can be set e.g. C2:79:38:95:D:A + if (!len || len > 2) break; // 1 nibble can be set e.g. C2:79:38:95:D:A hw_addr += len; *p++ = val; } diff --git a/toys/net/ping.c b/toys/net/ping.c index e7b296db..4237d8a9 100644 --- a/toys/net/ping.c +++ b/toys/net/ping.c @@ -13,7 +13,7 @@ // -s > 4064 = sizeof(toybuf)-sizeof(struct icmphdr)-CMSG_SPACE(sizeof(uint8_t)), then kernel adds 20 bytes USE_PING(NEWTOY(ping, "<1>1m#t#<0>255=64c#<0=3s#<0>4064=56i%W#<0=3w#<0qf46I:[-46]", TOYFLAG_USR|TOYFLAG_BIN)) USE_PING(OLDTOY(ping6, ping, TOYFLAG_USR|TOYFLAG_BIN)) - + config PING bool "ping" default y @@ -40,7 +40,7 @@ config PING -w SEC Exit after this many seconds */ -#define FOR_ping +#define FOR_ping #include "toys.h" #include <ifaddrs.h> diff --git a/toys/net/sntp.c b/toys/net/sntp.c index 4a216df4..2f9822b4 100644 --- a/toys/net/sntp.c +++ b/toys/net/sntp.c @@ -184,7 +184,7 @@ void sntp_main(void) // generating second request. (We know this time is in the past // because transmission took time, but it's a start. And if time is // miraculously exact, don't loop.) - + lunchtime(&tv2, diff); diff = nanodiff(&tv, &tv2); if (unset && diff) break; diff --git a/toys/net/tunctl.c b/toys/net/tunctl.c index 12855708..b18306f0 100644 --- a/toys/net/tunctl.c +++ b/toys/net/tunctl.c @@ -7,7 +7,7 @@ * This is useful for things like "kvm -netdev tap" and containers. * See https://landley.net/lxc/02-networking.html for example usage. * - * TODO: bridge mode + * TODO: bridge mode * -b bridge daemon (forwards packets between NAME and NAME2 interfaces) diff --git a/toys/other/acpi.c b/toys/other/acpi.c index 193ac28a..63553ce0 100644 --- a/toys/other/acpi.c +++ b/toys/other/acpi.c @@ -11,7 +11,7 @@ config ACPI default y help usage: acpi [-abctV] - + Show status of power sources and thermal devices. -a Show power adapters diff --git a/toys/other/fsfreeze.c b/toys/other/fsfreeze.c index ee7bd530..84188d34 100644 --- a/toys/other/fsfreeze.c +++ b/toys/other/fsfreeze.c @@ -22,7 +22,7 @@ config FSFREEZE void fsfreeze_main(void) { - int fd = xopenro(*toys.optargs); + int fd = xopenro(*toys.optargs); long p = 1; xioctl(fd, FLAG(f) ? FIFREEZE : FITHAW, &p); diff --git a/toys/other/gpiod.c b/toys/other/gpiod.c index e80452f8..3abdbc0c 100644 --- a/toys/other/gpiod.c +++ b/toys/other/gpiod.c @@ -58,7 +58,6 @@ config GPIOSET */ #define FOR_gpiodetect -#define TT this.gpiod #include "toys.h" GLOBALS( diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c index eaec842e..4087ec93 100644 --- a/toys/other/hwclock.c +++ b/toys/other/hwclock.c @@ -63,7 +63,7 @@ void hwclock_main() 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. + * 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); diff --git a/toys/other/i2ctools.c b/toys/other/i2ctools.c index 21317a12..fc905ea0 100644 --- a/toys/other/i2ctools.c +++ b/toys/other/i2ctools.c @@ -88,7 +88,6 @@ config I2CTRANSFER #define FOR_i2cdetect #define FORCE_FLAGS -#define TT this.i2ctools #include "toys.h" GLOBALS( diff --git a/toys/other/inotifyd.c b/toys/other/inotifyd.c index 42d1d76e..3dc66025 100644 --- a/toys/other/inotifyd.c +++ b/toys/other/inotifyd.c @@ -1,4 +1,4 @@ -/* inotifyd.c - inotify daemon. +/* inotifyd.c - inotify daemon. * * Copyright 2013 Ashwini Kumar <ak.ashwini1981@gmail.com> * Copyright 2013 Kyungwan Han <asura321@gmail.com> diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index 600858bb..6bbfe0df 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -128,7 +128,7 @@ struct dev_ids *parse_dev_ids(char *name, struct dev_ids **and) else if (s) fd = xopen(s, O_RDONLY); llist_traverse(sl, free); if (fd == -1) return 0; - + for (fp = fdopen(fd, "r"); (s = ss = xgetline(fp)); free(s)) { // TODO parse and use third level instead of skipping it here if (s[strspn(s, " \t")]=='#' || strstart(&ss, "\t\t")) continue; diff --git a/toys/other/makedevs.c b/toys/other/makedevs.c index 4edd0737..009b3ed9 100644 --- a/toys/other/makedevs.c +++ b/toys/other/makedevs.c @@ -4,7 +4,7 @@ * Copyright 2014 Kyungwan Han <asura321@gmail.com> * * No Standard - + USE_MAKEDEVS(NEWTOY(makedevs, "<1>1d:", TOYFLAG_USR|TOYFLAG_BIN)) config MAKEDEVS diff --git a/toys/other/mkpasswd.c b/toys/other/mkpasswd.c index 66d05a7d..9f895075 100644 --- a/toys/other/mkpasswd.c +++ b/toys/other/mkpasswd.c @@ -65,7 +65,7 @@ void mkpasswd_main(void) if (!*toys.optargs) { // Prompt and read interactively? if (isatty(0)) { - if (read_password(toybuf, sizeof(toybuf), "Password: ")) + if (read_password(toybuf, sizeof(toybuf), "Password: ")) perror_exit("password read failed"); } else { for (ii = 0; ii<sizeof(toybuf)-1; ii++) { diff --git a/toys/other/partprobe.c b/toys/other/partprobe.c index 5c44cb3f..69e66431 100644 --- a/toys/other/partprobe.c +++ b/toys/other/partprobe.c @@ -26,5 +26,5 @@ static void do_partprobe(int fd, char *name) void partprobe_main(void) { - loopfiles(toys.optargs, do_partprobe); + loopfiles(toys.optargs, do_partprobe); } diff --git a/toys/other/pwdx.c b/toys/other/pwdx.c index 2a72dba3..9875af9a 100644 --- a/toys/other/pwdx.c +++ b/toys/other/pwdx.c @@ -1,4 +1,4 @@ -/* pwdx.c - report current directory of a process. +/* pwdx.c - report current directory of a process. * * Copyright 2013 Lukasz Skalski <l.skalski@partner.samsung.com> diff --git a/toys/other/readelf.c b/toys/other/readelf.c index 15e5e7d7..19387360 100644 --- a/toys/other/readelf.c +++ b/toys/other/readelf.c @@ -424,6 +424,8 @@ static void show_notes(unsigned long offset, unsigned long size) if (type == 1) { printf("NT_VERSION\tAPI level %u", elf_int(&p)), j=1; if (descsz>=132) printf(", NDK %.64s (%.64s)", p, p+64); + } else if (type == 5) { + printf("NT_PAD_SEGMENT\tpad_segment=%u", elf_int(&p)), j=1; } else p -= 8; } else if (notematch(namesz, &p, "CORE")) { if (*(desc = nt_type_core(type)) != '0') printf("%s", desc), j=1; diff --git a/toys/other/readlink.c b/toys/other/readlink.c index 6a64eca5..fb4460de 100644 --- a/toys/other/readlink.c +++ b/toys/other/readlink.c @@ -43,7 +43,6 @@ config REALPATH #define FOR_realpath #define FORCE_FLAGS -#define TT this.readlink // workaround: first FOR_ doesn't match filename #include "toys.h" GLOBALS( diff --git a/toys/other/switch_root.c b/toys/other/switch_root.c index d3fd3728..1c750608 100644 --- a/toys/other/switch_root.c +++ b/toys/other/switch_root.c @@ -93,7 +93,7 @@ void switch_root_main(void) perror_msg("bad console '%s'", TT.c); goto panic; } - + // Ok, enough safety checks: wipe root partition. dirtree_read("/", del_node); diff --git a/toys/other/sysctl.c b/toys/other/sysctl.c index 37735942..2d79176f 100644 --- a/toys/other/sysctl.c +++ b/toys/other/sysctl.c @@ -4,7 +4,7 @@ * Copyright 2014 Kyungwan Han <asura321@gmail.com> * * No Standard - + USE_SYSCTL(NEWTOY(sysctl, "^neNqwpaA[!ap][!aq][!aw][+aA]", TOYFLAG_SBIN)) config SYSCTL diff --git a/toys/other/watch.c b/toys/other/watch.c index f8f3dfb1..14048d85 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -106,8 +106,8 @@ void watch_main(void) // Get and measure time string, trimming gratuitous \n ctimelen = strlen(ss = ctime(&t)); if (ss[ctimelen-1]=='\n') ss[--ctimelen] = 0; - - // print cmdline, then * or ' ' (showing truncation), then ctime + + // print cmdline, then * or ' ' (showing truncation), then ctime pad = width-++ctimelen; if (pad>0) draw_trim(cmd, -pad, pad); printf("%c", pad<cmdlen ? '*' : ' '); diff --git a/toys/pending/arp.c b/toys/pending/arp.c index 5f7c4a1f..dd54441d 100644 --- a/toys/pending/arp.c +++ b/toys/pending/arp.c @@ -106,9 +106,9 @@ static void check_flags(int *i, char** argv) {"temp", 0, ~ATF_PERM}, {"dontpub",1, ATF_DONTPUB}, }; - + for (;*argv; argv++) { - for (j = 0; j < ARRAY_LEN(f); j++) { + for (j = 0; j < ARRAY_LEN(f); j++) { if (!strcmp(*argv, f[j].name)) { (f[j].or) ?(flag |= f[j].flag):(flag &= f[j].flag); break; @@ -120,7 +120,7 @@ static void check_flags(int *i, char** argv) resolve_host(toys.optargs[0], &sa); memcpy(&req.arp_netmask, &sa, sizeof(sa)); flag |= ATF_NETMASK; - } else argv++; + } else argv++; } else if (j > 4 && !strcmp(*argv, "dev")) { if (!*++argv) error_exit("NULL dev"); TT.device = *argv; @@ -129,10 +129,10 @@ static void check_flags(int *i, char** argv) *i = flag; } -static int set_entry(void) +static int set_entry(void) { int flags = 0; - + if (!toys.optargs[1]) error_exit("bad syntax"); if (!FLAG(D)) { @@ -173,11 +173,11 @@ static int set_entry(void) static int ip_to_host(struct sockaddr *sa, int flag) { int status = 0; - char hbuf[NI_MAXHOST] = {0,}, sbuf[NI_MAXSERV] = {0,}; + char hbuf[NI_MAXHOST] = {0,}, sbuf[NI_MAXSERV] = {0,}; socklen_t len = sizeof(struct sockaddr_in6); - + *toybuf = 0; - if (!(status = getnameinfo(sa, len, hbuf, sizeof(hbuf), sbuf, + if (!(status = getnameinfo(sa, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), flag))) { strcpy(toybuf, hbuf); return 0; diff --git a/toys/pending/arping.c b/toys/pending/arping.c index 68ee5eac..aae7161d 100644 --- a/toys/pending/arping.c +++ b/toys/pending/arping.c @@ -44,12 +44,12 @@ GLOBALS( unicast_flag; ) -struct sockaddr_ll src_pk, dst_pk; +struct sockaddr_ll src_pk, dst_pk; struct in_addr src_addr, dest_addr; extern void *mempcpy(void *dest, const void *src, size_t n); // Gets information of INTERFACE and updates IFINDEX, MAC and IP. -static void get_interface(char *interface, int *ifindex, uint32_t *oip, +static void get_interface(char *interface, int *ifindex, uint32_t *oip, uint8_t *mac) { struct ifreq req; @@ -84,16 +84,16 @@ static void done(int sig) { if (!(toys.optflags & FLAG_q)) { xprintf("Sent %u probe(s) (%u broadcast(s))\n", TT.sent_nr, TT.brd_sent); - xprintf("Received %u repl%s (%u request(s), %u broadcast(s))\n", + xprintf("Received %u repl%s (%u request(s), %u broadcast(s))\n", TT.rcvd_nr, TT.rcvd_nr == 1 ? "y":"ies", TT.rcvd_req, TT.brd_rcv); } if (toys.optflags & FLAG_D) exit(!!TT.rcvd_nr); //In -U mode, No reply is expected. - if (toys.optflags & FLAG_U) exit(EXIT_SUCCESS); + if (toys.optflags & FLAG_U) exit(EXIT_SUCCESS); exit(!TT.rcvd_nr); } -// Create and Send Packet +// Create and Send Packet static void send_packet() { int ret; @@ -104,8 +104,8 @@ static void send_packet() arp_h->ar_hrd = htons(ARPHRD_ETHER); arp_h->ar_pro = htons(ETH_P_IP); arp_h->ar_hln = src_pk.sll_halen; - arp_h->ar_pln = 4; - arp_h->ar_op = (toys.optflags & FLAG_A) ? htons(ARPOP_REPLY) + arp_h->ar_pln = 4; + arp_h->ar_op = (toys.optflags & FLAG_A) ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); ptr = mempcpy(ptr, &src_pk.sll_addr, src_pk.sll_halen); @@ -115,7 +115,7 @@ static void send_packet() src_pk.sll_halen); ptr = mempcpy(ptr, &dest_addr, 4); - ret = sendto(TT.sockfd, sbuf, ptr - sbuf, 0, + ret = sendto(TT.sockfd, sbuf, ptr - sbuf, 0, (struct sockaddr *)&dst_pk, sizeof(dst_pk)); if (ret == ptr - sbuf) { struct timeval tval; @@ -134,19 +134,19 @@ static void recv_from(struct sockaddr_ll *from, int *recv_len) struct arphdr *arp_hdr = (struct arphdr *)toybuf; unsigned char *p = (unsigned char *)(arp_hdr + 1); - if (arp_hdr->ar_op != htons(ARPOP_REQUEST) && - arp_hdr->ar_op != htons(ARPOP_REPLY)) return; + if (arp_hdr->ar_op != htons(ARPOP_REQUEST) && + arp_hdr->ar_op != htons(ARPOP_REPLY)) return; if (from->sll_pkttype != PACKET_HOST && from->sll_pkttype != PACKET_BROADCAST - && from->sll_pkttype != PACKET_MULTICAST) return; + && from->sll_pkttype != PACKET_MULTICAST) return; - if (arp_hdr->ar_pro != htons(ETH_P_IP) || (arp_hdr->ar_pln != 4) - || (arp_hdr->ar_hln != src_pk.sll_halen) + if (arp_hdr->ar_pro != htons(ETH_P_IP) || (arp_hdr->ar_pln != 4) + || (arp_hdr->ar_hln != src_pk.sll_halen) || (*recv_len < (int)(sizeof(*arp_hdr) + 2 * (4 + arp_hdr->ar_hln)))) - return; + return; memcpy(&s_ip.s_addr, p + arp_hdr->ar_hln, 4); - memcpy(&d_ip.s_addr, p + arp_hdr->ar_hln + 4 + arp_hdr->ar_hln, 4); + memcpy(&d_ip.s_addr, p + arp_hdr->ar_hln + 4 + arp_hdr->ar_hln, 4); if (dest_addr.s_addr != s_ip.s_addr) return; if (toys.optflags & FLAG_D) { @@ -159,7 +159,7 @@ static void recv_from(struct sockaddr_ll *from, int *recv_len) from->sll_pkttype == PACKET_HOST ? "Uni" : "Broad", arp_hdr->ar_op == htons(ARPOP_REPLY) ? "ply" : "quest", inet_ntoa(s_ip), ether_ntoa((struct ether_addr *) p)); - if (TT.sent_at) { + if (TT.sent_at) { unsigned delta; struct timeval tval; @@ -184,14 +184,14 @@ static void send_signal(int sig) struct timeval start; gettimeofday(&start, NULL); - if (!TT.start) + if (!TT.start) TT.end = TT.start = start.tv_sec * 1000 + start.tv_usec / 1000; else TT.end = start.tv_sec*1000 + start.tv_usec / 1000; if (toys.optflags & FLAG_c) { if (!TT.count) done(0); - TT.count--; + TT.count--; } - if ((toys.optflags & FLAG_w) && ((TT.end - TT.start) > + if ((toys.optflags & FLAG_w) && ((TT.end - TT.start) > ((TT.time_out)*1000))) done(0); send_packet(); alarm(1); @@ -227,9 +227,9 @@ void arping_main(void) if (!hp) perror_exit("bad address '%s'", *toys.optargs); memcpy(&dest_addr, hp->h_addr, 4); } - if ((toys.optflags & FLAG_s) && !(inet_aton(TT.src_ip, &src_addr))) + if ((toys.optflags & FLAG_s) && !(inet_aton(TT.src_ip, &src_addr))) perror_exit("invalid source address '%s'",TT.src_ip); - if (!(toys.optflags & FLAG_D) && (toys.optflags & FLAG_U) + if (!(toys.optflags & FLAG_D) && (toys.optflags & FLAG_U) && !src_addr.s_addr) src_addr = dest_addr; if (!(toys.optflags & FLAG_D) || src_addr.s_addr) { struct sockaddr_in saddr; diff --git a/toys/pending/bootchartd.c b/toys/pending/bootchartd.c index 49be5c48..bbb06b42 100644 --- a/toys/pending/bootchartd.c +++ b/toys/pending/bootchartd.c @@ -1,10 +1,10 @@ /* bootchartd.c - bootchartd is commonly used to profile the boot process. * * Copyright 2014 Bilal Qureshi <bilal.jmi@gmail.com> - * Copyright 2014 Kyungwan Han <asura321@gmail.com> + * Copyright 2014 Kyungwan Han <asura321@gmail.com> * * No Standard - + USE_BOOTCHARTD(NEWTOY(bootchartd, 0, TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN)) config BOOTCHARTD @@ -152,7 +152,7 @@ static void start_logging() (int) (ts.tv_nsec/10000000)); dump_data_in_file("/proc/stat", sfd); dump_data_in_file("/proc/diskstats", dfd); - // stop proc dumping in 2 secs if getty or gdm, kdm, xdm found + // stop proc dumping in 2 secs if getty or gdm, kdm, xdm found if (dump_proc_data(proc_ps_fp)) if (tcnt > 2 * 1000 / TT.msec) tcnt = 2 * 1000 / TT.msec; fflush(0); @@ -198,7 +198,7 @@ static void stop_logging(char *tmp_dir, char *prog) close(kcmd_line_fd); fclose(hdr_fp); memset(toybuf, 0, sizeof(toybuf)); - snprintf(toybuf, sizeof(toybuf), "tar -zcf /var/log/bootlog.tgz header %s *.log", + snprintf(toybuf, sizeof(toybuf), "tar -zcf /var/log/bootlog.tgz header %s *.log", TT.proc_accounting ? "kernel_procs_acct" : ""); system(toybuf); @@ -241,7 +241,7 @@ void bootchartd_main() } } else if (TT.pid != 1) error_exit("not PID 1"); - // Execute the code below for start or init or PID1 + // Execute the code below for start or init or PID1 if (!parse_config_file("bootchartd.conf")) parse_config_file("/etc/bootchartd.conf"); @@ -251,23 +251,23 @@ void bootchartd_main() sigatexit(generic_signal); raise(SIGSTOP); - if (!bchartd_opt && !getenv("PATH")) + if (!bchartd_opt && !getenv("PATH")) putenv("PATH=/sbin:/usr/sbin:/bin:/usr/bin"); start_logging(); stop_logging(tmp_dir, bchartd_opt == 1 ? toys.optargs[1] : NULL); return; - } + } waitpid(lgr_pid, NULL, WUNTRACED); kill(lgr_pid, SIGCONT); - if (!bchartd_opt) { + if (!bchartd_opt) { char *pbchart_init = getenv("bootchart_init"); if (pbchart_init) execl(pbchart_init, pbchart_init, NULL); execl("/init", "init", (void *)0); execl("/sbin/init", "init", (void *)0); } - if (bchartd_opt == 1 && toys.optargs[1]) { + if (bchartd_opt == 1 && toys.optargs[1]) { pid_t prog_pid; if (!(prog_pid = xfork())) xexec(toys.optargs+1); diff --git a/toys/pending/brctl.c b/toys/pending/brctl.c index c007618f..1ff13729 100644 --- a/toys/pending/brctl.c +++ b/toys/pending/brctl.c @@ -42,7 +42,7 @@ GLOBALS( static void get_ports(char *bridge, int *indices) { - struct ifreq ifr; + struct ifreq ifr; int ifindices[MAX_BRIDGES]; unsigned long args[4] = { BRCTL_GET_PORT_LIST, (unsigned long) ifindices, MAX_BRIDGES, 0 }; @@ -90,7 +90,7 @@ void br_show(char **argv) get_br_info(br, &info); id = (unsigned char*)&(info.bridge_id); printf("%s\t\t",br); - printf("%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x", id[0], id[1], + printf("%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]); printf("\t%s\t\t",(info.stp_enabled)?"yes" : "no"); @@ -112,13 +112,13 @@ void br_show(char **argv) void br_addbr(char **argv) { - char br[IFNAMSIZ]; + char br[IFNAMSIZ]; unsigned long args[4] = {BRCTL_ADD_BRIDGE, (unsigned long) br, 0, 0}; #ifdef SIOCBRADDBR xioctl(TT.sockfd, SIOCBRADDBR, argv[0]); -#else - xstrncpy(br, argv[0], IFNAMSIZ); +#else + xstrncpy(br, argv[0], IFNAMSIZ); xioctl(TT.sockfd, SIOCSIFBR, args); #endif } @@ -156,8 +156,8 @@ void br_addif(char **argv) void br_delif(char **argv) { - int index; - struct ifreq ifr; + int index; + struct ifreq ifr; unsigned long args[4] = {BRCTL_DEL_IF, 0, 0, 0}; if (!(index = if_nametoindex(argv[1]))) perror_exit("interface %s",argv[1]); @@ -166,8 +166,8 @@ void br_delif(char **argv) ifr.ifr_ifindex = index; xioctl(TT.sockfd, SIOCBRDELIF, &ifr); #else - args[1] = index; - ifr.ifr_data = (char *)args; + args[1] = index; + ifr.ifr_data = (char *)args; xioctl(TT.sockfd, SIOCDEVPRIVATE, &ifr); #endif } @@ -182,12 +182,12 @@ static void strtotimeval(struct timeval *tv, char *time) } static unsigned long tv_to_jify(struct timeval *tv) -{ +{ unsigned long long jify; jify = 1000000ULL * tv->tv_sec + tv->tv_usec; return (jify/10000); -} +} void set_time(char *br, unsigned long cmd, unsigned long val) { @@ -199,7 +199,7 @@ void set_time(char *br, unsigned long cmd, unsigned long val) xioctl(TT.sockfd, SIOCDEVPRIVATE, &ifr); } -void br_set_ageing_time(char **argv) +void br_set_ageing_time(char **argv) { struct timeval tv; @@ -217,17 +217,17 @@ void br_set_fwd_delay(char **argv) void br_set_hello_time(char **argv) { - struct timeval tv; + struct timeval tv; - strtotimeval(&tv, argv[1]); + strtotimeval(&tv, argv[1]); set_time(argv[0], BRCTL_SET_BRIDGE_HELLO_TIME, tv_to_jify(&tv)); } void br_set_max_age(char **argv) { - struct timeval tv; + struct timeval tv; - strtotimeval(&tv, argv[1]); + strtotimeval(&tv, argv[1]); set_time(argv[0], BRCTL_SET_BRIDGE_MAX_AGE, tv_to_jify(&tv)); } @@ -260,9 +260,9 @@ void set_cost_prio(char *br, char *port, unsigned long cmd, unsigned long val) struct ifreq ifr; int i, index, pindices[MAX_BRIDGES]; unsigned long args[4] = {cmd, 0, val, 0}; - + if (!(index = if_nametoindex(port))) error_exit("invalid port"); - + memset(pindices, 0, sizeof(pindices)); get_ports(br, pindices); for (i = 0; i < MAX_BRIDGES; i++) { @@ -284,7 +284,7 @@ void br_set_path_cost(char **argv) } void br_set_port_prio(char **argv) -{ +{ int prio; prio = atolx_range(argv[2], 0, INT_MAX); diff --git a/toys/pending/crond.c b/toys/pending/crond.c index 81cc8448..ac96061d 100644 --- a/toys/pending/crond.c +++ b/toys/pending/crond.c @@ -570,7 +570,7 @@ static void execute_jobs(void) free(mailfile); } } - loginfo(LOG_LEVEL8, "USER %s pid %3d cmd %s", + loginfo(LOG_LEVEL8, "USER %s pid %3d cmd %s", cfile->username, job->pid, job->cmd); if (job->pid < 0) job->needstart = 1; else job->isrunning = 1; diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c index 6c1c65a2..575398f2 100644 --- a/toys/pending/crontab.c +++ b/toys/pending/crontab.c @@ -349,7 +349,7 @@ void crontab_main(void) if (!toys.optc) { if (!FLAG_elr) { - if (toys.optflags & FLAG_u) + if (toys.optflags & FLAG_u) help_exit("file name must be specified for replace"); do_replace(pwd->pw_name); } diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c index dd54ee36..d90f9a2b 100644 --- a/toys/pending/dhcp.c +++ b/toys/pending/dhcp.c @@ -248,7 +248,7 @@ static struct sock_filter filter_instr[] = { }; static struct sock_fprog filter_prog = { - .len = ARRAY_LEN(filter_instr), + .len = ARRAY_LEN(filter_instr), .filter = (struct sock_filter *) filter_instr, }; @@ -465,7 +465,7 @@ static int strtoopt( char *str, uint8_t optonly) valstr = strtok(NULL," \t"); } break; - case DHCP_STRLST: + case DHCP_STRLST: case DHCP_IPPLST: break; case DHCP_STCRTS: @@ -668,7 +668,7 @@ static int read_raw(void) } // ignore any extra garbage bytes bytes = ntohs(packet.iph.tot_len); - // make sure its the right packet for us, and that it passes sanity checks + // make sure its the right packet for us, and that it passes sanity checks if (packet.iph.protocol != IPPROTO_UDP || packet.iph.version != IPVERSION || packet.iph.ihl != (sizeof(packet.iph) >> 2) || packet.udph.dest != htons(DHCPC_CLIENT_PORT) @@ -1199,14 +1199,14 @@ static void renew(void) break; case STATE_BOUND: mode_raw(); - case STATE_RENEWING: // FALLTHROUGH - case STATE_REBINDING: // FALLTHROUGH + case STATE_RENEWING: // FALLTHROUGH + case STATE_REBINDING: // FALLTHROUGH state->status = STATE_RENEW_REQUESTED; break; case STATE_RENEW_REQUESTED: run_script(NULL, "deconfig"); - case STATE_REQUESTING: // FALLTHROUGH - case STATE_RELEASED: // FALLTHROUGH + case STATE_REQUESTING: // FALLTHROUGH + case STATE_RELEASED: // FALLTHROUGH mode_raw(); state->status = STATE_INIT; break; diff --git a/toys/pending/dhcp6.c b/toys/pending/dhcp6.c index 72cda4f8..72affff6 100644 --- a/toys/pending/dhcp6.c +++ b/toys/pending/dhcp6.c @@ -34,7 +34,7 @@ config DHCP6 */ #define FOR_dhcp6 #include "toys.h" -#include <linux/sockios.h> +#include <linux/sockios.h> #include <linux/if_ether.h> #include <netinet/ip.h> #include <netinet/ip6.h> @@ -89,11 +89,11 @@ GLOBALS( #define DHCPC_SERVER_PORT 547 #define DHCPC_CLIENT_PORT 546 - + #define LOG_SILENT 0x0 #define LOG_CONSOLE 0x1 #define LOG_SYSTEM 0x2 - + typedef struct __attribute__((packed)) dhcp6_msg_s { uint8_t msgtype, transaction_id[3], options[524]; } dhcp6_msg_t; @@ -138,7 +138,7 @@ static void logit(char *format, ...) char *msg; va_list p, t; uint8_t infomode = LOG_SILENT; - + if (toys.optflags & FLAG_S) infomode |= LOG_SYSTEM; if(toys.optflags & FLAG_v) infomode |= LOG_CONSOLE; va_start(p, format); @@ -161,7 +161,7 @@ static void get_mac(uint8_t *mac, char *interface) { int fd; struct ifreq req; - + if (!mac) return; fd = xsocket(AF_INET6, SOCK_RAW, IPPROTO_RAW); req.ifr_addr.sa_family = AF_INET6; @@ -174,17 +174,17 @@ static void get_mac(uint8_t *mac, char *interface) static void fill_option(uint16_t option_id, uint16_t option_len, uint8_t **dhmesg) { uint8_t *tmp = *dhmesg; - + *((uint16_t*)tmp) = htons(option_id); *(uint16_t*)(tmp+2) = htons(option_len); *dhmesg += 4; TT.length += 4; } -static void fill_clientID() -{ +static void fill_clientID() +{ uint8_t *tmp = &mesg.options[TT.length]; - + if(!duid) { uint8_t mac[7] = {0,}; duid = (DUID*)malloc(sizeof(DUID)); @@ -204,10 +204,10 @@ static void fill_clientID() } // TODO: make it generic for multiple options. -static void fill_optionRequest() +static void fill_optionRequest() { uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_ORO,4,&tmp); *(uint16_t*)(tmp+4) = htons(23); *(uint16_t*)(tmp+6) = htons(24); @@ -217,17 +217,17 @@ static void fill_optionRequest() static void fill_elapsedTime() { uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_ELAPSED_TIME, 2, &tmp); *(uint16_t*)(tmp+6) = htons(0); TT.length += 2; } -static void fill_iaid() +static void fill_iaid() { IA_NA iana; uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_IA_NA, 12, &tmp); iana.iaid = rand(); iana.t1 = 0xffffffff; @@ -241,10 +241,10 @@ static void mode_raw() { int constone = 1; struct sockaddr_ll sockll; - + if (TT.sock > 0) xclose(TT.sock); TT.sock = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); - + memset(&sockll, 0, sizeof(sockll)); sockll.sll_family = AF_PACKET; sockll.sll_protocol = htons(ETH_P_IPV6); @@ -255,17 +255,17 @@ static void mode_raw() } } -static void generate_transection_id() +static void generate_transection_id() { int i, r = rand() % 0xffffff; - + for (i=0; i<3; i++) { TT.transction_id[i] = r%0xff; r = r/10; - } + } } -static void set_timeout(int seconds) +static void set_timeout(int seconds) { TT.tv.tv_sec = seconds; TT.tv.tv_usec = 100000; @@ -275,7 +275,7 @@ static void send_msg(int type) { struct sockaddr_in6 addr6; int sendlength = 0; - + memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; addr6.sin6_port = htons(DHCPC_SERVER_PORT); //SERVER_PORT @@ -283,7 +283,7 @@ static void send_msg(int type) mesg.msgtype = type; generate_transection_id(); memcpy(mesg.transaction_id, TT.transction_id, 3); - + if (type == DHCP6SOLICIT) { TT.length = 0; fill_clientID(); @@ -291,7 +291,7 @@ static void send_msg(int type) fill_elapsedTime(); fill_iaid(); sendlength = sizeof(dhcp6_msg_t) - 524 + TT.length; - } else if (type == DHCP6REQUEST || type == DHCP6RELEASE || type == DHCP6RENEW) + } else if (type == DHCP6REQUEST || type == DHCP6RELEASE || type == DHCP6RENEW) sendlength = TT.request_length; dbg("Sending message type: %d\n", type); sendlength = sendto(TT.sock1, &mesg, sendlength , 0,(struct sockaddr *)&addr6, @@ -302,7 +302,7 @@ static void send_msg(int type) uint8_t *get_msg_ptr(uint8_t *data, int data_length, int msgtype) { uint16_t type = *((uint16_t*)data), length = *((uint16_t*)(data+2)); - + type = ntohs(type); if (type == msgtype) return data; length = ntohs(length); @@ -327,20 +327,20 @@ static int check_client_id(uint8_t *data, int data_length) if ((data = get_msg_ptr(data, data_length, DHCP6_OPT_CLIENTID))) { DUID one = *((DUID*)(data+4)); DUID two = *((DUID*)&mesg.options[4]); - + if (!memcmp(&one, &two, sizeof(DUID))) return 1; } return 0; } -static int validate_ids() +static int validate_ids() { - if (!check_server_id(mymsg->dhcp6.options, + if (!check_server_id(mymsg->dhcp6.options, TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) { dbg("Invalid server id: %d\n"); return 0; } - if (!check_client_id(mymsg->dhcp6.options, + if (!check_client_id(mymsg->dhcp6.options, TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) { dbg("Invalid client id: %d\n"); return 0; @@ -348,24 +348,24 @@ static int validate_ids() return 1; } -static void parse_ia_na(uint8_t *data, int data_length) +static void parse_ia_na(uint8_t *data, int data_length) { uint8_t *t = get_msg_ptr(data, data_length, DHCP6_OPT_IA_NA); uint16_t iana_len, content_len = 0; - + memset(&dhcp_data,0,sizeof(dhcp_data)); if (!t) return; - + iana_len = ntohs(*((uint16_t*)(t+2))); dhcp_data.iaid = ntohl(*((uint32_t*)(t+4))); dhcp_data.t1 = ntohl(*((uint32_t*)(t+8))); dhcp_data.t2 = ntohl(*((uint32_t*)(t+12))); t += 16; iana_len -= 12; - + while(iana_len > 0) { uint16_t sub_type = ntohs(*((uint16_t*)(t))); - + switch (sub_type) { case DHCP6_OPT_IA_ADDR: content_len = ntohs(*((uint16_t*)(t+2))); @@ -373,7 +373,7 @@ static void parse_ia_na(uint8_t *data, int data_length) if (TT.state == DHCP6SOLICIT) { if (TT.req_ip) { struct addrinfo *res = NULL; - + if(!getaddrinfo(TT.req_ip, NULL, NULL,&res)) { dbg("Requesting IP: %s\n", TT.req_ip); memcpy (&TT.input_socket6, res->ai_addr, res->ai_addrlen); @@ -405,7 +405,7 @@ static void parse_ia_na(uint8_t *data, int data_length) static void write_pid(char *path) { int pidfile = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0666); - + if (pidfile > 0) { char pidbuf[12]; @@ -419,7 +419,7 @@ static void write_pid(char *path) static int fill_envp(DHCP_DATA *res) { int ret = setenv("interface", TT.interface_name, 1); - + if (ret) return ret; inet_ntop(AF_INET6, res->ipaddr, toybuf, INET6_ADDRSTRLEN); ret = setenv("ip",(const char*)toybuf , 1); @@ -432,7 +432,7 @@ static void run_script(DHCP_DATA *res, char *name) volatile int error = 0; struct stat sts; pid_t pid; - char *argv[3]; + char *argv[3]; char *script = (toys.optflags & FLAG_s) ? TT.script : "/usr/share/dhcp/default.script"; @@ -537,12 +537,12 @@ void dhcp6_main(void) struct sockaddr_in6 sinaddr6; int constone = 1; fd_set rfds; - - srand(time(NULL)); + + srand(time(NULL)); setlinebuf(stdout); dbg = dummy; TT.state = DHCP6SOLICIT; - + if (toys.optflags & FLAG_v) dbg = logit; if (!TT.interface_name) TT.interface_name = "eth0"; if (toys.optflags & FLAG_p) write_pid(TT.pidfile); @@ -553,34 +553,34 @@ void dhcp6_main(void) openlog("DHCP6 :", LOG_PID, LOG_DAEMON); dbg = logit; } - + dbg("Interface: %s\n", TT.interface_name); dbg("pid file: %s\n", TT.pidfile); dbg("Retry count: %d\n", TT.retry); dbg("Timeout : %d\n", TT.timeout); dbg("Error timeout: %d\n", TT.errortimeout); - - - + + + setup_signal(); - TT.sock1 = xsocket(PF_INET6, SOCK_DGRAM, 0); + TT.sock1 = xsocket(PF_INET6, SOCK_DGRAM, 0); memset(&sinaddr6, 0, sizeof(sinaddr6)); sinaddr6.sin6_family = AF_INET6; sinaddr6.sin6_port = htons(DHCPC_CLIENT_PORT); sinaddr6.sin6_scope_id = if_nametoindex(TT.interface_name); sinaddr6.sin6_addr = in6addr_any ; - + xsetsockopt(TT.sock1, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone)); - + xbind(TT.sock1, (struct sockaddr *)&sinaddr6, sizeof(sinaddr6)); - + mode_raw(); set_timeout(0); for (;;) { int maxfd = TT.sock; - + if (TT.sock >= 0) FD_SET(TT.sock, &rfds); - TT.retval = 0; + TT.retval = 0; if ((TT.retval = select(maxfd + 1, &rfds, NULL, NULL, &TT.tv)) < 0) { if(errno == EINTR) continue; perror_exit("Error in select"); @@ -599,7 +599,7 @@ void dhcp6_main(void) set_timeout(TT.errortimeout); } else set_timeout(TT.timeout); continue; - } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW || + } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW || TT.state == DHCP6RELEASE) { dbg("State is %d , sending packet\n", TT.state); send_msg(TT.state); @@ -614,7 +614,7 @@ void dhcp6_main(void) } else if (FD_ISSET(TT.sock, &rfds)) { if ((TT.status = read(TT.sock, toybuf, sizeof(toybuf))) <= 0) continue; mymsg = (dhcp6_raw_t*)toybuf; - if (ntohs(mymsg->udph.dest) == 546 && + if (ntohs(mymsg->udph.dest) == 546 && !memcmp(mymsg->dhcp6.transaction_id, TT.transction_id, 3)) { if (TT.state == DHCP6SOLICIT) { if (mymsg->dhcp6.msgtype == DHCP6ADVERTISE ) { @@ -672,7 +672,7 @@ void dhcp6_main(void) } else { dbg("Invalid reply.\n"); continue; - } + } } else if (TT.state == DHCP6RELEASE) { dbg("Got reply to release.\n"); run_script(NULL, "release"); @@ -680,7 +680,7 @@ void dhcp6_main(void) } } } - } + } xclose(TT.sock1); xclose(TT.sock); } diff --git a/toys/pending/dhcpd.c b/toys/pending/dhcpd.c index f6d063d6..5b5c63ef 100644 --- a/toys/pending/dhcpd.c +++ b/toys/pending/dhcpd.c @@ -36,7 +36,7 @@ config DEBUG_DHCP #define FOR_dhcpd #include "toys.h" -#include <linux/sockios.h> +#include <linux/sockios.h> #include <linux/if_ether.h> // Todo: headers not in posix @@ -1292,7 +1292,7 @@ static int verifyip6_in_lease(uint8_t *nip6, uint8_t *duid, uint16_t ia_type, ui return -1; if (!memcmp(((dyn_lease6*) listdls->arg)->duid, duid, ((dyn_lease6*) listdls->arg)->duid_len) - && ((dyn_lease6*) listdls->arg)->ia_type == ia_type) + && ((dyn_lease6*) listdls->arg)->ia_type == ia_type) return -1; } for (sls6 = gstate.leases.sleases6; sls6; sls6 = sls6->next) @@ -1376,12 +1376,12 @@ static int addip6_to_lease(uint8_t *assigned_nip, uint8_t *duid, uint16_t duid_l } dls6 = xzalloc(sizeof(dyn_lease6)); - dls6->duid_len = duid_len; + dls6->duid_len = duid_len; memcpy(dls6->duid, duid, duid_len); dls6->ia_type = ia_type; dls6->iaid = iaid; memcpy(dls6->lease_nip6, assigned_nip, sizeof(uint32_t)*4); - + if (update) *lifetime = get_lease(*lifetime + now); dls6->expires = *lifetime + now; @@ -1667,7 +1667,7 @@ void dhcpd_main(void) dbg("Error in select wait again...\n"); continue; } - if (!retval) { // Timed out + if (!retval) { // Timed out dbg("select wait Timed Out...\n"); waited = 0; (addr_version == AF_INET6)? write_lease6file() : write_leasefile(); @@ -1680,7 +1680,7 @@ void dhcpd_main(void) } continue; } - if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal + if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal unsigned char sig; if (read(sigfd.rd, &sig, 1) != 1) { dbg("signal read failed.\n"); @@ -1951,7 +1951,7 @@ void dhcpd_main(void) dbg("Message Type : %u\n", gstate.rqcode); break; } - + } else { if(read_packet() < 0) { open_listensock(); @@ -1961,7 +1961,7 @@ void dhcpd_main(void) get_optval((uint8_t*)&gstate.rcvd.rcvd_pkt.options, DHCP_OPT_MESSAGE_TYPE, &gstate.rqcode); - if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER + if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER || gstate.rqcode > DHCPINFORM) { dbg("no or bad message type option, ignoring packet.\n"); continue; diff --git a/toys/pending/diff.c b/toys/pending/diff.c index f12b4a3c..5d5ea3d6 100644 --- a/toys/pending/diff.c +++ b/toys/pending/diff.c @@ -586,7 +586,7 @@ static void do_diff(char **files) struct arg_list *llist = TT.L; int *J; regex_t reg; - + TT.offset[0] = TT.offset[1] = NULL; J = diff(files); diff --git a/toys/pending/dumpleases.c b/toys/pending/dumpleases.c index ef17aab4..a20c6b8d 100644 --- a/toys/pending/dumpleases.c +++ b/toys/pending/dumpleases.c @@ -26,7 +26,7 @@ GLOBALS( ) //lease structure -struct lease { +struct lease { uint32_t expires; uint32_t lease_nip; uint8_t lease_mac[6]; @@ -39,8 +39,8 @@ void dumpleases_main(void) struct in_addr addr; struct lease lease_struct; int64_t written_time , current_time, exp; - int i, fd; - + int i, fd; + if(!(toys.optflags & FLAG_f)) TT.file = "/var/lib/misc/dhcpd.leases"; //DEF_LEASE_FILE fd = xopenro(TT.file); xprintf("Mac Address IP Address Host Name Expires %s\n", (toys.optflags & FLAG_a) ? "at" : "in"); @@ -49,10 +49,10 @@ void dumpleases_main(void) written_time = SWAP_BE64(written_time); if(current_time < written_time) written_time = current_time; - while(sizeof(lease_struct) == + while(sizeof(lease_struct) == (readall(fd, &lease_struct, sizeof(lease_struct)))) { for (i = 0; i < 6; i++) printf(":%02x"+ !i, lease_struct.lease_mac[i]); - + addr.s_addr = lease_struct.lease_nip; lease_struct.hostname[19] = '\0'; xprintf(" %-16s%-20s", inet_ntoa(addr), lease_struct.hostname ); @@ -61,7 +61,7 @@ void dumpleases_main(void) xputs("expired"); continue; } - if (!(toys.optflags & FLAG_a)) { + if (!(toys.optflags & FLAG_a)) { unsigned dt, hr, m; unsigned expires = exp - current_time; dt = expires / (24*60*60); expires %= (24*60*60); diff --git a/toys/pending/expr.c b/toys/pending/expr.c index 54ebd14b..e56a75b7 100644 --- a/toys/pending/expr.c +++ b/toys/pending/expr.c @@ -135,7 +135,7 @@ static struct op_def { // comparison ops, precedence 3, signature SI_TO_I {"=", 3, SI_TO_I, EQ }, {"==", 3, SI_TO_I, EQ }, {"!=", 3, SI_TO_I, NE }, {">", 3, SI_TO_I, GT }, {">=", 3, SI_TO_I, GTE }, - {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, + {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, // arithmetic ops, precedence 4 and 5, signature I_TO_I {"+", 4, I_TO_I, ADD }, {"-", 4, I_TO_I, SUB }, {"*", 5, I_TO_I, MUL }, {"/", 5, I_TO_I, DIVI }, {"%", 5, I_TO_I, MOD }, @@ -156,7 +156,7 @@ void eval_op(struct op_def *o, struct value *ret, struct value *rhs) case OR: if (is_false(ret)) *ret = *rhs; break; case AND: if (is_false(ret) || is_false(rhs)) assign_int(ret, 0); break; } - break; + break; case SI_TO_I: if (get_int(ret, &a) && get_int(rhs, &b)) { // both are ints diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c index c29a49ee..fd8db258 100644 --- a/toys/pending/fdisk.c +++ b/toys/pending/fdisk.c @@ -34,7 +34,7 @@ GLOBALS( long cylinders; ) -#define EXTENDED 0x05 +#define EXTENDED 0x05 #define WIN98_EXTENDED 0x0f #define LINUX_NATIVE 0x83 #define LINUX_EXTENDED 0x85 @@ -136,7 +136,7 @@ static int chs_warn(void) static void list_types(void) { int i, adjust = 0, size = ARRAY_LEN(sys_types); - + if(size % 2) adjust = 1; for (i = 0; i < (size - adjust); i+=2) xprintf("%2x %-22s\t\t%2x %-22.22s\n", sys_types[i].id, sys_types[i].type, @@ -147,7 +147,7 @@ static void list_types(void) static void read_sec_sz() { - int arg; + int arg; if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) g_sect_size = arg; if (FLAG(b)) { if (TT.sect_sz != 512 && TT.sect_sz != 1024 && TT.sect_sz != 2048 && @@ -200,17 +200,17 @@ static uint32_t swap_le32toh(unsigned char *cp) return le32toh(val); } -static int check_order(void) -{ +static int check_order(void) +{ sector_t first[num_parts], last_seen_val = 0; int i; - struct part_entry *pe; + struct part_entry *pe; struct partition *px; for (i = 0; i < num_parts; i++) { if (i == 4) last_seen_val = 0; - pe = &partitions[i]; - px = pe->part; + pe = &partitions[i]; + px = pe->part; if (px->sys_ind) { first[i] = swap_le32toh(px->start4) + pe->start_offset; if (last_seen_val > first[i]) return 1; @@ -229,7 +229,7 @@ static void read_geometry(struct hd_geometry *disk) disk->sectors = geometry.sectors; } -/* Read the extended boot record for the +/* Read the extended boot record for the * logical partion details. */ static void read_ebr(int idx) @@ -269,7 +269,7 @@ static void read_ebr(int idx) } static void physical_HS(int* h, int *s) -{ +{ struct partition *p; int i, end_h, end_s, e_hh = 0, e_ss = 0, ini = 1, dirty = 0; const unsigned char *bufp = (const unsigned char *)MBRbuf; @@ -336,7 +336,7 @@ static void create_empty_doslabel(void) reset_boot(1); } -/* Read the Master Boot sector of the device for the +/* Read the Master Boot sector of the device for the * partition table entries/details. * If any extended partition is found then read the EBR * for logical partition details @@ -405,21 +405,21 @@ static char* get_type(int sys_ind) } static void consistency_check(const struct partition *p, int partition) -{ +{ unsigned physbc, physbh, physbs, physec, physeh, physes; unsigned lbc, lbh, lbs, lec, leh, les; sector_t start, end; if (!g_heads || !g_sectors || (partition >= 4)) return; - // physical beginning c, h, s + // physical beginning c, h, s physbc = cylinder(p->sector,p->cyl); physbh = p->head; physbs = sector(p->sector); - // physical ending c, h, s + // physical ending c, h, s physec = cylinder(p->end_sector, p->end_cyl); physeh = p->end_head; physes = sector(p->end_sector); - // logical begin and end CHS values + // logical begin and end CHS values start = swap_le32toh((unsigned char*)(p->start4)); end = start + swap_le32toh((unsigned char*)(p->size4)) -1; @@ -431,7 +431,7 @@ static void consistency_check(const struct partition *p, int partition) leh = (end/g_sectors) % g_heads; les = (end % g_sectors) + 1; - //Logical and Physical diff + //Logical and Physical diff if (g_cylinders <= ONE_K && (physbc != lbc || physbh != lbh || physbs != lbs)) { xprintf("Partition %u has different physical/logical beginnings (Non-Linux?): \n", partition+1); xprintf("phys = (%u %u %u) ",physbc, physbh, physbs); @@ -442,7 +442,7 @@ static void consistency_check(const struct partition *p, int partition) xprintf("phys = (%u %u %u) ",physec, physeh, physes); xprintf("logical = (%u %u %u)\n", lec, leh, les); } - // Ending on cylinder boundary? + // Ending on cylinder boundary? if (physeh != (g_heads - 1) || physes != g_sectors) xprintf("Partition %u does not end on cylinder boundary\n", partition + 1); } @@ -536,7 +536,7 @@ static int read_input(char *mesg, char *outp) do { xprintf("%s", mesg); p = fgets(toybuf, 80, stdin); - + if (!p || !(size = strlen(p))) exit(0); if (p[size-1] == '\n') p[--size] = '\0'; } while (!size); @@ -574,7 +574,7 @@ void delete_partition(int i) struct partition *p, *q, *ext_p, *ext_q; sector_t new_start; struct part_entry *pe = &partitions[i]; - + if (chs_warn()) return; p = pe->part; sys_id = p->sys_ind; @@ -588,7 +588,7 @@ void delete_partition(int i) pe->modified = 1; for (looper = 4; looper < num_parts; looper++) { pe = &partitions[looper]; - p = pe->part; + p = pe->part; if (is_partition_clear(p)) break; else { memset(p, 0, sizeof(struct partition)); //clear_partition @@ -608,7 +608,7 @@ void delete_partition(int i) ext_p = part_offset(partitions[i].sec_buffer, 1); ext_q = part_offset(partitions[i + 1].sec_buffer, 1); *ext_p = *ext_q; //copy the extended info pointer - // change the start of the 4th partiton. + // change the start of the 4th partiton. new_start = partitions[i + 1].start_offset + swap_le32toh(q->start4) - extended_offset; new_start = SWAP_LE32(new_start); memcpy(p->start4, (void *)&new_start, 4); @@ -648,7 +648,7 @@ static void toggle_active_flag(int i) { struct partition *p = partitions[i].part; if (is_partition_clear(p)) xprintf("Partition %u is empty\n", i+1); - + if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) xprintf("WARNING: Partition %u is an extended partition\n", i + 1); p->boot_ind = p->boot_ind == 0x80?0 : 0x80; @@ -687,7 +687,7 @@ void write_table(void) * one, then select the same, else ask from USER */ static int get_non_free_partition(int max) -{ +{ int num = -1, i = 0; for (i = 0; i < max; i++) { @@ -723,7 +723,7 @@ static int get_free_partition(int max) //taking user input for partition start/end sectors/cyinders static uint32_t ask_value(char *mesg, sector_t left, sector_t right, sector_t defalt) -{ +{ char *str = toybuf; uint32_t val; int use_default = 1; @@ -820,7 +820,7 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (disp_unit_cyl) limit = (sector_t)g_sectors * g_heads * g_cylinders - 1; else limit = total_number_sectors - 1; - if (disp_unit_cyl) //make the begin of every partition to cylnder boundary + if (disp_unit_cyl) //make the begin of every partition to cylnder boundary for (i = 0; i < num_parts; i++) begin[i] = (begin[i]/(g_heads* g_sectors)) * (g_heads* g_sectors); @@ -835,7 +835,7 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (valid) break; do { - for (i = start_index; i < num_parts; i++) + for (i = start_index; i < num_parts; i++) if (start >= begin[i] && start <= end[i]) start = end[i] + 1 + ((idx >= 4)? offset : 0); } while (!validate(start_index, begin, end, start, 0)); @@ -845,10 +845,10 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (start > limit) break; sprintf(mesg, "First %s (%lld - %lld, default %lld): ", disp_unit_cyl? "cylinder" : "sector", - (long long int)(disp_unit_cyl? start_cyl : start), + (long long int)(disp_unit_cyl? start_cyl : start), (long long int)(disp_unit_cyl? limit_cyl : limit), (long long int)(disp_unit_cyl? start_cyl : start)); - temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, + temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, disp_unit_cyl? limit_cyl : limit, disp_unit_cyl? start_cyl : start); asked = 1; @@ -893,10 +893,10 @@ static sector_t ask_end_sector(int idx, sector_t* begin, sector_t* end, int ext_ } sprintf(mesg, "Last %s or +size or +sizeM or +sizeK (%lld - %lld, default %lld): ", disp_unit_cyl? "cylinder" : "sector", - (long long int)(disp_unit_cyl? start_cyl : start), + (long long int)(disp_unit_cyl? start_cyl : start), (long long int)(disp_unit_cyl? limit_cyl : limit), (long long int)(disp_unit_cyl? limit_cyl : limit)); - temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, + temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, disp_unit_cyl? limit_cyl : limit, disp_unit_cyl? limit_cyl : limit); if (disp_unit_cyl) { // point to the cylinder start sector @@ -947,7 +947,7 @@ static int add_partition(int idx, int sys_id) if (pe->start_offset == extended_offset) pe->start_offset++; if (!dos_flag) start++; } - + set_levalue(p->start4, start - pe->start_offset); set_levalue(p->size4, end - start + 1); set_hsc(p, start, end); @@ -960,13 +960,13 @@ static int add_partition(int idx, int sys_id) set_levalue(p->start4, pe->start_offset - extended_offset); set_levalue(p->size4, end - start + 1 + (dos_flag? g_sectors: 1)); set_hsc(p, pe->start_offset, end); - p->boot_ind = 0; + p->boot_ind = 0; p->sys_ind = EXTENDED; - partitions[idx-1].modified = 1; + partitions[idx-1].modified = 1; } if (IS_EXTENDED(sys_id)) { pe = &partitions[4]; - pe->modified = 1; + pe->modified = 1; pe->sec_buffer = xzalloc(g_sect_size); pe->part = part_offset(pe->sec_buffer, 0); pe->start_offset = extended_offset = start; @@ -989,7 +989,7 @@ static void add_logical_partition(void) num_parts--; free(pe->sec_buffer); } - } + } else add_partition(num_parts -1, LINUX_NATIVE); } @@ -1000,13 +1000,13 @@ static void add_new_partition(void) { int choice, idx, i, free_part = 0; char *msg = NULL; - + if (chs_warn()) return; for (i = 0; i < 4; i++) if(is_partition_clear(partitions[i].part)) free_part++; if (!free_part && num_parts >= 60) { xprintf("The maximum number of partitions has been created\n"); - return; + return; } if (!free_part) { if (extended_offset) add_logical_partition(); @@ -1030,7 +1030,7 @@ static void add_new_partition(void) return; } if (choice == 'e' && !extended_offset) { - idx = get_free_partition(4); + idx = get_free_partition(4); if (idx >= 0) add_partition(idx, EXTENDED); return; } @@ -1062,7 +1062,7 @@ static void change_systype(void ) } static void check(int n, unsigned h, unsigned s, unsigned c, sector_t start) -{ +{ sector_t total, real_s, real_c; real_s = sector(s) - 1; @@ -1116,7 +1116,7 @@ static void verify_table(void) } } } - } + } if (extended_offset) { struct part_entry *pex = &partitions[ext_idx]; sector_t e_last = swap_le32toh(pex->part->start4) + @@ -1187,7 +1187,7 @@ static void print_raw_sectors() static void print_partitions_list(int ext) { - int i; + int i; struct part_entry *pe; struct partition *p; @@ -1204,7 +1204,7 @@ static void print_partitions_list(int ext) xprintf("%2u %02x%4u%4u%5u%4u%4u%5u%11u%11u %02x\n", i+1, p->boot_ind, p->head, sector(p->sector), cylinder(p->sector, p->cyl), - p->end_head, + p->end_head, sector(p->end_sector), cylinder(p->end_sector, p->end_cyl), swap_le32toh(p->start4), swap_le32toh(p->size4), @@ -1228,7 +1228,7 @@ static void fix_order(void) if (is_partition_clear(px)) first[i] = 0xffffffff; else first[i] = swap_le32toh(px->start4) + pe->start_offset; } - + if (!check_order()) { xprintf("Ordering is already correct\n\n"); return; @@ -1278,10 +1278,10 @@ static void fix_order(void) *pjj = tmp; set_levalue(pj->start4, ojj+sjj-oj); set_levalue(pjj->start4, oj+sj-ojj); - } - } + } + } } - // If anything changed + // If anything changed for (j = 4; j < num_parts; j++) partitions[j].modified = 1; xprintf("Done!\n"); } @@ -1311,7 +1311,7 @@ static void print_xmenu(void) "c\tchange number of cylinders\n" "d\tprint the raw data in the partition table\n" "e\tlist extended partitions\n" - "f\tfix partition order\n" + "f\tfix partition order\n" "h\tchange number of heads\n" "p\tprint the partition table\n" "q\tquit without saving changes\n" @@ -1450,7 +1450,7 @@ static void read_and_print_parts() memset(name, 0, sizeof(*name)); if (sscanf(buffer, " %u %u %u %[^\n ]", &ma, &mi, &sz, name) != 4) continue; - + sprintf(device,"/dev/%s",name); if (disk_proper(device)) { if (read_mbr(device, 0)) continue; diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c index ea7c59cd..e93409ea 100644 --- a/toys/pending/fsck.c +++ b/toys/pending/fsck.c @@ -61,11 +61,11 @@ struct child_list { static struct f_sys_info *filesys_info = NULL; //fstab entry list static struct child_list *c_list = NULL; //fsck.type child list. -static void kill_all(void) +static void kill_all(void) { struct child_list *child; - for (child = c_list; child; child = child->next) + for (child = c_list; child; child = child->next) kill(child->pid, SIGTERM); _exit(0); } @@ -107,7 +107,7 @@ static int is_no_prefix(char **p) { int no = 0; - if ((*p[0] == 'n' && *(*p + 1) == 'o')) no = 2; + if ((*p[0] == 'n' && *(*p + 1) == 'o')) no = 2; else if (*p[0] == '!') no = 1; *p += no; return ((no) ? 1 :0); @@ -161,7 +161,7 @@ static int ignore_type(char *type) } // return true if has to ignore the filesystem. -static int to_be_ignored(struct f_sys_info *finfo) +static int to_be_ignored(struct f_sys_info *finfo) { int i, ret = 0, type_present = 0; @@ -185,7 +185,7 @@ static int to_be_ignored(struct f_sys_info *finfo) } // find type and execute corresponding fsck.type prog. -static void do_fsck(struct f_sys_info *finfo) +static void do_fsck(struct f_sys_info *finfo) { struct child_list *child; char **args; @@ -201,7 +201,7 @@ static void do_fsck(struct f_sys_info *finfo) args = xzalloc((toys.optc + 2 + 1 + 1) * sizeof(char*)); //+1, for NULL, +1 if -C args[0] = xmprintf("fsck.%s", type); - + if(toys.optflags & FLAG_C) args[i++] = xmprintf("%s %d","-C", TT.fd_num); while(toys.optargs[j]) { if(*toys.optargs[j]) args[i++] = xstrdup(toys.optargs[j]); @@ -221,15 +221,15 @@ static void do_fsck(struct f_sys_info *finfo) for (j=0;j<i;j++) free(args[i]); free(args); return; - } else { + } else { if ((pid = fork()) < 0) { perror_msg_raw(*args); for (j=0;j<i;j++) free(args[i]); free(args); - return; + return; } if (!pid) xexec(args); //child, executes fsck.type - } + } child = xzalloc(sizeof(struct child_list)); //Parent, add to child list. child->dev_name = xstrdup(finfo->device); @@ -275,18 +275,18 @@ static int wait_for(int for_all) } if (child_exited) { if (WIFEXITED(status)) TT.sum_status |= WEXITSTATUS(status); - else if (WIFSIGNALED(status)) { + else if (WIFSIGNALED(status)) { TT.sum_status |= 4; //Uncorrected. if (WTERMSIG(status) != SIGINT) perror_msg("child Term. by sig: %d\n",(WTERMSIG(status))); TT.sum_status |= 8; //Operatinal error - } else { + } else { TT.sum_status |= 4; //Uncorrected. - perror_msg("%s %s: status is %x, should never happen\n", + perror_msg("%s %s: status is %x, should never happen\n", temp->prog_name, temp->dev_name, status); } TT.nr_run--; - if (prev == temp) c_list = c_list->next; //first node + if (prev == temp) c_list = c_list->next; //first node else prev->next = temp->next; free(temp->prog_name); free(temp->dev_name); @@ -334,7 +334,7 @@ static int scan_all(void) } passno = 1; while (1) { - for (finfo = filesys_info; finfo; finfo = finfo->next) + for (finfo = filesys_info; finfo; finfo = finfo->next) if (!finfo->flag) break; if (!finfo) break; @@ -343,7 +343,7 @@ static int scan_all(void) if (finfo->passno == passno) { do_fsck(finfo); finfo->flag |= FLAG_DONE; - if ((toys.optflags & FLAG_s) || (TT.nr_run + if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) ret |= wait_for(0); } } @@ -354,7 +354,7 @@ static int scan_all(void) return ret; } -void record_sig_num(int sig) +void record_sig_num(int sig) { TT.sig_num = sig; } @@ -395,7 +395,7 @@ void fsck_main(void) dev->prev->next = NULL; //break double list to traverse. for (; dev; dev = dev->next) { for (finfo = filesys_info; finfo; finfo = finfo->next) - if (!strcmp(finfo->device, dev->data) + if (!strcmp(finfo->device, dev->data) || !strcmp(finfo->mountpt, dev->data)) break; if (!finfo) { //if not present, fill def values. mt.mnt_fsname = dev->data; @@ -407,7 +407,7 @@ void fsck_main(void) } do_fsck(finfo); finfo->flag |= FLAG_DONE; - if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) + if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) toys.exitval |= wait_for(0); } if (TT.sig_num) kill_all(); diff --git a/toys/pending/git.c b/toys/pending/git.c index 82421483..ffe72f02 100644 --- a/toys/pending/git.c +++ b/toys/pending/git.c @@ -63,7 +63,6 @@ config GITCHECKOUT A minimal git checkout. */ -#define TT this.git #define FOR_gitclone #include "toys.h" #include "openssl/sha.h" //ToDo: borrowed from OpenSSL to not pipe or refactor the SHA1SUM in toybox @@ -221,7 +220,7 @@ int inf(FILE *source, char *dest) //modified signature to ease use } have = CHUNK - strm.avail_out; - memcpy(position, out, have); //added to original + memcpy(position, out, have); //added to original position += have; //added to original //if (fwrite(out, 1, have, dest) != have || ferror(dest)) { // (void)inflateEnd(&strm); diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c index efb3f941..67c0e929 100644 --- a/toys/pending/groupadd.c +++ b/toys/pending/groupadd.c @@ -15,7 +15,7 @@ config GROUPADD usage: groupadd [-S] [-g GID] [USER] GROUP Add a user to a group, or create a new group. - + -g GID Group id -R Operate within chroot -S Create a system group diff --git a/toys/pending/init.c b/toys/pending/init.c index 9f4e7ba6..84077b4b 100644 --- a/toys/pending/init.c +++ b/toys/pending/init.c @@ -69,7 +69,7 @@ static void initialize_console(void) static void reset_term(int fd) { struct termios terminal; - + tcgetattr(fd, &terminal); terminal.c_cc[VINTR] = 3; //ctrl-c terminal.c_cc[VQUIT] = 28; /*ctrl-\*/ @@ -255,7 +255,7 @@ static pid_t final_run(struct action_list_seed *x) sigfillset(&signal_set); sigprocmask(SIG_UNBLOCK, &signal_set, NULL); - return pid; + return pid; } else if (pid < 0) { perror_msg("fork fail"); sleep(1); @@ -358,7 +358,7 @@ static void halt_poweroff_reboot_handler(int sig_no) error_msg("Requesting system poweroff"); reboot_magic_no=RB_POWER_OFF; break; - case SIGTERM: + case SIGTERM: error_msg("Requesting system reboot"); reboot_magic_no=RB_AUTOBOOT; break; @@ -461,8 +461,8 @@ void init_main(void) { struct sigaction sig_act; - if (getpid() != 1) error_exit("Already running"); - printf("Started init\n"); + if (getpid() != 1) error_exit("Already running"); + printf("Started init\n"); initialize_console(); reset_term(0); @@ -486,8 +486,8 @@ void init_main(void) sigaction(SIGTSTP, &sig_act, NULL); memset(&sig_act, 0, sizeof(sig_act)); sig_act.sa_handler = catch_signal; - sigaction(SIGINT, &sig_act, NULL); - sigaction(SIGHUP, &sig_act, NULL); + sigaction(SIGINT, &sig_act, NULL); + sigaction(SIGHUP, &sig_act, NULL); run_action_from_list(SYSINIT); check_if_pending_signals(); run_action_from_list(WAIT); diff --git a/toys/pending/ip.c b/toys/pending/ip.c index e9b5dd0e..52deec4e 100644 --- a/toys/pending/ip.c +++ b/toys/pending/ip.c @@ -52,7 +52,7 @@ struct arglist { int idx; }; -static struct +static struct { int ifindex, scope, scopemask, up, to; char *label, *addr; @@ -290,7 +290,7 @@ static struct arglist **getlist(u_int8_t whichDB) parseRPDB("/etc/iproute2/rt_tables", alist, ARRAY_LEN(rt_tables)); } break; - default: + default: error_exit("wrong database"); break; // Unreachable code. } @@ -370,7 +370,7 @@ static int get_prefix(uint32_t *addr, uint8_t *af, char *name, int family) if (strchr(name, ':')) { *af = AF_INET6; if (family != AF_UNSPEC && family != AF_INET6) return 1; - if (inet_pton(AF_INET6, name, (void *)addr) != 1) + if (inet_pton(AF_INET6, name, (void *)addr) != 1) return 1; } else { // for IPv4. char *ptr = name; @@ -508,8 +508,8 @@ static uint32_t get_ifaceindex(char *name, int ext) if (!if_ni) perror_exit("if_nameindex"); for (i = if_ni; i->if_index && i->if_name; i++) - if (!strcmp(name, i->if_name)) { - index = i->if_index; + if (!strcmp(name, i->if_name)) { + index = i->if_index; break; } if_freenameindex(if_ni); @@ -553,7 +553,7 @@ static char *get_flag_string(struct arglist *aflags, int flags, int ismulti) static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) { - struct arglist vlan_optlist[] = {{"id", 0}, {"protocol", 1}, + struct arglist vlan_optlist[] = {{"id", 0}, {"protocol", 1}, {"reorder_hdr", 2}, {"gvrp", 3}, {NULL,-1}}; struct arglist vlan_protolist[] = {{"802.1q", 0}, {"802.1ad", 1}, {NULL,-1}}; struct arglist on_off[] = { {"on", 0}, {"off", 1}, {NULL,-1}}; @@ -583,13 +583,13 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) case 3: // ARG_gvrp if ((param = substring_to_idx(*argv, on_off)) == -1) help_exit(0); - flags.mask |= (idx -1); // VLAN FLAG REORDER Header - flags.flags &= ~(idx -1); // VLAN FLAG REORDER Header + flags.mask |= (idx -1); // VLAN FLAG REORDER Header + flags.flags &= ~(idx -1); // VLAN FLAG REORDER Header if (!param) flags.flags |= (idx -1); // VLAN FLAG REORDER Header break; } } - if (flags.mask) + if (flags.mask) add_string_to_rtattr(n, size, IFLA_VLAN_FLAGS, &flags, sizeof(flags)); } @@ -599,14 +599,14 @@ static int linkupdate(char **argv) struct nlmsghdr mhdr; struct ifinfomsg info; char buf[1024]; - } request; + } request; char *name, *dev, *type, *link, *addr; struct rtattr *attr = NULL; int len = 0, add = (*argv[-1] == 'a') ? 1 : 0; name = dev = type = link = addr = NULL; for (; *argv; argv++) { - struct arglist objectlist[] = { {"type", 0}, {"name", 1}, {"link", 2}, + struct arglist objectlist[] = { {"type", 0}, {"name", 1}, {"link", 2}, {"address", 3}, {NULL,-1}}; uint8_t idx = substring_to_idx(*argv, objectlist); @@ -644,7 +644,7 @@ static int linkupdate(char **argv) IFLA_INFO_KIND, type, strlen(type)); if (!strcmp(type, "vlan")) { struct rtattr *data = NLMSG_TAIL(&request.mhdr); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_INFO_DATA, NULL, 0); vlan_parse_opt(++argv, &request.mhdr, sizeof(request)); data->rta_len = (void *)NLMSG_TAIL(&request.mhdr) - (void *)data; @@ -654,14 +654,14 @@ static int linkupdate(char **argv) if (link) { uint32_t idx = get_ifaceindex(link, 1); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_LINK, &idx, sizeof(uint32_t)); } if (addr) { char abuf[IF_NAMESIZE] = {0,}; fill_hwaddr(addr, IF_NAMESIZE, (unsigned char *)abuf); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_ADDRESS, abuf, strlen(abuf)); } if (!name) { @@ -682,8 +682,8 @@ static int linkupdate(char **argv) static int link_set(char **argv) { - struct arglist cmd_objectlist[] = {{"up", 0}, {"down", 1}, {"arp", 2}, - {"multicast", 3}, {"dynamic", 4}, {"name", 5}, {"txqueuelen", 6}, + struct arglist cmd_objectlist[] = {{"up", 0}, {"down", 1}, {"arp", 2}, + {"multicast", 3}, {"dynamic", 4}, {"name", 5}, {"txqueuelen", 6}, {"mtu", 7},{"address", 8}, {"broadcast", 9}, {"dev", 10}, {NULL,-1}}; int case_flags[] = {IFF_NOARP,IFF_MULTICAST,IFF_DYNAMIC}; struct ifreq req; @@ -822,7 +822,7 @@ static void print_stats(struct rtnl_link_stats *rtstat) xprintf(" TX: errors aborted fifo window " "heartbeat%s%-10u %-8u %-7u %-8u %-8u\n", line_feed, rtstat->tx_errors, rtstat->tx_aborted_errors, - rtstat->tx_fifo_errors, rtstat->tx_window_errors, + rtstat->tx_fifo_errors, rtstat->tx_window_errors, rtstat->tx_heartbeat_errors); } } @@ -831,7 +831,7 @@ static void print_stats(struct rtnl_link_stats *rtstat) static int print_link_output(struct linkdata *link) { char *line_feed = " ", *flags,*peer = "brd"; - struct arglist iface_flags[] = {{"",0},{"UP", IFF_UP}, + struct arglist iface_flags[] = {{"",0},{"UP", IFF_UP}, {"BROADCAST", IFF_BROADCAST}, {"DEBUG", IFF_DEBUG}, {"LOOPBACK", IFF_LOOPBACK}, {"POINTOPOINT", IFF_POINTOPOINT}, {"NOTRAILERS", IFF_NOTRAILERS}, {"RUNNING", IFF_RUNNING}, @@ -859,7 +859,7 @@ static int print_link_output(struct linkdata *link) if (!(flags = get_flag_string(iface_flags, link->flags, 1))) - error_exit("Invalid data."); + error_exit("Invalid data."); if (!TT.singleline) line_feed="\n "; if (link->parent != -1) { char iface[IF_NAMESIZE]; @@ -970,10 +970,10 @@ static int get_link_info(struct nlmsghdr* h,struct linkdata* link,char **argv) case IFLA_TXQLEN: link->txqueuelen = *((int*)(RTA_DATA(attr))); break; - case IFLA_OPERSTATE: + case IFLA_OPERSTATE: { - struct arglist flags[]={{"UNKNOWN", 0}, {"NOTPRESENT", 1}, - {"DOWN", 2}, {"LOWERLAYERDOWN", 3}, {"TESTING", 4}, + struct arglist flags[]={{"UNKNOWN", 0}, {"NOTPRESENT", 1}, + {"DOWN", 2}, {"LOWERLAYERDOWN", 3}, {"TESTING", 4}, {"DORMANT", 5}, {"UP", 6}, {NULL, -1}}; if (!(lname = get_flag_string(flags, *((int*)(RTA_DATA(attr))), 0))) error_exit("Invalid state."); @@ -1337,7 +1337,7 @@ static int ipaddr_listflush(char **argv) addrinfo.scope = -1; while (*argv) { switch (idx = substring_to_idx(*argv, cmd_objectlist)) { - case 0: + case 0: {// ADDR_TO if (!*++argv) error_exit("Incomplete Command line"); else if (!strcmp(*argv, "0")) return 0; @@ -1374,10 +1374,10 @@ static int ipaddr_listflush(char **argv) free(name); addrinfo.scope = scope; } - break; + break; case 2: // ADDR_UP addrinfo.up = 1; - break; + break; case 3: // ADDR_LABEL if (!*++argv) error_exit("Incomplete Command line"); addrinfo.label = *argv; @@ -1385,7 +1385,7 @@ static int ipaddr_listflush(char **argv) case 4: // ADDR_DEV if (!*++argv) error_exit("Incomplete Command line"); - default: + default: if (TT.filter_dev) error_exit("Either \"dev\" is duplicate or %s is garbage", *argv); @@ -1396,7 +1396,7 @@ static int ipaddr_listflush(char **argv) } link_show(&tmp); - while ( linfo && (dlist = dlist_pop(&linfo))){ + while ( linfo && (dlist = dlist_pop(&linfo))){ struct linkdata *tmp = (struct linkdata*) dlist; char *temp = &tmp->iface[0]; @@ -1412,7 +1412,7 @@ static int ipaddr_listflush(char **argv) if ( fnmatch(addrinfo.label, temp, 0)) { ipaddr_print(tmp, 1); continue; - } + } } if (!TT.addressfamily && ! TT.flush ) print_link_output(tmp); @@ -1456,7 +1456,7 @@ static int ipaddr_print( struct linkdata *link, int flag_l) if (addrinfo.ifindex && addrinfo.ifindex != addressInfo->ifa_index) continue; - if (addrinfo.to) { + if (addrinfo.to) { memset(rta_tb, 0, sizeof(rta_tb)); int rt_len = IFA_PAYLOAD(addr_ptr); for (rta = IFA_RTA(addressInfo); RTA_OK(rta, rt_len); rta=RTA_NEXT(rta, rt_len)) { @@ -1499,7 +1499,7 @@ static int ipaddr_print( struct linkdata *link, int flag_l) if ((addr_ptr->nlmsg_type == NLMSG_DONE) || (addr_ptr->nlmsg_type == NLMSG_ERROR) || (TT.flush && addrinfo.to)) - goto ret_stop; + goto ret_stop; } if ((addr_ptr->nlmsg_type == NLMSG_DONE) || (addr_ptr->nlmsg_type == NLMSG_ERROR)) @@ -1703,7 +1703,7 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) if (attr[RTA_OIF]) { if (gfilter.odev !=0 && gfilter.odev != *(int*)RTA_DATA(attr[RTA_OIF])) return 0; - sprintf(out, "%s dev %s ", out, + sprintf(out, "%s dev %s ", out, if_indextoname(*(int*)RTA_DATA(attr[RTA_OIF]), toybuf)); } @@ -1741,13 +1741,13 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) sprintf(out, "%s error %d", out, ci->rta_error); } if (attr[RTA_IIF] && !gfilter.idev) - sprintf(out, "%s iif %s", out, + sprintf(out, "%s iif %s", out, if_indextoname(*(int*)RTA_DATA(attr[RTA_IIF]), toybuf)); if (attr[RTA_METRICS]) print_rta_metrics(out, attr[RTA_METRICS]); - if (TT.flush || (TT.connected && !TT.from_ok)) + if (TT.flush || (TT.connected && !TT.from_ok)) memcpy(toybuf, (void*)mhdr,mhdr->nlmsg_len); if (TT.flush) { @@ -1824,7 +1824,7 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) static int route_get(char **argv) { int idx, flag; - struct arglist cmd_objectlist[] = {{"from", 0}, {"iif", 1}, {"oif", 2}, + struct arglist cmd_objectlist[] = {{"from", 0}, {"iif", 1}, {"oif", 2}, {"dev", 3}, {"notify", 4}, {"connected", 5}, {"to", 6}, {NULL, -1}}; char *idev = NULL, *odev = NULL; struct { @@ -1843,7 +1843,7 @@ static int route_get(char **argv) switch(idx = substring_to_idx(*argv, cmd_objectlist)) { case 0: TT.from_ok = 1; // dst address case 6: argv++; //fallthrough - default: + default: { uint32_t addr[8] = {0,}, netmask = 0; uint8_t len = 0; @@ -1876,7 +1876,7 @@ static int route_get(char **argv) break; } } - if (!request.msg.rtm_dst_len) + if (!request.msg.rtm_dst_len) error_exit("need at least destination address"); send_nlmesg(0, 0, 0, &request, sizeof(request)); @@ -1917,8 +1917,8 @@ static int route_get(char **argv) static int route_show_flush(char **argv) { struct arglist cmd_objectlist[] = {{"protocol", 0}, {"dev", 1}, {"oif", 2}, - {"iif", 3}, {"via", 4}, {"table", 5}, {"cache", 6}, {"from", 7}, - {"to", 8}, {"all", 9}, {"root", 10}, {"match", 11}, {"exact", 12}, + {"iif", 3}, {"via", 4}, {"table", 5}, {"cache", 6}, {"from", 7}, + {"to", 8}, {"all", 9}, {"root", 10}, {"match", 11}, {"exact", 12}, {"main", 13}, {NULL,-1}}; int family = TT.addressfamily, idx; struct { @@ -1946,7 +1946,7 @@ static int route_show_flush(char **argv) int dev = get_ifaceindex(*argv, 1); if (idx == 3) gfilter.idev = dev; - else gfilter.odev = dev; + else gfilter.odev = dev; } break; case 4: @@ -2121,7 +2121,7 @@ static int route_update(char **argv, unsigned int route_flags) char* ptr; if (!*++argv) show_iproute_help(); metric = strtoul(*argv, &ptr, 0); - if (!(!*ptr && metric <= 0xFFFFFFFFUL)) + if (!(!*ptr && metric <= 0xFFFFFFFFUL)) error_exit("Invalid argument metric %s.",*argv); else res = metric; @@ -2252,7 +2252,7 @@ static int ruleupdate(char **argv) for (; *argv; argv++) { switch ((idx = substring_to_idx(*argv, options))) { case 0: - case 1: + case 1: { // e.g. from IP/Netmask and to IP/Netmask. uint32_t addr[4] = {0,}, netmask = 0; uint8_t len = 0, *tmp; @@ -2269,7 +2269,7 @@ static int ruleupdate(char **argv) } break; case 2: - case 4: + case 4: { // e.g. Preference p# and fwmark MARK uint32_t pref; char *ptr; @@ -2352,10 +2352,10 @@ static int ruleupdate(char **argv) request.msg.rtm_type = rtmtype_str2idx(*argv); } break; - case 10: + case 10: show_iprule_help(); break; // Unreachable code. - default: + default: error_exit("Invalid argument '%s'", *argv); break; // Unreachable code. } @@ -2578,7 +2578,7 @@ static int read_tunnel(struct ip_tunnel_parm *ptnl) return 0; } -static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, +static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, int ipt_opt_idx) { int idx; @@ -2588,7 +2588,7 @@ static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, {"okey", 3}, {"seq", 4}, {"iseq", 5}, {"oseq", 6}, {"csum", 7}, {"icsum", 8}, {"ocsum", 9}, {"nopmtudisc", 10}, {"pmtudisc", 11}, {"remote", 12}, {"local", 13},{"dev", 14}, {"ttl", 15}, {"tos", 16}, - {"dsfield", 17}, {"name", 18}, {NULL, -1} + {"dsfield", 17}, {"name", 18}, {NULL, -1} }; ptnl->iph.version = 4; // The value indicates the version of IP (4 or 6) @@ -2764,11 +2764,11 @@ static int tunnellist(char **argv) memset(&iptnl, 0, sizeof(iptnl)); parse_iptunnel_args(&iptnl, argv, 3); - if (iptnl.iph.protocol == IPPROTO_IPIP) + if (iptnl.iph.protocol == IPPROTO_IPIP) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "tunl0", SIOCGETTUNNEL, &iptnl); - else if (iptnl.iph.protocol == IPPROTO_GRE) + else if (iptnl.iph.protocol == IPPROTO_GRE) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "gre0", SIOCGETTUNNEL, &iptnl); - else if (iptnl.iph.protocol == IPPROTO_IPV6) + else if (iptnl.iph.protocol == IPPROTO_IPV6) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "sit0", SIOCGETTUNNEL, &iptnl); else return read_tunnel(&iptnl); diff --git a/toys/pending/ipcrm.c b/toys/pending/ipcrm.c index cec1b12f..6febfa4d 100644 --- a/toys/pending/ipcrm.c +++ b/toys/pending/ipcrm.c @@ -73,7 +73,7 @@ void ipcrm_main(void) !strcmp(*toys.argv, "sem") || !strcmp(*toys.argv, "msg"))) { int t = (toys.argv[0][1] == 'h')? 1 : (toys.argv[0][1] == 's')? 2:3; - while (*(++toys.argv)) do_ipcrm(0, t, *toys.argv); + while (*(++toys.argv)) do_ipcrm(0, t, *toys.argv); } else { struct arg_list *tmp; diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index b5986af7..af3ff31e 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -268,7 +268,7 @@ static void sem_array(void) "allocated semaphores = %d\n", info_buf.semusz, info_buf.semaem); return; - } + } if (flag(l)) { printf("------ Semaphore Limits --------\n"); u.array = (unsigned short *)&info_buf; diff --git a/toys/pending/klogd.c b/toys/pending/klogd.c index 517edafd..c888e9e7 100644 --- a/toys/pending/klogd.c +++ b/toys/pending/klogd.c @@ -33,7 +33,7 @@ GLOBALS( ) static void set_log_level(int level) -{ +{ if (CFG_KLOGD_SOURCE_RING_BUFFER) klogctl(8, NULL, level); else { @@ -47,7 +47,7 @@ static void set_log_level(int level) static void handle_signal(int sig) { if (CFG_KLOGD_SOURCE_RING_BUFFER) { - klogctl(7, NULL, 0); + klogctl(7, NULL, 0); klogctl(0, NULL, 0); } else { set_log_level(7); diff --git a/toys/pending/last.c b/toys/pending/last.c index fd33ad53..4730a675 100644 --- a/toys/pending/last.c +++ b/toys/pending/last.c @@ -44,7 +44,7 @@ static void free_list() static void llist_add_node(struct arg_list **old, void *data) { struct arg_list *new = xmalloc(sizeof(struct arg_list)); - + new->arg = (char*)data; new->next = *old; *old = new; @@ -54,7 +54,7 @@ static void llist_add_node(struct arg_list **old, void *data) static struct arg_list *find_and_dlink(struct arg_list **list, char *devname) { struct arg_list *l = *list; - + while (*list) { struct utmp *ut = (struct utmp *)l->arg; @@ -73,7 +73,7 @@ static void seize_duration(time_t tm0, time_t tm1) { unsigned days, hours, mins; double diff = difftime(tm1, tm0); - + diff = (diff > 0) ? (tm1 - tm0) : 0; toybuf[0] = toybuf[18] = toybuf[28] = '\0'; strncpy(toybuf, ctime(&tm0), 16); // Login Time. @@ -117,13 +117,13 @@ void last_main(void) && strcmp(ut.ut_user, "LOGIN")) ut.ut_type = USER_PROCESS; /* The pair of terminal names '|' / '}' logs the * old/new system time when date changes it. - */ + */ if (!strcmp(ut.ut_user, "date")) { if (ut.ut_line[0] == '|') ut.ut_type = OLD_TIME; if (ut.ut_line[0] == '{') ut.ut_type = NEW_TIME; } - if ((ut.ut_type == SHUTDOWN_TIME) || ((ut.ut_type == RUN_LVL) && + if ((ut.ut_type == SHUTDOWN_TIME) || ((ut.ut_type == RUN_LVL) && (((ut.ut_pid & 255) == '0') || ((ut.ut_pid & 255) == '6')))) { tm[1] = tm[2] = (time_t)ut.ut_tv.tv_sec; @@ -133,8 +133,8 @@ void last_main(void) seize_duration(tm[0], tm[1]); strcpy(ut.ut_line, "system boot"); free_list(); - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); curlog_type = BOOT_TIME; tm[2] = (time_t)ut.ut_tv.tv_sec; @@ -144,8 +144,8 @@ void last_main(void) if (l) { struct utmp *u = (struct utmp *)l->arg; seize_duration(tm[0], u->ut_tv.tv_sec); - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); free(l->arg); free(l); @@ -159,7 +159,7 @@ void last_main(void) switch (type) { case EMPTY: strcpy(toybuf+18, " still"); - strcpy(toybuf+28, "logged in"); + strcpy(toybuf+28, "logged in"); break; case RUN_LVL: strcpy(toybuf+18, "- down "); @@ -174,8 +174,8 @@ void last_main(void) default: break; } - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); } llist_add_node(&TT.list, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut))); diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c index 133d8785..4db3ddef 100644 --- a/toys/pending/modprobe.c +++ b/toys/pending/modprobe.c @@ -61,7 +61,7 @@ static char *path2mod(char *file, char *mod) if (!mod) mod = xmalloc(MODNAME_LEN); from = getbasename(file); - + for (i = 0; i < (MODNAME_LEN-1) && from[i] && from[i] != '.'; i++) mod[i] = (from[i] == '-') ? '_' : from[i]; mod[i] = '\0'; @@ -177,11 +177,11 @@ static int read_line(FILE *fl, char **li) } for (;;) { if (line[len - 1] == '\n') len--; - if (!len) { + if (!len) { free(line); return len; } else if (line[len - 1] != '\\') break; - + len--; nxtlen = getline(&nxtline, &nxtlinelen, fl); if (nxtlen <= 0) break; @@ -223,7 +223,7 @@ static int config_action(struct dirtree *node) free(line), free(linecp), line = linecp = NULL) { char *tk = NULL; - if (!strlen(line)) continue; + if (!strlen(line)) continue; linecp = xstrdup(line); for (tk = strtok(linecp, "# \t"), tcount = 0; tk; tk = strtok(NULL, "# \t"), tcount++) { @@ -317,7 +317,7 @@ static void find_dep(void) mod = get_mod(line, 0); if (!mod) continue; if ((mod->flags & MOD_ALOADED) && !(FLAG(r)|FLAG(D))) continue; - + mod->flags |= MOD_FNDDEPMOD; if ((mod->flags & MOD_NDDEPS) && !mod->dep) { TT.nudeps--; @@ -404,7 +404,7 @@ static void go_probe(struct module_s *m) } if (FLAG(v)) printf("go_prob'ing %s\n", m->name); if (!FLAG(r)) m->dep = llist_rev(m->dep); - + while (m->dep) { struct module_s *m2; char *fn, *options; @@ -534,11 +534,11 @@ void modprobe_main(void) do { // Probe all real names for the alias. char *real = ((struct arg_list *)llist_pop(&module->rnames))->arg; struct module_s *m2 = get_mod(real, 0); - + if (FLAG(v)) printf("probing alias %s by realname %s\n", module->name, real); if (!m2) continue; - if (!(m2->flags & MOD_BLACKLIST) + if (!(m2->flags & MOD_BLACKLIST) && (!(m2->flags & MOD_ALOADED) || FLAG(r) || FLAG(D))) go_probe(m2); free(real); diff --git a/toys/pending/route.c b/toys/pending/route.c index 36089ae3..3b0e5be2 100644 --- a/toys/pending/route.c +++ b/toys/pending/route.c @@ -191,7 +191,7 @@ static void display_routes(sa_family_t f) metric_len = RTA_PAYLOAD(rteattr); for (metric = RTA_DATA(rteattr); RTA_OK(metric, metric_len); metric = RTA_NEXT(metric, metric_len)) - if (metric->rta_type == RTAX_ADVMSS) + if (metric->rta_type == RTAX_ADVMSS) mss = *(unsigned *)RTA_DATA(metric); else if (metric->rta_type == RTAX_WINDOW) win = *(unsigned *)RTA_DATA(metric); diff --git a/toys/pending/sh.c b/toys/pending/sh.c index dffa514c..2ca2aa01 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -1053,7 +1053,7 @@ static char *declarep(struct sh_vars *var) } *out = 0; - return ss; + return ss; } // Skip past valid prefix that could go before redirect @@ -1621,7 +1621,7 @@ int do_wildcard_files(struct dirtree *node) lvl = ll; patend = wildcard_path(TT.wcpat, pattern-TT.wcpat, TT.wcdeck, &ll, 1); - // Don't include . entries unless explicitly asked for them + // Don't include . entries unless explicitly asked for them if (*node->name=='.' && *pattern!='.') return 0; // Don't descend into non-directory (was called with DIRTREE_SYMFOLLOW) @@ -4693,7 +4693,7 @@ void local_main(void) if (ff->vars) break; } - // list existing vars (todo: + // list existing vars (todo: if (!toys.optc) { for (var = ff->vars; var; var++) xputs(var->str); // TODO escape return; diff --git a/toys/pending/strace.c b/toys/pending/strace.c index 24ec52a8..b5047851 100644 --- a/toys/pending/strace.c +++ b/toys/pending/strace.c @@ -288,8 +288,8 @@ static void print_struct(long addr) fprintf(stderr, ", st_nlink=%ld, st_uid=%d, st_gid=%d, " "st_blksize=%ld, st_blocks=%ld, st_size=%lld, st_atime=%ld, " "st_mtime=%ld, st_ctime=%ld}", (long) sb.st_nlink, sb.st_uid, - sb.st_gid, (long) sb.st_blksize, sb.st_blocks, (long long)sb.st_size, - sb.st_atime, sb.st_mtime, sb.st_ctime); + sb.st_gid, (long) sb.st_blksize, sb.st_blocks, (long long)sb.st_size, + sb.st_atime, sb.st_mtime, sb.st_ctime); } else { fprintf(stderr, "{st_mode="); print_mode(sb.st_mode); diff --git a/toys/pending/stty.c b/toys/pending/stty.c index a997f49d..217c0c2b 100644 --- a/toys/pending/stty.c +++ b/toys/pending/stty.c @@ -65,7 +65,7 @@ static speed_t speed(int baud) for (i=0;i<ARRAY_LEN(bauds);i++) if (bauds[i] == baud) break; if (i == ARRAY_LEN(bauds)) error_exit("unknown speed: %d", baud); - return i+4081*(i>16); + return i+4081*(i>=16); } struct flag { diff --git a/toys/pending/sulogin.c b/toys/pending/sulogin.c index f58754bc..4c26f351 100644 --- a/toys/pending/sulogin.c +++ b/toys/pending/sulogin.c @@ -3,8 +3,8 @@ * Copyright 2014 Ashish Kumar Gupta <ashishkguptaiit.cse@gmail.com> * Copyright 2014 Kyungwan Han <asura321@gmail.com> * - * - * Relies on libcrypt for hash calculation. + * + * Relies on libcrypt for hash calculation. * No support for PAM/securetty/selinux/login script/issue/utmp @@ -27,7 +27,7 @@ GLOBALS( struct termios crntio; ) -static void timeout_handle(int signo) +static void timeout_handle(int signo) { tcsetattr(0, TCSANOW, &(TT.crntio)); fflush(stdout); @@ -54,7 +54,7 @@ static int validate_password(char *pwd) ret = read_password(toybuf, sizeof(toybuf), s); if(TT.timeout) alarm(0); - if ( ret && !toybuf[0]) { + if ( ret && !toybuf[0]) { xprintf("Normal startup.\n"); return -1; } @@ -66,7 +66,7 @@ static int validate_password(char *pwd) return ret; } -static void run_shell(char *shell) +static void run_shell(char *shell) { snprintf(toybuf,sizeof(toybuf), "-%s", shell); execl(shell, toybuf, NULL); @@ -92,7 +92,7 @@ void sulogin_main(void) dup2( fd, 1); dup2( fd, 2); if (fd > 2) close(fd); - } + } for (temp = forbid; *temp; temp++) unsetenv(*temp); diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c index 8c60dcd8..d80bea0e 100644 --- a/toys/pending/syslogd.c +++ b/toys/pending/syslogd.c @@ -84,7 +84,7 @@ int logger_lookup(int where, char *key) //search the given name and return its value static char *dec(int val, CODE *clist, char *buf) { - for (; clist->c_name; clist++) + for (; clist->c_name; clist++) if (val == clist->c_val) return clist->c_name; sprintf(buf, "%u", val); @@ -258,7 +258,7 @@ static void open_logfiles(void) rp.ai_socktype = SOCK_DGRAM; rp.ai_protocol = IPPROTO_UDP; - if (getaddrinfo(tmpfile, NULL, &rp, &info) || !info) + if (getaddrinfo(tmpfile, NULL, &rp, &info) || !info) perror_exit("BAD ADDRESS: can't find : %s ", tmpfile); ((struct sockaddr_in*)info->ai_addr)->sin_port = htons(port); memcpy(&tfd->saddr, info->ai_addr, info->ai_addrlen); diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c index fb0aa77d..ef614c65 100644 --- a/toys/pending/tcpsvd.c +++ b/toys/pending/tcpsvd.c @@ -1,9 +1,9 @@ -/* tcpsvd.c - TCP(UDP)/IP service daemon +/* tcpsvd.c - TCP(UDP)/IP service daemon * * Copyright 2013 Ashwini Kumar <ak.ashwini@gmail.com> * Copyright 2013 Sandeep Sharma <sandeep.jack2756@gmail.com> * Copyright 2013 Kyungwan Han <asura321@gmail.com> - * + * * No Standard. USE_TCPSVD(NEWTOY(tcpsvd, "^<3c#=30<1b#=20<0C:u:l:hEv", TOYFLAG_USR|TOYFLAG_BIN)) @@ -16,8 +16,8 @@ config TCPSVD help usage: tcpsvd [-hEv] [-c N] [-C N[:MSG]] [-b N] [-u User] [-l Name] IP Port Prog usage: udpsvd [-hEv] [-c N] [-u User] [-l Name] IP Port Prog - - Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection. + + Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection. Run PROG for each connection. IP IP to listen on, 0 = all @@ -49,7 +49,7 @@ GLOBALS( struct list_pid { struct list_pid *next; - char *ip; + char *ip; int pid; }; @@ -71,11 +71,11 @@ struct list_pid *pids = NULL; static char *sock_to_address(struct sockaddr *sock, int flags) { char hbuf[NI_MAXHOST] = {0,}; - char sbuf[NI_MAXSERV] = {0,}; + char sbuf[NI_MAXSERV] = {0,}; int status = 0; socklen_t len = sizeof(struct sockaddr_in6); - if (!(status = getnameinfo(sock, len, hbuf, sizeof(hbuf), sbuf, + if (!(status = getnameinfo(sock, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), flags))) { if (flags & NI_NUMERICSERV) return xmprintf("%s:%s",hbuf, sbuf); return xmprintf("%s",hbuf); @@ -119,9 +119,9 @@ static int haship(char *addr) // Remove a node from the list. static char *delete(struct list_pid **pids, int pid) { - struct list_pid *prev, *free_node, *head = *pids; + struct list_pid *prev, *free_node, *head = *pids; char *ip = NULL; - + if (!head) return NULL; prev = free_node = NULL; while (head) { @@ -182,7 +182,7 @@ static void handle_exit(int sig) } } -// Grab uid and gid +// Grab uid and gid static void get_uidgid(uid_t *uid, gid_t *gid, char *ug) { struct passwd *pass = NULL; @@ -207,7 +207,7 @@ static void get_uidgid(uid_t *uid, gid_t *gid, char *ug) if (!(grp = getgrnam(group))) { n = atolx_range(group, 0, INT_MAX); if (!(grp = getgrgid(n))) perror_exit("Invalid group '%s'",group); - } + } } if (grp) *gid = grp->gr_gid; } @@ -221,8 +221,8 @@ static int create_bind_sock(char *host, struct sockaddr *haddr) unsigned long port; errno = 0; - port = strtoul(toys.optargs[1], &ptr, 10); - if (errno || port > 65535) + port = strtoul(toys.optargs[1], &ptr, 10); + if (errno || port > 65535) error_exit("Invalid port, Range is [0-65535]"); if (*ptr) ptr = toys.optargs[1]; else { @@ -231,12 +231,12 @@ static int create_bind_sock(char *host, struct sockaddr *haddr) } memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = (TT.udp ? SOCK_DGRAM : SOCK_STREAM); - if ((ret = getaddrinfo(host, ptr, &hints, &res))) + if ((ret = getaddrinfo(host, ptr, &hints, &res))) perror_exit("%s", gai_strerror(ret)); - for (rp = res; rp; rp = rp->ai_next) + for (rp = res; rp; rp = rp->ai_next) if ( (rp->ai_family == AF_INET) || (rp->ai_family == AF_INET6)) break; if (!rp) error_exit("Invalid IP %s", host); @@ -255,7 +255,7 @@ static void handle_signal(int sig) if (FLAG(v)) xprintf("got signal %d, exit\n", sig); raise(sig); _exit(sig + 128); //should not reach here -} +} void tcpsvd_main(void) { @@ -275,7 +275,7 @@ void tcpsvd_main(void) if ((ptr = strchr(TT.C, ':'))) *ptr++ = 0; TT.maxc = atolx_range(TT.C, 1, INT_MAX); } - + fd = create_bind_sock(toys.optargs[0], (struct sockaddr*)&haddr); if (FLAG(u)) { get_uidgid(&uid, &gid, TT.u); @@ -289,11 +289,11 @@ void tcpsvd_main(void) if (FLAG(u)) xprintf("%s: listening on %s, starting, uid %u, gid %u\n", toys.which->name, server, uid, gid); - else + else xprintf("%s: listening on %s, starting\n", toys.which->name, server); } for (j = 0; j < HASH_NR; j++) h[j].head = 0; - sigatexit(handle_signal); + sigatexit(handle_signal); signal(SIGCHLD, handle_exit); while (1) { diff --git a/toys/pending/telnetd.c b/toys/pending/telnetd.c index 235bd174..47107dcc 100644 --- a/toys/pending/telnetd.c +++ b/toys/pending/telnetd.c @@ -1,4 +1,4 @@ -/* telnetd.c - Telnet Server +/* telnetd.c - Telnet Server * * Copyright 2013 Sandeep Sharma <sandeep.jack2756@gmail.com> * Copyright 2013 Kyungwan Han <asura321@gmail.com> @@ -177,7 +177,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) char *curr ,*start,*end; int i = 0; - curr = start = tm->buff2+tm->buff2_avail; + curr = start = tm->buff2+tm->buff2_avail; end = tm->buff2 + c -1; tm->rem = 0; while (curr <= end) { @@ -189,7 +189,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) } else { toybuf[i++] = *curr++; curr++; - if (curr < end && (*curr == '\n' || *curr == '\0')) + if (curr < end && (*curr == '\n' || *curr == '\0')) curr++; continue; } @@ -197,7 +197,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) if ((curr + 1) > end) { tm->rem = 1; - break; + break; } if (*(curr+1) == IAC) { //IAC as data --> IAC IAC toybuf[i++] = *(curr+1); @@ -213,8 +213,8 @@ static int handle_iacs(struct term_session *tm, int c, int fd) if (*(curr+2) == TELOPT_NAWS) { struct winsize ws; if ((curr+8) >= end) { //ensure we have data to process. - tm->rem = end - curr; - break; + tm->rem = end - curr; + break; } ws.ws_col = (curr[3] << 8) | curr[4]; ws.ws_row = (curr[5] << 8) | curr[6]; @@ -226,7 +226,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) while (*curr != IAC && curr <= end) { curr++; tm->rem++; - } + } if (*curr == IAC) { tm->rem = 0; continue; @@ -259,7 +259,7 @@ static int dup_iacs(char *start, int fd, int len) if (needle) c = needle - start; else c = len; count = writeall(fd, start, c); - if (count < 0) break; + if (count < 0) break; len -= count; ret += count; start += count; @@ -287,11 +287,11 @@ void telnetd_main(void) if (pty_fd > TT.gmax_fd) TT.gmax_fd = pty_fd; tm = xzalloc(sizeof(struct term_session)); tm->child_pid = TT.fork_pid; - tm->new_fd = 0; - tm->pty_fd = pty_fd; - if (session_list) { + tm->new_fd = 0; + tm->pty_fd = pty_fd; + if (session_list) { tm->next = session_list; - session_list = tm; + session_list = tm; } else session_list = tm; } @@ -299,7 +299,7 @@ void telnetd_main(void) tv.tv_sec = TT.w_sec; tv.tv_usec = 0; tv_ptr = &tv; - } + } signal(SIGCHLD, generic_signal); for (;;) { @@ -312,9 +312,9 @@ void telnetd_main(void) if (tm->pty_fd > 0 && tm->buff1_avail < BUFSIZE) FD_SET(tm->pty_fd, &rd); if (tm->new_fd >= 0 && tm->buff2_avail < BUFSIZE) FD_SET(tm->new_fd, &rd); - if (tm->pty_fd > 0 && (tm->buff2_avail - tm->buff2_written) > 0) + if (tm->pty_fd > 0 && (tm->buff2_avail - tm->buff2_written) > 0) FD_SET(tm->pty_fd, &wr); - if (tm->new_fd >= 0 && (tm->buff1_avail - tm->buff1_written) > 0) + if (tm->new_fd >= 0 && (tm->buff1_avail - tm->buff1_written) > 0) FD_SET(tm->new_fd, &wr); tm = tm->next; } @@ -366,12 +366,12 @@ void telnetd_main(void) } c = handle_iacs(tm, c, tm->pty_fd); tm->buff2_avail += c; - if ((w = write(tm->pty_fd, tm->buff2+ tm->buff2_written, + if ((w = write(tm->pty_fd, tm->buff2+ tm->buff2_written, tm->buff2_avail - tm->buff2_written)) < 0) break; tm->buff2_written += w; } if (FD_ISSET(tm->pty_fd, &wr)) { - if ((w = write(tm->pty_fd, tm->buff2 + tm->buff2_written, + if ((w = write(tm->pty_fd, tm->buff2 + tm->buff2_written, tm->buff2_avail - tm->buff2_written)) < 0) break; tm->buff2_written += w; } diff --git a/toys/pending/tftp.c b/toys/pending/tftp.c index 80f14392..967e7a11 100644 --- a/toys/pending/tftp.c +++ b/toys/pending/tftp.c @@ -97,7 +97,7 @@ static int mkpkt_request(uint8_t *buffer, int opcode, char *path, int mode) buffer[0] = opcode >> 8; buffer[1] = opcode & 0xff; if(strlen(path) > TFTP_BLKSIZE) error_exit("path too long"); - return sprintf((char*) &buffer[2], "%s%c%s", path, 0, + return sprintf((char*) &buffer[2], "%s%c%s", path, 0, (mode ? "octet" : "netascii")) + 3; } @@ -137,7 +137,7 @@ static int read_server(int sd, void *buf, int len, { socklen_t alen; ssize_t nb; - + for (;;) { memset(buf, 0, len); alen = sizeof(struct sockaddr_storage); @@ -163,7 +163,7 @@ static ssize_t write_server(int sd, void *buf, size_t len, struct sockaddr_storage *to) { ssize_t nb; - + for (;;) { nb = sendto(sd, buf, len, 0, (struct sockaddr *)to, sizeof(struct sockaddr_storage)); @@ -178,7 +178,7 @@ static ssize_t write_server(int sd, void *buf, size_t len, } // checks packet for data and updates block no -static inline int check_data( uint8_t *packet, uint16_t *opcode, +static inline int check_data( uint8_t *packet, uint16_t *opcode, uint16_t *blockno) { *opcode = (uint16_t) packet[0] << 8 | (uint16_t) packet[1]; diff --git a/toys/pending/traceroute.c b/toys/pending/traceroute.c index c6bcfc31..6107ff3b 100644 --- a/toys/pending/traceroute.c +++ b/toys/pending/traceroute.c @@ -100,7 +100,7 @@ static u_int16_t in_cksum(u_int16_t *p, u_int len) u.c[1] = 0; sum += u.w; } - // end-around-carry + // end-around-carry sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return (~sum); @@ -133,7 +133,7 @@ static void send_probe4(int seq, int ttl) if (res < 0) perror_exit("setsockopt ttl %d", ttl); len = TT.msg_len; - res = sendto(TT.snd_sock, out, len, 0, (struct sockaddr *) &dest, + res = sendto(TT.snd_sock, out, len, 0, (struct sockaddr *) &dest, sizeof(struct sockaddr_in)); if (res != len) perror_exit(" sendto"); } @@ -148,7 +148,7 @@ static void send_probe6(int seq, int ttl) send_data6->ident = TT.ident; ((struct sockaddr_in6 *)&dest)->sin6_port = TT.port; - if (setsockopt(TT.snd_sock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, + if (setsockopt(TT.snd_sock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) error_exit("setsockopt ttl %d", ttl); out = send_data6; @@ -225,12 +225,12 @@ static void do_trace() gettimeofday(&t1, NULL); t2 = t1; - while ((tleft = (int)(tv - ((unsigned long long)(t2.tv_sec * 1000ULL + while ((tleft = (int)(tv - ((unsigned long long)(t2.tv_sec * 1000ULL + t2.tv_usec/1000) - (unsigned long long)(t1.tv_sec * 1000ULL + t1.tv_usec/1000)))) >= 0) { unsigned delta = 0; - if (!(res = poll(pfd, 1, tleft))) { - xprintf(" *"); + if (!(res = poll(pfd, 1, tleft))) { + xprintf(" *"); break; } gettimeofday(&t2, NULL); @@ -276,28 +276,28 @@ static void do_trace() ricmp->icmp_code); } else { hicmp = (struct icmp *) ((char*)hip + (hip->ip_hl << 2)); - if (ricmp->icmp_type == ICMP_ECHOREPLY + if (ricmp->icmp_type == ICMP_ECHOREPLY && ricmp->icmp_id == ntohs(TT.ident) && ricmp->icmp_seq == ntohs(seq)) icmp_res = ICMP_UNREACH_PORT; - else if ((hip->ip_hl << 2) + ICMP_HD_SIZE4 + else if ((hip->ip_hl << 2) + ICMP_HD_SIZE4 <= (rcv_len - (rcv_pkt->ip_hl << 2)) && hip->ip_p == IPPROTO_ICMP && hicmp->icmp_id == htons(TT.ident) && hicmp->icmp_seq == htons(seq)) - icmp_res = (ricmp->icmp_type == ICMP_TIMXCEED ? -1 : + icmp_res = (ricmp->icmp_type == ICMP_TIMXCEED ? -1 : ricmp->icmp_code); } } if (!icmp_res) continue; if (addrlen > 0) { - if (memcmp(&((struct sockaddr_in *)&last_addr)->sin_addr, - &((struct sockaddr_in *)&from)->sin_addr, + if (memcmp(&((struct sockaddr_in *)&last_addr)->sin_addr, + &((struct sockaddr_in *)&from)->sin_addr, sizeof(struct in_addr))) { if (!(toys.optflags & FLAG_n)) { char host[NI_MAXHOST]; - if (!getnameinfo((struct sockaddr *) &from, + if (!getnameinfo((struct sockaddr *) &from, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, 0)) xprintf(" %s (", host); else xprintf(" %s (", inet_ntoa( @@ -359,7 +359,7 @@ static void do_trace() xprintf(" !C"); ++fexit; break; - case ICMP_UNREACH_NET_UNKNOWN: + case ICMP_UNREACH_NET_UNKNOWN: case ICMP_UNREACH_HOST_UNKNOWN: xprintf(" !U"); ++fexit; @@ -407,8 +407,8 @@ static void do_trace() if (!icmp_res) continue; if (addrlen > 0) { - if (memcmp(&((struct sockaddr_in6 *)&last_addr)->sin6_addr, - &((struct sockaddr_in6 *)&from)->sin6_addr, + if (memcmp(&((struct sockaddr_in6 *)&last_addr)->sin6_addr, + &((struct sockaddr_in6 *)&from)->sin6_addr, sizeof(struct in6_addr))) { if (!(toys.optflags & FLAG_n)) { char host[NI_MAXHOST]; @@ -467,7 +467,7 @@ static void do_trace() } xputc('\n'); if(!TT.istraceroute6) { - if (!memcmp(&((struct sockaddr_in *)&from)->sin_addr, + if (!memcmp(&((struct sockaddr_in *)&from)->sin_addr, &((struct sockaddr_in *)&dest)->sin_addr, sizeof(struct in_addr)) || dest_reach || (fexit && fexit >= TT.ttl_probes -1)) break; @@ -479,8 +479,8 @@ void traceroute_main(void) { unsigned pack_size = 0, tyser = 0; int lsrr = 0, set = 1; - - if(!(toys.optflags & FLAG_4) && + + if(!(toys.optflags & FLAG_4) && (inet_pton(AF_INET6, toys.optargs[0], &dest))) toys.optflags |= FLAG_6; @@ -511,29 +511,29 @@ void traceroute_main(void) if (TT.istraceroute6) { int two = 2; #ifdef IPV6_RECVPKTINFO - setsockopt(TT.recv_sock, SOL_IPV6, IPV6_RECVPKTINFO, &set, + setsockopt(TT.recv_sock, SOL_IPV6, IPV6_RECVPKTINFO, &set, sizeof(set)); - setsockopt(TT.recv_sock, SOL_IPV6, IPV6_2292PKTINFO, &set, + setsockopt(TT.recv_sock, SOL_IPV6, IPV6_2292PKTINFO, &set, sizeof(set)); #else setsockopt(TT.recv_sock, SOL_IPV6, IPV6_PKTINFO, &set, sizeof(set)); #endif - if (setsockopt(TT.recv_sock, SOL_RAW, IPV6_CHECKSUM, &two, + if (setsockopt(TT.recv_sock, SOL_RAW, IPV6_CHECKSUM, &two, sizeof(two)) < 0) perror_exit("setsockopt RAW_CHECKSUM"); } set_flag_dr(TT.recv_sock); if (!TT.istraceroute6) { - if (toys.optflags & FLAG_U) + if (toys.optflags & FLAG_U) TT.snd_sock = xsocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); else TT.snd_sock = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if (toys.optflags & FLAG_i) bind_to_interface(TT.snd_sock); - resolve_addr(toys.optargs[0], AF_INET, ((toys.optflags & FLAG_U) ? - SOCK_DGRAM : SOCK_RAW), ((toys.optflags & FLAG_U) ? IPPROTO_UDP : + resolve_addr(toys.optargs[0], AF_INET, ((toys.optflags & FLAG_U) ? + SOCK_DGRAM : SOCK_RAW), ((toys.optflags & FLAG_U) ? IPPROTO_UDP : IPPROTO_ICMP), &dest); if (lsrr > 0) { unsigned char optlist[MAX_IPOPTLEN]; @@ -543,7 +543,7 @@ void traceroute_main(void) ++lsrr; optlist[0] = IPOPT_NOP; - optlist[1] = IPOPT_LSRR;// loose source route option + optlist[1] = IPOPT_LSRR;// loose source route option size = lsrr * sizeof(TT.gw_list[0]); optlist[2] = size + 3; optlist[3] = IPOPT_MINOFF; @@ -555,17 +555,17 @@ void traceroute_main(void) } } else TT.snd_sock = xsocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); - if (setsockopt(TT.snd_sock, SOL_SOCKET, SO_SNDBUF, &TT.msg_len, + if (setsockopt(TT.snd_sock, SOL_SOCKET, SO_SNDBUF, &TT.msg_len, sizeof(TT.msg_len)) < 0) perror_exit("SO_SNDBUF failed "); if (!TT.istraceroute6) { - if ((toys.optflags & FLAG_t) && + if ((toys.optflags & FLAG_t) && setsockopt(TT.snd_sock, IPPROTO_IP, IP_TOS, &tyser, sizeof(tyser)) < 0) perror_exit("IP_TOS %ld failed ", TT.tos); #ifdef IP_DONTFRAG if ((toys.optflags & FLAG_F) && - (setsockopt(TT.snd_sock, IPPROTO_IP, IP_DONTFRAG, &set, + (setsockopt(TT.snd_sock, IPPROTO_IP, IP_DONTFRAG, &set, sizeof(set)) < 0)) perror_exit("IP_DONTFRAG failed "); #endif } else if (setsockopt(TT.snd_sock, IPPROTO_IPV6, IPV6_TCLASS, &TT.tos, @@ -589,10 +589,10 @@ void traceroute_main(void) xbind(TT.snd_sock,(struct sockaddr*)&source, sizeof(struct sockaddr_in)); } - if(TT.first_ttl > TT.max_ttl) + if(TT.first_ttl > TT.max_ttl) error_exit("ERROR :Range for -f is 1 to %ld (max ttl)", TT.max_ttl); - xprintf("traceroute to %s(%s)", toys.optargs[0], + xprintf("traceroute to %s(%s)", toys.optargs[0], inet_ntoa(((struct sockaddr_in *)&dest)->sin_addr)); } else { if (toys.optflags & FLAG_i) bind_to_interface(TT.snd_sock); @@ -614,7 +614,7 @@ void traceroute_main(void) ((struct sockaddr_in6 *)&dest)->sin6_port = htons(1025); xconnect(p_fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_in6)); - if(getsockname(p_fd, (struct sockaddr *)&prb, &len)) + if(getsockname(p_fd, (struct sockaddr *)&prb, &len)) error_exit("probe addr failed"); close(p_fd); prb.sin6_port = 0; @@ -622,7 +622,7 @@ void traceroute_main(void) xbind(TT.recv_sock, (struct sockaddr*)&prb, sizeof(struct sockaddr_in6)); } - inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&dest)->sin6_addr, + inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&dest)->sin6_addr, addr_str, INET6_ADDRSTRLEN); xprintf("traceroute6 to %s(%s)", toys.optargs[0], addr_str); } diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c index c421498e..261c7e48 100644 --- a/toys/pending/useradd.c +++ b/toys/pending/useradd.c @@ -110,7 +110,7 @@ void useradd_main(void) free(s); } - /*add user to system + /*add user to system * 1. add an entry to /etc/passwd and /etcshadow file * 2. Copy /etc/skel dir contents to use home dir * 3. update the user passwd by running 'passwd' utility @@ -123,10 +123,10 @@ void useradd_main(void) update_password("/etc/passwd", pwd.pw_name, entry, 0); free(entry); - if (toys.optflags & FLAG_S) - entry = xmprintf("%s:!!:%u::::::", pwd.pw_name, + if (toys.optflags & FLAG_S) + entry = xmprintf("%s:!!:%u::::::", pwd.pw_name, (unsigned)(time(NULL))/(24*60*60)); //passwd is not set initially - else entry = xmprintf("%s:!!:%u:0:99999:7:::", pwd.pw_name, + else entry = xmprintf("%s:!!:%u:0:99999:7:::", pwd.pw_name, (unsigned)(time(0))/(24*60*60)); //passwd is not set initially update_password("/etc/shadow", pwd.pw_name, entry, 0); free(entry); diff --git a/toys/pending/userdel.c b/toys/pending/userdel.c index 69c520aa..a77fb28e 100644 --- a/toys/pending/userdel.c +++ b/toys/pending/userdel.c @@ -13,7 +13,7 @@ config USERDEL help usage: userdel [-r] USER usage: deluser [-r] USER - + Delete USER from the SYSTEM -r remove home directory @@ -96,9 +96,9 @@ void userdel_main(void) update_password("/etc/shadow", pwd->pw_name, 0, 0); // delete the group named USER, and remove user from group. - // could update_password() be used for this? + // could update_password() be used for this? // not a good idea, as update_passwd() updates one entry at a time - // in this case it will be modifying the files as many times the + // in this case it will be modifying the files as many times the // USER appears in group database files. So the customized version // of update_passwd() is here. update_groupfiles("/etc/group", *toys.optargs); diff --git a/toys/pending/xzcat.c b/toys/pending/xzcat.c index 6fdf3428..cbe48fb7 100644 --- a/toys/pending/xzcat.c +++ b/toys/pending/xzcat.c @@ -13,7 +13,7 @@ config XZCAT default n help usage: xzcat [filename...] - + Decompress listed files to stdout. Use stdin if no files listed. */ @@ -35,7 +35,7 @@ config XZCAT * which is not used in the kernel. Unsupported * check types return XZ_OPTIONS_ERROR if * XZ_DEC_ANY_CHECK was not defined at build time. - * @XZ_MEM_ERROR: Allocating memory failed. The amount of memory + * @XZ_MEM_ERROR: Allocating memory failed. The amount of memory * that was tried to be allocated was no more than the * dict_max argument given to xz_dec_init(). * @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than @@ -52,11 +52,11 @@ config XZCAT * different between multi-call and single-call * mode; more information below. * - * XZ_BUF_ERROR is returned when two consecutive calls to XZ code cannot + * XZ_BUF_ERROR is returned when two consecutive calls to XZ code cannot * consume any input and cannot produce any new output. This happens when * there is no new input available, or the output buffer is full while at * least one output byte is still pending. Assuming your code is not buggy, - * you can get this error only when decoding a compressed stream that is + * you can get this error only when decoding a compressed stream that is * truncated or otherwise corrupt. */ enum xz_ret { @@ -305,7 +305,7 @@ void xzcat_main(void) // BEGIN xz_private.h -/* Uncomment as needed to enable BCJ filter decoders. +/* Uncomment as needed to enable BCJ filter decoders. * These cost about 2.5 k when all are enabled; SPARC and IA64 make 0.7 k * */ diff --git a/toys/posix/kill.c b/toys/posix/kill.c index f869e368..dc4c370f 100644 --- a/toys/posix/kill.c +++ b/toys/posix/kill.c @@ -130,7 +130,7 @@ void kill_main(void) if (!readfile(toybuf, toybuf, sizeof(toybuf)) || !*toybuf) continue; // Check with omit list. - for (count = 0; count < ocount; count++) + for (count = 0; count < ocount; count++) if (procpid == olist[count]) break; if (count != ocount) continue; diff --git a/toys/posix/od.c b/toys/posix/od.c index c12055e6..b4f77fd5 100644 --- a/toys/posix/od.c +++ b/toys/posix/od.c @@ -163,7 +163,7 @@ static void od_outline(void) // If more than one byte of input consumed, average rounding up. j = od_out_t(types+i, buf, &bytes); j = (j+bytes-1)/bytes; - + if (j > pad) pad = j; } diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 173c97f3..5c1b234c 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -2,7 +2,7 @@ * * Copyright 2012 Felix Janda <felix.janda@posteo.de> * - * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html + * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html * * Deviations from posix: the FILE argument isn't mandatory, none == '-' diff --git a/toys/posix/ps.c b/toys/posix/ps.c index e4a69a4f..676bfcb9 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -556,7 +556,7 @@ static char *string_field(struct procpid *tb, struct ofields *field) // Clock displays } else if (which <= PS_TIME_) { - int unit = 60, pad = 2, j = TT.ticks; + int unit = 60, pad = 2, j = TT.ticks; time_t seconds; if (which!=PS_TIME_) unit *= 60*24; @@ -619,7 +619,7 @@ static char *string_field(struct procpid *tb, struct ofields *field) if (slot[SLOT_sid]==*slot) *s++ = 's'; if (slot[SLOT_vmlck]) *s++ = 'L'; if (slot[SLOT_ttypgrp]==*slot) *s++ = '+'; - } + } *s = 0; } else if (which==PS_STIME) { time_t t = time(0)-slot[SLOT_uptime]+slot[SLOT_starttime]/TT.ticks; @@ -1255,7 +1255,7 @@ static int ksort(void *aa, void *bb) // Collect ->extra field from leaf nodes DIRTREE_SAVEd by get_ps() into array // (recursion because tree from get_thread() isn't flat list of siblings) -static struct procpid **collate_leaves(struct procpid **tb, struct dirtree *dt) +static struct procpid **collate_leaves(struct procpid **tb, struct dirtree *dt) { while (dt) { struct dirtree *next = dt->next; @@ -1278,7 +1278,7 @@ static struct procpid **collate(int count, struct dirtree *dt) collate_leaves(tbsort, dt); return tbsort; -} +} // parse command line arguments (ala -k -o) with a comma separated FIELD list static void default_ko(char *s, void *fields, char *err, struct arg_list *arg) @@ -1742,13 +1742,15 @@ static void top_common( if (timeout<=now) timeout = new.whence+TT.top.d; if (timeout<=now || timeout>now+TT.top.d) timeout = now+TT.top.d; + fflush(stdout); + // In batch mode, we ignore the keyboard. if (FLAG(b)) { msleep(timeout-now); // Make an obvious gap between datasets. xputs("\n\n"); break; - } else fflush(stdout); + } recalc = 1; i = scan_key_getsize(scratch, timeout-now, &TT.width, &TT.height); diff --git a/toys/posix/sed.c b/toys/posix/sed.c index f7a49f2a..98fbd957 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -91,7 +91,7 @@ config SED = Print the current line number (plus newline) # Comment, ignores rest of this line of SCRIPT (until newline) - Commands that take an argument: + Commands that take an argument: : LABEL Target for jump commands a TEXT Append text to output before reading next line @@ -109,7 +109,7 @@ config SED i/I Ignore case when matching p Print resulting line when match found and replaced w [file] Write (append) line to file when match replaced - t LABEL Test, jump if s/// command matched this line since last test + t LABEL Test, jump if s/// command matched this line since last test T LABEL Test false, jump to :LABEL only if no s/// found a match w FILE Write (append) line to file y/old/new/ Change each character in 'old' to corresponding character @@ -308,7 +308,7 @@ static void sed_line(char **pline, long plen) command->hit = TT.count; if (!command->lmatch[1] && !command->rmatch[1]) miss = 1; - } + } // Didn't match? lm = !(command->not^!!command->hit); @@ -449,7 +449,7 @@ static void sed_line(char **pline, long plen) } // Pending append goes out right after N - goto done; + goto done; } else if (c=='p' || c=='P') { char *l = (c=='P') ? strchr(line, TT.delim) : 0; @@ -1110,7 +1110,7 @@ void sed_main(void) } parse_pattern(0, 0); dlist_terminate(TT.pattern); - if (TT.nextlen) error_exit("no }"); + if (TT.nextlen) error_exit("no }"); TT.fdout = 1; TT.remember = xstrdup(""); diff --git a/toys/posix/tail.c b/toys/posix/tail.c index 1b17fcd5..494e1516 100644 --- a/toys/posix/tail.c +++ b/toys/posix/tail.c @@ -148,7 +148,7 @@ static void tail_continue() } fd = TT.F[i].fd; path = TT.F[i].path; - + if (stat(TT.F[i].path, &sb)) { if (fd >= 0) { close(fd); diff --git a/toys/posix/tar.c b/toys/posix/tar.c index 00cbe968..780acc4c 100644 --- a/toys/posix/tar.c +++ b/toys/posix/tar.c @@ -289,7 +289,7 @@ static int add_to_tar(struct dirtree *node) } else if ((node->again&DIRTREE_BREADTH) && node->child) { struct dirtree *dt, **sort = xmalloc(sizeof(void *)*node->extra); - for (node->extra = 0, dt = node->child; dt; dt = dt->next) + for (node->extra = 0, dt = node->child; dt; dt = dt->next) sort[node->extra++] = dt; qsort(sort, node->extra--, sizeof(void *), (void *)dirtree_sort); node->child = *sort; @@ -616,7 +616,7 @@ static void extract_to_disk(char *name) if (dirflush(name, S_ISDIR(ala))) { if (S_ISREG(ala) && !TT.hdr.link_target) skippy(TT.hdr.size); - + return; } diff --git a/toys/posix/ulimit.c b/toys/posix/ulimit.c index 642f8871..ffb1eb38 100644 --- a/toys/posix/ulimit.c +++ b/toys/posix/ulimit.c @@ -28,7 +28,7 @@ config ULIMIT Print or set resource limits for process number PID. If no LIMIT specified (or read-only -ap selected) display current value (sizes in bytes). Default is ulimit -P $PPID -Sf" (show soft filesize of your shell). - + -P PID to affect (default $PPID) -a Show all limits -S Set/show soft limit -H Set/show hard (maximum) limit diff --git a/toys/posix/uname.c b/toys/posix/uname.c index c89e84c3..dfa5762f 100644 --- a/toys/posix/uname.c +++ b/toys/posix/uname.c @@ -7,7 +7,7 @@ USE_UNAME(NEWTOY(uname, "paomvrns", TOYFLAG_BIN)) USE_ARCH(NEWTOY(arch, 0, TOYFLAG_USR|TOYFLAG_BIN)) -config ARCH +config ARCH bool "arch" default y help @@ -26,7 +26,7 @@ config UNAME -s System name -n Network (domain) name -r Kernel Release number - -v Kernel Version + -v Kernel Version -m Machine (hardware) name -a All of the above (in order) diff --git a/toys/posix/uuencode.c b/toys/posix/uuencode.c index 3bede303..3d9b2fef 100644 --- a/toys/posix/uuencode.c +++ b/toys/posix/uuencode.c @@ -8,7 +8,7 @@ USE_UUENCODE(NEWTOY(uuencode, "<1>2m", TOYFLAG_USR|TOYFLAG_BIN)) config UUENCODE bool "uuencode" - default y + default y help usage: uuencode [-m] [INFILE] ENCODE_FILENAME @@ -51,7 +51,7 @@ void uuencode_main(void) out = (x>>((3-j)*6)) & 0x3f; xputc(FLAG(m) ? (j > bytes ? '=' : toybuf[out]) : (out ? out + 0x20 : 0x60)); - } + } } xputc('\n'); } diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 0fd9b550..1762d879 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -4,16 +4,17 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/wc.html -USE_WC(NEWTOY(wc, "mcwl", TOYFLAG_USR|TOYFLAG_BIN)) +USE_WC(NEWTOY(wc, "Lcmwl", TOYFLAG_USR|TOYFLAG_BIN)) config WC bool "wc" default y help - usage: wc [-lwcm] [FILE...] + usage: wc [-Llwcm] [FILE...] Count lines, words, and characters in input. + -L Show max line length -l Show lines -w Show words -c Show bytes @@ -28,7 +29,7 @@ config WC #include "toys.h" GLOBALS( - unsigned long totals[4]; + unsigned long totals[5]; ) static void show_lengths(unsigned long *lengths, char *name) @@ -45,12 +46,13 @@ static void show_lengths(unsigned long *lengths, char *name) if (!(!toys.optc && !(toys.optflags & (toys.optflags-1))) && toys.optc!=1) space = 7; - for (i = 0; i<4; i++) { + for (i = 0; i<ARRAY_LEN(TT.totals); i++) { if (toys.optflags&(1<<i)) { printf(" %*ld"+first, space, lengths[i]); first = 0; } - TT.totals[i] += lengths[i]; + if (i==4) TT.totals[i] = maxof(TT.totals[i], lengths[i]); + else TT.totals[i] += lengths[i]; } if (*toys.optargs) printf(" %s", name); xputc('\n'); @@ -59,15 +61,15 @@ static void show_lengths(unsigned long *lengths, char *name) static void do_wc(int fd, char *name) { int len = 0, clen = 1, space = 0; - unsigned long word = 0, lengths[] = {0,0,0,0}; + unsigned long word = 0, lengths[ARRAY_LEN(TT.totals)] = {0}, line = 0; - // Speed up common case: wc -c normalfile is file length. + // fast path: wc -c normalfile is file length. if (toys.optflags == FLAG_c) { struct stat st; // On Linux, files in /proc often report their size as 0. if (!fstat(fd, &st) && S_ISREG(st.st_mode) && st.st_size) { - lengths[2] = st.st_size; + lengths[3] = st.st_size; goto show; } } @@ -82,8 +84,8 @@ static void do_wc(int fd, char *name) for (pos = 0; pos<len; pos++) { if (toybuf[pos]=='\n') lengths[0]++; - lengths[2]++; - if (FLAG(m)) { + lengths[3]++; + if (FLAG(m)||FLAG(L)) { // If we've consumed next wide char if (--clen<1) { // next wide size, don't count invalid, fetch more data if necessary @@ -91,7 +93,14 @@ static void do_wc(int fd, char *name) if (clen == -1) continue; if (clen == -2 && !done) break; - lengths[3]++; + lengths[2]++; + line += maxof(wcwidth(wchar), 0); + if (wchar=='\t') line += 8-(line&7); + else if (wchar=='\n' || wchar=='\r') { + if (line>lengths[4]) lengths[4] = line; + line = 0; + } + space = iswspace(wchar); } } else space = isspace(toybuf[pos]); @@ -106,6 +115,7 @@ static void do_wc(int fd, char *name) if (pos != len) memmove(toybuf, toybuf+pos, len-pos); len -= pos; } + if (line>lengths[4]) lengths[4] = line; show: show_lengths(lengths, name); diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c index c5dca26a..c2a1f02d 100644 --- a/toys/posix/xargs.c +++ b/toys/posix/xargs.c @@ -98,10 +98,25 @@ static void signal_P(int sig) else TT.P++; } +static void waitchild(int options) +{ + int ii, status; + + if (1>waitpid(-1, &status, options)) return; + TT.np--; + ii = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+128; + if (ii == 255) { + error_msg("%s: exited with status 255; aborting", *toys.optargs); + toys.exitval = 124; + } else if ((ii|1)==127) toys.exitval = ii; + else if (ii>127) toys.exitval = 125; + else if (ii) toys.exitval = 123; +} + void xargs_main(void) { struct double_list *dlist = 0, *dtemp; - int entries, bytes, done = 0, status; + int entries, bytes, done = 0; char *data = 0, **out = 0; pid_t pid = 0; @@ -133,10 +148,17 @@ void xargs_main(void) while (data || !done) { TT.entries = 0; TT.bytes = bytes; + if (TT.np) waitchild(WNOHANG*!(TT.np==TT.P||(!data && done))); + if (toys.exitval==124) break; + + // Arbitrary number of execs, can't just leak memory each time... + llist_traverse(dlist, llist_free_double); + dlist = 0; + free(out); + out = 0; // Loop reading input for (;;) { - // Read line if (!data) { size_t l = 0; @@ -159,15 +181,15 @@ void xargs_main(void) if (!TT.entries) { if (data) error_exit("argument too long"); - if (pid || FLAG(r)) goto reap_children; + if (pid || FLAG(r)) break; } // Fill out command line to exec - out = xzalloc((entries+TT.entries+1)*sizeof(char *)); - memcpy(out, toys.optargs, entries*sizeof(char *)); + out = xzalloc((toys.optc+TT.entries+1)*sizeof(char *)); + memcpy(out, toys.optargs, toys.optc*sizeof(char *)); TT.entries = 0; TT.bytes = bytes; - if (dlist) dlist->prev->next = 0; + dlist_terminate(dlist); for (dtemp = dlist; dtemp; dtemp = dtemp->next) handle_entries(dtemp->data, out+entries); @@ -178,7 +200,7 @@ void xargs_main(void) if (FLAG(p)) { fprintf(stderr, "?"); if (!TT.tty) TT.tty = xfopen("/dev/tty", "re"); - if (!fyesno(TT.tty, 0)) goto reap_children; + if (!fyesno(TT.tty, 0)) continue; } else fprintf(stderr, "\n"); } @@ -188,29 +210,7 @@ void xargs_main(void) xexec(out); } TT.np++; - -reap_children: - while (TT.np) { - int xv = (TT.np == TT.P) || (!data && done); - - if (1>(xv = waitpid(-1, &status, WNOHANG*!xv))) break; - TT.np--; - xv = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+128; - if (xv == 255) { - error_msg("%s: exited with status 255; aborting", *out); - toys.exitval = 124; - break; - } else if ((xv|1)==127) toys.exitval = xv; - else if (xv>127) xv = 125; - else if (xv) toys.exitval = 123; - } - - // Abritrary number of execs, can't just leak memory each time... - llist_traverse(dlist, llist_free_double); - dlist = 0; - free(out); - out = 0; } - while (TT.np && -1 != wait(&status)) TT.np--; + while (TT.np) waitchild(0); if (TT.tty) fclose(TT.tty); } |