aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-05-12Switch to C11 noreturn to work around a compiler bug in llvm.android13-devRob Landley
Elliott said: Works around a clang bug in the version of clang shipping with Android T that causes a miscompile in xstdio_create() on x86-64, that oddly only affects __attribute__((__noreturn__)) and not _Noreturn! Bug: http://b/225806996 Test: manual inspection of generated code on x86-64 Change-Id: I12302d2300fc454f92352b43090745c04ed66fd0
2022-04-12All PEDANTIC_ARGS does is set a macro that's never used.Rob Landley
2022-04-11lib/portability.c: don't assume we have __NR_copy_file_range.Elliott Hughes
Android's host tools currently build with glibc from 2012, but even if we were more up to date (or had already switched to musl for host tools, which hopefully will be the case by this time next year), it was added to glibc recently enough to miss the "seven year window".
2022-04-04When args.c is just enforcing max/min argument count with no options, imply ?Rob Landley
so "command -123" isn't an unknown option error.
2022-04-02Add tar --strip-components.Rob Landley
Also in lib/ add bufget name variants for password and group.
2022-03-26Cleanup pass and make -O - write to stdout.Rob Landley
Teach chomp() to remove any number of trailing \r\n
2022-03-22Avoid redundant strlen() inside libc.Rob Landley
2022-03-19Fix copy_file_range() fallback.Rob Landley
2022-03-18Fix macOS build after copy_file_range() changes.Elliott Hughes
2022-03-17Update comments and add "sanity check" from kernel commit f16acc9d9b376.Rob Landley
(The kernel's been doing this since 2019, but older kernels may not, so...)
2022-03-17Enable copy_file_range when it is available.LongPing Wei
Fallback to read+write when copy_file_range failed, as both fd_in and fd_out must refer to regular files. Signed-off-by: LongPing Wei <weilongping@huawei.com>
2022-03-06Silence more false positive warnings in llvm.Rob Landley
2022-02-16Move a struct from lib.h into the one toys/pending command that uses it.Rob Landley
2022-02-12Move lib/lib.c into main.c so make.sh doesn't have to split it out ↵Rob Landley
seperately. (Nothing else in lib/ has to rebuild when command list changes.)
2022-02-10Fix @time.nanosecond parsing, and add test.Rob Landley
2022-01-30Move ANSI escape cheat sheet to tty.cRob Landley
2022-01-28Rename remains of linestack.c to utf8.cRob Landley
2022-01-28Remove the linestack plumbing, an old unfinished todo item that gotRob Landley
interrupted long enough ago it would be easier to restart from scratch. It was never used and hasn't been touched in years.
2022-01-10Shut up an unused variable warning triggered by an #ifdef.Rob Landley
2022-01-03Replace \033 with \e in strings.Rob Landley
2022-01-03Remove tty_esc() and tty_jump() wrappers, just output ANSI directly.Rob Landley
2022-01-01Yank some unnecessarily exported global variables that should be static.Rob Landley
2021-12-28Have llist_pop(0) return NULL the same way dlist_pop() does.Rob Landley
2021-12-27Make xsignal_all_killers() slightly less magic. (Use SIG_DFL instead of NULL.)Rob Landley
2021-12-19Minor cleanups: comments, whitespace, use \e instead of \033Rob Landley
2021-12-05Clean up password plumbing.Rob Landley
2021-12-05Move get_line() out of lib/ into last user.Rob Landley
2021-12-04Tiny cleanup.Rob Landley
2021-11-28Fix unused variable warnings found by clang/llvm 13.Rob Landley
2021-11-06Fix env properly: env -i uses old $PATH, but use new PATH= when redefined.Rob Landley
Also add QUIET macro to shut up gcc's "isn't actually used uninitalized" warnings, instead of doing the "int x=x;" trick.
2021-11-05Yank -lrt linking entirely: when statically linked it pulls in pthreads for ↵Rob Landley
non-threaded programs, and neither bionic nor musl have it. (This means glibc always does the HASTIMERS syscall wrap.)
2021-10-31Add HASTIMERS probe to work around bug in gcc 9.3Rob Landley
2021-10-18mkdir: return error for existing directories without -p flagMikhail Kashkarov
Existing directories should be ignored without errors only with -p flag (according to POSIX). Signed-off-by: Mikhail Kashkarov <m.kashkarov@samsung.com>
2021-10-05pidof: fix -s.Elliott Hughes
Also modernize pidof.c, even though the bug was in lib.
2021-10-01Use -dead_strip for --gc-sections on macOS.Elliott Hughes
2021-09-28The mac compiler can't optimize out unused functions.Rob Landley
For some reason "configure" is explicitly NOT passing LDOPTIMIZE="-Wl,--gc-sections" to the mac build. I don't know why, but it means the linker includes unused functions in the binary, and thus complains about unused dependencies being missing.
2021-09-28Attempt to fix yesterday's mac commit.Rob Landley
2021-09-27Move the sys/personality.h import Mac can't do into portability.h.Rob Landley
(Need to test this on FreeBSD too...)
2021-09-24Fix warnings.Rob Landley
2021-09-24macOS: add a timer_create() and timer_settimer() to fix the build.Elliott Hughes
Note that these aren't equivalent to the CLOCK_MONOTONIC timer we have on Linux, but short of spinning up another thread ourselves I can't see how to implement that on macOS at present.
2021-09-23timeout: use the monotonic clock.Elliott Hughes
On a desktop or server the difference between the realtime and monotonic clocks doesn't matter much, but we've seen cases on Android where something's run under timeout(1) but killed before it's had a chance to do anything because the device went into sleep shortly afterwards and by the time it came back, the timeout had elapsed (as far as the realtime clock is concerned) but the process had only had a tiny fraction of the timeout where the system wasn't suspended. This patch also adds an xparsetimespec() function; at this point the only remaining users of xparsetime() are in lib, so maybe that should become static, at least until we have another need for it? A bigger question is whether timeout(1) needs to offer the user a choice between the two different clocks? Although monotonic is usally the right default choice on Android, and I don't have a specific counter-example to hand, I can imagine that someone might actually mean "wall clock time" rather than "cpu clock time" when setting a timeout... Luckily, timer_create() lets us trivially choose between both clocks if so.
2021-09-20strace: fix macOS build.Elliott Hughes
Obviously we're never going to be able to build strace for macOS, but right now the reference to the struct was breaking even a macOS build with strace disabled! From poking at building for arm on the Raspberry Pi over the weekend, changes like this will be needed there too (because different architectures have different _names_ for this struct, not just different contents). Tested on macOS (where it juts fixes the build) and on x86-64 (where strace continues to function as before).
2021-09-17strace: initial commit.Elliott Hughes
This is most notably lacking -p and -f, and only covers a small subset of system calls, but it's "useful" in the sense that you can strace something like toybox date, say, and see everything. There's a fundamental assumption here that we don't need to worry about multiple personalities. (This is what makes "real" strace's build so complex, and why Android has _never_ actually shipped a fully correct strace build.) Given that the desktop's already been 64-bit only for a while, microcontrollers are likely to stay 32-bit only for a while, and the odd one out -- mobile -- is moving to be 64-bit only (https://www.arm.com/blogs/blueprint/64-bit), so by the time this is ready to graduate from pending, I'm assuming no-one will care!
2021-09-11Check for --help before "Not root".Rob Landley
2021-09-06Add find -lname -ilname and -d as a synonym for -depth.Rob Landley
2021-08-30Fix "xsignal 0: Invalid argument" after commit 0737ba9e8dd1.Rob Landley
2021-08-27kill: allow `kill -0` for testing process existence.Elliott Hughes
Allow num_to_sig(0) so kill doesn't disallow -0 because it can't round-trip, and then teach list_signals() to avoid the special case of signal 0 rather than assume that all the signals it shouldn't print don't have names now signal 0 has the name "0".
2021-08-15Samanta Navarro pointed out leftover 32 bit flag limitation in argument groups.Rob Landley
2021-08-07Change xabspath() to more granular (flag based) control interface.Rob Landley
2021-07-08Work around a posix violation in the croups filesystem that LTP requires.Rob Landley
Posix says you removing a non-empty directory "shall fail" in both: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/unlinkat.html https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/rmdir.html So toybox mv went ahead and unlinked the directory even if the contents hadn't all been deleted because posix guarantees it to be harmless. But cgroups (https://lwn.net/Articles/679786/) deletes the non-empty directory, thus the Linux Test Project's cgroups_fj_function test6 was failing with toybox mv because they depend on not triggering the posix violating behavior. Work around it by having mv DIRTREE_SAVE failing nodes and then check for a non-empty ->child in the COMEAGAIN as a signal not to unlink the dir. While I'm there do some code cleanup, add a cp -i test...