aboutsummaryrefslogtreecommitdiff
path: root/toys/other
AgeCommit message (Collapse)Author
2020-10-22Add nommu-able xvdaemon() and use it to remove some TOYBOX_FORK dependenciesRob Landley
2020-10-21blkdiscard: fix uninitialised offsetPatrick Oppenlander
2020-10-21Tweak watchdog help.Rob Landley
2020-10-21Promote watchdog.Rob Landley
2020-10-18Add sha3sum.Rob Landley
2020-10-15rtcwake: default to UTC if /etc/adjtime can't be readPatrick Oppenlander
This is consistent with the util-linux implementation.
2020-10-15hwclock: default to UTC if /etc/adjtime can't be readPatrick Oppenlander
This is consistent with the util-linux implementation.
2020-10-05Update i2ctools.cchrisrfq
Fix i2cdetect parameter reading so "last" value is read from correct argument.
2020-09-10blkid: don't show empty tags.Elliott Hughes
The util-linux blkid (even if explicitly asked with -s) won't show you a tag with no value.
2020-09-09Use flag macros and document -rn options.Rob Landley
2020-06-11hwclock: just assume /dev/rtc0.Elliott Hughes
(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
2020-05-27devmem: replace getpagesize with POSIX sysconf(_SC_PAGESIZE)Ethan Sommer
2020-05-24Cleanup blkdiscard.Rob Landley
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?
2020-05-21vmstat: increase column sizesPetri Gynther
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
2020-05-13devmem: avoid sign extension.Elliott Hughes
Bug: http://b/156292059 Signed-off-by: Wei Wang <wvw@google.com>
2020-04-16Promote rtcwake.Rob Landley
2020-04-16Promote blkdiscard.Rob Landley
2020-04-14shred: fix -z flag check, switch to FLAG() macros.Ethan Sommer
2020-04-12Minor cleanup.Rob Landley
2020-04-02Move #include <linux/*.h> into individual commands, initialize structRob Landley
with memset() instead of = {}, and move TT.alarm to local variable.
2020-04-01Add rtcwake.Elliott Hughes
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
2020-03-13Fix various typos.Elliott Hughes
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`.)
2020-03-11Redo NOFORK plumbing so commands like eval/unset can access/edit shell state.Rob Landley
2020-03-10modinfo: various fixes.Elliott Hughes
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.
2020-03-02Merge realpath into readlink, use xabspath() instead of libc realpath().Rob Landley
2020-02-27chattr: allow `chattr =`.Elliott Hughes
Also fix another bug where we were testing `set` twice. Fixes https://github.com/landley/toybox/issues/172.
2020-02-11chattr: fix exit status, redo the tests.Elliott Hughes
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.
2020-02-06chattr: improve error messages.Elliott Hughes
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.)
2020-02-06Remove old GNU style `' quoting.Elliott Hughes
Even GNU don't pretend they're still on 1970s terminals where ` and ' were a matching pair any more.
2020-02-05chattr: reuse toybox argument parsing.Elliott Hughes
Rewrite -v and -p to not use ad hoc argument parsing.
2020-02-01lsattr/chattr: improve help text.Elliott Hughes
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).
2020-01-22lsattr/chattr: -p support.Elliott Hughes
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.
2020-01-20lsattr/chattr: add missing flags.Elliott Hughes
Also update help to include flags that were already added. Remove useless duplicative comments. Swich to FLAG macros.
2020-01-10setsid: document -w.Elliott Hughes
-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.
2020-01-03Finish cd, make help -ahu unconditional, fix expand memory cleanup path,Rob Landley
set $HOME $PWD and $OLDPWD, fix prompt \w, shuffle some functions around to avoid prototypes, implement tilde expansion, add FORCE_COPY.
2020-01-03No, optflags gets cleared by toy_init(), use toys.rebound instead.Rob Landley
2020-01-03Add MAYFORK to "help", teach it to behave differently when called as aRob Landley
builtin, and add -u.
2019-12-28Cleanup: use FLAG() macros and new argument variable names.Rob Landley
2019-12-26Fix setsid with vfork, redo command line arguments.Rob Landley
Switch -t to -c (like man page says), add -w (wait) and -d (detach from tty)
2019-12-06stat: fix filesystem type on macOS.Elliott Hughes
(Also show unknown values on Linux in hex rather than just "unknown".)
2019-10-27Switch fallocate to new style global names.Rob Landley
2019-10-27fallocate: remove uClibc workaround to benefit macOS.Elliott Hughes
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).
2019-10-26losetup: Change variable name to improve readabilityAlessio Balsini
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>
2019-10-26losetup: Fix memory leaks in loopback_setup()Alessio Balsini
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>
2019-10-14losetup: Fix null-termination of src string instead of dest after copyAlessio Balsini
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>
2019-10-04readlink: add missing line, plus a test.Elliott Hughes
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 :-( )
2019-10-02readlink: support multiple arguments.Elliott Hughes
Required by the new `ln -t` test if it's to pass on an all-toybox system :-)
2019-09-26hexedit: fix scrolling on legacy terminalsJarno Mäkipää
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
2019-09-18Get exit code right when command intercepts signal, make timeout useRob Landley
xwaitpid(), fix off by one in xwaitpid().
2019-09-13timeout: fix exit status for sneaky subprocesses.Elliott Hughes
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