aboutsummaryrefslogtreecommitdiff
path: root/lib/xwrap.c
AgeCommit message (Collapse)Author
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".
2018-04-08Add readlink -m to show where a missing path would be.Rob Landley
Note: ubuntu will show -m through a file, this treat that as error.
2018-04-03Factor out xtempfile()Rob Landley
2017-09-09Last commit used xstrtod(), forgot to check it in.Rob Landley
2017-05-24Add and use xmmap.Elliott Hughes
Everyone forgets that mmap returns MAP_FAILED rather than NULL on failure. Every use of mmap in toybox was either doing the wrong check, or no check at all (including the two I personally added).
2017-02-04Posix says stdio.h should define 'stdout' as a macro, and bionic turns it intoRob Landley
an array index, which doesn't work as a local variable name. So rename it.
2017-02-04Switch oneit to use xopen_stdio() for -c (oops) and switch XVFORK() to useRob Landley
__attribute__((returns_twice)) instead of noinline. Yes LLVM supports it: https://llvm.org/bugs/show_bug.cgi?id=6287
2017-01-04Some lib fixes: mark xvfork() noinline, make xsendfile() return bytes copied,Rob Landley
make xsocket()'s returned fd CLOEXEC.
2016-09-05Export notstdio() wrapper.Rob Landley
2016-09-04Add openro() and WARN_ONLY flag so xopen() and friends can warn without exiting.Rob Landley
2016-08-18Change xgetpwnamid/xgetgrnamid to xgetuid/xgetgid returning the id numberRob Landley
instead of a struct. This means it can return "12345" even if that user/group doesn't exist in /etc/passwd and similar. All the users were immediately dereferencing it to get pw_uid or gr_gid anyway, so just return it directly and adjust the users. This fixes things like "chown 12345:23456 filename".
2016-08-04Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout,Rob Landley
add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users.
2016-06-30Use libbuf instead of stack buffer.Rob Landley
2016-04-23Fix more to not append an extra newline.Elliott Hughes
More's sigatexit handler needs to distinguish between normal exit and exit due to receipt of a signal. Change tty_sigreset to look at the signal number too, so that pressing 'q' to exit top doesn't cause its exit status to be 128.
2016-03-13Split out _xexit() from xexit() and give sigatexit() multiple callbacks.Rob Landley
2016-02-09Fix xpipe. (thinko.)Rob Landley
2016-02-08Add xpipe() to lib.Rob Landley
2016-01-28Bugfix I forgot to checkin, plus a wrapper function.Rob Landley
2016-01-10Fix hwclock -u.Elliott Hughes
You can't pass a NULL value to setenv(3). The "put things back how they were" intent of this code is best achieved by calling unsetenv(3) in the NULL case. (This causes a crash with "hwclock -u" on Android. glibc silently corrupts the environment instead.)
2016-01-05Add error_msg_raw() and friends, replace error_msg("%s", s) uses, enable formatRob Landley
checking, and fix up format checking complaints. Added out(type, value) function to stat to avoid a zillion printf typecasts.
2015-12-31Tweak error message.Rob Landley
2015-10-27Replace xcount_cpus() with a call to sysconf(_SC_NPROCESSORS_CONF)Rob Landley