Commit Graph

870 Commits

Author SHA1 Message Date
Elliott Hughes
6150398479 xwrap.c: fix build.
The last change was a bit mangled.
2022-08-26 20:51:53 -05:00
Rob Landley
3dae8ebfe5 Some headers define stdin as a macro, avoid unnecessarily stepping on that. 2022-08-25 21:01:53 -05:00
Rob Landley
63f787b602 If the kernel hasn't got sendfile() it can return ENOSYS, not just EINVAL. 2022-08-21 00:51:30 -05:00
Rob Landley
41d43d8a53 Use TOYFLAG_ARGFAIL() value for error_msg(), and add sort -C in passing. 2022-08-19 01:50:33 -05:00
Elliott Hughes
7768ecdf2a Add loongarch's ELF value. 2022-08-11 14:26:05 -05:00
Rob Landley
d1a5bf6a43 Fix fencepost error. 2022-08-09 04:12:29 -05:00
Ed Maste
3b7613a8cf portability: Add some FreeBSD cases
Use existing Apple or OpenBSD implementations.
2022-07-29 13:49:07 -05:00
Rob Landley
658cdf4435 Fix --longopt= empty argument and add tests. 2022-07-28 12:19:09 -05:00
Elliott Hughes
00c97a06be killall: fix a logic error in names_to_pid().
This broke a lot of tests in postsubmit, and even seems to have had the
effect of causing reboots (presumably by accidentally killing init)
which made it quite hard to track down.

Sadly I'm too stupid by this point in the afternoon to come up with the
missing test :-(
2022-07-27 00:59:34 -05:00
Rob Landley
92a7778fcf Make lib/args.c handle ":;", ": ", and ":; " in combination, and use
":; " in unshare.
2022-07-24 04:12:07 -05:00
Rob Landley
3e32402589 Another thinko. 2022-07-20 08:23:30 -05:00
Rob Landley
dc8b46d5dd Don't close stdin/stdout when passing them through. 2022-07-15 03:09:19 -05:00
Rob Landley
df627c90b4 Fix comment: short options can have optional arguments. 2022-07-12 05:20:02 -05:00
Rob Landley
f51b02947b Add same_file() and same_def_ino() convenience functions, plus minor cleanups. 2022-06-29 21:54:42 -05:00
Rob Landley
c7342f8b72 Block signals in exit_signal() so sigatexit() list isn't re-entered.
xexit() uses siglongjmp() when not exiting, so should clean itself up.
2022-06-29 21:48:18 -05:00
Elliott Hughes
15d1af8951 xgetrandom: fix macOS build.
BSD has <sys/random.h> first, but has getentropy() in there. glibc
has getentropy() in addition to getrandom(), but they keep it in
<unistd.h> instead. Since both went in in glibc 2.25 I don't think
this will matter in practice, but if this does cause trouble, we
can have separate getentropy() and getrandom() implementations for
the BSDs versus glibc.

This does mean that the only valid values for `flags` are now 0 or
WARN_ONLY, but that was already effectively true anyway because
GRND_NONBLOCK != O_NONBLOCK so the fallback path was already broken.
2022-06-20 17:27:49 -05:00
Rob Landley
587ed3db6b Switch getrandom() from compile time probe to __has_include() 2022-06-17 17:36:08 -05:00
Rob Landley
6cf4d6d4d1 Switch shadow.h and utmpx.h from compile time probes to __has_include().
This does mean "make defconfig" can't automatically drop them out, but
the platforms that don't have this aren't building defconfig anyway.
2022-06-17 17:26:16 -05:00
Rob Landley
2d58f28e90 HASTIMERS is a bug workaround for glibc, just test for glibc instead of probing. 2022-06-17 17:06:35 -05:00
Elliott Hughes
f564bb3cca Avoid copy_file_range(2) on Android.
Strictly we could use it if the target API level is high enough,
but that would mean that you couldn't safely run the resulting
binary on an older Android release, and anecdotally I don't think
people are that careful.

The obvious alternative would be to install a signal handler for
SIGSYS so we can probe for copy_file_range(2) at runtime rather
than compile time, but it's not obvious to me that it matters enough?
2022-06-15 07:38:01 -05:00
Rob Landley
6ef2431a0f Don't probe for copy_file_range, we already have an #ifdef. 2022-05-29 17:47:33 -05:00
Rob Landley
b63778e00f Accept unambiguous --longopt abbreviations. 2022-05-21 22:59:50 -05:00
Rob Landley
ea52d3048a Add tar --xform.
Adds xrunread() to lib and makes mount use it instead of a local function.
2022-05-21 12:40:28 -05:00
Rob Landley
5e8c74d7d6 Ubuntu enables gcc's "fortify" false positive generator by default,
which broke the build.
2022-05-19 15:47:51 -05:00
Rob Landley
401898110f Add ~ to collate bare longopts. 2022-05-17 09:22:20 -05:00
Rob Landley
3625a26006 Switch to C11 noreturn to work around a compiler bug in llvm.
Elliott said:

Works around a clang bug in the version of clang shipping with Android T
that causes a miscompile in xstdio_create() on x86-64, that oddly only
affects __attribute__((__noreturn__)) and not _Noreturn!
2022-05-11 10:09:07 -05:00
Rob Landley
abb6ebbe67 A little more ANSI cheat sheet. 2022-05-05 05:39:04 -05:00
Rob Landley
e3b461fc3f Silence two more "are never used uninitialized" warnings. 2022-04-25 00:12:23 -05:00
Rob Landley
a9d0e2386f Add simple static httpd.
And move url escape/unescape into lib/net.c.
2022-04-24 19:57:53 -05:00
Rob Landley
feb39a12c3 Move struct ptr_len into only remaining user. 2022-04-19 01:33:17 -05:00
Rob Landley
a6e0c86f77 All PEDANTIC_ARGS does is set a macro that's never used. 2022-04-12 02:31:17 -05:00
Elliott Hughes
50361a1b07 lib/portability.c: don't assume we have __NR_copy_file_range.
Android's host tools currently build with glibc from 2012, but even if
we were more up to date (or had already switched to musl for host tools,
which hopefully will be the case by this time next year), it was added
to glibc recently enough to miss the "seven year window".
2022-04-11 22:52:14 -05:00
Rob Landley
42ce6272f5 When args.c is just enforcing max/min argument count with no options, imply ?
so "command -123" isn't an unknown option error.
2022-04-04 11:44:30 -05:00
Rob Landley
72e7e3821b Add tar --strip-components.
Also in lib/ add bufget name variants for password and group.
2022-04-02 19:33:14 -05:00
Rob Landley
5f36552394 Cleanup pass and make -O - write to stdout.
Teach chomp() to remove any number of trailing \r\n
2022-03-26 13:28:12 -05:00
Rob Landley
1ba8a12c4d Avoid redundant strlen() inside libc. 2022-03-22 14:25:46 -05:00
Rob Landley
7baa990683 Fix copy_file_range() fallback. 2022-03-19 19:57:46 -05:00
Elliott Hughes
2f4e6e18b4 Fix macOS build after copy_file_range() changes. 2022-03-18 15:47:53 -05:00
Rob Landley
9b368059de Update comments and add "sanity check" from kernel commit f16acc9d9b376.
(The kernel's been doing this since 2019, but older kernels may not, so...)
2022-03-17 18:25:38 -05:00
LongPing Wei
613db35596 Enable copy_file_range when it is available.
Fallback to read+write when copy_file_range failed, as both fd_in and fd_out must refer to regular files.

Signed-off-by: LongPing Wei <weilongping@huawei.com>
2022-03-17 09:10:17 -05:00
Rob Landley
20376512ae Silence more false positive warnings in llvm. 2022-03-06 00:24:43 -06:00
Rob Landley
3b06f9600e Move a struct from lib.h into the one toys/pending command that uses it. 2022-02-16 17:13:07 -06:00
Rob Landley
fc0fbe6788 Move lib/lib.c into main.c so make.sh doesn't have to split it out seperately. (Nothing else in lib/ has to rebuild when command list changes.) 2022-02-12 03:18:10 -06:00
Rob Landley
eaf3949cb7 Fix @time.nanosecond parsing, and add test. 2022-02-10 14:32:09 -06:00
Rob Landley
7fe3cb1fa9 Move ANSI escape cheat sheet to tty.c 2022-01-30 00:51:24 -06:00
Rob Landley
66ecd116ed Rename remains of linestack.c to utf8.c 2022-01-28 19:18:39 -06:00
Rob Landley
0f5f00c1d8 Remove the linestack plumbing, an old unfinished todo item that got
interrupted long enough ago it would be easier to restart from scratch.
It was never used and hasn't been touched in years.
2022-01-28 19:15:59 -06:00
Rob Landley
64f12b4f6a Shut up an unused variable warning triggered by an #ifdef. 2022-01-10 17:58:56 -06:00
Rob Landley
c3f3f842c5 Replace \033 with \e in strings. 2022-01-03 22:21:30 -06:00
Rob Landley
9a1b068c35 Remove tty_esc() and tty_jump() wrappers, just output ANSI directly. 2022-01-03 22:02:21 -06:00