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.
|
|
Even GNU don't pretend they're still on 1970s terminals where ` and '
were a matching pair any more.
|
|
(Also show unknown values on Linux in hex rather than just "unknown".)
|
|
output 5 digits of octal stat data instead of 4, due to hardwired leading 0
instead of %04a sprintf prefix.
|
|
file now shows the target of a symbolic link and calls out broken
symbolic links.
file now shows the device type for block/character special files.
file now shows specific reason when it can't open.
stat now includes the device type, plus a little more space between the
number of blocks and the human-readable file type.
Adjusted tests accordingly, which actually makes more of them pass on
the host as a convenient side-effect, but I actually made these changes
because I've been finding the desktop file and stat output more convenient
in these cases.
|
|
This patch adds a BSD version of xgetmountlist (for the path ==
NULL case only), tested on macOS. It also papers over the differences
between macOS' and Linux's xattr APIs. For once I think the macOS
one is better. The imitation of mknodat I've had to write swings
things back in Linux's favor though.
BSD calls f_frsize by the name f_iosize instead. (FWIW, it looks
like this is meaningless on Linux and actually meaningful on macOS.)
I've added one #if to toys/ --- I'm calling pathconf in stat.c to
work around the absence of f_namelen, and have left a TODO with an
explanation. I'm not sure what the best fix is here, so punting.
No-one can agree what f_fsid is, even if they're all basically the
same, so work around the `val` versus `__val` issue between macOS
and Linux.
With this patch, it's now possible to build cp/mv/install and stat
for macOS too. (Which completes the set of "toybox commands currently
used on Linux as part of the AOSP build" if you ignore stuff that
deals with processes, which I doubt we'll ever be able to support
for lack of any API.)
|
|
We'd documented find %Z but not implemented it. We'd neither documented
nor implemented stat's corresponding %C (they'd already taken %Z for
ctime, which is ironic because %c/%C sounds more obvious than %z/%Z for
that to me).
|
|
next_printf() shouldn't return null unless it never found the start of an
escape sequence (it'll return a pointer to the null at the end of the string
otherwise), and the only time we point it at a % and it doesn't is when it's
%%. So handle that before calling. (Also, a single trailing % prints in
other implementations, and while I'm there update to use FLAG() macros,
add a couple comments, and only xflush() once per pattern.)
|
|
When the specified format string has odd '%' in the end,
the next_printf function will return null. Checking
the result value before using it.
Signed-off-by: liwugang <liwugang@xiaomi.com>
|
|
Used in the AOSP x86 host build.
|
|
Be consistent about upper versus lower case. (Upper seems to have the
majority, so I went with that, though I'm happy to provide the opposite
patch as long as we're consistent!)
Be consistent about using \t. (Though saving a few bytes seems like it
might be better done in the code that generates help.h rather than
directly in the source, since tabs make careful ASCII art layout hard
enough that we regularly have things misaligned.)
Remove trailing periods (most of which seem to have been added by me).
Always use the US "human readable" rather than my British
"human-readable", and be more consistent about declaring whether we're
showing multiples of 1000 or 1024.
Just say "verbose" rather than adding a useless "mode" or "output".
|
|
|
|
(My apologies for mixing these two unrelated changes up.)
|
|
(At least for coreutils 8.28.)
|
|
`stat -c %a` doesn't output a leading zero, but `stat` does.
|
|
Even GNU coreutils 8.28 doesn't use the lopsided `quoting' any more.
|
|
|
|
POSIX does have a name for the struct timespec in struct stat.
|
|
|
|
not segfault on a lookup failure (they print the number instead of UNKNOWN).
The whitespace in the default output may need some adjusting.
|
|
(man 2 stat says so) and %B is the units on %b (I.E. always 512), so change
output and help text. This matches what other implementations produce.
|
|
|
|
7ca5dc4232b9ac5ee5cd25c8b5b33a58904cd251 didn't switch all callers over
to the new functions.
|
|
Suggested by Sameer Pradhan, or possibly Bilal Qureshi.
|
|
checking, and fix up format checking complaints.
Added out(type, value) function to stat to avoid a zillion printf typecasts.
|
|
|
|
|
|
Change-Id: I0ad65a40bf380d789c4396ebdc01be217901a2e3
|
|
Elliott Hughes).
|
|
|
|
|