aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2016-10-18Unify touch -t and -d handling, allow posix's underspecified "time designator"Rob Landley
T to be a space instead (because the posix says so, no idea why), initialize default values reliably including zeroing daylight savings time field (which is handled inconsistently by libc and just screws stuff up).
2016-10-12Stop renaming the ADDR field to PC on Android.Elliott Hughes
It's causing confusion, and it's not obvious that anyone's relying on it (and even if they are, let's try to find and fix them first).
2016-10-09Izabera pointed out that ls defaults to -q when output is a tty.Rob Landley
2016-10-08Teach ps -w not to truncate any fields.Rob Landley
2016-10-08Evgenii Stepanov found a bug where argv0len was set wrong for threadsRob Landley
(no /proc/$PID/cmdline so setting was skipped and previous value retained), which led to memcpy() with an overlapping source/dest range (annoying asan). Fix: move temp variable and assignment outside the if() statement so we assign zero if we can''t read the file.
2016-10-01du: 32 bit systems were maxing out at 2GB when they should max out at 2TBRob Landley
(1<<32 blocks * 512 bytes, done with unsigned 64 bit math).
2016-10-01Move --version handling next to --help handling, so it applies to all commands.Rob Landley
Say "toybox" before version string. Tweak sed to preserve lie-to-autoconf.
2016-09-29Accept extra ps arguments as additional pids.Elliott Hughes
POSIX says nothing, but traditional ps lets you say "ps 123" in addition to "ps -p 123". (You can mix and match too: "ps -p 123,124 666 667" works fine.) Bug: 31778761
2016-09-28Show thread names with "ps -T" on Android.Elliott Hughes
Android uses NAME rather than CMD by default, but that's not what we want with -T. Noticed because it broke systrace's reporting of thread names (see https://developer.android.com/studio/profile/systrace.html). Bug: 31741954
2016-09-14Fix ls -lh.Elliott Hughes
The recent refactoring broke ls -lh by multiplying all sizes by 0 rather than 1.
2016-09-13Add ar archive support to file.Elliott Hughes
2016-09-13Add -h and -L to file.Elliott Hughes
On a toybox system, most of your bin directory is symbolic links. Bug: http://b/31294746
2016-09-11Izabera pointed out that "file -" was inconsistent (calling stat on "-" butRob Landley
then reading from stdin if it detected a file). Fixed it so "-" always means stdin and you have to say ./- to look at a local "-". Did some whitespace tweaks while I was there...
2016-09-06Teach sed s/// how to handle [:space:] type sequences.Rob Landley
Or more accurately, s@[[:space:]@]@replace@ which can't treat the @ in [] as a delimiter but has to know about nested [[]] to make that decision.
2016-09-05Replace loopfiles' failok with WARN_ONLY open flag.Rob Landley
2016-09-03Move genericish function to lib.Rob Landley
2016-08-27Make "LC_ALL=C ls -Cs --color" produce the same output on toybox and ubuntu.Rob Landley
(Two spaces padding between columns, and -k is hardwired on.)
2016-08-27Remove some redundancy and unnecessary xprintf().Rob Landley
(We should use xprintf and similar to flush and check if stdout went away once per line. No point flushing partway through a line, so in ls only use it on things outputting a newline char.)
2016-08-27Fix ls -sh.Elliott Hughes
-h should apply to -s too. (Previously it only applied to the "total" line in -s output.)
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-13Document deviations from posix for echo.Rob Landley
2016-08-13Add TOYFLAG_NOHELP to disable --help processing for individual commands,Rob Landley
apply it to "true" and "false".
2016-08-13Move getusername/getgroupname to lib. (Return name or string representationRob Landley
of number, but never NULL. Both returned in static buffer good through next call.)
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-08-01Fix touch(1) date parsing on tzcode-derived systems.Elliott Hughes
The IANA tzcode implementation of mktime (used on Android and BSDs) sets errno in some cases where it doesn't return -1 to indicate failure, so the existing test always failed on those systems. I don't think glibc ever sets errno (which is fine by ISO C, but not POSIX). Other uses of mktime in toybox are already fine. This one would have been caught by the existing tests if I was running them on the device :-(
2016-07-26Move regexec0 into lib (regexec that takes length and matches after NUL).Rob Landley
2016-07-23Usischev Yury pointed out that id shouldn't use exit() directly.Rob Landley
2016-07-23Usischev Yury pointed out a use after free error.Rob Landley
2016-07-13Increase ps' default RSS and VSIZE widths.Elliott Hughes
This is enough for everything on Android and everything except Java on my desktop. Even desktop Chrome fits!
2016-07-12Implement NOP find -noleafRob Landley
2016-07-05Don't try to guess the build id type in file(1).Elliott Hughes
They're really just arbitrary byte sequences of arbitrary length. Sure, a 20-byte sequence is _probably_ a SHA-1, but there's no way to know, so let's stop pretending...
2016-07-04Fix a bug (octal digits are 0-7, not 0-8) and deal with a case where posixRob Landley
is explicitly outright insane (%b handles octal escapes differently for no obvious reason).
2016-07-03Promote file.Rob Landley
2016-06-30Add patch -d and --dry-runRob Landley
2016-06-30Teach wc to do -cm together. Fix testsuite so TEST_HOST passes too.Rob Landley
2016-06-29Remove unused argument from do_lines()Rob Landley
2016-06-28Fix a "may be used uninitialized".Rob Landley
2016-06-17Make it clearer that CMD is the thread name.Elliott Hughes
It should come as no surprise to those who followed the development of this that it's not well known which of the various names is actually the thread name. Adding "thread" to the ps --help output seems like a good idea. I'm also assuming that "stat2" was meant to read "stat[2]", since that's how it mostly appeared on the list while discussing this. Still fits in 80 columns.
2016-06-15Add readlink0() and readlinkat0() which null terminate the data.Rob Landley
2016-06-15The glibc bug at https://sourceware.org/bugzilla/show_bug.cgi?id=17829Rob Landley
continues to get worse, and now can't handle INT_MAX/2 either. So our first workaround _also_ broke. But posix says "A negative precision is taken as if the precision were omitted." and that _doesn't_ trigger the glibc bug, so use that instead.
2016-06-10Shuffle arguments around (TNAME->NAME->COMM->CMD), working around posixRob Landley
constraints while still trying to get sane behavior. Discard the old CMD, move COMM to CMD, move the old NAME to COMM, and move TNAME to NAME. Posix assumes argv[] is the only source of process name data, but Linux has three sources (/proc/$PID/cmdline, /proc/$PID/exe, /proc/$PID/stat field 2) and android uses multiple sources simultaneously to identify its processes and threads. Toybox ps also assumes that the field names displayed in the headers can be fed to -o to get that output, which is an assumption posix's ps spec clearly does not have. Before we were erring on the side of posix, now we're erring on the side of sanity. CMD now shows stat[2], all the time. The posix -f behavior change is now just an ARGS=CMD alias in the -f default command line, which -o overrides. (Before -f changed the behavior of -o CMD, which is closer to what posix says but is _insane_ and we've stopped doing it.) COMM now shows /proc/$PID/exe minus the path. (I'm aware posix says argv[0] here, but it says argv everywhere.) NAME is now argv[0] of $PID. TNAME went away. Both $COMM and $NAME show the data for $PID, which is a thread's parent process when $TID != $PID.
2016-06-10Revert commit e02e41373ea3, we're always initializing the TNAME stringRob Landley
field (that's the ptb/tb switching in get_ps) so it's never blank, so this doesn't trigger. (Conditionally initializing it would save runtime memory, but at the expense of more complex code.)
2016-06-10HACK: restore Android ps behavior.Elliott Hughes
"NAME" is no longer doing what we want; "TNAME" is what "NAME" used to be, except that "TNAME" implies -T. This patch switches us over to "TNAME", disables the implicit -T. Change-Id: I5553703d3939b24eaf39976162d2f75a591e1ce8
2016-06-09Fix dangling link after cp commandKyungsik Lee
"toybuf" should be initialized before calling symlinkat() or dangling link could occur.
2016-06-08Fix ps bug, last field wasn't expanding to width.Rob Landley
(Still fixing the fallout from that "Don't truncate number fields" logic rewrite.)
2016-06-08Change the TNAME behavior to "Show parent argv[0]. If that's blank, showour ↵Rob Landley
argv[0]. If that's blank, show [stat2]." That way threads show their parents, parents show themselves, and kernel threads show the [stat2] name.
2016-06-07Izabera pointed out that cmp -ls are contradictory.Rob Landley
2016-06-04Basic success/failure return from pgrep/pkill.Elliott Hughes
The man page says they also return 2 for syntax errors and 3 for "fatal error: out of memory etc", but I don't know how to implement that and don't need it (or have any reason to believe anyone needs it). Bug: 29092208
2016-06-04ps: Show [stat2] for any otherwise blank process name field, expand TNAME to 27,Rob Landley
use generated constant for stat field parsing loop.
2016-05-31In cp -a, don't complain if non-root user can't chown, failure is expected.0.7.1Rob Landley