aboutsummaryrefslogtreecommitdiff
path: root/lib/xwrap.c
AgeCommit message (Collapse)Author
2020-11-17That last sh.c change had a lib/ change I forgot to check in.Rob Landley
2020-11-07xregcomp: add the specific regex we couldn't parse to the error message.Elliott Hughes
This makes it more likely that you can actually debug something like "sed: bad regex: empty (sub)expression" or "sed: bad regex: parentheses not balanced" from a build failure log, where you don't necessarily know where the failure came from. This also seems like it might be useful generally, although GNU grep doesn't include this detail in its error messages, and busybox doesn't even seem to notice that regcomp() failed? (Realistically if the Android build team wants to move forward with "one true regex implementation", we're going to have to add some GNU-isms to the Android regex implementation. But we'd need to find them first! Note that the two examples given above are real examples from failed buildbot builds, but they occur early in the respective builds so there are likely many more to look at after these. Interestingly, the first of the two appears to be the more general case of something disallowed by POSIX that xregcomp() already has a workaround for.)
2020-10-22Fix thinko.Rob Landley
2020-10-22Add nommu-able xvdaemon() and use it to remove some TOYBOX_FORK dependenciesRob Landley
2020-08-27xparsedate: support default date(1) output format.Elliott Hughes
This round trip occurs in practice with $KBUILD_BUILD_TIMESTAMP in kernel builds.
2020-08-21xputsl: fix the *other* line in this function :-)Elliott Hughes
Some of the grep tests were still failing because we weren't flushing stdout --- xflush takes a bool that says whether to actually flush, so we need to pass 1, not 0.
2020-08-20xputsl: write to stdout, not stdin!Elliott Hughes
This is why the tests have been failing since 42303209f44a335025b9cd1dbe5dd2f3069f2e99.
2020-08-19xputsl: remove unused variable.Elliott Hughes
2020-08-15If we fflush(stdout) first we can just write to filehandle.Rob Landley
2020-08-04Inline convert_tz()Rob Landley
2020-08-04xparsedate: support UTC offsets.Elliott Hughes
Requested in https://github.com/landley/toybox/issues/130, quoting an old version of the toybox help. This is also supported by coreutils. Set $LANG to C in the date tests so that they pass with TEST_HOST=1 (they were already failing for me, presumably related to a newer glibc).
2020-08-04Toysh signal handling adds a few EINTR recovery corner cases to lib.Rob Landley
2020-06-19Bugfix: the code to trim \n off xgetline() was using allocated not read length.Rob Landley
2020-06-01Use copy_file_range() when available.Rob Landley
2020-05-03Next round of shell work.Rob Landley
2020-04-01Add rtcwake.Elliott Hughes
Some of the bringup folks are debugging RTC issues and asked for this. Rather than duplicate the weird xtzset dance with mktime, I've factored that out into a new xmktime that takes a boolean for whether to use UTC or local time. Otherwise, the slight cleanup of hwclock.c is entirely optional. The only functional change there is that util-linux 2.34's hwclock uses ISO time format, which is the usual toybox preference anyway, so I've switched it over to that rather than ctime(3). Bug: http://b/152042947
2020-03-18Fix WARN_ONLY (and the one caller feeding it in the field it was checking).Rob Landley
2019-12-14Bugfix: xgetline() wasn't returning NULL at EOF.Rob Landley
2019-12-12Next round of toysh work, with associated lib plumbing.Rob Landley
2019-10-27Tar extract should delete files or symlinks where it's making a directory,Rob Landley
but --restrict checking should run on the path up to the last component before unlinking so tar can't be tricked into deleting random files off the system.
2019-09-18Get exit code right when command intercepts signal, make timeout useRob Landley
xwaitpid(), fix off by one in xwaitpid().
2019-08-21Add xgetline (which the last sh checkin used, oops).Rob Landley
2019-07-31Move the empty regex workaround into xregcomp.Elliott Hughes
No current caller except grep needs this, but consistency seems like a good idea. Also change the xregcomp error message to be a bit more human-readable, rather than mention an implementation detail.
2019-07-31Fix error path and tweak comments.Rob Landley
2019-05-19Don't complain about short writes to stdout.Rob Landley
2019-05-11Teach tar to extract type 'S' sparse file headers.Rob Landley
2019-04-16Add argument to xflush() so it can test for stdout err without flushing.Rob Landley
2019-04-02Don't leak stdout pipe filehandle into children.Rob Landley
2019-04-02Have xflush() only flush stdout (that's all it checks errors on),Rob Landley
and tweak a couple comments.
2019-03-27xabspath: use O_PATH for dirfd.Elliott Hughes
SELinux on Android is unhappy if you try to read "/": avc: denied { read } for name="/" dev="dm-3" ino=2 scontext=u:r:hal_dumpstate_impl:s0 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 That could happen via the open of ".." too, and potentially any other directory might have similar restrictions, so move all of the open calls to using O_PATH. O_PATH seems more intention-revealing given what this function is doing anyway.
2019-03-26xabspath: use O_PATH.Elliott Hughes
SELinux on Android is unhappy if you try to read "/": avc: denied { read } for name="/" dev="dm-3" ino=2 scontext=u:r:hal_dumpstate_impl:s0 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 O_PATH seems more intention-revealing anyway.
2019-03-26Make touch use xparsedate() (result: -t and -d the same, autodetects format),Rob Landley
and fix tests to pass on host too.
2019-03-24Factor out xparsedate() and xvali_date() into lib.Rob Landley
2019-03-17Fix xstrndup() bug.Rob Landley
Now there's a second user... the libc function already null terminates at len+1, and it doesn't malloc the full size if strlen() smaller so the redundant termination stomped unallocated memory. Oops. sort.c never noticed because it calculated length to truncate or copy existing string, so never hit this.
2019-03-10Add TOYFLAG_ARGFAIL() to allow argument parsing failures to exit with value.Rob Landley
2019-03-10Make xsendfile() variants handle -1 length properly again.Rob Landley
2019-03-10Don't redirect stderr or xexec() error hidden.Rob Landley
2019-03-10Make multiple sendfile variants, and teach xpopen_both() to use existingRob Landley
stdin/stdout filehandles.
2019-02-15Fix typos: e.g. change "cannonical" to "canonical".Jason Spiro
2019-02-03William Djupström pointed out that xexec() lost the absolute path check.Rob Landley
2019-01-08xchdir: show the specific failure.Elliott Hughes
2018-12-23Add grep --colorRob Landley
2018-12-14Add xrename()Rob Landley
2018-10-21Make ./top -d .1234567890m work.Rob Landley
2018-10-21Add % to lib/args.c (long time in milliseconds), add xmillitime(), redoRob Landley
xparsetime() not to need floating point, adjust callers.
2018-10-10Trivial speedup to format_iso_time(), teach parsetime() leading garbage != 0.Rob Landley
2018-10-10Add xsignal_flags() and more consistently use xsignal() instead of signal().Rob Landley
xsignal() wraps sigaction() giving control of SA_RESTART behavior and such.
2018-09-16Nommu systems want to _exit() after vfork when exec fails, but should do ↵Rob Landley
cleanup ala fflush(0) after a normal exec() failure.
2018-07-08Fix division by zero errors and double summary in ping.Rob Landley
2018-05-06Support fractional seconds (and other time units) in `top -d`.Elliott Hughes
LTP uses `top -d 0.1`, which isn't convincingly useful, but general support for other time units might be useful, and switching to xparsetime addresses both at once. Also fix 3169d948c049664bcf7216d4c4ae751881099d3e where I mistakenly treated `rev` and `toys.optflags&FLAG_b` as interchangeable. (Without this second fix, `top -b` looks fine but `top` is broken!) Also fix xparsetime to reject input such as "monkey" or "1monkey".