Age | Commit message (Collapse) | Author |
|
(Update to the 64 bit API while we're there. And yes, I checked in the
kernel, it's 512 byte units.)
|
|
|
|
Basic readelf(1) implementation, with output close enough to the binutils
version to be usable with scripts that expect the binutils version. This
started as an implementation of nm(1) until I realized that I almost always
want readelf instead, and that you actually have to do much of the work
needed for readelf just to implement nm. Arguably nm (being part of POSIX)
belongs in toybox while readelf doesn't. An argument could also be made that
neither really belongs in toybox, belonging in a separate set of development
tools (such as binutils or the LLVM binutils).
Doesn't support most of the architecture-specific stuff, most notably
relocations, but is aware of things like ARM exidx sections and the common
register state notes in core dumps for the "big four" architectures: arm,
arm64, x86, and x86-64.
Doesn't support symbol versions (but probably should).
Doesn't support section groups or the -t "section details" (which is a long
form of -S "section headers" that I've never seen used in practice and which
isn't part of -a). Doesn't support dumping unwind info or the hash table
bucket histograms.
Reuses the table of ELF architectures from file(1).
Not fuzzed, but successfully parses all the ELF files in my Ubuntu 18.04
system's lib directories. Attempts to exit with an error when presented with
an invalid ELF file rather than struggle on as binutils seems to.
|
|
|
|
builtin, and add -u.
|
|
Major/minor device encoding is not portable. No two BSDs agree with
each other, and Darwin is different again.
Everyone does agree on having major()/minor()/makedev() macros, but
they disagree whether they should be in <sys/types.h> (the BSDs
including Darwin, and old versions of glibc) or <sys/sysmacros.h>
(glibc >= 2.26 and bionic).
This fixes `ls -l /dev/zero` and `stat /dev/zero` on Mac.
|
|
And a few small cleanups while I was there.
|
|
(it returns a malloc), and doesn't match the object lifetime of getbasename()
(which always returns some or all of its argument string). The dirname() in
libc modifies its argument string, but that's what posix says to do:
https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/dirname.html
so I guess we can live with it.
|
|
In order to be used as drop in replacement for dirname()
If path is a null pointer or points to an empty string,
dirname() shall return a pointer to the string "." .
|
|
|
|
|
|
|
|
The downside is we don't use assembly optimized libc comparison functions,
but the common case is short/no matches until full match. Probably net win.
|
|
|
|
The Linux kernel uses the --max-args synonym for -n.
Barbarians who use vi need xargs' -o to be able to do something like:
find -name xargs.c | xargs vi # Sad vi.
find -name xargs.c | xargs -o vi # Happy vi.
The -p option needs fixing to read from /dev/tty because stdin is
otherwise occupied in xargs. I think xargs is the only place that needs
this, so it didn't seem sensible to make all callers to yesno() be
specific about which they wanted, hence the new function.
Also remove the documentation for the build-time XARGS_PEDANTIC option
which isn't actually implemented.
Also add a TODO for -P (which is used by at least one script in the
Linux kernel).
|
|
This was the last user of get_rawline, which lets us remove it.
|
|
Test: no EBADF in `strace -e close ./toybox tac /proc/version`
|
|
Before this patch, we're effectively doing `pidof -x` all the time. This
patch changes names_to_pid() to allow us to say whether or not we want to
include scripts, and adjusts the callers appropriately.
Also add tests for `pidof` versus `pidof -x` which pass after this
patch, without regressing the existing killall tests.
|
|
Change names_to_pid() so that we can actually match shell scripts with
long names (the code to get the shell script's name was correct, but
there was an extra test preventing us from actually comparing it to the
sought name).
In kill.c itself, remove a dead test for -l and switch to the FLAG()
macro.
Also extend the tests to explicitly cover long and short names.
|
|
macOS doesn't have real-time signals, and it has a slightly different
set of non-portable signals from Linux.
With this, the toybox `kill -l` output matches the default macOS kill(1).
|
|
Include all the signals, not just the POSIX ones.
In particular, improve support for real-time signals. My attempt to
switch AOSP builds over to toybox timeout got reverted when I broke the
ART build bots which use SIGRTMIN+2.
Also fix `kill -l 3` to show "QUIT" and `kill -l QUIT` to show "3".
Also make the `kill -l` output include numbers and names, and format it
to look better on a 80x24 tty, because it's always August 1978 somewhere.
|
|
|
|
This only implements the format specifiers that I've seen used in the
wild (which is actually a significant fraction of the total supported by
findutils' find). The most obvious gap is in the time support. I'm happy
to add more, but didn't want to add stuff "just because".
I'd say %A@, %C@, and -- for SELinux users -- %Z are probably the most
plausibly useful formats still missing. I don't think the human-readable
date formatting is particularly useful unless someone's seen it actually
used in the wild. The %T+ "full ISO" format being the most likely
exception to that.
Anyway, this is enough for me get started building AOSP with toybox find.
|
|
|
|
|
|
This is a 15 year old freebsd extension (presumably thus also available on
MacOS) that glibc adopted in 2004, uClibc adopted in 2005, and bionic
supports. The only thing that DOESN'T support it is musl, once again
because its maintainer explicitly decided not to
(https://www.openwall.com/lists/musl/2013/01/15/26), so add an #ifdef
to let musl stay uniquely broken. (It'll stop at first NUL, everything
else can match NULs).
Finally fixes "s/x/y/g on a megabyte line of x's takes forever" issue.
|
|
Don't strlen() to find NUL to skip to until after we've confirmed first
section hasn't got a match (by calling regexec() on it).
|
|
leaking memory), and mod env command to test it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inspired by some of the small patches that have gone by recently.
Limited to only things found in `generated/help.h`, plus a wider cleanup
for the more common "milisecond" typo.
|
|
|
|
Used to construct SELinux policies in the AOSP build.
I left loopfiles_lines with its hard-coded '\n' because although cut(1)
also has a -z option, I can't find any case where it's used in any of
the codebases searchable by me. (And fmt(1), the other user, doesn't
even have the option.) YAGNI.
Bug: http://b/122744241
|
|
|
|
|
|
bionic, glibc, macOS, and musl all have strcasestr
(see http://man7.org/linux/man-pages/man3/strstr.3.html).
macOS (via BSD) has a strnstr that does what strnstr sounds like it
should do by analogy with strnlen and strncpy.
So we at least need to rename strnstr, but it probably makes more sense
just to switch to strcasestr instead.
|
|
|
|
xsignal() wraps sigaction() giving control of SA_RESTART behavior and such.
|
|
|
|
|
|
(My apologies for mixing these two unrelated changes up.)
|
|
|
|
Slightly tweaked version of Elliott's patch. We probably only need to do this
for groups (struct group * has a list of users that belong to it, but
struct passwd doesn't, getgrouplist() is separate) but keeping the code of
the two similar in case there's a way to merge them later.
|
|
adjusting existing users.
|
|
Reuse create_uuid, but make it match the current RFC.
|
|
|