aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2023-08-01 17:29:43 -0700
committerElliott Hughes <enh@google.com>2023-08-02 11:01:05 -0700
commite827a9371f88e6e0401da61eb7db5b0b2996c931 (patch)
tree004d8ddc0924805bc5e3bdad4aabf78b8d1f185b
parentbb9e0218b46de02007f6253aea43440cce7b7416 (diff)
parentf19d41bdce188ba9c07fc06dc078015bc81b3e9a (diff)
downloadtoybox-e827a9371f88e6e0401da61eb7db5b0b2996c931.tar.gz
Upgrade toybox to f19d41bdce188ba9c07fc06dc078015bc81b3e9a
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update toybox For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I9dadf1366b36acf6a89e7a8c67442ed0122c217c
-rw-r--r--.github/workflows/toybox.yml2
-rw-r--r--Android.bp2
-rw-r--r--METADATA8
-rw-r--r--android/device/generated/flags.h12
-rw-r--r--android/device/generated/globals.h27
-rw-r--r--android/device/generated/help.h6
-rw-r--r--android/device/generated/newtoys.h2
-rw-r--r--android/device/generated/tags.h20
-rw-r--r--android/linux/generated/flags.h12
-rw-r--r--android/linux/generated/globals.h27
-rw-r--r--android/linux/generated/help.h6
-rw-r--r--android/linux/generated/newtoys.h2
-rw-r--r--android/linux/generated/tags.h20
-rw-r--r--android/mac/generated/flags.h12
-rw-r--r--android/mac/generated/globals.h27
-rw-r--r--android/mac/generated/help.h6
-rw-r--r--android/mac/generated/newtoys.h2
-rw-r--r--android/mac/generated/tags.h20
-rw-r--r--lib/lib.c28
-rw-r--r--mkroot/README.root18
-rwxr-xr-xmkroot/mkroot.sh77
-rwxr-xr-xmkroot/packages/busybox43
-rwxr-xr-xmkroot/packages/dropbear (renamed from mkroot/root/dropbear)0
-rwxr-xr-xmkroot/packages/dynamic (renamed from mkroot/root/dynamic)0
-rwxr-xr-xmkroot/packages/overlay (renamed from mkroot/root/overlay)0
-rwxr-xr-xmkroot/packages/plumbing (renamed from mkroot/root/plumbing)0
-rwxr-xr-xmkroot/packages/tests (renamed from mkroot/root/tests)0
-rwxr-xr-xmkroot/record-commands5
-rwxr-xr-xmkroot/tar-for-web.sh41
-rwxr-xr-xmkroot/testroot.sh5
-rwxr-xr-xrun-tests-on-android.sh1
-rw-r--r--scripts/runtest.sh8
-rw-r--r--tests/dd.test17
-rwxr-xr-xtests/tar.test9
-rw-r--r--toys.h2
-rw-r--r--toys/other/blkid.c2
-rw-r--r--toys/other/bzcat.c7
-rw-r--r--toys/other/xxd.c4
-rw-r--r--toys/posix/cp.c3
-rw-r--r--toys/posix/cpio.c1
-rw-r--r--toys/posix/dd.c (renamed from toys/pending/dd.c)240
-rw-r--r--toys/posix/id.c2
-rw-r--r--toys/posix/ls.c22
-rw-r--r--www/news.html264
-rw-r--r--www/release.txt33
-rw-r--r--www/roadmap.html3
46 files changed, 712 insertions, 336 deletions
diff --git a/.github/workflows/toybox.yml b/.github/workflows/toybox.yml
index 1c69b31f..a2f06219 100644
--- a/.github/workflows/toybox.yml
+++ b/.github/workflows/toybox.yml
@@ -26,8 +26,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- - env:
- ASAN: 1
- name: Setup
run: sudo apt-get install build-essential
- name: Configure
diff --git a/Android.bp b/Android.bp
index 4fecb10d..3927a6a4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -80,7 +80,6 @@ all_srcs = [
"toys/other/which.c",
"toys/other/xxd.c",
"toys/other/yes.c",
- "toys/pending/dd.c",
"toys/pending/diff.c",
"toys/pending/expr.c",
"toys/pending/getopt.c",
@@ -94,6 +93,7 @@ all_srcs = [
"toys/posix/cpio.c",
"toys/posix/cut.c",
"toys/posix/date.c",
+ "toys/posix/dd.c",
"toys/posix/dirname.c",
"toys/posix/du.c",
"toys/posix/echo.c",
diff --git a/METADATA b/METADATA
index ac5b154e..1cac2965 100644
--- a/METADATA
+++ b/METADATA
@@ -1,6 +1,6 @@
# This project was upgraded with external_updater.
# Usage: tools/external_updater/updater.sh update toybox
-# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
name: "toybox"
description: "Toybox: all-in-one Linux command line."
@@ -13,11 +13,11 @@ third_party {
type: GIT
value: "https://github.com/landley/toybox"
}
- version: "b564a6028bead88340f76e3ecaf5516d1b0d85f9"
+ version: "f19d41bdce188ba9c07fc06dc078015bc81b3e9a"
license_type: UNENCUMBERED
last_upgrade_date {
year: 2023
- month: 7
- day: 11
+ month: 8
+ day: 1
}
}
diff --git a/android/device/generated/flags.h b/android/device/generated/flags.h
index 726c1777..c34f2116 100644
--- a/android/device/generated/flags.h
+++ b/android/device/generated/flags.h
@@ -1844,9 +1844,9 @@
#undef FLAG_S
#endif
-// ls (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
+// ls (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
#undef OPTSTR_ls
-#define OPTSTR_ls "(sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
+#define OPTSTR_ls "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
#ifdef CLEANUP_ls
#undef CLEANUP_ls
#undef FOR_ls
@@ -1886,6 +1886,7 @@
#undef FLAG_X7E
#undef FLAG_X21
#undef FLAG_show_control_chars
+#undef FLAG_block_size
#undef FLAG_full_time
#undef FLAG_color
#undef FLAG_sort
@@ -5605,9 +5606,10 @@
#define FLAG_X7E (1LL<<33)
#define FLAG_X21 (1LL<<34)
#define FLAG_show_control_chars (1LL<<35)
-#define FLAG_full_time (1LL<<36)
-#define FLAG_color (1LL<<37)
-#define FLAG_sort (1LL<<38)
+#define FLAG_block_size (1LL<<36)
+#define FLAG_full_time (1LL<<37)
+#define FLAG_color (1LL<<38)
+#define FLAG_sort (1LL<<39)
#endif
#ifdef FOR_lsattr
diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h
index 95f67779..39abc8f6 100644
--- a/android/device/generated/globals.h
+++ b/android/device/generated/globals.h
@@ -659,21 +659,6 @@ struct crontab_data {
char *cdir;
};
-// toys/pending/dd.c
-
-struct dd_data {
- int show_xfer, show_records;
- unsigned long long bytes, in_full, in_part, out_full, out_part, start;
- char *buff;
- struct {
- char *name, *bp;
- int fd;
- long sz, count;
- unsigned long long offset;
- } in, out;
- unsigned conv, iflag, oflag;
-};
-
// toys/pending/dhcp.c
struct dhcp_data {
@@ -1300,6 +1285,14 @@ struct date_data {
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 {
@@ -1409,7 +1402,7 @@ struct logger_data {
// toys/posix/ls.c
struct ls_data {
- long w, l;
+ long w, l, block_size;
char *color, *sort;
struct dirtree *files, *singledir;
@@ -1752,7 +1745,6 @@ extern union global_union {
struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
- struct dd_data dd;
struct dhcp_data dhcp;
struct dhcp6_data dhcp6;
struct dhcpd_data dhcpd;
@@ -1803,6 +1795,7 @@ extern union global_union {
struct cpio_data cpio;
struct cut_data cut;
struct date_data date;
+ struct dd_data dd;
struct df_data df;
struct du_data du;
struct env_data env;
diff --git a/android/device/generated/help.h b/android/device/generated/help.h
index 210acc62..2d5b3fe2 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -492,8 +492,6 @@
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
-#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
-
#define HELP_crontab "usage: crontab [-u user] FILE\n [-u user] [-e | -l | -r]\n [-c dir]\n\nFiles used to schedule the execution of programs.\n\n-c crontab dir\n-e edit user's crontab\n-l list user's crontab\n-r delete user's crontab\n-u user\nFILE Replace crontab by FILE ('-': stdin)"
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
@@ -596,7 +594,7 @@
#define HELP_mkdir "usage: mkdir [-vp] [-m MODE] [DIR...]\n\nCreate one or more directories.\n\n-m Set permissions of directory to mode\n-p Make parent directories as needed\n-v Verbose"
-#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (1024 byte units)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
+#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (in --block-size)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--block-size N block size (default 1024)\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
#define HELP_logger "usage: logger [-s] [-t TAG] [-p [FACILITY.]PRIORITY] [MESSAGE...]\n\nLog message (or stdin) to syslog.\n\n-s Also write message to stderr\n-t Use TAG instead of username to identify message source\n-p Specify PRIORITY with optional FACILITY. Default is \"user.notice\""
@@ -642,6 +640,8 @@
#define HELP_df "usage: df [-HPkhi] [-t type] [FILE...]\n\nThe \"disk free\" command shows total/used/available disk space for\neach filesystem listed on the command line, or all currently mounted\nfilesystems.\n\n-a Show all (including /proc and friends)\n-P The SUSv3 \"Pedantic\" option\n-k Sets units back to 1024 bytes (the default without -P)\n-h Human readable (K=1024)\n-H Human readable (k=1000)\n-i Show inodes instead of blocks\n-t type Display only filesystems of this type\n\nPedantic provides a slightly less useful output format dictated by POSIX,\nand sets the units to 512 bytes instead of the default 1024 bytes."
+#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
+
#define HELP_date "usage: date [-u] [-I RES] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]\n\nSet/get the current date/time. With no SET shows the current date.\n\n-d Show DATE instead of current time (convert date format)\n-D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])\n-I RES ISO 8601 with RESolution d=date/h=hours/m=minutes/s=seconds/n=ns\n-r Use modification time of FILE instead of current date\n-s DATE Set the system clock to DATE.\n-u Use UTC instead of current timezone\n\nSupported input formats:\n\nMMDDhhmm[[CC]YY][.ss] POSIX\n@UNIXTIME[.FRACTION] seconds since midnight 1970-01-01\nYYYY-MM-DD [hh:mm[:ss]] ISO 8601\nhh:mm[:ss] 24-hour time today\n\nAll input formats can be followed by fractional seconds, and/or a UTC\noffset such as -0800.\n\nAll input formats can be preceded by TZ=\"id\" to set the input time zone\nseparately from the output time zone. Otherwise $TZ sets both.\n\n+FORMAT specifies display format string using strftime(3) syntax:\n\n%% literal % %n newline %t tab\n%S seconds (00-60) %M minute (00-59) %m month (01-12)\n%H hour (0-23) %I hour (01-12) %p AM/PM\n%y short year (00-99) %Y year %C century\n%a short weekday name %A weekday name %u day of week (1-7, 1=mon)\n%b short month name %B month name %Z timezone name\n%j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)\n%N nanosec (output only)\n\n%U Week of year (0-53 start Sunday) %W Week of year (0-53 start Monday)\n%V Week of year (1-53 start Monday, week < 4 days not part of this year)\n\n%F \"%Y-%m-%d\" %R \"%H:%M\" %T \"%H:%M:%S\" %z timezone (-0800)\n%D \"%m/%d/%y\" %r \"%I:%M:%S %p\" %h \"%b\" %:z timezone (-08:00)\n%x locale date %X locale time %c locale date/time %s unix epoch time"
#define HELP_cut "usage: cut [-Ds] [-bcCfF LIST] [-dO DELIM] [FILE...]\n\nPrint selected parts of lines from each FILE to standard output.\n\nEach selection LIST is comma separated, either numbers (counting from 1)\nor dash separated ranges (inclusive, with X- meaning to end of line and -X\nfrom start). By default selection ranges are sorted and collated, use -D\nto prevent that.\n\n-b Select bytes (with -n round start/end down to start of utf8 char)\n-c Select UTF-8 characters\n-C Select unicode columns\n-d Use DELIM (default is TAB for -f, run of whitespace for -F)\n-D Don't sort/collate selections or match -fF lines without delimiter\n-f Select fields (words) separated by single DELIM character\n-F Select fields separated by DELIM regex\n-O Output delimiter (default one space for -F, input delim for -f)\n-s Skip lines without delimiters"
diff --git a/android/device/generated/newtoys.h b/android/device/generated/newtoys.h
index 58d74078..01dc7e84 100644
--- a/android/device/generated/newtoys.h
+++ b/android/device/generated/newtoys.h
@@ -171,7 +171,7 @@ USE_LOGIN(NEWTOY(login, ">1f:ph:", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_USR|TOYFLAG_BIN))
USE_LOGPATH(NEWTOY(logpath, 0, TOYFLAG_NOHELP|TOYFLAG_USR|TOYFLAG_BIN))
USE_LOSETUP(NEWTOY(losetup, ">2S(sizelimit)#s(show)ro#j:fdcaD[!afj]", TOYFLAG_SBIN))
-USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
USE_LSATTR(NEWTOY(lsattr, "ldapvR", TOYFLAG_BIN))
USE_LSMOD(NEWTOY(lsmod, NULL, TOYFLAG_SBIN))
USE_LSOF(NEWTOY(lsof, "lp*t", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/device/generated/tags.h b/android/device/generated/tags.h
index e1e4d314..463e8d2c 100644
--- a/android/device/generated/tags.h
+++ b/android/device/generated/tags.h
@@ -1,3 +1,13 @@
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
#define DD_conv_fsync 0
#define _DD_conv_fsync (1<<0)
#define DD_conv_noerror 1
@@ -12,16 +22,6 @@
#define _DD_iflag_skip_bytes (1<<1)
#define DD_oflag_seek_bytes 0
#define _DD_oflag_seek_bytes (1<<0)
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
#define PS_PID 0
#define _PS_PID (1<<0)
#define PS_PPID 1
diff --git a/android/linux/generated/flags.h b/android/linux/generated/flags.h
index 58b09159..7ee4cb29 100644
--- a/android/linux/generated/flags.h
+++ b/android/linux/generated/flags.h
@@ -1844,9 +1844,9 @@
#undef FLAG_S
#endif
-// ls (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
+// ls (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
#undef OPTSTR_ls
-#define OPTSTR_ls "(sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
+#define OPTSTR_ls "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
#ifdef CLEANUP_ls
#undef CLEANUP_ls
#undef FOR_ls
@@ -1886,6 +1886,7 @@
#undef FLAG_X7E
#undef FLAG_X21
#undef FLAG_show_control_chars
+#undef FLAG_block_size
#undef FLAG_full_time
#undef FLAG_color
#undef FLAG_sort
@@ -5605,9 +5606,10 @@
#define FLAG_X7E (1LL<<33)
#define FLAG_X21 (1LL<<34)
#define FLAG_show_control_chars (1LL<<35)
-#define FLAG_full_time (1LL<<36)
-#define FLAG_color (1LL<<37)
-#define FLAG_sort (1LL<<38)
+#define FLAG_block_size (1LL<<36)
+#define FLAG_full_time (1LL<<37)
+#define FLAG_color (1LL<<38)
+#define FLAG_sort (1LL<<39)
#endif
#ifdef FOR_lsattr
diff --git a/android/linux/generated/globals.h b/android/linux/generated/globals.h
index 95f67779..39abc8f6 100644
--- a/android/linux/generated/globals.h
+++ b/android/linux/generated/globals.h
@@ -659,21 +659,6 @@ struct crontab_data {
char *cdir;
};
-// toys/pending/dd.c
-
-struct dd_data {
- int show_xfer, show_records;
- unsigned long long bytes, in_full, in_part, out_full, out_part, start;
- char *buff;
- struct {
- char *name, *bp;
- int fd;
- long sz, count;
- unsigned long long offset;
- } in, out;
- unsigned conv, iflag, oflag;
-};
-
// toys/pending/dhcp.c
struct dhcp_data {
@@ -1300,6 +1285,14 @@ struct date_data {
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 {
@@ -1409,7 +1402,7 @@ struct logger_data {
// toys/posix/ls.c
struct ls_data {
- long w, l;
+ long w, l, block_size;
char *color, *sort;
struct dirtree *files, *singledir;
@@ -1752,7 +1745,6 @@ extern union global_union {
struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
- struct dd_data dd;
struct dhcp_data dhcp;
struct dhcp6_data dhcp6;
struct dhcpd_data dhcpd;
@@ -1803,6 +1795,7 @@ extern union global_union {
struct cpio_data cpio;
struct cut_data cut;
struct date_data date;
+ struct dd_data dd;
struct df_data df;
struct du_data du;
struct env_data env;
diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h
index a47bea3d..cc279e8a 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -494,8 +494,6 @@
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
-#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
-
#define HELP_crontab "usage: crontab [-u user] FILE\n [-u user] [-e | -l | -r]\n [-c dir]\n\nFiles used to schedule the execution of programs.\n\n-c crontab dir\n-e edit user's crontab\n-l list user's crontab\n-r delete user's crontab\n-u user\nFILE Replace crontab by FILE ('-': stdin)"
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
@@ -600,7 +598,7 @@
#define HELP_mkdir "usage: mkdir [-vp] [-m MODE] [DIR...]\n\nCreate one or more directories.\n\n-m Set permissions of directory to mode\n-p Make parent directories as needed\n-v Verbose"
-#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (1024 byte units)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
+#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (in --block-size)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--block-size N block size (default 1024)\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
#define HELP_logger "usage: logger [-s] [-t TAG] [-p [FACILITY.]PRIORITY] [MESSAGE...]\n\nLog message (or stdin) to syslog.\n\n-s Also write message to stderr\n-t Use TAG instead of username to identify message source\n-p Specify PRIORITY with optional FACILITY. Default is \"user.notice\""
@@ -648,6 +646,8 @@
#define HELP_df "usage: df [-HPkhi] [-t type] [FILE...]\n\nThe \"disk free\" command shows total/used/available disk space for\neach filesystem listed on the command line, or all currently mounted\nfilesystems.\n\n-a Show all (including /proc and friends)\n-P The SUSv3 \"Pedantic\" option\n-k Sets units back to 1024 bytes (the default without -P)\n-h Human readable (K=1024)\n-H Human readable (k=1000)\n-i Show inodes instead of blocks\n-t type Display only filesystems of this type\n\nPedantic provides a slightly less useful output format dictated by POSIX,\nand sets the units to 512 bytes instead of the default 1024 bytes."
+#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
+
#define HELP_date "usage: date [-u] [-I RES] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]\n\nSet/get the current date/time. With no SET shows the current date.\n\n-d Show DATE instead of current time (convert date format)\n-D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])\n-I RES ISO 8601 with RESolution d=date/h=hours/m=minutes/s=seconds/n=ns\n-r Use modification time of FILE instead of current date\n-s DATE Set the system clock to DATE.\n-u Use UTC instead of current timezone\n\nSupported input formats:\n\nMMDDhhmm[[CC]YY][.ss] POSIX\n@UNIXTIME[.FRACTION] seconds since midnight 1970-01-01\nYYYY-MM-DD [hh:mm[:ss]] ISO 8601\nhh:mm[:ss] 24-hour time today\n\nAll input formats can be followed by fractional seconds, and/or a UTC\noffset such as -0800.\n\nAll input formats can be preceded by TZ=\"id\" to set the input time zone\nseparately from the output time zone. Otherwise $TZ sets both.\n\n+FORMAT specifies display format string using strftime(3) syntax:\n\n%% literal % %n newline %t tab\n%S seconds (00-60) %M minute (00-59) %m month (01-12)\n%H hour (0-23) %I hour (01-12) %p AM/PM\n%y short year (00-99) %Y year %C century\n%a short weekday name %A weekday name %u day of week (1-7, 1=mon)\n%b short month name %B month name %Z timezone name\n%j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)\n%N nanosec (output only)\n\n%U Week of year (0-53 start Sunday) %W Week of year (0-53 start Monday)\n%V Week of year (1-53 start Monday, week < 4 days not part of this year)\n\n%F \"%Y-%m-%d\" %R \"%H:%M\" %T \"%H:%M:%S\" %z timezone (-0800)\n%D \"%m/%d/%y\" %r \"%I:%M:%S %p\" %h \"%b\" %:z timezone (-08:00)\n%x locale date %X locale time %c locale date/time %s unix epoch time"
#define HELP_cut "usage: cut [-Ds] [-bcCfF LIST] [-dO DELIM] [FILE...]\n\nPrint selected parts of lines from each FILE to standard output.\n\nEach selection LIST is comma separated, either numbers (counting from 1)\nor dash separated ranges (inclusive, with X- meaning to end of line and -X\nfrom start). By default selection ranges are sorted and collated, use -D\nto prevent that.\n\n-b Select bytes (with -n round start/end down to start of utf8 char)\n-c Select UTF-8 characters\n-C Select unicode columns\n-d Use DELIM (default is TAB for -f, run of whitespace for -F)\n-D Don't sort/collate selections or match -fF lines without delimiter\n-f Select fields (words) separated by single DELIM character\n-F Select fields separated by DELIM regex\n-O Output delimiter (default one space for -F, input delim for -f)\n-s Skip lines without delimiters"
diff --git a/android/linux/generated/newtoys.h b/android/linux/generated/newtoys.h
index 58d74078..01dc7e84 100644
--- a/android/linux/generated/newtoys.h
+++ b/android/linux/generated/newtoys.h
@@ -171,7 +171,7 @@ USE_LOGIN(NEWTOY(login, ">1f:ph:", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_USR|TOYFLAG_BIN))
USE_LOGPATH(NEWTOY(logpath, 0, TOYFLAG_NOHELP|TOYFLAG_USR|TOYFLAG_BIN))
USE_LOSETUP(NEWTOY(losetup, ">2S(sizelimit)#s(show)ro#j:fdcaD[!afj]", TOYFLAG_SBIN))
-USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
USE_LSATTR(NEWTOY(lsattr, "ldapvR", TOYFLAG_BIN))
USE_LSMOD(NEWTOY(lsmod, NULL, TOYFLAG_SBIN))
USE_LSOF(NEWTOY(lsof, "lp*t", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/linux/generated/tags.h b/android/linux/generated/tags.h
index e1e4d314..463e8d2c 100644
--- a/android/linux/generated/tags.h
+++ b/android/linux/generated/tags.h
@@ -1,3 +1,13 @@
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
#define DD_conv_fsync 0
#define _DD_conv_fsync (1<<0)
#define DD_conv_noerror 1
@@ -12,16 +22,6 @@
#define _DD_iflag_skip_bytes (1<<1)
#define DD_oflag_seek_bytes 0
#define _DD_oflag_seek_bytes (1<<0)
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
#define PS_PID 0
#define _PS_PID (1<<0)
#define PS_PPID 1
diff --git a/android/mac/generated/flags.h b/android/mac/generated/flags.h
index 3f0120bb..7b1829f7 100644
--- a/android/mac/generated/flags.h
+++ b/android/mac/generated/flags.h
@@ -1844,9 +1844,9 @@
#undef FLAG_S
#endif
-// ls (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
+// ls (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb] (sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]
#undef OPTSTR_ls
-#define OPTSTR_ls "(sort):(color):;(full-time)(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
+#define OPTSTR_ls "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)¡(group-directories-first)þZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]"
#ifdef CLEANUP_ls
#undef CLEANUP_ls
#undef FOR_ls
@@ -1886,6 +1886,7 @@
#undef FLAG_X7E
#undef FLAG_X21
#undef FLAG_show_control_chars
+#undef FLAG_block_size
#undef FLAG_full_time
#undef FLAG_color
#undef FLAG_sort
@@ -5605,9 +5606,10 @@
#define FLAG_X7E (1LL<<33)
#define FLAG_X21 (1LL<<34)
#define FLAG_show_control_chars (1LL<<35)
-#define FLAG_full_time (1LL<<36)
-#define FLAG_color (1LL<<37)
-#define FLAG_sort (1LL<<38)
+#define FLAG_block_size (1LL<<36)
+#define FLAG_full_time (1LL<<37)
+#define FLAG_color (1LL<<38)
+#define FLAG_sort (1LL<<39)
#endif
#ifdef FOR_lsattr
diff --git a/android/mac/generated/globals.h b/android/mac/generated/globals.h
index 95f67779..39abc8f6 100644
--- a/android/mac/generated/globals.h
+++ b/android/mac/generated/globals.h
@@ -659,21 +659,6 @@ struct crontab_data {
char *cdir;
};
-// toys/pending/dd.c
-
-struct dd_data {
- int show_xfer, show_records;
- unsigned long long bytes, in_full, in_part, out_full, out_part, start;
- char *buff;
- struct {
- char *name, *bp;
- int fd;
- long sz, count;
- unsigned long long offset;
- } in, out;
- unsigned conv, iflag, oflag;
-};
-
// toys/pending/dhcp.c
struct dhcp_data {
@@ -1300,6 +1285,14 @@ struct date_data {
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 {
@@ -1409,7 +1402,7 @@ struct logger_data {
// toys/posix/ls.c
struct ls_data {
- long w, l;
+ long w, l, block_size;
char *color, *sort;
struct dirtree *files, *singledir;
@@ -1752,7 +1745,6 @@ extern union global_union {
struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
- struct dd_data dd;
struct dhcp_data dhcp;
struct dhcp6_data dhcp6;
struct dhcpd_data dhcpd;
@@ -1803,6 +1795,7 @@ extern union global_union {
struct cpio_data cpio;
struct cut_data cut;
struct date_data date;
+ struct dd_data dd;
struct df_data df;
struct du_data du;
struct env_data env;
diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h
index a47bea3d..cc279e8a 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -494,8 +494,6 @@
#define HELP_dhcp "usage: dhcp [-fbnqvoCRB] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL] [-O OPT]\n\n Configure network dynamically using DHCP.\n\n -i Interface to use (default eth0)\n -p Create pidfile\n -s Run PROG at DHCP events (default /usr/share/dhcp/default.script)\n -B Request broadcast replies\n -t Send up to N discover packets\n -T Pause between packets (default 3 seconds)\n -A Wait N seconds after failure (default 20)\n -f Run in foreground\n -b Background if lease is not obtained\n -n Exit if lease is not obtained\n -q Exit after obtaining lease\n -R Release IP on exit\n -S Log to syslog too\n -a Use arping to validate offered address\n -O Request option OPT from server (cumulative)\n -o Don't request any options (unless -O is given)\n -r Request this IP address\n -x OPT:VAL Include option OPT in sent packets (cumulative)\n -F Ask server to update DNS mapping for NAME\n -H Send NAME as client hostname (default none)\n -V VENDOR Vendor identifier (default 'toybox VERSION')\n -C Don't send MAC as client identifier\n -v Verbose\n\n Signals:\n USR1 Renew current lease\n USR2 Release current lease"
-#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
-
#define HELP_crontab "usage: crontab [-u user] FILE\n [-u user] [-e | -l | -r]\n [-c dir]\n\nFiles used to schedule the execution of programs.\n\n-c crontab dir\n-e edit user's crontab\n-l list user's crontab\n-r delete user's crontab\n-u user\nFILE Replace crontab by FILE ('-': stdin)"
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
@@ -600,7 +598,7 @@
#define HELP_mkdir "usage: mkdir [-vp] [-m MODE] [DIR...]\n\nCreate one or more directories.\n\n-m Set permissions of directory to mode\n-p Make parent directories as needed\n-v Verbose"
-#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (1024 byte units)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
+#define HELP_ls "usage: ls [-1ACFHLNRSUXZabcdfghilmnopqrstuwx] [--color[=auto]] [FILE...]\n\nList files\n\nwhat to show:\n-A all files except . and .. -a all files including .hidden\n-b escape nongraphic chars -d directory, not contents\n-F append /dir *exe @sym |FIFO -f files (no sort/filter/format)\n-H follow command line symlinks -i inode number\n-L follow symlinks -N no escaping, even on tty\n-p put '/' after dir names -q unprintable chars as '?'\n-R recursively list in subdirs -s storage used (in --block-size)\n-Z security context\n\noutput formats:\n-1 list one file per line -C columns (sorted vertically)\n-g like -l but no owner -h human readable sizes\n-l long (show full details) -ll long with nanoseconds (--full-time)\n-m comma separated -n long with numeric uid/gid\n-o long without group column -r reverse order\n-w set column width -x columns (horizontal sort)\n\nsort by: (also --sort=longname,longname... ends with alphabetical)\n-c ctime -r reverse -S size -t time -u atime -U none\n-X extension -! dirfirst -~ nocase\n\n--block-size N block size (default 1024)\n--color =always (default) =auto (when stdout is tty) =never\n exe=green suid=red suidfile=redback stickydir=greenback\n device=yellow symlink=turquoise/red dir=blue socket=purple\n\nLong output uses -cu for display, use -ltc/-ltu to also sort by ctime/atime."
#define HELP_logger "usage: logger [-s] [-t TAG] [-p [FACILITY.]PRIORITY] [MESSAGE...]\n\nLog message (or stdin) to syslog.\n\n-s Also write message to stderr\n-t Use TAG instead of username to identify message source\n-p Specify PRIORITY with optional FACILITY. Default is \"user.notice\""
@@ -648,6 +646,8 @@
#define HELP_df "usage: df [-HPkhi] [-t type] [FILE...]\n\nThe \"disk free\" command shows total/used/available disk space for\neach filesystem listed on the command line, or all currently mounted\nfilesystems.\n\n-a Show all (including /proc and friends)\n-P The SUSv3 \"Pedantic\" option\n-k Sets units back to 1024 bytes (the default without -P)\n-h Human readable (K=1024)\n-H Human readable (k=1000)\n-i Show inodes instead of blocks\n-t type Display only filesystems of this type\n\nPedantic provides a slightly less useful output format dictated by POSIX,\nand sets the units to 512 bytes instead of the default 1024 bytes."
+#define HELP_dd "usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]\n\nCopy/convert blocks of data from input to output, with the following\nkeyword=value modifiers (and their default values):\n\nif=FILE Read FILE (stdin) of=FILE Write to FILE (stdout)\n bs=N Block size in bytes (512) count=N Stop after copying N blocks (all)\n ibs=N Input block size (bs=) obs=N Output block size (bs=)\n skip=N Skip N input blocks (0) seek=N Skip N output blocks (0)\n\nEach =N value accepts the normal unit suffixes (see toybox --help).\n\nThese modifiers take a comma separated list of potential options:\n\niflag=count_bytes,skip_bytes count=N or skip=N is in bytes not blocks\noflag=seek_bytes,append seek=N is in bytes, append output to file\nstatus=noxfer,none don't show transfer rate, no summary info\nconv=\n notrunc Don't truncate output noerror Continue after read errors\n sync Zero pad short reads fsync Flush output to disk at end\n sparse Seek past zeroed output excl Fail if output file exists\n nocreat Fail if of=FILE missing"
+
#define HELP_date "usage: date [-u] [-I RES] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]\n\nSet/get the current date/time. With no SET shows the current date.\n\n-d Show DATE instead of current time (convert date format)\n-D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])\n-I RES ISO 8601 with RESolution d=date/h=hours/m=minutes/s=seconds/n=ns\n-r Use modification time of FILE instead of current date\n-s DATE Set the system clock to DATE.\n-u Use UTC instead of current timezone\n\nSupported input formats:\n\nMMDDhhmm[[CC]YY][.ss] POSIX\n@UNIXTIME[.FRACTION] seconds since midnight 1970-01-01\nYYYY-MM-DD [hh:mm[:ss]] ISO 8601\nhh:mm[:ss] 24-hour time today\n\nAll input formats can be followed by fractional seconds, and/or a UTC\noffset such as -0800.\n\nAll input formats can be preceded by TZ=\"id\" to set the input time zone\nseparately from the output time zone. Otherwise $TZ sets both.\n\n+FORMAT specifies display format string using strftime(3) syntax:\n\n%% literal % %n newline %t tab\n%S seconds (00-60) %M minute (00-59) %m month (01-12)\n%H hour (0-23) %I hour (01-12) %p AM/PM\n%y short year (00-99) %Y year %C century\n%a short weekday name %A weekday name %u day of week (1-7, 1=mon)\n%b short month name %B month name %Z timezone name\n%j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)\n%N nanosec (output only)\n\n%U Week of year (0-53 start Sunday) %W Week of year (0-53 start Monday)\n%V Week of year (1-53 start Monday, week < 4 days not part of this year)\n\n%F \"%Y-%m-%d\" %R \"%H:%M\" %T \"%H:%M:%S\" %z timezone (-0800)\n%D \"%m/%d/%y\" %r \"%I:%M:%S %p\" %h \"%b\" %:z timezone (-08:00)\n%x locale date %X locale time %c locale date/time %s unix epoch time"
#define HELP_cut "usage: cut [-Ds] [-bcCfF LIST] [-dO DELIM] [FILE...]\n\nPrint selected parts of lines from each FILE to standard output.\n\nEach selection LIST is comma separated, either numbers (counting from 1)\nor dash separated ranges (inclusive, with X- meaning to end of line and -X\nfrom start). By default selection ranges are sorted and collated, use -D\nto prevent that.\n\n-b Select bytes (with -n round start/end down to start of utf8 char)\n-c Select UTF-8 characters\n-C Select unicode columns\n-d Use DELIM (default is TAB for -f, run of whitespace for -F)\n-D Don't sort/collate selections or match -fF lines without delimiter\n-f Select fields (words) separated by single DELIM character\n-F Select fields separated by DELIM regex\n-O Output delimiter (default one space for -F, input delim for -f)\n-s Skip lines without delimiters"
diff --git a/android/mac/generated/newtoys.h b/android/mac/generated/newtoys.h
index 58d74078..01dc7e84 100644
--- a/android/mac/generated/newtoys.h
+++ b/android/mac/generated/newtoys.h
@@ -171,7 +171,7 @@ USE_LOGIN(NEWTOY(login, ">1f:ph:", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_USR|TOYFLAG_BIN))
USE_LOGPATH(NEWTOY(logpath, 0, TOYFLAG_NOHELP|TOYFLAG_USR|TOYFLAG_BIN))
USE_LOSETUP(NEWTOY(losetup, ">2S(sizelimit)#s(show)ro#j:fdcaD[!afj]", TOYFLAG_SBIN))
-USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
USE_LSATTR(NEWTOY(lsattr, "ldapvR", TOYFLAG_BIN))
USE_LSMOD(NEWTOY(lsmod, NULL, TOYFLAG_SBIN))
USE_LSOF(NEWTOY(lsof, "lp*t", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/mac/generated/tags.h b/android/mac/generated/tags.h
index e1e4d314..463e8d2c 100644
--- a/android/mac/generated/tags.h
+++ b/android/mac/generated/tags.h
@@ -1,3 +1,13 @@
+#define CP_mode 0
+#define _CP_mode (1<<0)
+#define CP_ownership 1
+#define _CP_ownership (1<<1)
+#define CP_timestamps 2
+#define _CP_timestamps (1<<2)
+#define CP_context 3
+#define _CP_context (1<<3)
+#define CP_xattr 4
+#define _CP_xattr (1<<4)
#define DD_conv_fsync 0
#define _DD_conv_fsync (1<<0)
#define DD_conv_noerror 1
@@ -12,16 +22,6 @@
#define _DD_iflag_skip_bytes (1<<1)
#define DD_oflag_seek_bytes 0
#define _DD_oflag_seek_bytes (1<<0)
-#define CP_mode 0
-#define _CP_mode (1<<0)
-#define CP_ownership 1
-#define _CP_ownership (1<<1)
-#define CP_timestamps 2
-#define _CP_timestamps (1<<2)
-#define CP_context 3
-#define _CP_context (1<<3)
-#define CP_xattr 4
-#define _CP_xattr (1<<4)
#define PS_PID 0
#define _PS_PID (1<<0)
#define PS_PPID 1
diff --git a/lib/lib.c b/lib/lib.c
index c9207a99..4473f89f 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -10,13 +10,16 @@ void verror_msg(char *msg, int err, va_list va)
{
char *s = ": %s";
- fprintf(stderr, "%s: ", toys.which->name);
- if (msg) vfprintf(stderr, msg, va);
- else s+=2;
- if (err>0) fprintf(stderr, s, strerror(err));
- if (err<0 && CFG_TOYBOX_HELP)
- fprintf(stderr, " (see \"%s --help\")", toys.which->name);
- if (msg || err) putc('\n', stderr);
+ // Exit silently in a pipeline
+ if (err != EPIPE) {
+ fprintf(stderr, "%s: ", toys.which->name);
+ if (msg) vfprintf(stderr, msg, va);
+ else s+=2;
+ if (err>0) fprintf(stderr, s, strerror(err));
+ if (err<0 && CFG_TOYBOX_HELP)
+ fprintf(stderr, " (see \"%s --help\")", toys.which->name);
+ if (msg || err) putc('\n', stderr);
+ }
if (!toys.exitval) toys.exitval = (toys.which->flags>>24) ? : 1;
}
@@ -55,14 +58,11 @@ void error_exit(char *msg, ...)
// Die with an error message and strerror(errno)
void perror_exit(char *msg, ...)
{
- // Die silently if our pipeline exited.
- if (errno != EPIPE) {
- va_list va;
+ va_list va;
- va_start(va, msg);
- verror_msg(msg, errno, va);
- va_end(va);
- }
+ va_start(va, msg);
+ verror_msg(msg, errno, va);
+ va_end(va);
xexit();
}
diff --git a/mkroot/README.root b/mkroot/README.root
new file mode 100644
index 00000000..c50d728c
--- /dev/null
+++ b/mkroot/README.root
@@ -0,0 +1,18 @@
+Use ./run-qemu.sh to boot system image to a shell prompt, "exit" when done.
+
+Additional arguments to run-qemu.sh are QEMU arguments,
+$KARGS contains additional linux kernel arguments. For example:
+
+ KARGS=quiet ./run-qemu.sh -hda docs/linux-fullconfig
+ # cat /dev/?da
+ # exit
+
+To extract the root filesystem from cpio.gz and chroot into it
+
+ ( mkdir fs && cd fs && zcat ../initramfs.cpio.gz | cpio -i -d -H newc )
+ chroot fs /init
+
+To recreate the initramfs.cpio.gz from fs directory
+
+ ( cd fs && find . -printf '%P\n' | cpio -o -H newc -R +0:+0 | gzip ) \
+ > initramfs.cpio.gz
diff --git a/mkroot/mkroot.sh b/mkroot/mkroot.sh
index 1c0bc7d0..689faa4f 100755
--- a/mkroot/mkroot.sh
+++ b/mkroot/mkroot.sh
@@ -15,7 +15,7 @@ done
# Set default directory locations (overrideable from command line)
: ${TOP:=$PWD/root} ${BUILD:=$TOP/build} ${LOG:=$BUILD/log}
-: ${AIRLOCK:=$BUILD/airlock} ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/mkroot/root}
+: ${AIRLOCK:=$BUILD/airlock} ${CCC:=$PWD/ccc} ${PKGDIR:=$PWD/mkroot/packages}
announce() { printf "\033]2;$CROSS $*\007" >/dev/tty; printf "\n=== $*\n";}
die() { echo "$@" >&2; exit 1; }
@@ -45,7 +45,7 @@ elif [ -n "$CROSS" ]; then # CROSS=all/allnonstop/$ARCH else list known $ARCHes
fi
# Set per-target output directory (using "host" if not cross-compiling)
-: ${CROSS:=host} ${OUTPUT:=$TOP/$CROSS}
+: ${CROSS:=host} ${OUTPUT:=$TOP/$CROSS} ${OUTDOC:=$OUTPUT/docs}
# Verify selected compiler works
${CROSS_COMPILE}cc --static -xc - -o /dev/null <<< "int main(void){return 0;}"||
@@ -64,13 +64,13 @@ if [ -z "$NOAIRLOCK"] && [ -n "$CROSS_COMPILE" ]; then
rm .singleconfig_airlock || exit 1
fi
export PATH="$AIRLOCK"
- CPIO_OPTS+=--no-preserve-owner
fi
# Create per-target work directories
TEMP="$BUILD/${CROSS}-tmp" && rm -rf "$TEMP" &&
mkdir -p "$TEMP" "$OUTPUT" "$LOG" || exit 1
[ -z "$ROOT" ] && ROOT="$OUTPUT/fs" && rm -rf "$ROOT"
+LOG="$LOG/$CROSS"
# ----- log build output
@@ -79,15 +79,15 @@ if [ -z "$NOLOGPATH" ]; then
# Move cross compiler into $PATH so calls to it get logged
[ -n "$CROSS_COMPILE" ] && PATH="${CROSS_COMPILE%/*}:$PATH" &&
CROSS_COMPILE=${CROSS_COMPILE##*/}
- export WRAPDIR="$BUILD/record-commands" LOGPATH="$LOG/$CROSS-commands.txt"
+ export WRAPDIR="$BUILD/record-commands" LOGPATH="$LOG"-commands.txt
rm -rf "$WRAPDIR" "$LOGPATH" generated/obj &&
WRAPDIR="$WRAPDIR" CROSS_COMPILE= NOSTRIP=1 source mkroot/record-commands ||
exit 1
fi
# Start logging stdout/stderr
-rm -f "$LOG/$CROSS".{n,y} || exit 1
-[ -z "$NOLOG" ] && exec > >(tee "$LOG/$CROSS.n") 2>&1
+rm -f "$LOG".{n,y} || exit 1
+[ -z "$NOLOG" ] && exec > >(tee "$LOG".n) 2>&1
echo "Building for $CROSS"
# ---------------------- Part 2: Create root filesystem -----------------------
@@ -158,7 +158,7 @@ done
# Build static toybox with existing .config if there is one, else defconfig+sh
announce toybox
[ -n "$PENDING" ] && rm -f .config
-[ -e .config ] && CONF=silentoldconfig || unset CONF
+grep -q CONFIG_SH=y .config 2>/dev/null && CONF=silentoldconfig || unset CONF
for i in $PENDING sh route; do XX="$XX"$'\n'CONFIG_${i^^?}=y; done
[ -e "$ROOT"/lib/libc.so ] || export LDFLAGS=--static
PREFIX="$ROOT" make clean \
@@ -177,21 +177,20 @@ if [ -z "$LINUX" ] || [ ! -d "$LINUX/kernel" ]; then
else
# Which architecture are we building a kernel for?
LINUX="$(realpath "$LINUX")"
- [ -z "$TARGET" ] &&
- { [ "$CROSS" == host ] && TARGET="$(uname -m)" || TARGET="$CROSS"; }
+ [ "$CROSS" == host ] && CROSS="$(uname -m)"
# Target-specific info in an (alphabetical order) if/else staircase
# Each target needs board config, serial console, RTC, ethernet, block device.
- if [ "$TARGET" == armv5l ]; then
+ if [ "$CROSS" == armv5l ]; then
# This could use the same VIRT board as armv7, but let's demonstrate a
# different one requiring a separate device tree binary.
QEMU="arm -M versatilepb -net nic,model=rtl8139 -net user"
KARCH=arm KARGS=ttyAMA0 VMLINUX=arch/arm/boot/zImage
KCONF=CPU_ARM926T,MMU,VFP,ARM_THUMB,AEABI,ARCH_VERSATILE,ATAGS,DEPRECATED_PARAM_STRUCT,ARM_ATAG_DTB_COMPAT,ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND,SERIAL_AMBA_PL011,SERIAL_AMBA_PL011_CONSOLE,RTC_CLASS,RTC_DRV_PL031,RTC_HCTOSYS,PCI,PCI_VERSATILE,BLK_DEV_SD,SCSI,SCSI_LOWLEVEL,SCSI_SYM53C8XX_2,SCSI_SYM53C8XX_MMIO,NET_VENDOR_REALTEK,8139CP,SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
DTB=arch/arm/boot/dts/versatile-pb.dtb
- elif [ "$TARGET" == armv7l ] || [ "$TARGET" == aarch64 ]; then
- if [ "$TARGET" == aarch64 ]; then
+ elif [ "$CROSS" == armv7l ] || [ "$CROSS" == aarch64 ]; then
+ if [ "$CROSS" == aarch64 ]; then
QEMU="aarch64 -M virt -cpu cortex-a57"
KARCH=arm64 VMLINUX=arch/arm64/boot/Image
else
@@ -199,59 +198,59 @@ else
fi
KARGS=ttyAMA0
KCONF=MMU,ARCH_MULTI_V7,ARCH_VIRT,SOC_DRA7XX,ARCH_OMAP2PLUS_TYPICAL,ARCH_ALPINE,ARM_THUMB,VDSO,CPU_IDLE,ARM_CPUIDLE,KERNEL_MODE_NEON,SERIAL_AMBA_PL011,SERIAL_AMBA_PL011_CONSOLE,RTC_CLASS,RTC_HCTOSYS,RTC_DRV_PL031,VIRTIO_MENU,VIRTIO_NET,PCI,PCI_HOST_GENERIC,VIRTIO_BLK,VIRTIO_PCI,VIRTIO_MMIO,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,PATA_PLATFORM,PATA_OF_PLATFORM,ATA_GENERIC,ARM_LPAE
- elif [ "$TARGET" == hexagon ]; then
+ elif [ "$CROSS" == hexagon ]; then
QEMU="hexagon -M comet" KARGS=ttyS0 VMLINUX=vmlinux
KARCH="hexagon LLVM_IAS=1" KCONF=SPI,SPI_BITBANG,IOMMU_SUPPORT
- elif [ "$TARGET" == i486 ] || [ "$TARGET" == i686 ] ||
- [ "$TARGET" == x86_64 ] || [ "$TARGET" == x32 ]; then
- if [ "$TARGET" == i486 ]; then
+ elif [ "$CROSS" == i486 ] || [ "$CROSS" == i686 ] ||
+ [ "$CROSS" == x86_64 ] || [ "$CROSS" == x32 ]; then
+ if [ "$CROSS" == i486 ]; then
QEMU="i386 -cpu 486 -global fw_cfg.dma_enabled=false" KCONF=M486
- elif [ "$TARGET" == i686 ]; then
+ elif [ "$CROSS" == i686 ]; then
QEMU="i386 -cpu pentium3" KCONF=MPENTIUMII
else
QEMU=x86_64 KCONF=64BIT
- [ "$TARGET" == x32 ] && KCONF=X86_X32
+ [ "$CROSS" == x32 ] && KCONF=X86_X32
fi
KARCH=x86 KARGS=ttyS0 VMLINUX=arch/x86/boot/bzImage
KCONF=$KCONF,UNWINDER_FRAME_POINTER,PCI,BLK_DEV_SD,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,NET_VENDOR_INTEL,E1000,SERIAL_8250,SERIAL_8250_CONSOLE,RTC_CLASS
- elif [ "$TARGET" == m68k ]; then
+ elif [ "$CROSS" == m68k ]; then
QEMU="m68k -M q800" KARCH=m68k KARGS=ttyS0 VMLINUX=vmlinux
KCONF=MMU,M68040,M68KFPU_EMU,MAC,SCSI,SCSI_LOWLEVEL,BLK_DEV_SD,SCSI_MAC_ESP,MACINTOSH_DRIVERS,NET_VENDOR_NATSEMI,MACSONIC,SERIAL_PMACZILOG,SERIAL_PMACZILOG_TTYS,SERIAL_PMACZILOG_CONSOLE
- elif [ "$TARGET" == mips ] || [ "$TARGET" == mipsel ]; then
+ elif [ "$CROSS" == mips ] || [ "$CROSS" == mipsel ]; then
QEMU="mips -M malta" KARCH=mips KARGS=ttyS0 VMLINUX=vmlinux
KCONF=MIPS_MALTA,CPU_MIPS32_R2,SERIAL_8250,SERIAL_8250_CONSOLE,PCI,BLK_DEV_SD,ATA,ATA_SFF,ATA_BMDMA,ATA_PIIX,NET_VENDOR_AMD,PCNET32,POWER_RESET,POWER_RESET_SYSCON
- [ "$TARGET" == mipsel ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN &&
+ [ "$CROSS" == mipsel ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN &&
QEMU="mipsel -M malta"
- elif [ "$TARGET" == powerpc ]; then
+ elif [ "$CROSS" == powerpc ]; then
KARCH=powerpc QEMU="ppc -M g3beige" KARGS=ttyS0 VMLINUX=vmlinux
KCONF=ALTIVEC,PPC_PMAC,PPC_OF_BOOT_TRAMPOLINE,ATA,ATA_SFF,ATA_BMDMA,PATA_MACIO,BLK_DEV_SD,MACINTOSH_DRIVERS,ADB,ADB_CUDA,NET_VENDOR_NATSEMI,NET_VENDOR_8390,NE2K_PCI,SERIO,SERIAL_PMACZILOG,SERIAL_PMACZILOG_TTYS,SERIAL_PMACZILOG_CONSOLE,BOOTX_TEXT
- elif [ "$TARGET" == powerpc64 ] || [ "$TARGET" == powerpc64le ]; then
+ elif [ "$CROSS" == powerpc64 ] || [ "$CROSS" == powerpc64le ]; then
KARCH=powerpc QEMU="ppc64 -M pseries -vga none" KARGS=hvc0
VMLINUX=vmlinux
KCONF=PPC64,PPC_PSERIES,PPC_OF_BOOT_TRAMPOLINE,BLK_DEV_SD,SCSI_LOWLEVEL,SCSI_IBMVSCSI,ATA,NET_VENDOR_IBM,IBMVETH,HVC_CONSOLE,PPC_TRANSACTIONAL_MEM,PPC_DISABLE_WERROR,SECTION_MISMATCH_WARN_ONLY
- [ "$TARGET" == powerpc64le ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN
- elif [ "$TARGET" = s390x ]; then
+ [ "$CROSS" == powerpc64le ] && KCONF=$KCONF,CPU_LITTLE_ENDIAN
+ elif [ "$CROSS" = s390x ]; then
QEMU="s390x" KARCH=s390 VMLINUX=arch/s390/boot/bzImage
KCONF=MARCH_Z900,PACK_STACK,VIRTIO_NET,VIRTIO_BLK,SCLP_TTY,SCLP_CONSOLE,SCLP_VT220_TTY,SCLP_VT220_CONSOLE,S390_GUEST
- elif [ "$TARGET" == sh2eb ]; then
+ elif [ "$CROSS" == sh2eb ]; then
BUILTIN=1 KARCH=sh VMLINUX=vmlinux
KCONF=CPU_SUBTYPE_J2,CPU_BIG_ENDIAN,SH_JCORE_SOC,SMP,BINFMT_ELF_FDPIC,JCORE_EMAC,SERIAL_UARTLITE,SERIAL_UARTLITE_CONSOLE,HZ_100,CMDLINE_OVERWRITE,SPI,SPI_JCORE,MMC,PWRSEQ_SIMPLE,MMC_BLOCK,MMC_SPI,BINMT_FLAT,BINFMT_MISC,DNOTIFY,INOTIFY_USER,FUSE_FS,I2C,I2C_HELPER_AUTO,LOCALVERSION_AUTO,MTD,MTD_SPI_NOR,MTD_SST25L,MTD_OF_PARTS,POSIX_MQUEUE,SYSVIPC,UEVENT_HELPER,UIO,UIO_PDRV_GENIRQ,FLATMEM_MANUAL,MEMORY_START=0x10000000,CMDLINE=\"console=ttyUL0\ earlycon\"
KCONF+=,BFP_SYSCALL,CRYPTO_DES,CRYPTO_DH,CRYPTO_ECHAINIV,CRYPTO_LZO,CRYPTO_MANAGER_DISABLE_TESTS,CRYPTO_RSA,CRYPTO_SHA1,CRYPTO_SHA3,INET_DIAG,SERIAL_8250
# TODO NET_9P,9P_FS fails to boot in 6.3, unaligned access?
- elif [ "$TARGET" == sh4 ]; then
+ elif [ "$CROSS" == sh4 ]; then
QEMU="sh4 -M r2d -serial null -serial mon:stdio" KARCH=sh
KARGS="ttySC1 noiotrap" VMLINUX=arch/sh/boot/zImage
KCONF=CPU_SUBTYPE_SH7751R,MMU,VSYSCALL,SH_FPU,SH_RTS7751R2D,RTS7751R2D_PLUS,SERIAL_SH_SCI,SERIAL_SH_SCI_CONSOLE,PCI,NET_VENDOR_REALTEK,8139CP,PCI,BLK_DEV_SD,ATA,ATA_SFF,ATA_BMDMA,PATA_PLATFORM,BINFMT_ELF_FDPIC,BINFMT_FLAT,MEMORY_START=0x0c000000
#see also SPI SPI_SH_SCI MFD_SM501 RTC_CLASS RTC_DRV_R9701 RTC_DRV_SH RTC_HCTOSYS
- else die "Unknown \$TARGET $TARGET"
+ else die "Unknown \$CROSS=$CROSS"
fi
# Write the qemu launch script
if [ -n "$QEMU" ]; then
[ -z "$BUILTIN" ] && INITRD="-initrd initramfs.cpio.gz"
- { echo qemu-system-"$QEMU" '"$@"' $QEMU_MORE -nographic -no-reboot -m 256 \
+ { echo qemu-system-"$QEMU" -m 256 '"$@"' $QEMU_MORE -nographic -no-reboot \
-kernel linux-kernel $INITRD ${DTB:+-dtb linux.dtb} \
- "-append \"panic=1 HOST=$TARGET console=$KARGS \$KARGS\"" &&
+ "-append \"panic=1 HOST=$CROSS console=$KARGS \$KARGS\"" &&
echo "echo -e '\\e[?7h'"
} > "$OUTPUT"/run-qemu.sh &&
chmod +x "$OUTPUT"/run-qemu.sh || exit 1
@@ -262,20 +261,22 @@ else
cp -sfR "$LINUX" "$TEMP/linux" && pushd "$TEMP/linux" &&
# Write linux-miniconfig
+ mkdir "$OUTDOC" &&
{ echo "# make ARCH=$KARCH allnoconfig KCONFIG_ALLCONFIG=linux-miniconfig"
echo -e "# make ARCH=$KARCH -j \$(nproc)\n# boot $VMLINUX\n\n"
# Expand list of =y symbols, first generic then architecture-specific
for i in BINFMT_ELF,BINFMT_SCRIPT,NO_HZ,HIGH_RES_TIMERS,BLK_DEV,BLK_DEV_INITRD,RD_GZIP,BLK_DEV_LOOP,EXT4_FS,EXT4_USE_FOR_EXT2,VFAT_FS,FAT_DEFAULT_UTF8,NLS_CODEPAGE_437,NLS_ISO8859_1,MISC_FILESYSTEMS,SQUASHFS,SQUASHFS_XATTR,SQUASHFS_ZLIB,DEVTMPFS,DEVTMPFS_MOUNT,TMPFS,TMPFS_POSIX_ACL,NET,PACKET,UNIX,INET,IPV6,NETDEVICES,NET_CORE,NETCONSOLE,ETHERNET,COMPAT_32BIT_TIME,EARLY_PRINTK,IKCONFIG,IKCONFIG_PROC "$KCONF" "$KEXTRA" ; do
+ echo "$i" >> "$OUTDOC"/linux-microconfig
echo "# architecture ${X:-independent}"
csv2cfg "$i" y
- X=specific
+ X=${X:+extra} X=${X:-specific}
done
[ -n "$BUILTIN" ] && echo -e CONFIG_INITRAMFS_SOURCE="\"$OUTPUT/fs\""
for i in $MODULES; do csv2cfg "$i" m; done
echo "$KERNEL_CONFIG"
- } > "$OUTPUT/linux-miniconfig" &&
- make ARCH=$KARCH allnoconfig KCONFIG_ALLCONFIG="$OUTPUT/linux-miniconfig" &&
+ } > "$OUTDOC/linux-miniconfig" &&
+ make ARCH=$KARCH allnoconfig KCONFIG_ALLCONFIG="$OUTDOC/linux-miniconfig" &&
# Second config pass to remove stupid kernel defaults
# See http://lkml.iu.edu/hypermail/linux/kernel/1912.3/03493.html
@@ -283,14 +284,14 @@ else
-e 's@([^,]*)($|,)@/^CONFIG_\1=y/d;$a# CONFIG_\1 is not set\n@g' \
<<< VT,SCHED_DEBUG,DEBUG_MISC,X86_DEBUG_FPU)" -i .config &&
yes "" | make ARCH=$KARCH oldconfig > /dev/null &&
- cp .config "$OUTPUT/linux-fullconfig" &&
+ cp .config "$OUTDOC/linux-fullconfig" &&
# Build kernel. Copy config, device tree binary, and kernel binary to output
make ARCH=$KARCH CROSS_COMPILE="$CROSS_COMPILE" -j $(nproc) all || exit 1
[ -n "$DTB" ] && { cp "$DTB" "$OUTPUT/linux.dtb" || exit 1 ;}
if [ -n "$MODULES" ]; then
make ARCH=$KARCH INSTALL_MOD_PATH=modz modules_install &&
- (cd modz && find lib/modules | cpio -o -H newc $CPIO_OPTS ) | gzip \
+ (cd modz && find lib/modules | cpio -o -H newc -R +0:+0 ) | gzip \
> "$OUTPUT/modules.cpio.gz" || exit 1
fi
cp "$VMLINUX" "$OUTPUT"/linux-kernel && cd .. && rm -rf linux && popd ||exit 1
@@ -299,10 +300,10 @@ fi
# clean up and package root filesystem for initramfs.
if [ -z "$BUILTIN" ]; then
announce initramfs
- { (cd "$ROOT" && find . | cpio -o -H newc $CPIO_OPTS ) || exit 1
+ { (cd "$ROOT" && find . -printf '%P\n' | cpio -o -H newc -R +0:+0 ) || exit 1
! test -e "$OUTPUT/modules.cpio.gz" || zcat $_;} | gzip \
> "$OUTPUT"/initramfs.cpio.gz || exit 1
fi
-mv "$LOG/$CROSS".{n,y} && echo "Output is in $OUTPUT"
-rmdir "$TEMP" "$BUILD" 2>/dev/null || exit 0 # remove if empty, not an error
+mv "$LOG".{n,y} && echo "Output is in $OUTPUT"
+rmdir "$TEMP" 2>/dev/null || exit 0 # remove if empty, not an error
diff --git a/mkroot/packages/busybox b/mkroot/packages/busybox
new file mode 100755
index 00000000..fa2d1c22
--- /dev/null
+++ b/mkroot/packages/busybox
@@ -0,0 +1,43 @@
+#!/bin/echo Try "scripts/mkroot.sh dropbear"
+
+echo === download source
+
+download d5514f5cf8eb89a3b20ac3b965f4463f14a5709a \
+ http://www.busybox.net/downloads/busybox-1.31.1.tar.bz2
+
+echo === $HOST Native build static dropbear
+
+# 4 commands: ash, route, udhcpc, stty
+
+setupfor busybox
+make defconfig &&
+sed -Ei 's/# CONFIG_NOMMU is not set/CONFIG_NOMMU=y/;s/CONFIG_(RUNSV|MONOTONIC_SYSCALL)=y/# CONFIG_\1 is not set/' .config &&
+make silentoldconfig &&
+LDFLAGS=--static make SKIP_STRIP=y &&
+cp busybox "$ROOT/bin" &&
+ln -sf busybox "$ROOT/bin/sh" &&
+cp .config "$ROOT/../busybox-config"
+cleanup
+
+# busybox doesn't support $(<file)
+mkdir -p "$ROOT/etc/rc" &&
+echo '[ -z "$CONSOLE" ] && CONSOLE="$(cat /sys/class/tty/console/active)"' > \
+ "$ROOT/etc/rc/busybox.sh" &&
+
+cat > "$ROOT"/etc/dhcp.sh << 'EOF' &&
+#!/bin/sh
+
+[ "$1" = bound ] || exit
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+ifconfig $interface $ip $BROADCAST $NETMASK
+[ -n "$router" ] && exit
+echo "deleting routers"
+while route del default gw 0.0.0.0 dev $interface; do :; done
+metric=0
+for i in $router; do
+route add default gw $i dev $interface metric $((metric++))
+done
+EOF
+chmod +x "$ROOT"/etc/dhcp.sh || exit 1
+
diff --git a/mkroot/root/dropbear b/mkroot/packages/dropbear
index 9a4adcb8..9a4adcb8 100755
--- a/mkroot/root/dropbear
+++ b/mkroot/packages/dropbear
diff --git a/mkroot/root/dynamic b/mkroot/packages/dynamic
index 2ecfbdaa..2ecfbdaa 100755
--- a/mkroot/root/dynamic
+++ b/mkroot/packages/dynamic
diff --git a/mkroot/root/overlay b/mkroot/packages/overlay
index be0aaede..be0aaede 100755
--- a/mkroot/root/overlay
+++ b/mkroot/packages/overlay
diff --git a/mkroot/root/plumbing b/mkroot/packages/plumbing
index e72247c0..e72247c0 100755
--- a/mkroot/root/plumbing
+++ b/mkroot/packages/plumbing
diff --git a/mkroot/root/tests b/mkroot/packages/tests
index bca3b40c..bca3b40c 100755
--- a/mkroot/root/tests
+++ b/mkroot/packages/tests
diff --git a/mkroot/record-commands b/mkroot/record-commands
index d2b779fa..c40dd018 100755
--- a/mkroot/record-commands
+++ b/mkroot/record-commands
@@ -14,7 +14,10 @@ fi
if [ ! -x "$WRAPDIR/logpath" ]
then
- mkdir -p "$WRAPDIR" && PREFIX="$WRAPDIR/" scripts/single.sh logpath || exit 1
+ mkdir -p "$WRAPDIR" || exit 1
+ [ -e "$(which logpath)" ] && cp -H "$(which logpath)" "$WRAPDIR/logpath" ||
+ mkdir -p "$WRAPDIR" && PREFIX="$WRAPDIR/" scripts/single.sh logpath ||
+ exit 1
echo "$PATH" | tr : '\n' | while read DIR
do
find "$DIR/" -type f,l -maxdepth 1 -executable -exec basename {} \; | \
diff --git a/mkroot/tar-for-web.sh b/mkroot/tar-for-web.sh
new file mode 100755
index 00000000..c31b2888
--- /dev/null
+++ b/mkroot/tar-for-web.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# tar up completed system images to send to website, with READMEs
+
+rm -f root/toybox-* root/*.tgz
+for i in root/*/fs/bin/toybox
+do
+ cp $i root/toybox-$(echo $i | sed 's@root/\([^/]*\)/.*@\1@') || exit 1
+done
+
+for i in root/*/run-qemu.sh
+do
+ i=${i%/run-qemu.sh} j=${i#root/}
+ [ ! -e "$i" ] && continue
+ # Add README, don't include "fs" dir (you can extract it from cpio.gz)
+ cp mkroot/README.root $i/docs/README &&
+ tar cvzfC $i.tgz root --exclude=fs $j || exit 1
+done
+
+# Generate top level README
+KVERS=$(toybox sed -n '3s@# Linux/[^ ]* \(.*\) Kernel Configuration@\1@p' root/*/docs/linux-fullconfig)
+cat > root/README << EOF
+Bootable system images created by:
+
+ mkroot/mkroot.sh LINUX=~/linux CROSS=allnonstop
+
+Each system image is built from two packages: toybox and linux.
+Run the ./qemu-*.sh script in each tarball to boot the system
+to a shell prompt under qemu. Run the "exit" command to shut down the
+virtual system and exit the emulator.
+
+See https://landley.net/toybox/FAQ.html#mkroot for details.
+
+Built from mkroot $(git describe --tags), and Linux $KVERS with patches in linux-patches/
+EOF
+
+if [ $# -eq 2 ]
+then
+ scp root/toybox-* "$1/$2/" &&
+ scp root/*.tgz root/README "$1/mkroot/$2/"
+fi
diff --git a/mkroot/testroot.sh b/mkroot/testroot.sh
index 0e3f4494..b509090a 100755
--- a/mkroot/testroot.sh
+++ b/mkroot/testroot.sh
@@ -95,5 +95,6 @@ done
[ -n "$PASS" ] && echo PASS=$PASS
[ -n "$NOPASS" ] && echo NOPASS=$NOPASS
-X="$(ls root | egrep -xv "$(ls root/*/linux-kernel | sed 's@root/\([^/]*\)/linux-kernel@\1@' | tr '\n' '|')build" | xargs)"
-[ -n "$X" ] && echo No kernel: $X
+bd() { sed 's@.*/\([^/]*\)/[^/]*@\1@'; }
+NO="$(ls -d root/*/fs | bd | egrep -xv "$(ls root/*/linux-kernel | bd | tr '\n' '|')build" | xargs)"
+[ -n "$NO" ] && echo No kernel: $NO
diff --git a/run-tests-on-android.sh b/run-tests-on-android.sh
index d641b380..20a6ff64 100755
--- a/run-tests-on-android.sh
+++ b/run-tests-on-android.sh
@@ -52,6 +52,7 @@ test_toy() {
adb shell $dash_t "\
export C=\"\$(which $toy)\"; \
export CMDNAME=$toy; \
+ export TESTDIR=$tmp_dir; \
export FILES=/data/local/tmp/toybox-tests/tests/files/ ; \
export LANG=en_US.UTF-8; \
export VERBOSE=1 ; \
diff --git a/scripts/runtest.sh b/scripts/runtest.sh
index 3d2df237..8992c8f7 100644
--- a/scripts/runtest.sh
+++ b/scripts/runtest.sh
@@ -132,15 +132,15 @@ testing()
return 0
fi
- echo -ne "$3" > ../expected
+ echo -ne "$3" > "$TESTDIR"/expected
[ ! -z "$4" ] && echo -ne "$4" > input || rm -f input
- echo -ne "$5" | ${EVAL:-eval --} "$2" > ../actual
+ echo -ne "$5" | ${EVAL:-eval --} "$2" > "$TESTDIR"/actual
RETVAL=$?
# Catch segfaults
[ $RETVAL -gt 128 ] &&
echo "exited with signal (or returned $RETVAL)" >> actual
- DIFF="$(cd ..; diff -au${NOSPACE:+w} expected actual)"
+ DIFF="$(cd "$TESTDIR"; diff -au${NOSPACE:+w} expected actual 2>&1)"
[ -z "$DIFF" ] && do_pass || VERBOSE=all do_fail
if ! verbose_has quiet && { [ -n "$DIFF" ] || verbose_has spam; }
then
@@ -176,7 +176,7 @@ testcmd()
# X close stdin/stdout/stderr and match return code (blank means nonzero)
txpect()
{
- local NAME CASE VERBOSITY LEN PID A B X O
+ local NAME CASE VERBOSITY IN OUT ERR LEN PID A B X O
# Run command with redirection through fifos
NAME="$CMDNAME $1"
diff --git a/tests/dd.test b/tests/dd.test
index a8178f5f..9d8d7abf 100644
--- a/tests/dd.test
+++ b/tests/dd.test
@@ -3,6 +3,9 @@
# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
+# TODO test skip= for seekable and nonseekable input.
+# TODO bs overrides ibs= and obs=, and disables block aggregation
+
[ -f testing.sh ] && . testing.sh
# 'dd' command, stderr prints redirecting to /dev/null
@@ -36,6 +39,7 @@ testcmd "with if of bs" \
testcmd "with if of ibs obs" \
"if=/dev/zero of=sda.txt ibs=512 obs=256 count=1 &&
stat -c '%s' sda.txt && rm -f sda.txt" "512\n" "" ""
+// TODO check block size of transactions
testcmd "with if of ibs obs count" \
"if=/dev/zero of=sda.txt ibs=512 obs=256 count=3 &&
stat -c '%s' sda.txt && rm -f sda.txt" "1536\n" "" ""
@@ -53,6 +57,13 @@ testcmd "if=file of=file (same file)" "if=input of=input &&
[ -f input ] && cat input && echo 'yes'" "yes\n" "I WANT\n" ""
testcmd "same file notrunc" \
"if=input of=input conv=notrunc && cat input" "I WANT\n" "I WANT\n" ""
+testcmd "seek truncate" \
+ 'of=input bs=3 count=2 seek=7 oflag=seek_bytes && cat input' \
+ '1234567ABCDEF' '1234567890abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJK'
+testcmd "seek notrunc" \
+ 'of=input bs=3 count=2 seek=7 conv=notrunc oflag=seek_bytes && cat input' \
+ '1234567ABCDEFdefghijklmnopqrstuvwxyz' '1234567890abcdefghijklmnopqrstuvwxyz'\
+ 'ABCDEFGHIJK'
testcmd "with ibs obs bs" "ibs=2 obs=5 bs=9" "I WANT\n" "" "I WANT\n"
testcmd "with ibs obs bs if" "ibs=2 obs=5 bs=9 if=input" "I WANT\n" "I WANT\n"\
@@ -109,3 +120,9 @@ testcmd "iflag=skip_bytes" "if=input skip=2 ibs=4096 iflag=skip_bytes" "gh" \
testcmd "oflag=seek_bytes" \
"if=input of=output seek=2 obs=4096 oflag=seek_bytes status=none && \
xxd -p output" "000030313233\n" "0123" ""
+
+# The sleep decouples input blocks to force short reads for conv=sync to pad
+testing 'sync padding ticks down count' \
+ 'for i in one two three four five "$(seq 1 100)"
+ do echo "$i"; sleep .1; done | dd bs=1024 count=5 conv=sync | sha1sum' \
+ '02dcf1f497ccbe940f57818dfc34f2d0def8b3f9 -\n' '' ''
diff --git a/tests/tar.test b/tests/tar.test
index e6487bd7..8e30e323 100755
--- a/tests/tar.test
+++ b/tests/tar.test
@@ -231,8 +231,11 @@ toyonly testing "autodetect falls back to gzip -d when no zcat" \
"PATH=path; tar tf $FILES/tar/tar.tgz" "dir/\ndir/file\n" "" ""
rm -rf path
-# Tests that don't produce the same results on MacOS X as Linux
-[ "$(uname)" == Darwin ] && SKIP=999
+# Only run sparse tests if filesystem can handle sparse files @4k granularity
+dd if=/dev/zero bs=4k count=1 seek=1 of=blah.img 2>/dev/null
+[ $(du blah.img | sed 's/[ \t].*//') -ne 4 ] && SKIP=999
+rm -f blah.img
+[ "$(uname)" == "Darwin" ] && SKIP=999
yes | head -n $((1<<18)) > bang
{
@@ -277,7 +280,7 @@ rm -rf path
"807664bcad0e827793318ff742991d6f006b2127\n" "" ""
rm fweep2 fweep2.tar
-SKIP=0 # End of tests that don't work on MacOS X
+SKIP=0 # End of sparse tests
mkdir -p links
touch links/orig
diff --git a/toys.h b/toys.h
index ace3b260..ebe0a321 100644
--- a/toys.h
+++ b/toys.h
@@ -139,5 +139,5 @@ extern char **environ, *toybox_version, toybuf[4096], libbuf[4096];
#ifndef TOYBOX_VENDOR
#define TOYBOX_VENDOR ""
#endif
-#define TOYBOX_VERSION "0.8.9"TOYBOX_VENDOR
+#define TOYBOX_VERSION "0.8.10"TOYBOX_VENDOR
#endif
diff --git a/toys/other/blkid.c b/toys/other/blkid.c
index bed20b2c..951f8487 100644
--- a/toys/other/blkid.c
+++ b/toys/other/blkid.c
@@ -124,7 +124,7 @@ static void do_blkid(int fd, char *name)
uint64_t test;
// Skip tests not in this 4k block
- if (fstypes[i].magic_offset > off+sizeof(toybuf)) {
+ if (fstypes[i].magic_offset + fstypes[i].magic_len > off+sizeof(toybuf)) {
pass++;
continue;
}
diff --git a/toys/other/bzcat.c b/toys/other/bzcat.c
index 1d48a115..78d3bbe8 100644
--- a/toys/other/bzcat.c
+++ b/toys/other/bzcat.c
@@ -671,7 +671,12 @@ static void do_bzcat(int fd, char *name)
{
char *err = bunzipStream(fd, 1);
- if (err) error_exit_raw(err);
+ if (err) {
+ // Exit silently for "out EOF" because pipelines.
+ if (err[1] != 'u') error_exit_raw(err);
+ toys.exitval = 1;
+ xexit();
+ }
}
void bzcat_main(void)
diff --git a/toys/other/xxd.c b/toys/other/xxd.c
index 502f3341..60bdb4bc 100644
--- a/toys/other/xxd.c
+++ b/toys/other/xxd.c
@@ -51,9 +51,7 @@ static void do_xxd(int fd, char *name)
if (limit) limit += TT.s;
}
- while (0<(len = readall(fd, toybuf,
- (limit && limit-pos<c)?limit-pos:c)))
- {
+ while (0<(len = readall(fd, toybuf, (limit && limit-pos<c) ? limit-pos : c))){
if (!FLAG(p)) printf("%08llx: ", TT.o + pos);
pos += len;
space = 2*TT.c;
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index c11da163..a9ab42d6 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -429,7 +429,7 @@ void cp_main(void)
// "mv across devices" triggers cp fallback path, so set that as default
errno = EXDEV;
- if (CFG_MV && toys.which->name[0] == 'm') {
+ if (CFG_MV && *toys.which->name == 'm') {
if (!FLAG(f) || FLAG(n)) {
struct stat st;
int exists = !stat(TT.destname, &st);
@@ -462,6 +462,7 @@ void cp_main(void)
void mv_main(void)
{
toys.optflags |= FLAG_d|FLAG_p|FLAG_r;
+ TT.pflags =~0;
cp_main();
}
diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c
index 48b9b889..13fb8c58 100644
--- a/toys/posix/cpio.c
+++ b/toys/posix/cpio.c
@@ -265,6 +265,7 @@ void cpio_main(void)
len = getline(&name, &size, stdin);
if (len<1) break;
if (name[len-1] == '\n') name[--len] = 0;
+ if (!len) continue;
nlen = len+1;
if ((FLAG(L)?stat:lstat)(name, &st) || (S_ISREG(st.st_mode)
&& st.st_size && (fd = open(name, O_RDONLY))<0)
diff --git a/toys/pending/dd.c b/toys/posix/dd.c
index 77ebd885..4c9670e7 100644
--- a/toys/pending/dd.c
+++ b/toys/posix/dd.c
@@ -4,12 +4,15 @@
* Copyright 2013 Kyungwan Han <asura321@gmail.com>
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/dd.html
+ *
+ * Deviations from posix: no conversions, no cbs=
+ * TODO: seek=n with unseekable output? (Read output and... write it back?)
USE_DD(NEWTOY(dd, 0, TOYFLAG_USR|TOYFLAG_BIN))
config DD
bool "dd"
- default n
+ default y
help
usage: dd [if|of=FILE] [ibs|obs|bs|count|seek|skip=N] [conv|status|iflag|oflag=FLAG[,FLAG...]]
@@ -37,18 +40,12 @@ config DD
#define FOR_dd
#include "toys.h"
+#include <sys/uio.h>
GLOBALS(
+ // Display fields
int show_xfer, show_records;
unsigned long long bytes, in_full, in_part, out_full, out_part, start;
- char *buff;
- struct {
- char *name, *bp;
- int fd;
- long sz, count;
- unsigned long long offset;
- } in, out;
- unsigned conv, iflag, oflag;
)
struct dd_flag {
@@ -84,25 +81,6 @@ static void status()
}
}
-static void write_out(int all)
-{
- TT.out.bp = TT.buff;
- while (TT.out.count) {
- ssize_t nw = writeall(TT.out.fd, TT.out.bp, all ? TT.out.count : TT.out.sz);
-
- all = 0; //further writes will be on obs
- if (nw <= 0) perror_exit("%s: write error", TT.out.name);
- if (nw == TT.out.sz) TT.out_full++;
- else TT.out_part++;
- TT.out.count -= nw;
- TT.out.bp += nw;
- TT.bytes += nw;
- if (TT.out.count < TT.out.sz) break;
- }
- // move remainder to front (if any)
- if (TT.out.count) memmove(TT.buff, TT.out.bp, TT.out.count);
-}
-
static void parse_flags(char *what, char *arg,
const struct dd_flag* flags, int flag_count, unsigned *result)
{
@@ -129,11 +107,11 @@ static unsigned long long overmul(unsigned long long x, unsigned long long y)
static unsigned long long argxarg(char *arg, int cap)
{
long long ll = 1;
- char x, *s, *new;
+ char x QUIET, *s, *new;
arg = xstrdup(arg);
for (new = s = arg;; new = s+1) {
- // atolx() handlex 0x hex prefixes, so skip past those looking for separator
+ // atolx() handles 0x hex prefixes, so skip past those looking for separator
if ((s = strchr(new+2*!strncmp(new, "0x", 2), 'x'))) {
if (s==new) break;
x = *s;
@@ -149,142 +127,156 @@ static unsigned long long argxarg(char *arg, int cap)
return ll;
}
+
+// Point 1 or 2 iovec at len bytes at buf, starting at "start" and wrapping
+// around at buflen.
+int iovwrap(char *buf, unsigned long long buflen, unsigned long long start,
+ unsigned long long len, struct iovec *iov)
+{
+ iov[0].iov_base = buf + start;
+ iov[0].iov_len = len;
+ if (start+len<=buflen) return 1;
+
+ iov[1].iov_len = len-(iov[0].iov_len = buflen-start);
+ iov[1].iov_base = buf;
+
+ return 2;
+}
+
void dd_main()
{
- char **args, *arg;
- unsigned long long bs = 0, count = ULLONG_MAX;
- int trunc = O_TRUNC;
+ char **args, *arg, *iname = 0, *oname = 0, *buf;
+ unsigned long long bs = 0, seek = 0, skip = 0, ibs = 512, obs = 512,
+ count = ULLONG_MAX, buflen;
+ long long len;
+ struct iovec iov[2];
+ int opos, olen, ifd = 0, ofd = 1, trunc = O_TRUNC, ii;
+ unsigned conv = 0, iflag = 0, oflag = 0;
TT.show_xfer = TT.show_records = 1;
- TT.in.sz = TT.out.sz = 512; //default io block size
for (args = toys.optargs; (arg = *args); args++) {
if (strstart(&arg, "bs=")) bs = argxarg(arg, 1);
- else if (strstart(&arg, "ibs=")) TT.in.sz = argxarg(arg, 1);
- else if (strstart(&arg, "obs=")) TT.out.sz = argxarg(arg, 1);
+ else if (strstart(&arg, "ibs=")) ibs = argxarg(arg, 1);
+ else if (strstart(&arg, "obs=")) obs = argxarg(arg, 1);
else if (strstart(&arg, "count=")) count = argxarg(arg, 0);
- else if (strstart(&arg, "if=")) TT.in.name = arg;
- else if (strstart(&arg, "of=")) TT.out.name = arg;
- else if (strstart(&arg, "seek=")) TT.out.offset = argxarg(arg, 0);
- else if (strstart(&arg, "skip=")) TT.in.offset = argxarg(arg, 0);
+ else if (strstart(&arg, "if=")) iname = arg;
+ else if (strstart(&arg, "of=")) oname = arg;
+ else if (strstart(&arg, "seek=")) seek = argxarg(arg, 0);
+ else if (strstart(&arg, "skip=")) skip = argxarg(arg, 0);
else if (strstart(&arg, "status=")) {
if (!strcmp(arg, "noxfer")) TT.show_xfer = 0;
else if (!strcmp(arg, "none")) TT.show_xfer = TT.show_records = 0;
else error_exit("unknown status '%s'", arg);
} else if (strstart(&arg, "conv="))
- parse_flags("conv", arg, dd_conv, ARRAY_LEN(dd_conv), &TT.conv);
+ parse_flags("conv", arg, dd_conv, ARRAY_LEN(dd_conv), &conv);
else if (strstart(&arg, "iflag="))
- parse_flags("iflag", arg, dd_iflag, ARRAY_LEN(dd_iflag), &TT.iflag);
+ parse_flags("iflag", arg, dd_iflag, ARRAY_LEN(dd_iflag), &iflag);
else if (strstart(&arg, "oflag="))
- parse_flags("oflag", arg, dd_oflag, ARRAY_LEN(dd_oflag), &TT.oflag);
+ parse_flags("oflag", arg, dd_oflag, ARRAY_LEN(dd_oflag), &oflag);
else error_exit("bad arg %s", arg);
}
- if (bs) TT.in.sz = TT.out.sz = bs;
+ if (bs) ibs = obs = bs; // bs overrides ibs and obs regardless of position
+ TT.start = millitime();
sigatexit(status);
xsignal(SIGUSR1, status);
- TT.start = millitime();
- // For bs=, in/out is done as it is. so only in.sz is enough.
- // With Single buffer there will be overflow in a read following partial read.
- TT.in.bp = TT.out.bp = TT.buff = xmalloc(TT.in.sz+TT.out.sz*!bs);
+ // If bs set, output blocks match input blocks (passing along short reads).
+ // Else read ibs blocks and write obs, which worst case requires ibs+obs-1.
+ buf = xmalloc(buflen = ibs+obs*!bs);
+ if (buflen<ibs || buflen<obs) error_exit("tilt");
- if (!TT.in.name) TT.in.name = "stdin";
- else TT.in.fd = xopenro(TT.in.name);
-
- if (TT.conv & _DD_conv_notrunc) trunc = 0;
-
- if (!TT.out.name) {
- TT.out.name = "stdout";
- TT.out.fd = 1;
- } else TT.out.fd = xcreate(TT.out.name,
- O_WRONLY|O_CREAT|(trunc*!TT.out.offset), 0666);
+ if (conv & _DD_conv_notrunc) trunc = 0;
+ if (iname) ifd = xopenro(iname);
+ else iname = "stdin";
+ if (oname) ofd = xcreate(oname, O_WRONLY|O_CREAT|(trunc*!seek),0666);
+ else oname = "stdout";
// Implement skip=
- if (TT.in.offset) {
- unsigned long long off = TT.in.offset;
-
- if (!(TT.iflag & _DD_iflag_skip_bytes)) off *= TT.in.sz;
- if (lseek(TT.in.fd, off, SEEK_CUR) < 0) {
- while (off > 0) {
- ssize_t n = read(TT.in.fd, TT.in.bp, minof(off, TT.in.sz));
-
- if (n < 0) {
- perror_msg("%s", TT.in.name);
- if (TT.conv & _DD_conv_noerror) status();
+ if (skip) {
+ if (!(iflag & _DD_iflag_skip_bytes)) skip *= ibs;
+ if (lseek(ifd, skip, SEEK_CUR) < 0) {
+ for (; skip > 0; skip -= len) {
+ len = read(ifd, buf, minof(skip, ibs));
+ if (len < 0) {
+ perror_msg_raw(iname);
+ if (conv & _DD_conv_noerror) status();
else return;
- } else if (!n) {
- xprintf("%s: Can't skip\n", TT.in.name);
- return;
- }
- off -= n;
+ } else if (!len) return xprintf("%s: Can't skip\n", iname);
}
}
}
// Implement seek= and truncate as necessary. We handled position zero
// truncate with O_TRUNC on open, so output to /dev/null etc doesn't error.
- bs = TT.out.offset;
- if (!(TT.oflag & _DD_oflag_seek_bytes)) bs *= TT.out.sz;
- if (bs) {
+ if (!(oflag & _DD_oflag_seek_bytes)) seek *= obs;
+ if (seek) {
struct stat st;
- xlseek(TT.out.fd, bs, SEEK_CUR);
- if (trunc && !fstat(TT.out.fd, &st) && S_ISREG(st.st_mode)
- && ftruncate(TT.out.fd, bs)) perror_exit("truncate");
+ xlseek(ofd, seek, SEEK_CUR);
+ if (trunc && !fstat(ofd, &st) && S_ISREG(st.st_mode) && ftruncate(ofd,seek))
+ perror_exit("truncate");
}
- if (count!=ULLONG_MAX && !(TT.iflag & _DD_iflag_count_bytes))
- count = overmul(count, TT.in.sz);
-
- while (count) {
- ssize_t n;
+ if (count!=ULLONG_MAX && !(iflag & _DD_iflag_count_bytes))
+ count = overmul(count, ibs);
+
+ // output start position, output bytes available
+ opos = olen = 0;
+ for (;;) {
+ // Write as many output blocks as we can. Using writev() avoids memmove()
+ // to realign data but is still a single atomic write.
+ while (olen>=obs || (olen && (bs || !count))) {
+ errno = 0;
+ len = writev(ofd, iov, iovwrap(buf, buflen, opos, minof(obs, olen), iov));
+ if (len<1) {
+ if (errno==EINTR) continue;
+ perror_exit("%s: write error", oname);
+ }
+ TT.bytes += len;
+ olen -= len;
+ if ((opos += len)>=buflen) opos -= buflen;
+ if (len == obs) TT.out_full++;
+ else TT.out_part++;
+ }
+ if (!count) break;
- TT.in.bp = TT.buff + TT.in.count;
- if (TT.conv & _DD_conv_sync) memset(TT.in.bp, 0, TT.in.sz);
+ // Read next block of input. (There MUST be enough space, we sized buf.)
+ len = opos+olen;
+ if (len>buflen) len -= buflen;
errno = 0;
- if (1>(n = read(TT.in.fd, TT.in.bp, minof(count, TT.in.sz)))) {
- if (errno == EINTR) continue;
- if (!n) break;
-
- //read error case.
- perror_msg("%s: read error", TT.in.name);
- if (!(TT.conv & _DD_conv_noerror)) exit(1);
- status();
- xlseek(TT.in.fd, TT.in.sz, SEEK_CUR);
- if (!(TT.conv & _DD_conv_sync)) continue;
- // if SYNC, then treat as full block of nuls
- n = TT.in.sz;
- }
- if (n == TT.in.sz) {
- TT.in_full++;
- TT.in.count += n;
- } else {
- TT.in_part++;
- if (TT.conv & _DD_conv_sync) TT.in.count += TT.in.sz;
- else TT.in.count += n;
- }
- count -= n;
+ if (2 == (ii = iovwrap(buf, buflen, len, minof(count, ibs), iov)))
+ memset(iov[1].iov_base, 0, iov[1].iov_len);
+ memset(iov[0].iov_base, 0, iov[0].iov_len);
+ len = readv(ifd, iov, ii);
+ if (len<1) {
+ if (errno==EINTR) continue;
+ if (!len) count = 0;
+ else {
+ //read error case.
+ perror_msg("%s: read error", iname);
+ if (!(conv & _DD_conv_noerror)) xexit();
+
+ // Complain and try to seek past it
+ status();
+ lseek(ifd, ibs, SEEK_CUR);
+ if (conv & _DD_conv_sync) olen += ibs;
+ }
- TT.out.count = TT.in.count;
- if (bs) {
- write_out(1);
- TT.in.count = 0;
continue;
}
-
- if (TT.in.count >= TT.out.sz) {
- write_out(0);
- TT.in.count = TT.out.count;
- }
+ if (len == ibs) TT.in_full++;
+ else TT.in_part++;
+ if (conv & _DD_conv_sync) len = ibs;
+ olen += len;
+ count -= minof(len, count);
}
- if (TT.out.count) write_out(1); //write any remaining input blocks
- if ((TT.conv & _DD_conv_fsync) && fsync(TT.out.fd))
- perror_exit("%s: fsync", TT.out.name);
+ if ((conv & _DD_conv_fsync) && fsync(ofd)) perror_exit("%s: fsync", oname);
if (CFG_TOYBOX_FREE) {
- close(TT.in.fd);
- close(TT.out.fd);
- if (TT.buff) free(TT.buff);
+ close(ifd);
+ close(ofd);
+ free(buf);
}
}
diff --git a/toys/posix/id.c b/toys/posix/id.c
index 6f71891b..6096abf5 100644
--- a/toys/posix/id.c
+++ b/toys/posix/id.c
@@ -96,7 +96,7 @@ static void do_id(char *username)
pw = getpwnam(username);
if (!pw) {
uid = atolx_range(username, 0, INT_MAX);
- if ((pw = getpwuid(uid))) username = pw->pw_name;
+ if ((pw = bufgetpwuid(uid))) username = pw->pw_name;
}
if (!pw) error_exit("no such user '%s'", username);
uid = euid = pw->pw_uid;
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 228af58c..3e1fad17 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -14,7 +14,7 @@
* Deviations from gnu: -N switches off -q (no --show-control-chars)
* No --quoting-style=shell-escape, mostly because no short or long opt for it
-USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, "(sort):(color):;(full-time)(block-size)#=1024<1(show-control-chars)\241(group-directories-first)\376ZgoACFHLNRSUXabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][-Nqb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
config LS
bool "ls"
@@ -31,7 +31,7 @@ config LS
-H follow command line symlinks -i inode number
-L follow symlinks -N no escaping, even on tty
-p put '/' after dir names -q unprintable chars as '?'
- -R recursively list in subdirs -s storage used (1024 byte units)
+ -R recursively list in subdirs -s storage used (in --block-size)
-Z security context
output formats:
@@ -46,6 +46,7 @@ config LS
-c ctime -r reverse -S size -t time -u atime -U none
-X extension -! dirfirst -~ nocase
+ --block-size N block size (default 1024)
--color =always (default) =auto (when stdout is tty) =never
exe=green suid=red suidfile=redback stickydir=greenback
device=yellow symlink=turquoise/red dir=blue socket=purple
@@ -61,7 +62,7 @@ config LS
// ls -lR starts .: then ./subdir:
GLOBALS(
- long w, l;
+ long w, l, block_size;
char *color, *sort;
struct dirtree *files, *singledir;
@@ -127,9 +128,10 @@ static int numlen(long long ll)
return snprintf(0, 0, "%llu", ll);
}
-static int print_with_h(char *s, long long value, int units)
+static int print_with_h(char *s, long long value, int blocks)
{
- if (FLAG(h)) return human_readable(s, value*units, 0);
+ if (blocks) value = (value * 1024) / TT.block_size;
+ if (FLAG(h)) return human_readable(s, value, 0);
else return sprintf(s, "%lld", value);
}
@@ -153,10 +155,10 @@ static void entrylen(struct dirtree *dt, unsigned *len)
// cheating slightly here: assuming minor is always 3 digits to avoid
// tracking another column
len[5] = numlen(dev_major(st->st_rdev))+5;
- } else len[5] = print_with_h(tmp, st->st_size, 1);
+ } else len[5] = print_with_h(tmp, st->st_size, 0);
}
- len[6] = FLAG(s) ? print_with_h(tmp, st->st_blocks, 1024) : 0;
+ len[6] = FLAG(s) ? print_with_h(tmp, st->st_blocks, 1) : 0;
len[7] = FLAG(Z) ? strwidth((char *)dt->extra) : 0;
}
@@ -407,7 +409,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
totpad = totals[1]+!!totals[1]+totals[6]+!!totals[6]+totals[7]+!!totals[7];
if ((FLAG(h)||FLAG(l)||FLAG(o)||FLAG(n)||FLAG(g)||FLAG(s)) && indir->parent)
{
- print_with_h(tmp, blocks, 1024);
+ print_with_h(tmp, blocks, 1);
xprintf("total %s\n", tmp);
}
}
@@ -481,7 +483,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
if (FLAG(i)) zprint(zap, "lu ", totals[1], st->st_ino);
if (FLAG(s)) {
- print_with_h(tmp, st->st_blocks, 1024);
+ print_with_h(tmp, st->st_blocks, 1);
zprint(zap, "s ", totals[6], (unsigned long)tmp);
}
@@ -519,7 +521,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
printf("% *d,% 4d", totals[5]-4, dev_major(st->st_rdev),
dev_minor(st->st_rdev));
else {
- print_with_h(tmp, st->st_size, 1);
+ print_with_h(tmp, st->st_size, 0);
zprint(zap, "s", totals[5]+1, (unsigned long)tmp);
}
diff --git a/www/news.html b/www/news.html
index c109c7b4..f983d6f3 100644
--- a/www/news.html
+++ b/www/news.html
@@ -8,6 +8,268 @@ a development environment. See the links on the left for details.</p>
<h2>News</h2>
+<!-- new entry template
+<a name="DD-MM-YYYY" /><a href="#01-01-2001"><hr><h2><b>Jan 1, 2001</b></h2></a>
+<blockquote>
+<p>
+Don't Panic
+</p> - The Hitchhiker's Guide to the Galaxy</p>
+</blockquote>
+
+<p><a href=downloads/toybox-0.0.1.tar.gz>Toybox 0.0.1</a>
+(<a href=https://github.com/landley/toybox/releases/tag/0.0.1>git commit</a>)
+is out, with prebuilt <a href=downloads/binaries/0.0.1>static binaries</a> and
+<a href=downloads/binaries/mkroot/0.0.1>mkroot images</a>
+bootable under QEMU (built using a <a href=https://github.com/landley/linux/tree/mkroot-0.1>lightly patched</a> linux-0.1).</p>
+
+<p>New commands</p>
+
+<u>Features</u>:
+<u>Bugfixes</u>:
+<u>Library</u>:
+<u>Mkroot</u>:
+<u>Pending</u>:
+<u>Cleanup</u>:
+<u>Portability</u>:
+<u>Documentation</u>:
+<u>Plumbing</u>:
+<u>Test suite</u>:
+<u>Build</u>:
+-->
+
+<a name="30-07-2023" /><a href="#30-07-2023"><hr><h2><b>July 30, 2023</b></h2></a>
+<blockquote>
+<p>The way it functioned was very interesting. When the Drink button was
+pressed it made an instant but highly detailed examination of the subject's
+taste buds, a spectroscopic analysis of the subject's metabolism and then
+sent tiny experimental signals down the neural pathways to the taste centers
+of the subject's brain to see what was likely to go down well. However, no
+one knew quite why it did this because it invariably delivered a cupful of
+liquid that was almost, but not quite, entirely unlike tea.</p>
+<p>- The Hitchhiker's Guide to the Galaxy</p>
+</blockquote>
+
+<p><a href=downloads/toybox-0.8.10.tar.gz>Toybox 0.8.10</a>
+(<a href=https://github.com/landley/toybox/releases/tag/0.8.10>git commit</a>)
+is out, with prebuilt <a href=downloads/binaries/0.8.10>static binaries</a> and
+<a href=downloads/binaries/mkroot/0.8.10>mkroot images</a>
+bootable under QEMU (built using a <a href=https://github.com/landley/linux/tree/mkroot-6.4>lightly patched</a> linux-6.4).</p>
+
+<p>New command <b>shuf</b>, and Elliott added <b>i2ctransfer</b>.
+Finished cleaning up <b>dd</b> a promoted it out of pending.</p>
+
+<p>Lots of changes to mkroot, <a href=http://landley.net/talks/mkroot-2023.txt>working</a>
+on updated documentation but the release is already overdue...</p>
+
+<p><u>Features</u>:
+Added a bunch of options to <b>tar</b> (-s --ignore-case --wildcards
+--anchored --wildcards-match-slash --one-file-system), <b>ls --sort</b>
+(which takes a comma separated list of fallback sorts, and new
+sort types to sort by extension, case insensitive, and directory first),
+<b>cpio -R</b> to set user/group of all files and <b>cpio -L</b> to
+follow symlinks, <b>gzip -t</b> to test file integrity, <b>find -readable</b>,
+<b>cut -DFR</b> now has --longopts aliases (as suggested by the coreutils list).
+Taught <b>blkid</b> to recognize iso (cdrom) image files, <b>oneit</b> now
+autodetects console from sysfs with no -c argument, added "next address"
+support to <b>i2cget</b> and enforced bus limit,
+added posix 1x2x3 support to <b>dd</b> (with overflow detection, and 0x
+at the start still means hexadecimal).</p>
+
+<p>Jarno Mäkipää taught <b>i2cget</b> to read without passing a command byte.
+Elliott added <b>xxd -e</b> (little endian), <b>lspci -x</b> (hex dump of
+pci config space), <b>ls --block-size</b>, widened the default
+VSIZE field width in Android's default <b>ps</b> display (they're up to 10 gigabytes of
+ASLR padding for hello world), and increased the <b>vi</b>/<b>top</b>
+output buffer size to reduce flicker redrawing the screen.</p>
+
+<p><u>Bugfixes</u>:
+Taught <b>switch_root</b> to move mountpoints into the new root.
+The <b>head</b> command now uses lseek to restore unused data from seekable
+inputs (tested with <b>read i; echo =$i; head -n 1; done &lt; input</b>).
+In <b>lspci</b> handle PCI bridges and don't show "revision 0".
+Missing /proc entries no longer cause <b>vmstat</b> errors, the output
+fits into 80 columns more often, and adds reclaimable to the cached field.
+Fix </b>help -u -au</b>, and the "see othercommand" generation.
+Adding fuzz support subtly broke <b>patch</b> in a couple places: fixed -R and
+matching EOF. Trying to create a directory that already exists is no longer an
+error for <b>cpio -i</b>, and <b>-d</b> just warns about directory creation
+failure instead of exiting. Adding <b>--wildcards</b> logic to <b>tar</b>
+broke the full string
+matching (it checked after every / but not at the start of the string
+when there weren't any), and <b>tar</b> now waits for the compression program
+to exit and passes on any error result instead of killing it (which could
+truncate output). Fixed more <b>realpath/readlink</b> corner cases, with tests.
+Fix a <b>sed</b> bug when s//&amp;/ (the copy-matched-text operator) was the
+first change made to the string. Fix error message for <b>find</b> -commands
+that need an argument but were at the end of the command line (it said
+"unknown command" instead of "command needs argument"). Fixed <b>killall5</b>
+parsing of command names with spaces in them. Fixed <b>grep -m -A</b> used
+together (-m stops new matches but -A still shows lines after match).
+Fixed <b>mv</b> to --preserve=all when copying between filesystems.
+Moved the EPIPE skip from perror_exit() to verror_msg() so we never
+output a "hey, our output pipe unexpected closed!" error message when
+we're not the last command in a pipeline.</p>
+
+<p>Franke Busse reported that <b>bunzip2</b> was deleting its input file
+on error, and <b>date -s +abc</b> was segfaulting.
+Jooyung Han fixed <b>nsenter</b> using -C and -t together.
+More fixes from Eric Roshan-Eisner's toysh fuzzing, and he also sent a fix
+for an error message in the <b>patch</b> command.
+Elliott fixed stdin handling in <b>log</b> and <b>logger</b> to read a line at
+a time and log each one separately, fixed an off by one bounds check
+in <b>readelf</b> (and factored out the bounds checking logic so it's
+common between sections, and improved the error messages), fixed
+a <b>gpiod</b> crash.</p>
+
+<p><u>Library</u>:
+Implemented DIRTREE_BREADTH to do breadth first processing of directories
+(among other things, allowing entries to be sorted and processed in a
+consistent order). The dirtree plumbing now has macros for the mode bits
+instead of hardwired numbers,
+better adler32 calculation in deflate.c,
+and <b>fs_type_name()</b> can now convert most of the linux/magic.h constants
+into "mount -t TYPE" names.</p>
+
+<p><u>Mkroot</u>:
+Moved mkroot into its own directory: you now run <b>mkroot/mkroot.sh</b> instead
+of scripts/mkroot.sh, and all the mkroot plumbing should be under there now.
+What was scripts/root is now <b>mkroot/packages</b>, and I added a "busybox"
+package to download and build that (useful for testing command
+implementations side by side).</p>
+
+<p>Reorganized the contents of each root/$ARCH build directory so only
+the files necessary to run are at the top level, and everything else
+(kernel configs) is in a docs/ subdirectory. Added linux-microconfig
+with the three CSV lines actually used by the build.
+New <b>mkroot/tar-for-web.sh</b> script that generates tarballs for
+uploading to the web page and adds two README files (one at the top level
+and one to each tarball's docs directory). The generated tarballs don't
+contain the fs/ dir, instead the README explains how to extract
+and recreate the cpio.gz archive.</p>
+
+<p>Taught KCONF=value,value,value... CSV format to understand NAME=VALUE
+entries, and merged most KERNEL_CONFIG lines into KCONF.
+(Note that while it can handle NAME="this that" you need to escape it as
+NAME=\"this\ that\" to work right.) Added the legacy NLS
+dependencies the VFAT driver needs (even though we selected UTF8) to the
+base config. The init script now tests if stdin is open via
+"2>/dev/null <0 || blah" so only does the exec redirect for /dev/console
+when necessary.
+Fixed the .config checker to replace the toybox config when CONFIG_SH=y
+isn't set, so "make defconfig; mkroot/mkroot.sh" should work now.
+Switched initramfs packaging to use more portable <b>cpio -R 0:0</b>
+instead of --no-preserve-owner. Moved the -m 256 before $@ in run-qemu.sh
+so setting memory size on the command line overrides the default.
+The <b>mkroot/record-commands</b> setup script will now use logpath
+out of the $PATH if it exists, rather than having to compile it each time.
+Bo Svangård fixed a typo in the cpio command line that's ignored by toybox but
+breaks with the host tools.</p>
+
+<p><u>Pending</u>:
+Moritz Weber put in more work on <b>git</b> (still very unfinished).
+Eli Lipsitz fixed bugs in init and login. Elliott added risc-v support
+to strace, and fixed :w in vi (it didn't
+takes a filename argument and would crash if you started with no filename)
+and improved error reporting. Jarno Mäkipää taught vi about backspace
+and improved empty file handling. Rob fixed vi -s. Various cleanups to
+<b>tcpsvd</b>.</p>
+
+<p>More toysh work: command line option parsing stops at first nonoption argument,
+all piped segments are now implicitly subshelled so variable
+lifetimes match bash's and loops don't have to exit before proceedinng to the
+next one (ala "while true; do echo hello; done | while read i; do echo $i; done"
+hanging on a full output pipe). Several changes to HERE document processing
+(variable expansions can cause line continuations in a HERE document, etc),
+and better line continuation handling in general, added set -u,
+fixed if/while return codes, wired up the "local" builtin, fixed an escape
+passthrough bug reported by Mingliang Hu, support undelimited redirects
+(ala cat&lt;file with no spaces), fixed ${X::} with no arguments.</p>
+
+<p><u>Cleanup</u>:
+Converted <b>chgrp</b> to FLAG() macros and did some minor cleanup on <b>bootchartd</b>,
+(which needs tests), <b>basename</b>, <b>bzcat</b>, <b>test</b>,
+<b>i2cdetect</b>. Elliott switched <b>flock</b>
+to FLAG() macros, switched nohup to use octal permissions insted of macros,
+widened the default VSIZE field width in Android's default <b>ps</b> display
+(which is now inserting 10 gigabytes of ASLR padding into "hello world"), and increased
+the vi/top output buffer size to reduce flicker redrawing the screen. Multiple cleanups to
+<b>cpio</b>. Added requested --gratuitous-longopt synonyms to <b>ls</b>.
+Consistently capitalize TODO comments in the tree so they're easier to search for.
+Silence yet more perennial "warning: variable is never used uninitialized" gcc false
+positives.</p>
+
+<p><u>Portability</u>:
+utf-8 support still isn't automatic in libc (you have to set an appropriate locale to
+enable it), and locales aren't entirely standardized: try C.UTF-8 (which MacOS hasn't got)
+and fall back to en_US.UTF-8 (which Gentoo hasn't got).
+Removed itoa() from seq.c because cygwin pollutes the namespace with
+DOS debris.</p>
+
+<p>Dan Bryant renamed xrunread()'s "stdin" argument to "to_stdin" to work around
+broken headers that #define stdin as a macro instead of a global variable.
+Elliott enabled copy_file_range() on Android.</p>
+
+<p><u>Documentation</u>:
+Calling <b>command --help</b> and <b>toybox --help command</b> shows
+the toybox URL banner, but "help command" doesn't.
+Reorder the <b>find</b> help text so match filters that take an argument are mostly
+in the left column. Minor help text tweaks in sleep, find, xxd, cpio.
+The README now points to the same binary cross compilers as the FAQ.
+Update <b>sed</b> help text now that -e and -f get processed in command
+line order when used together.</p>
+
+<p><u>Plumbing</u>:
+The FLAG() macros now always return 1 or 0, so we can CONSTANT*FLAG(X) without needing
+a !! in there. The help plumbing now has HELP_FLAGS.
+Each command's option string in NEWTOY() may now use octal escapes with the
+high bit set to use control characters as option flags, with the resulting
+FLAG_X## macro using the 2 digit hex value (without the high bit set). For
+example if you needed "command -:" then ":" is ascii 58 (hex 3A,
+toybox's <b>ascii</b> command is useful for this), +128 is 186, which in octal
+becomes "\272" and tested with if (FLAG(X3A)) in the code.</p>
+
+<p><u>Test suite</u>:
+Each command.test now runs in an empty subdirectory, and working files like
+expected/actual go elsewhere (only "input" is created for you in there, and only
+when you provide input in the current test's 4th argument), so the directory
+listing doesn't contain anything the test didn't put there. (This simplified
+several tests.)
+The realpath test broke on mksh (which doesn't export $PWD by default).
+Elliott fixed the ifconfig tests on android. General tidying and adding
+tests to sed, ls, modinfo. The tar tests broke on github because it
+switched to a filesystem that can't do sparse files with 4k granularity,
+added a check to skip those tests (and also skip them on MacOS, which
+fails for a different reason.)
+When a test's name field was blank (meaning the actual test command line
+should be displayed as the name) the test plumbing was adding the command
+name to the display twice.
+The <b>make tests</b> target now defaults to building toybox with ASAN when
+not testing an existing binary. (You still have to specify ASAN=1 manually
+for individual command tests.)</p>
+
+<p>Fixed <b>demo_utf8towc</b> which had the range check backwards (0x10ffff is
+the biggest _output_, not input). The range check was an attempt to avoid
+spending a long time going through all 4 billion entries, but wasn't testing
+everything it needed to, so now it advances the counter with a bit shift
+based on the number of bytes consumed by the match (avoiding large swaths
+of redundant checks but still theoretically testing all meaningfully different
+4 byte inputs).</p>
+
+<p><u>Build</u>:
+Fix return code of verbose mode in scripts/build.sh so <b>make V=1</b> succeeds.
+Speed up the MacOS build: their gsed is slow to launch so avoid one repeated call in a
+loop, and reimplement the wait $PID codepath because their bash is 17 years old.
+The llvm+bionic toolchain warns about printf(" "+FLAG(m)) unless you add an
+extra ,0 argument, but gcc+glibc warns if you DO add the extra argument... so
+I used the write() system call to avoid the compiler "helping" in a way I
+can't make it STOP. Similarly, now that FLAG(u) is always 1 or 0,
+<b>size = FLAG(u) ? : sizeof(toybuf)</b>
+is either 1 or 4096, which is what I _want_, and the compiler warning about it
+is counterproductive. LLVM needs a new -Wno-invalid-source-encoding flag
+or else it complains about octal escapes in string constants. (When I want
+to put utf-8 in there I can just do so, why would I octal escape it?
+Stop "helping".)</p>
+
<a name="10-01-2023" /><a href="#10-01-2023"><hr><h2><b>January 10, 2023</b></h2></a>
<blockquote>
<p>"Why," Arthur said, "is there a sofa in that field?"</br>
@@ -15,7 +277,7 @@ a development environment. See the links on the left for details.</p>
continuum!"</br>
"And this is his sofa, is it?"</p>
<p>- The Hitchhiker's Guide to the Galaxy</p>
-</p></blockquote>
+</blockquote>
<p><a href=downloads/toybox-0.8.9.tar.gz>Toybox 0.8.9</a>
(<a href=https://github.com/landley/toybox/releases/tag/0.8.9>git commit</a>)
diff --git a/www/release.txt b/www/release.txt
index 7dede942..164b19f2 100644
--- a/www/release.txt
+++ b/www/release.txt
@@ -1,6 +1,6 @@
-VERBOSE=fail make distclean defconfig toybox tests
+make distclean defconfig tests
news.html - release notes
-Update version in main.c
+Update version in toys.h
- git commit toys.h www/news.html
tag repo
- git tag $VER
@@ -12,18 +12,21 @@ source tarball
scp www/news.html landley.net:landley.net/toybox/
binaries
cd ../clean
- git pull ../toybox
- make distclean; make defconfig root CROSS=all
- mkdir send; for i in root/*/fs/bin/toybox; do X=${i#*/}; X=${X%%/*}; cp $i send/toybox-$X; done
- ssh landley.net "mkdir landley.net/toybox/downloads/binaries/$VER"
- scp send/toybox-* landley.net:landley.net/toybox/downloads/binaries/$VER/
- update symlink
-update help.html
- make clean; make defconfig; make
- (./toybox --version && ./toybox help -ah) > www/help.html
- scp www/help.html landley.net:landley.net/toybox/
-scripts/mkstatus.py -> status.html
- - scp www/status.gen landley.net:landley.net/toybox/
+ git pull --tags ../toybox
+ mkroot/mkroot.sh CROSS=allnonstop LINUX=~/linux/linux
+ mkroot/testroot.sh
+
+ ssh landley.net "mkdir -p landley.net/toybox/downloads/binaries/{,mkroot/}$VER"
+ mkroot/tar-for-web.sh landley.net:landley.net/toybox/downloads/binaries $VER
+
+ ssh landley.net "cd landley.net/toybox/downloads/binaries && rm -f latest && ln -s $VER latest && cd mkroot && rm -f latest && ln -s $VER latest"
+
+ make clean; make defconfig toybox
+ ./toybox help -ah > www/help.html
+ scripts/mkstatus.py
+
+ scp www/{news,help,status}.html landley.net:landley.net/toybox/
+
roadmap.html
code.html
Inform mailing list (with link to https://landley.net/toybox)
@@ -31,4 +34,4 @@ Update #toybox topic
Toybox 0.7.3 released February 21, 2017. http://landley.net/toybox
todo:
- x86-64, sparc, cortex-m toolchains
+ sparc, cortex-m toolchains
diff --git a/www/roadmap.html b/www/roadmap.html
index 6b54c1a8..947e0f63 100644
--- a/www/roadmap.html
+++ b/www/roadmap.html
@@ -1244,13 +1244,14 @@ deallocvt iorenice
udpsvd adduser
microcom tunctl chrt getfattr setfattr
kexec
-ascii crc32 devmem fmt i2cdetect i2cdump i2cget i2cset mcookie prlimit sntp ulimit uuidgen dhcp6 ipaddr iplink iproute iprule iptunnel cd exit toysh bash traceroute6
+ascii crc32 devmem fmt i2cdetect i2cdump i2cget i2cset i2ctransfer mcookie prlimit sntp ulimit uuidgen dhcp6 ipaddr iplink iproute iprule iptunnel cd exit toysh bash traceroute6
blkdiscard rtcwake
watchdog
pwgen readelf unicode
rsync
linux32 hd strace
gpiodetect gpiofind gpioget gpioinfo gpioset httpd uclampset
+nbd-server
</span>
</b></blockquote>