Age | Commit message (Collapse) | Author |
|
|
|
My patch to fix df behavior on macOS broke the stat build on macOS.
First off, we had %s and %S the wrong way round compared to coreutils,
though since Linux always seems to use the same value for both,
no-one will ever have noticed.
Annoyingly, Linux and macOS disagree about what statfs::f_bsize
means, and whether statfs::f_iosize and statfs::f_frsize exist (each
has one or the other, depending on what f_bsize *doesn't* mean to
them). This mess is presumably why statvfs exists.
Unfortunately, statvfs on macOS at least doesn't contain the file
system type information. So we either need to do *both* statfs()
and statvfs() for macOS, or we need to take into account the different
fields.
This patch adds an #ifdef outside of portability.h because I wasn't
sure we actually wanted to add statfs_best_transfer_size() and
statfs_real_block_size() functions to lib for this. But that's an
easy cleanup if desired.
|
|
|
|
And fix one test for NUL that should be a length test for -z support
|
|
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.
|
|
|
|
|
|
more recently than the resulting mount point.
|
|
|
|
|
|
|
|
|
|
Requested by aheirman on github: uses access(X_OK) which checks access
control lists as well as permissions, and that _we_ can access them
(u+x could be owned by a different user)...
|
|
|
|
|
|
|
|
|
|
Also reorder the --help output to separate the "whats" from the "hows",
as with other commands that have lots of options, and add units to the
help too.
|
|
by not writing as much payload as the header promised.
|
|
|
|
Ethan Sommer noticed that chown is using chgrp_main() due to OLDTOY, so
the wrapper function isn't needed.
|
|
|
|
Avoid fgets() into toybuf other than to skip header lines, preferring
fscanf() or xgetline() instead.
Remove the early returns if we fail to skip a header line (fixes #62).
Fix `netstat -xl` which was previously broken (because only -a would
include listening sockets).
Fix a variety of formatting issues, bringing the diff between toybox
netstat and net-tools netstat down (which was what I used for testing).
Use FLAG() more consistently.
|
|
|
|
I need to set up a test environment for this...
|
|
|
|
Instead of unlink() && check errno, call lstat() explicitly to check
file existence if "-f" is specified.
There is a regression when if the path to be removed is nonexistence
and within a readonly filesystem, then unlink() could set the EROFS
errno instead of ENOENT, thus screwing up the output of `rm`.
|
|
or else singlemake enables it for all commands. (I was trying to
move it out of the command namespace, but it's not a global config
option either...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Remove STDIN_FILENO and use FLAG().
Use xsetspeed() rather than have a duplicate table.
Inline getty's print_prompt().
There's still a lot of cleanup needed here, in particular use of toybuf
and removal of the inappropriately-named HOSTNAME_SIZE (and ideally
sharing that logic with login(1) which already contains a better
implementation of it).
|
|
and address TODO where -z was still splitting patterns on \n
|
|
|
|
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.
|
|
Pointed out by the compiler combined with glibc's use of
__attribute__((__warn_unused_result__)) on write().
|
|
|
|
|
|
|
|
Note: can't put in portability.h because it's a linux/ include.
|
|
It can't actually be used for INT_MIN in the current context because the
`dd += increment` on line 100 means that even if "last" is INT_MIN, we
won't take the fast path because INT_MIN - 1 isn't representable.
|
|
The kernel will do this for us on both Linux and macOS, but error
messages are a bit misleading if we don't do it ourselves --- it
can look as if the failure is because of the type bits.
|
|
|
|
|
|
|
|
configurable.
|