cp currently will exit with success even if the underlying
write syscall fails with an error. Fixing this behavior.
Signed-off-by: Utsav Munendra <utsavm@meta.com>
In some network environment, we would like the dhcp client to receive
unicast offer/ack packets. This requires the broadcast bit to be unset.
However, the current implementation always sets this bit. This patch
adds a new option -u to unset broadcast bit to enable unicast offer/ack.
leading zeroes for some reason, so take the rightmost 8k of mask data
and test with leading zeroes. (It could instead specifically skip
leading zeroes, but would still have to check sizeof(toybuf) anyway.)
Again, the 6.16 kernel can only set NR_CPUS to 8k (1/4 of the bits in
toybuf) for 2 architectures (x86-64 and powerpc64, and ARM64 maxes out
at 4k (1/8 of toybuf). Last I checked nobody's made hardware anywhere
near that: they thought they might 20 years ago but NUMA didn't scale.
Beowulf clusters existed back in the 1990s and if you really want to
have a cluster mmap() shared memory from network storage you can just do
that and address contentional manually (with manual flock and madvise or
your own bespoke mechanism), or create data stores like riak, or...
syscalls on some 32 bit architectures, and this one is used as the
_example_ in the the "Architecture-specific requirements" section of
"man 2 syscall".
Some 32-bit processors can only use 64 bit values in even register
pairs. Eight old syscalls (fadvise64_64, ftruncate64, posix_fadvise,
pread64, pwrite64, readahead, sync_file_range, and truncate64) didn't
arrange the argument order to naturally align, so required padding on
32-bit arm eabi, mips oabi, powerpc, parisc, and xtensa.
The libc wrapper inserts this padding when necessary, and using that is
less ugly than architecture specific whack-a-mole in toybox, even
working around glibc's refusal to provide the prototype unless we
declare Linux to be somehow owned by the Free Softare Foundation (which
was why it was using the syscall directly before).
Also try to clean up the #ifdefery. These things have been in the kernel
headers since 2012, so let's assume that -- other than the glibc
header/uapi header conflict -- we can get everything we need now.
Since util-linux/util-linux@6c87a3ac5e (taskset: Accept 0 pid for current
process), util-linux's taskset has accepted a 0 PID for the taskset
process.
Toybox has always had this behavior, inherited from sched_getaffinity(2)
and sched_setaffinity(2).
https://www.man7.org/linux/man-pages/man2/sched_getaffinity.2.html
Document the zero PID behavior and use it to simplify the tests.
Note that toybox and util-linux show different output. I'm not sure if
this should be considered a bug or not.
% ./toybox taskset 1 ./toybox taskset -p 0
pid 0's current affinity mask: 1
% ./taskset 1 ./taskset -p 0
pid 2140985's current affinity mask: 1
While both gcc 12.2 and clang 18.0 compiled weak and non-weak versions
of the same symbol in the same file just fine, newer versions only work
if the weak symbol is in a different compilation unit than the non-weak
one. Otherwise they error out on the "redefinition".
"make defconfig" calls kconfig twice, and the first one (kconfig -h)
was consuming the KCONFIG_ALLCONFIG=<(echo blah) input so the actual
defconfig generation (kconfig -d) didn't see the PENDING overrides.
with toys.rebound to continue and accept additional input after error file,
reduce error message granularity (it worked or it didn't),
mark more functions static, use toybuf for input.
Fix tests to not look for specific error messages (fixes TEST_HOST).
Move sh_process allocation out of expand_redir() and have caller allocate
and supply it, so multiple expand_redir() calls can append to the
same argv[] and filehandle unredirect context.
Move argv[0] out of ff->arg into TT.argv0 (because $0 is special: shift
and $* don't include it, set can't update it, source and function calls
don't change it...)
Rename call_function() to add_fcall(), because sh_function is function()
definitions and sh_fcall is call stack.
Remove pp->envlen, and replace pp->flags/PFLAG_NOT with pp->not.
Make sh_fcall more sparse: instead of copying fields from parent context
search for them with find_fcall() (convenience wrapper: FIND_FF()) and
get_lineno(). Having one copy greatly simplifies updating the values.
Note: run_command() no longer returns NULL: pp->exit will be nonzero if
setup failed.