Toybox: all-in-one Linux command line. --- Getting started You can download static binaries for various targets from: http://landley.net/toybox/bin The special name "." indicates the current directory (just like ".." means the parent directory), and you can run a program that isn't in the $PATH by specifying a path to it, so this should work: wget http://landley.net/toybox/bin/toybox-x86_64 chmod +x toybox-x86_64 ./toybox-x86_64 echo hello world --- Building toybox Type "make help" for build instructions. Toybox uses the "make menuconfig; make; make install" idiom same as the Linux kernel. Usually you want something like: make defconfig make make install Or maybe: LDFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox PREFIX=/path/to/root/filesystem/bin make install_flat The file "configure" defines default values for many environment variables that control the toybox build; if you export any of these variables into your environment, your value is used instead of the default in that file. The CROSS_COMPILE argument above is optional, the default builds a version of toybox to run on the current machine. Cross compiling requires an appropriately prefixed cross compiler toolchain, several example toolchains (built using the file "scripts/mcm-buildall.sh" in the toybox source) are available at: https://mkroot.musl.cc/latest/ For the "CROSS_COMPILE=armv5l-" example above, download cross-compiler-armv5l.tar.bz2, extract it, and add its "bin" subdirectory to your $PATH. (And yes, the trailing - is significant, because the prefix includes a dash.) For more about cross compiling, see: https://landley.net/toybox/faq.html#cross http://landley.net/writing/docs/cross-compiling.html http://landley.net/aboriginal/architectures.html For a more thorough description of the toybox build process, see: http://landley.net/toybox/code.html#building --- Using toybox The toybox build produces a multicall binary, a "swiss-army-knife" program that acts differently depending on the name it was called by (cp, mv, cat...). Installing toybox adds symlinks for each command name to the $PATH. The special "toybox" command treats its first argument as the command to run. With no arguments, it lists available commands. This allows you to use toybox without installing it, and is the only command that can have an arbitrary suffix (hence "toybox-armv5l"). The "help" command provides information about each command (ala "help cat"), and "help toybox" provides general information about toybox. --- Configuring toybox It works like the Linux kernel: allnoconfig, defconfig, and menuconfig edit a ".config" file that selects which features to include in the resulting binary. You can save and re-use your .config file, but may want to run "make oldconfig" to re-run the dependency resolver when migrating to new versions. The maximum sane configuration is "make defconfig": allyesconfig isn't recommended as a starting point for toybox because it enables unfinished commands, debug code, and optional dependencies your build environment may not provide. --- Creating a Toybox-based Linux system Toybox has a built-in simple system builder (scripts/mkroot.sh) with a Makefile target: make root sudo chroot root/host/fs /init Type "exit" to get back out. If you install appropriate cross compilers and point it at Linux source code, it can build simple three-package systems that boot to a shell prompt under qemu: make root CROSS_COMPILE=sh4-linux-musl- LINUX=~/linux cd root/sh4 ./qemu-sh4.sh By calling scripts/mkroot.sh directly you can add additional packages to the build, see scripts/root/dropbear as an example. The FAQ explains this in a lot more detail: https://landley.net/toybox/faq.html#system https://landley.net/toybox/faq.html#mkroot --- Presentations 1) "Why Toybox?" talk at the Embedded Linux Conference in 2013 outline: http://landley.net/talks/celf-2013.txt video: http://youtu.be/SGmtP5Lg_t0 The https://landley.net/toybox/about.html page has nav links breaking that talk down into sections. 2) "Why Public Domain?" The rise and fall of copyleft, Ohio LinuxFest 2013 outline: http://landley.net/talks/ohio-2013.txt audio: https://archive.org/download/OhioLinuxfest2013/24-Rob_Landley-The_Rise_and_Fall_of_Copyleft.mp3 3) Why did I do Aboriginal Linux (which led me here) 260 slide presentation: https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu How and why to make android self-hosting: http://landley.net/aboriginal/about.html#selfhost More backstory than strictly necessary: https://landley.net/aboriginal/history.html 4) What's new with toybox (ELC 2015 status update): video: http://elinux.org/ELC_2015_Presentations outline: http://landley.net/talks/celf-2015.txt 5) Toybox vs BusyBox (2019 ELC talk): outline: http://landley.net/talks/elc-2019.txt video: https://www.youtube.com/watch?v=MkJkyMuBm3g --- Contributing The three important URLs for communicating with the toybox project are: web page: http://landley.net/toybox mailing list: http://lists.landley.net/listinfo.cgi/toybox-landley.net git repo: http://github.com/landley/toybox The maintainer prefers patches be sent to the mailing list. If you use git, the easy thing to do is: git format-patch -1 $HASH Then send a file attachment. The list holds messages from non-subscribers for moderation, but I usually get to them in a day or two. I download github pull requests as patches and apply them with "git am" (which avoids gratuitous merge commits). Sometimes I even remember to close the pull request. If I haven't responded to your patch after one week, feel free to remind me of it. Android's policy for toybox patches is that non-build patches should go upstream first (into vanilla toybox, with discussion on the toybox mailing list) and then be pulled into android's toybox repo from there. (They generally resync on fridays). The exception is patches to their build scripts (Android.mk and the checked-in generated/* files) which go directly to AOSP. (As for the other meaning of "contributing", https://patreon.com/landley is always welcome but I warn you up front I'm terrible about updating it.)
Toybox: all-in-one Linux command line.
Overview
Issues
-
rm: $directory: Directory not empty
When attempting to remove multiple directories containing many files and subdirectories (let's call them
$bigdirectory1
,$bigdirectory2
and$bigdirectory3
), using the following command:rm -frv $bigdirectory1 $bigdirectory2 $bigdirectory3
rm
throws the following errors:... rm: $directory1: Directory not empty rm: $directory2: Directory not empty rm: $directory3: Directory not empty rm: $directory4: Directory not empty rm: $directory5: Directory not empty rm: $directory6: Directory not empty ...
Where
$directory1
to$directory6
are subdirectories in$bigdirectory1
to$bigdirectory3
that are left empty and require a rerun of the command:rm -frv $bigdirectory1 $bigdirectory2 $bigdirectory3
to remove them completely.
(To recreate the issue just grab any Linux kernel tarball (e.g. version 5.5.5), extract the tarball and run
rm -frv
on the extracted directory and notice how itrm
stops midway through the deletion and throws theDirectory not empty
error)Could this be possibly related to the following lines in
rm.c
?... // Intentionally fail non-recursive attempts to remove even an empty dir // (via wrong flags to unlinkat) because POSIX says to. if (dir && !(toys.optflags & (FLAG_r|FLAG_R))) goto skip; ...
-
ls -Z doesn't seem to print selinux context
So, I have tried this in my 64 bit linux vm and also in arm64 android, the
ls -Z
doesn't show the selinux contentI used the binaries from here: http://landley.net/toybox/bin/
Also, the binaries provided in the android OS seems to print selinux without any issue
-
When I call any applet with the --help option, please show this general information first
Hi! When I call any applet with the
--help
option, it would be good if you could please start the output with the following lines, then a newline.Toybox multi-call binary
$(git describe)
Web page: http://landley.net/toybox/ Bug reports: https://github.com/landley/toybox/issues Feedback: http://lists.landley.net/listinfo.cgi/toybox-landley.net Contributors, see: https://landley.net/toybox/cleanup.html#introSome users have Toybox because it came preinstalled on their device. The above information will make it easier for such users to figure out where and how to submit bug reports and patches.
git describe
looks at tag names and commits, and hopefully outputs a version number like "0.7.1-106-g409a8e0" or "0.7.2". -
Add ln -r
I had to make getdirname return "." instead of the file when the path has no '/', like dirname does, for my code to work correctly. I checked the new flag and toybox ln in general against GNU's ln tests. Use cases: https://git.archlinux.org/svntogit/packages.git/tree/trunk/update-ca-trust?h=packages/ca-certificates#n38 https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/linux#n201
-
Can’t compile on Apple Silicon with macOS Monterey
Apologies if this has been explained elsewhere... I'm new to this...
The AARCH64/ARM64 binary won't run on macOS Monterey 12.x and I can't seem to build it from source either.
Should it be working? Trying to build Android and I think it's dependent on toybox. Can't find a working build of toybox for Apple Silicon anywhere.
Thanks.
-
Mention that GNU sed is needed for MacOS
Building with
make
fails with errors from clang on MacOS. The reason is thatgsed
is not found and there is no warning or instruction to install it.I think, that either a warning should be added (possibly into
scripts/portability.sh
) or a note into the "Building toybox" section of README. Better both.P.S. Also, to compile toybox I had to set
CPUS=1
, comment#include "generated/newtoys.h"
in lib/help.c, and comment quite a few commands in.config
, ending up with 136 of them. (Maybe it helps someone out there.)OS version: MacOS Mojave 10.14.6
-
install -D -t
does not create This also doesn't work with
install -D file1 file2 dir
, where dir doesn't exist, but busybox also messes that up (differently, instead of making dir and putting file[12] there, it makes dir's parents and makes puts file2 as dir) so I'm not sure what should be done in that situation. Either way, with any install I've seen that has-t
, it creates the dir given to-t
when-D
is also passed. -
iOS 14.4 | byte read Translation fault | possible pointer authentication failure
Infrequent Crash for id|toybox on iOS 14.4 | byte read Translation fault | possible pointer authentication failure
Toolchain Details Apple clang version 12.0.0 (clang-1200.0.32.29) Xcode 12.4 Build version 12D4e -sdk iphoneos14.4
Built from https://github.com/landley/toybox/commit/f1be076b52adcad7b2419315cc148009a1bc2fec.
Reproduction Case: Using Terminal and ssh'd into the device as root, Executed the command: id
id
... Hardware Model: iPhone12,1 Process: toybox [489] Identifier: toybox Code Type: ARM-64 (Native) Parent Process: sh [453] OS Version: iPhone OS 14.4 (18D52) ... Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x6b726f7774656e50 -> 0x0000007774656e50 (possible pointer authentication failure) VM Region Info: 0x7774656e50 is not in any region. Bytes after previous region: 32017575505
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) --->
UNUSED SPACE AT ENDTermination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [489] Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_platform.dylib 0x00000001e953bbc4 _platform_strlen + 4 1 libsystem_c.dylib 0x00000001a6e8c16c __vfprintf + 4328 2 libsystem_c.dylib 0x00000001a6eaee0c __v2printf + 396 3 libsystem_c.dylib 0x00000001a6eaf044 __xvprintf + 240 4 libsystem_c.dylib 0x00000001a6e8af80 vfprintf_l + 68 5 libsystem_c.dylib 0x00000001a6e897b8 printf + 84 6 id 0x00000001042ea540 0x1042bc000 + 189760 7 id 0x00000001042ce930 0x1042bc000 + 76080 8 id 0x00000001042ce320 0x1042bc000 + 74528 9 id 0x00000001042ce978 0x1042bc000 + 76152 10 libdyld.dylib 0x000000019d6c66b0 start + 4
Thread 0 crashed with ARM Thread State (64-bit): x0: 0x6b726f7774656e5f x1: 0x6b726f7774656e50 x2: 0x0000000000000000 x3: 0x000000016bb432c3 x4: 0x000000016bb42e80 x5: 0x000000016bb43810 x6: 0x0000000000000031 x7: 0x0000000000000f70 x8: 0x6b726f7774656e5f x9: 0x00000001a6ec5aac x10: 0x0000000000000001 x11: 0x0000000000000003 x12: 0x0000000000000000 x13: 0x0000000000000000 x14: 0x0000000000000010 x15: 0x0000000000000001 x16: 0x00000001e953bbc0 x17: 0x00000001a6e8dde4 x18: 0x0000000000000000 x19: 0x000000016bb42d70 x20: 0x0000000000000003 x21: 0x0000000000000073 x22: 0x0000000104307526 x23: 0x000000000000000a x24: 0x0000000000000000 x25: 0x0000000104307524 x26: 0x6b726f7774656e5f x27: 0x0000000000000000 x28: 0x000000016bb42e88 fp: 0x000000016bb43140 lr: 0x00000001a6e8c16c sp: 0x000000016bb42d70 pc: 0x00000001e953bbc4 cpsr: 0x20000000 esr: 0x92000004 (Data Abort) byte read Translation fault
Binary Images: 0x1042bc000 - 0x104307fff id arm64e
... 0x19d6c5000 - 0x19d6fffff libdyld.dylib arm64e <21b19919133438bcb233896e929945e0> /usr/lib/system/libdyld.dylib ... 0x1a6e49000 - 0x1a6ec7fff libsystem_c.dylib arm64e <961a8fb0de8a3567b4375d99cd549fae> /usr/lib/system/libsystem_c.dylib 0x1e9536000 - 0x1e953cfff libsystem_platform.dylib arm64e <88fa2f54074d32c49f4879eb67e67b7b> /usr/lib/system/libsystem_platform.dylib EOF The answer could be that this functionality is not expected to work on iOS 14.4. Please let me know if any additional details can be provided.
-
Adding prefix to toybox produces error
Adding prefix to toybox (e.g. renaming toybox to mytoybox) produces the following error:
toybox: Unknown command ./mytoybox (see "toybox --help")
Is there anyway around to this problem?
-
Segmentation Fault in sed 's' command if skipping initial match
toybox sed crashes with a segfault when given certain substitution commands that specify to only substitute the nth match where n > 1.
Steps to reproduce
echo "e" | toybox sed -e "s/e//2"
Analysis
In sed.c:498, sed decides correctly that, since it is looking at the 1st match but should only replace the nth match, the current match should be skipped. To do so, it copies the remainder of the current line not covered by the match into
l2
. The memory forl2
is allocated in line 526, when carrying out a substitution. However, if the first match already needs to be skipped, there have been no substitutions yet andl2
is still a null pointer, leading to the crash.Additional Information
This behavior was detected using techniques developed by the SYMBIOSYS research project at COMSYS RWTH Aachen University. This research is supported by the European Research Council (ERC) under the EU's Horizon 2020 Research and Innovation Programme grant agreement n. 647295 (SYMBIOSYS).
-
cp --parents broken
I tried this option and I found that it didn't behave like I think it should. It also doesn't have a test case for it.
mkdir -p 1/2/3 touch 1/2/3/blah mkdir 4 ./toybox cp -D 1/2/3/blah 4/ ctree -F 4/ 4/ `-- 1/ `-- 2/ `-- 3 2 directories, 1 file
I expected the file 'blah' to be created at the end of 3, but it's actually the last directory portion which is created as the file '3'.
-
There is a bug in line 165 of toys/pending/brctl.c
There is a bug in line 165 of toys/pending/brctl.c
I thinke the varable of
ifindex
should beindex
157 void br_delif(char **argv) 158 { 159 int index;····························· 160 struct ifreq ifr;······················ 161 unsigned long args[4] = {BRCTL_DEL_IF, 0, 0, 0}; 162 163 if (!(index = if_nametoindex(argv[1]))) perror_exit("interface %s",argv[1]); 164 #ifdef SIOCBRDELIF 165 ifr.ifr_ifindex = ifindex; 166 xioctl(TT.sockfd, SIOCBRDELIF, &ifr); 167 #else 168 args[1] = index;····· 169 xstrncpy(ifr.ifr_name, argv[0], IFNAMSIZ); 170 ifr.ifr_data = (char *)args;·· 171 xioctl(TT.sockfd, SIOCDEVPRIVATE, &ifr); 172 #endif 173 }
-
top command issue: thread is sleeping, but %cpu is high
When I use top -H to see thread info, I found an strange scene: some threads state is sleeping, but it's cpu usage is very high, why?
focus on RxSchedulerPurg in data below:
Threads: 126 total, 3 running, 123 sleeping, 0 stopped, 0 zombie Mem: 7603288K total, 6278480K used, 1324808K free, 19079168 buffers Swap: 6291452K total, 1072264K used, 5219188K free, 2972628K cached 800%cpu 527%user 14%nice 85%sys 156%idle 0%iow 14%irq 4%sirq 0%host TID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ THREAD PROCESS 24483 u0_a449 20 0 7.4G 226M 145M S 366 3.0 0:00.00 RxSchedulerPurg com.strange.om ...
-
Adjusted the linker flags for kconfig mconf (menuconfig)
For some reason, this breaks on my Gentoo systems. There, libcurses does not contain nodelay, so the linking fails with symbol resolution errors regarding the nodelay symbol.
I have added -ltinfo to fix this issue.
Signed-off-by: Michael T. Kloos [email protected]
-
tar: does not support "strip-components" option
Does not support the option, which appears to be used by some NixOS tool.
--strip-components=NUMBER strip NUMBER leading components from file names on extraction
A command-line tool to generate Linux manual pages from C source code.
mangen A command-line tool to generate Linux manual pages from C source code. Description mangen is, as said above, a program to generate Linux manual
A simple to use, composable, command line parser for C++ 11 and beyond
Clara v1.1.5 !! This repository is unmaintained. Go here for a fork that is somewhat maintained. !! A simple to use, composable, command line parser f
A library for interactive command line interfaces in modern C++
cli A cross-platform header only C++14 library for interactive command line interfaces (Cisco style) Features Header only Cross-platform (linux and wi
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri
Lightweight C++ command line option parser
Release versions Note that master is generally a work in progress, and you probably want to use a tagged release version. Version 3 breaking changes I
A simple to use, composable, command line parser for C++ 11 and beyond
Lyra A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond. Obtain License Standards Stats Tests License Distri
A single header C++ library for parsing command line arguments and options with minimal amount of code
Quick Arg Parser Tired of unwieldy tools like getopt or argp? Quick Arg Parser is a single header C++ library for parsing command line arguments
CLIp is a clipboard emulator for a command line interface written in 100% standard C only. Pipe to it to copy, pipe from it to paste.
CLIp v2 About CLIp is a powerful yet easy to use and minimal clipboard manager for a command line environment, with no dependencies or bloat. Usage Sy
pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material.
pbr2gltf2 is a command line tool for converting PBR images to a glTF 2.0 material. The tool is detecting depending on the filename, which PBR information is stored. It swizzles the images and does reassign the channels to a glTF 2.0 image. The tool stores the images plus a minimal, valid glTF 2.0 file containing the required material, textures and images.
cmdlime - is a C++17 header-only library for command line parsing with minimum of code and pain things to remember
Possibly the least verbose command line parsing library for C++
A command-line tool to display colorful distro information.
sjfetch A command-line tool to display colorful distro information.
LwSHELL is lightweight, platform independent, command line shell for embedded systems.
LwSHELL is lightweight, platform independent, command line shell for embedded systems. It targets communication with embedded systems from remote terminal to quickly send commands and the retrieve data from the device.
Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.
Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.
Command-line flag parsing in C
flag.h Inspired by Go's flag module: https://pkg.go.dev/flag WARNING! The design of the library is not finished and may be a subject to change. Quick
A command line tool with no external dependencies to print information about an X server instance.
xinfo A command line tool with no external dependencies to print information about an X server instance. Building and running To build the code in thi
Windows command line program for Spleeter, written in pure C, no need of Python.
SpleeterMsvcExe is a Windows command line program for Spleeter, which can be used directly. It is written in pure C language, using ffmpeg to read and write audio files, and using Tensorflow C API to make use of Spleeter models. No need to install Python environment, and it does not contain anything related to Python.
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation
clipp - command line interfaces for modern C++ Easy to use, powerful and expressive command line argument handling for C++11/14/17 contained in a sing
Parse command line arguments by defining a struct
Parse command line arguments by defining a struct Quick Start #include <structopt/app.hpp> struct Options { // positional argument // e.g., .
Rizin - UNIX-like reverse engineering framework and command-line toolset.
Rizin - UNIX-like reverse engineering framework and command-line toolset.