aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2015-12-06Attempt at making cpio chown() mode 000 files sanely.Rob Landley
2015-12-06Remove trailing whitespace and wrap lines to 80 chars.Rob Landley
2015-12-06CPIO: Add --no-preserve-owner option.Mike Moreton
2015-12-06Correct setting of guid and uid when extracting from a cpio archive.Mike Moreton
2015-12-06Enable matching any perm bits.Gilad Arnold
Includes tests for the new feature, and a failure case for the minimal perms test as well. Also some typo fixing / massaging the help text so it fits in 80 columns.
2015-12-05Add start of top infrastructure to ps, null terminate some stridx() searches,Rob Landley
move slot[] documentation into C code, add PR %VSZ VIRT RES SHR
2015-11-29Implement ps --sort.Rob Landley
2015-11-29Add basic sort logic.Rob Landley
2015-11-28Split out string_field() from show_ps().Rob Landley
2015-11-28Save string offsets rather than recalculating them each time, and use structRob Landley
instead of carving up toybuf by hand. This makes breaking out the field conversion logic into its own function less expensive.
2015-11-26Split do_ps() into get_ps() and show_ps() as a start on implementing --sort.Rob Landley
Change readfileat() to pass back length of read.
2015-11-19Fix find -perm.Elliott Hughes
1) It read st_dev instead of st_mode. 2) It reversed the semantics of absolute vs minimal ('-' prefixed) tests. Add tests for these, and move the "unterminated -exec" test into the "Still fails" section because it's still dumping core for me.
2015-11-12Document %s in date(1).Elliott Hughes
2015-11-12Fix year parsing in date(1).Elliott Hughes
Four-digit years were being mangled by the code for two-digit years. Move all the two-digit year code into the "we only saw two digits" case. Add some new tests and fix existing tests.
2015-11-09Cleanup pass: inline find_tty_name(), bounds check fscanf(), use libcRob Landley
functions to read major()/minor(), fix printf format warnings in error msg.
2015-11-09Make ps try harder to find a name for a tty.Elliott Hughes
2015-11-09On Android, ps' default output should match toolbox.Elliott Hughes
2015-11-09Add ps -n.Elliott Hughes
Both Android and GNU interpret -n to mean "show numeric users and groups", despite what POSIX says.
2015-11-09Add ps -o CMDLINE.Elliott Hughes
This is equivalent to Android's historical "NAME" column, showing the first element of /proc/pid/cmdline.
2015-11-05Fix sed bug where any ] right after [ was skipped, not just first one in range.Rob Landley
2015-11-02Add -P as short option for --ppid.Rob Landley
(The help infrastructure can collate and alphebetize short options, long options haven't got a standardized help text format. Not a hard requirement to have a short opt, but it's nice.)
2015-11-02Fix the ps -o CMD vs COMM distinction.Elliott Hughes
"comm" is the command name without arguments, and "cmd" the command line including arguments. Confusingly, "command" is a synonym for the *latter*, not the former. This implementation of "comm" matches the GNU ps behavior where the names are truncated, but Android historically used the full name from /proc/pid/cmdline instead, so this patch isn't sufficient to let us match the Android behavior.
2015-11-02Make ps -o error reporting intelligible.Elliott Hughes
I actually thought ps was segfaulting, and it wasn't until I was in gdb that I even noticed there was an error message at all, and even then I had to read the source to work out what it was trying to tell me. Before: $ ps -o user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd ps: -o 'user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd'@41 USER PID PPID VSZ RSS NI WCHAN ADDR$ After: $ ps -o user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd ps: bad -o field 'user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd' ^
2015-11-02Add ps -Z.Elliott Hughes
As with ls, it doesn't seem like -Z should be guarded behind LSM availability. On a non-SELinux system, the label is always "unconfined".
2015-11-02Add ps --ppid.Elliott Hughes
Used by Android.
2015-11-01Last patch broke creating new file as a patch, fix it.Rob Landley
(Matches beginning and EOF at once.)
2015-11-01Fix applying patch hunks with trailing context to the start of the file.Rob Landley
2015-11-01Change grep -w to checking matches after the fact rather than modifing regex.Rob Landley
This lets '(x)\1' match, as reported by Isabella Parakiss.
2015-10-29Fix sed bug reported by Isabella Parakiss, where sed -e "/x/c\" -e "y" addedRob Landley
an extra newline because the test for whether we have an existing string to append a newline to was checking if struct step had data appended to it, and the /x/ regex is data appended to it. Change test to check for null terminator at ->arg1 offset.
2015-10-28Promote ps to posix.Rob Landley
2015-10-27Use the /proc/self/fd/%d workaround for O_PATH not letting you read xattrs,Rob Landley
inspired by: https://android-review.googlesource.com/#/c/152663/4/libc/bionic/fgetxattr.cpp
2015-10-27Fix ls error message for chmod -r directories.Rob Landley
Also, if you mkdir "$(echo -e "one\ntwo"); chmod -r one*; ls -q one* it honors -q.
2015-10-27Install without a mode should use 0755, and check FLAG_preserve instead ofRob Landley
the global so "install -g 0" doesn't alias to "cp --preserve 0" and error out. through to --preserve 0"
2015-10-22Auto-size df columns.Elliott Hughes
On Android, the filesystem column is pretty wide. Actually measure the widths.
2015-10-05Fix bug in od that screwed up position indicator on arm and mips.Rob Landley
2015-09-29Make defconfig build for nommu.Rob Landley
Adds XVFORK() macro, teaches xpopen_both() to call /proc/self/exe with NULL argv (and converts cpio -p to use that), adds TOYBOX_FORK guards to some unconverted commands.
2015-09-23Add xvfork() as a static inline and use it from various places.Rob Landley
Note: vfork(), like fork(), can return -1 if too many processes, and we should notice and fail loudly.
2015-09-12Fix a find segfault.Rob Landley
Elliott Hughes found a bug https://android-review.googlesource.com/#/c/170020/ and Daniel K. Levy worked out the problem: the user/group/newer arguments to find weren't consuming their arguments when not checking the results of their comparison (because an earlier test had already caused their parenthetical group to fail). This confused the argument parsing logic and could lead to segfaults. I applied a different fix that reorganized the existing tests instead of adding a new test. (Looks like a big commit but it's mostly whitespace due to extra curly brackets changing indendentation levels.)
2015-09-11Replace toys.exithelp with help_exit() in lib.Rob Landley
2015-09-08Squish a warning in pending.Rob Landley
2015-09-07Remove prompt argument from yesno(), caller can fprintf(stderr, "blah") itself.Rob Landley
This fixes the build break, the change to yesno() prototype accidentally got checked in last commit. (Oops, sorry.)
2015-09-06Switch HR_SI to HR_1000, make binary the default, make HR_B only affect bytes,Rob Landley
and update the tests.
2015-09-05ls -h support.Elliott Hughes
It turns out that people are anticipating the switch to toybox ls from toolbox ls on the assumption that this will finally bring -h support. Let's not disappoint. I've merged two existing buffers in listfiles whose uses didn't overlap into one. It may be possible to cram this into toybuf with the other stuff, but it didn't seem worth the extra complexity for 64B of stack, especially since we were already living with that for time formatting anyway.
2015-09-05df -h and -H.Elliott Hughes
This doesn't address the lack of support for a variable-width "Filesystems" column, but it doesn't make the current situation any worse either. This is the last of the missing -h options. The other commands with -h also have --si, but only for df did it get a corresponding short option (and I've never personally used --si on du or ls, so let's wait until someone actually cares).
2015-08-31ls -l user/group/security context should be left-aligned.Elliott Hughes
Right-aligned looks pretty good to me, but it's not what anyone else does.
2015-08-30Fix mv on overwrite.Elliott Hughes
We need to remove the destination, not the source, to be able to overwrite.
2015-08-25Static analysis from Hyejin Kim found possible pointer underflow.Rob Landley
Now that the kernel's 128k environment size has been lifted, it might be possible to feed in a gigabyte of suffix so argv[2] is enough larger than argv[1] that char *s decrements past NULL and points to arbitrary high memory (I.E. strlen(suffix) > (long)base), at which point the base > s test is defeated and we strcmp() against a wild pointer. Which is read only anyway and on 64 bit you probably couldn't hit any interesting addresses, but the fix is easy enough: compare strlen values instead of pointers. So do that instead.
2015-08-15Kylie McClain pointed out that env should clear variables with NAME= by itself.Rob Landley
2015-08-11Fix more date bugs.Elliott Hughes
Correctly and portably check for non-normal dates, and explicitly show the "before" and "after" dates (in the format of the user's choosing). Clear the struct tm in date_main rather than parse_default because on one path the struct tm is actually initialized. Explicitly clear the tm_sec field in parse_default because -- experiment shows -- that should not be preserved. Only do the "what does this 2-digit year mean?" dance if we actually parsed a 2-digit year. Show the right string in the error message if strptime fails. Also add more tests, and use UTC in the tests to avoid flakiness.
2015-08-11Bugfixes from Elliott Hughes: debug code got checked in (oops) andRob Landley
uninitialized trash in struct tm fields could segfault glibc's strftime().