Age | Commit message (Collapse) | Author |
|
On Linux, struct statvfs' f_bsize and f_frsize seem to be
interchangeable. On macOS, they're wildly different. f_bsize is the
"preferred length of I/O requests for files on this file system"
(corresponding to statfs::f_iosize), and f_frsize is the "size in
bytes of the minimum unit of allocation on this file system"
(corresponding to statfs::f_bsize. POSIX appears to say nothing
about the interpretation of these fields, but man7.org's statvfs(2)
page is quite clear that statvfs::f_blocks, for example, is in units
of f_frsize, not f_bsize.
This is the only place in the tree where we use statvfs::f_bsize
(other than the stat(1) output that's supposed to be f_bsize and
that has a corresponding f_frsize dual anyway.
I've removed the Apple-specific #define f_frsize in portability.h
because that seems to have been from my previous attempt to understand
what was going on here. The output of the relevant stat(1) fields
on macOS are the same before/after this patch.
This makes toybox df's output match the system's df on a MacBook
Pro running macOS 11.2.1.
Tested on a Raspberry Pi 400 running Linux too, where I see no
change in the output before/after this patch.
|
|
|
|
Add a test, with comment that "make install_test" doesn't currently exist...
|
|
|
|
|
|
|
|
no argument returns NULL same as --opt without =
|
|
Add new toy `base32`. Add tests for `base32`.
base32 is added by adapting the base64 encode/decode function to also do
base32 encoding/decoding. Then their respective main functions set up
the global parameter `n` to be the number of bits used in the encoding
(5 for base32 and 6 for base64) and `align` to align the result to a
certain length via padding. These are deliberately kept as parameters to
enable future expansion for other bases easily.
|
|
We need <xlocale.h> for newlocale(3) on macOS, despite it being in POSIX 2008's <locale.h>. musl apparently doesn't have <xlocale.h>, so that's another trick
to teach to portability.h...
|
|
|
|
|
|
The FEXTRA field, indicated by bit 2 of the flag byte, contains
arbitrary extra data, prefixed by a 16-bit length value. The previous
code skipped over the length, but not the actual contents, breaking
decompression of certain files.
|
|
configurable.
|
|
Based loosely on the Plan9/Inferno utility, and a convenient way to go back
and forth between code points and utf8 sequences.
This patch also fixes a couple of bugs in wctoutf8 (and the tests for this
toy effectively serve as unit tests for wctoutf8/utf8towc).
|
|
|
|
|
|
Change 5109da9b3e6a898c8e0ad647303a1b375e3d97d3 caused test.test to call
chmod with mode `u+s+s` which passes on the host (where you have a
toybox test but a GNU chmod) but fails on Android where chmod is toybox
too.
Add the missing loop to string_to_mode(), which means this will also
affect other toys, but that seems like a feature (and, for example, GNU
mkdir also accepts a mode like `a=r+w+x`).
|
|
Can't use the same set_terminal() logic as ptys because it not displaying
data, it should just accurately copy it.
|
|
|
|
|
|
This makes it more likely that you can actually debug something like
"sed: bad regex: empty (sub)expression" or
"sed: bad regex: parentheses not balanced" from a build failure log,
where you don't necessarily know where the failure came from.
This also seems like it might be useful generally, although GNU grep
doesn't include this detail in its error messages, and busybox doesn't
even seem to notice that regcomp() failed?
(Realistically if the Android build team wants to move forward with "one
true regex implementation", we're going to have to add some GNU-isms to
the Android regex implementation. But we'd need to find them first! Note
that the two examples given above are real examples from failed buildbot
builds, but they occur early in the respective builds so there are
likely many more to look at after these. Interestingly, the first of the
two appears to be the more general case of something disallowed by POSIX
that xregcomp() already has a workaround for.)
|
|
I added a #include above this, which caused subtle breakages on 32-bit
systems. Move it to the top of the file to fix it and avoid making a
similar mistake in future.
|
|
One reason to use toybox on the host is to get the same behavior across
Android/Linux/macOS. Unfortunately (as we've seen from a few bugs) one
area where that doesn't quite work is that toybox uses the libc regular
expression implementation. That's fine, and mostly what users want, but
those folks trying to get the exact same behavior everywhere might want
to switch in a known regex implementation (bionic's NetBSD regex
implementation, say) for increased consistency.
That actually works pretty well, but portability.h has an #ifndef test
for REG_STARTEND before including <regex.h> that gets in the way. To
make up for that, this patch removes the unnecessary #include <regex.h>
from grep.c itself.
|
|
|
|
|
|
|
|
|
|
We need to *name = 0 explicitly for the !name && !statless case, so don't
need the +1 in memset that was only zeroing in the !name && statless case.
|
|
tar asks dirtree_path() to reserve space for a trailing '/', but recent
changes broke that for the case that was resolving to just a strdup().
Caught by `export ASAN=1` and `make test_tar`.
|
|
|
|
|
|
|
|
|
|
when passed in extra allocation length or else free() gets very unhappy.
|
|
|
|
|
|
broke the password: prompt.
|
|
The comma thing turned into an internationalization can of worms,
don't go there. Keep the "show megabytes on systems with >10G"
logic which includes not showing 0.0 for single digit values.
|
|
and use the comma format when selected even if <3 digits (no 0.0M)
|
|
|
|
This round trip occurs in practice with $KBUILD_BUILD_TIMESTAMP in
kernel builds.
|
|
Some of the grep tests were still failing because we weren't flushing
stdout --- xflush takes a bool that says whether to actually flush, so
we need to pass 1, not 0.
|
|
This is why the tests have been failing since
42303209f44a335025b9cd1dbe5dd2f3069f2e99.
|
|
|
|
|
|
Helps for terminals narrower than 80 columns (such as ConnectBot on a
current Android device).
|
|
|
|
Requested in https://github.com/landley/toybox/issues/130, quoting an
old version of the toybox help. This is also supported by coreutils.
Set $LANG to C in the date tests so that they pass with TEST_HOST=1
(they were already failing for me, presumably related to a newer glibc).
|
|
|
|
This is a follow-on from 310eefe, addressing the case where sscanf fails
and returns -1.
|