Age | Commit message (Collapse) | Author |
|
(Apologies for the length of this commit message, but it's not entirely
clear how we arrived at our present state, and right now all three of
toybox, busybox, and util-linux differ from each other. And it took a
week of arguments behind the scenes to agree on what we thought was the
right behavior, which seemed worth capturing for posterity.)
This reverts my change ef0546d4f536f42a57af4c32bd37f7fd752d10c2 from
2015. The commit message back then claimed:
For systems using /dev/rtcN, /dev/rtc0 isn't necessarily the RTC
that's used to provide the system time at boot time. We need to
search for the RTC whose /sys/class/rtc/rtcN/hctosys contains "1".
A few things to note here:
1. I can't find any historical motivation for this change. There's no
bug, there's no internal email thread, and I can't even find anything
referring to devices using anything other than /dev/rtc0.
2. It turns out (though this wasn't true at the time) that the kernel
since 4.19 interprets hctosys as the RTC that *did* set the clock,
not the RTC that *should* set the clock.
3. That's not an academic difference. If you have a cheap RTC that isn't
battery-backed, or you have an RTC whose battery died, and you're
using Linux 4.19 or later, you will boot with no RTC having hctosys=1.
4. An actual SoC vendor has hit this in practice.
My original toybox patch appears to be equivalent to code in the Android
frameworks, which -- under the auspices of the SoC vendor's bug --
I'm about to replace with code that checks "/dev/rtc" first, then
"/dev/rtc0", then fails hard. (Strictly, it's this copy of the search
that's causing the SoC vendor issues. AFAIK no-one's using
hwclock/rtcwake except interactively. And even if they are, Android
devices ship with [at least] two copies of toybox, so code/scripts on
the vendor partition will continue to run the vendor copy of toybox they
were developed against, and a newer toybox elsewhere on the system won't
affect them.)
All Android devices (and emulators) available to me at the moment use
/dev/rtc0, but supporting /dev/rtc gives a workaround for anyone who
really insists on using an RTC other than /dev/rtc0. That said, the
Generic Kernel Image (GKI) always assumes /dev/rtc0, so going forward
/dev/rtc0 is always the right choice.
I did consider making toybox hwclock try /dev/rtc, /dev/rtc0, and
/dev/misc/rtc -- and even wrote the code for that first -- but strace
shows that busybox and util-linux's hwclock implementations differ in
the order in which they try these (busybox tries /dev/rtc first,
util-linux tries /dev/rtc0 first). Given that util-linux seems like the
more canonical precedent, trying /dev/rtc0 and then falling back to
/dev/rtc would offer no advantage to Android users (and would seem to be
just another stumbling block in getting everyone to a world where
/dev/rtc0 is "the" system RTC).
Note that rtcwake is unaffected by all this, because the toybox and
util-linux implementations both default to only trying /dev/rtc0 already.
Bug: https://issuetracker.google.com/158051176
|
|
|
|
Yeah, this limits 32 bit support, but that's a "fix it properly in lib/args.c
or don't care" issue. Why work around it here when truncate -s doesn't?
|
|
Increase memory:swpd,free,cache to 7 characters
Increase swap:si,so to 5 characters
Increase system:in,cs to 5 characters
Sample output from Pixel 4 phone:
procs ------------memory------------ ----swap--- -----io---- ---system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
4 0 1111676 87896 6328 2268596 8152 11896 10712 14280 0 25712 31 21 46 3
17 0 1082788 224292 5972 2213996 73220 68908 2432 3948 1 26611 41 38 22 0
6 0 1127316 203196 5972 2225164 8980 53996 11796 788 0 25200 33 22 45 1
0 0 1133072 200984 5972 2225280 416 6260 52 88 0 8543 10 6 84 0
2 0 1128976 196976 5972 2225692 3588 0 340 800 0 5243 5 4 91 0
|
|
Bug: http://b/156292059
Signed-off-by: Wei Wang <wvw@google.com>
|
|
|
|
|
|
|
|
|
|
with memset() instead of = {}, and move TT.alarm to local variable.
|
|
Some of the bringup folks are debugging RTC issues and asked for this.
Rather than duplicate the weird xtzset dance with mktime, I've factored
that out into a new xmktime that takes a boolean for whether to use UTC
or local time.
Otherwise, the slight cleanup of hwclock.c is entirely optional. The
only functional change there is that util-linux 2.34's hwclock uses ISO
time format, which is the usual toybox preference anyway, so I've
switched it over to that rather than ctime(3).
Bug: http://b/152042947
|
|
In case I'm not yet in the running for the most pedantic change of this
release, I think the "days of the week are written with initial capitals
in English" subset of this patch is a strong contender.
(Found via `toybox help -a | ispell -l | sort | uniq`.)
|
|
|
|
I came here because the new -Wno-unreachable-code-loop-increment warning
didn't like the for loop on line 86. That loop is indeed not necessary.
Use strend() to do a string suffix match.
Use memmem() to search. It's available on macOS and Android by default,
but it's behind _GNU_SOURCE for glibc, so add that to portability.h.
Output the tags in the same order as the Debian modinfo.
I've left "parmtype" in even though the Debian modinfo doesn't output it
at all.
Also fix the tests so that they work on a device that has modules for
multiple kernels installed (like my laptop) --- make sure that the two
modules we pick come from the same kernel.
|
|
|
|
Also fix another bug where we were testing `set` twice.
Fixes https://github.com/landley/toybox/issues/172.
|
|
The e2fsprogs chattr(1) returns failure when it fails to do what was
asked of it, and so should we. Fixing this then reveals a lot of issues
with the tests that were being accidentally swept under the carpet.
The bulk of this patch is going through all the tests, removing the
duplicates and making the remaining tests more thorough.
I've tested this on ext4 and f2fs on a variety of 4.x and 5.x kernel
versions (but nothing older). We might need to reduce the list of
attribtues we try to toggle, but the more thorough tests use
well-supported attributes.
I've also fixed the -R test to actually involve a directory hierarchy.
|
|
When chattr fails in production, it helps to see what it was trying to
do. Reuse the lsattr format but without the '-'s.
Only read the flags if we have any intention of changing them:
`chattr -p 123` has no reason to read the flags.
Only write the flags back if they actually change: `chattr +a`
shouldn't do anything if that flag is already set, for example.
Switch -p and -v to perror_msg() instead of perror_exit() in case
they're used with -R.
(I suspect that the uses of DIRTREE_ABORT are mistakes given -R, but
I'll leave them until I actually hit this.)
|
|
Even GNU don't pretend they're still on 1970s terminals where ` and '
were a matching pair any more.
|
|
Rewrite -v and -p to not use ad hoc argument parsing.
|
|
Document all the attributes, and take less space doing so.
Switch to CAPITALS for user input in the synopses.
Don't imply that this is only for ext2 (but also don't try to list the
subset of file systems that do support which subset of attributes).
|
|
Add support for setting projid in chattr, and dumping it in lsattr.
Also fix the lsattr output formatting, and undo my well-intentioned
sorting of the flags because that broke the ordering in the lsattr terse
output.
|
|
Also update help to include flags that were already added. Remove
useless duplicative comments. Swich to FLAG macros.
|
|
-w was added recently. The change in behavior so we now always fork
means that it's needed in more cases too: other implementations of
setsid(1) only fork if getpgrp() != getpid(). This broke a script, which
is what made me notice the missing help.
This seems to have been an accidental change, and is contrary to what
the util-linux setsid(1) man page says: "The command calls fork(2) if
already a process group leader. Otherwise, it executes a program
in the current process", but whether we change our behavior or not, we
should document the new option.
|
|
set $HOME $PWD and $OLDPWD, fix prompt \w, shuffle some functions around
to avoid prototypes, implement tilde expansion, add FORCE_COPY.
|
|
|
|
builtin, and add -u.
|
|
|
|
Switch -t to -c (like man page says), add -w (wait) and -d (detach from tty)
|
|
(Also show unknown values on Linux in hex rather than just "unknown".)
|
|
|
|
My understanding is that uClibc is dead, and the probe for fallocate
would need to be made more complicated to work for macOS (where we fake
posix_fallocate() in lib/portability.c).
|
|
Having a dynamic memory pointer named as "s", issuing "free(s)" and then
performing "FLAG(s)" is correct: "FLAG(s)" is a macro which uses "s" as
a token and expands as "FLAG_s". At a glance, this would instead look
like a use-after-free violation.
Fix this readability issue by renaming the "s" pointer variable to
"f_path".
Change-Id: I51f139034a7dcd67a08a6952bc22c1a904162c65
Signed-off-by: Alessio Balsini <balsini@android.com>
|
|
The function loopback_setup() uses xabspath() to get the loopback path.
This function allocates dynamic memory which should be freed by the
function caller.
But there are early return cases where the dynamic memory is not freed.
Besides the special cases of perror_exit(), for which the "early" free
operation is simply used to silence memory analysis tools, the
if (racy && errno == EBUSY) return 1;
branch may be a real cause of memory leak.
Fix by adding a new free() in the racy+EBUSY branch and anticipating the
existing free().
Signed-off-by: Alessio Balsini <balsini@android.com>
|
|
The function loopback_setup(), after copying the loopback device name
with xstrncpy(), ensures the null-termination of the string by forcing
its last byte to 0.
Unfortunately, this operation:
- was probably intended to null-terminate dest instead;
- does not affect the program execution because src is free()d right
after;
- if the size of src is smaller than the offset of the written zero, it
modifies an unknown byte in the heap.
Drop the null-termination line to fix the issue: xstrcpy() automatically
null-terminates dest, or fails if the size of src is bigger than the the
requested number of bytes to copy.
Signed-off-by: Alessio Balsini <balsini@android.com>
|
|
I must have lost this line somehow when I moved the patch from my AOSP
tree to a toybox tree. (But the ln tests passed on the host because I
was using coreutils ln there :-( )
|
|
Required by the new `ln -t` test if it's to pass on an all-toybox
system :-)
|
|
Thanks for James McMechan for pointing this out.
Using esc[1L and esc[1M escapes with cursor jump to
1, 1 to make scrolling effect instead of S and T
fixes scrolling inside Linux terminal and tmux
-Jarno
|
|
xwaitpid(), fix off by one in xwaitpid().
|
|
There's nothing to stop a subprocess from catching our SIGTERM on timeout
and exiting, causing us to incorrectly report that it didn't time out.
Android's ART has a utility that does exactly this.
Explicitly catch this case, and add corresponding tests.
Bug: http://b/141007616
|
|
|
|
|
|
|
|
This gets the tests passing with both toybox and util-linux 2.32.1
blkid. We use -s to get around the fact that we still don't support ntfs'
$VOLUME_NAME attribute.
|
|
There's a race between LOOP_CTL_GET_FREE and LOOP_SET_FD. Work around it
by just retrying if we get EBUSY on the LOOP_SET_FD call. This is what
similar code in ChromeOS already does.
Bug: http://b/135716654
|
|
output 5 digits of octal stat data instead of 4, due to hardwired leading 0
instead of %04a sprintf prefix.
|
|
|
|
|
|
I started this last night, but thought I'd aim to send multiple small
patches rather than work through all the callers and send one big patch.
I've deliberately chosen the ugly name `allocated_length` because we've
had historical bugs where folks think this a line length in the sense of
the return value. I do wonder whether we should actually have some kind
of getline() wrapper that hides the `char *`/`size_t` pair in lib/,
which makes the function easier to use in most cases but does add the
less common gotcha that you wouldn't be able to getline() through
multiple files at once (which does happen in at least one toy).
But maybe the real fix is to look harder for places where we can just
use loopfiles_lines? Speaking of which, should we actually add two more
arguments to that? Specifically: switch it to getdelim() rather than
getline() behind the scenes, and also add a way to have the trailing
'\n' automatically removed, since that seems to be what most callers
want?
Anyway, that seemed like enough questions that it was time to send this
initial patch out before doing too much more...
|
|
Rename the existing xbind/xconnect to xbindany/xconnectany, to make room
for new xbind/xconnect that are more like 'x' versions of the regular
bind and connect. Move explicit bind/connect callers over to
xbind/xconnect.
Of the affected commands, only netcat is actually used by Android. It
was the most recent patch to netcat that made the lack of a more
traditional xbind/xconnect apparent.
|