summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorLines
2025-04-08ls: support capabilities with device 0,0Pádraig Brady-2/+6
* src/ls.c (has_capability_cache): Don't assume a device major,minor of 0,0 never occurs.
2025-04-08ls: fix crash of "ls -Z ." on OpenBSD's /dev/wd0a diskBruno Haible-1/+3
* src/ls.c (file_has_aclinfo_cache): Add new static variable 'unsupported_cached'. Don't assume that device 0 never occurs.
2025-04-07build: use _GL_ATTRIBUTE_NONSTRING attribute to avoid new warningsJim Meyering-2/+2
Avoid warnings like this from GCC 15: src/basenc.c:1139:20: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Werror=unterminated-string-initialization] * src/basenc.c (z85_encoding, do_decode): Mark two more variables as non-terminated.
2025-04-07timeout: don’t sleep less than requestedPaul Eggert-32/+21
Also, change sleep and tail to not sleep less than requested. * bootstrap.conf (gnulib_modules): Add dtimespec-bound. * gl/lib/dtimespec-bound.c, gl/lib/dtimespec-bound.h: * gl/modules/dtimespec-bound: New files. * src/sleep.c, src/tail.c, src/timeout.c: Include dtimespec-bound.h. * src/sleep.c, src/tail.c: Don’t include xstrtod.h. * src/sleep.c (apply_suffix, main): * src/tail.c (parse_options): * src/timeout.c (apply_time_suffix): Don’t sleep less than the true number of seconds. * src/timeout.c: Don’t include ctype.h. (is_negative): Remove; no longer needed. (parse_duration): Use a slightly looser bound on the timeout, one that doesn’t need -lm on GNU/Linux. Clear errno before calling cl_strtod.
2025-04-06maint: silence a -Wunterminated-string-initialization warningJim Meyering-1/+1
* src/basenc.c (base16_encode): Mark BASE16 as not NUL-terminated.
2025-04-06timeout: remove dependence on libmPádraig Brady-28/+11
This was seen to add about 100,000 ns to the startup time, on a 2.6 GHz i7-5600U with glibc 2.40. * .gitignore: Remove /lib/fenv.h. * bootstrap.conf: Remove fenv-rounding and signbit deps. * src/local.mk: Remove fenv lib dependency. * src/timeout.c (is_negative): A new helper function to be equivalent of signbit in the underflow case. (parse_duration): Remove the rounding up logic, as a nanosecond here or there has no significance.
2025-04-05timeout: round timeouts upPaul Eggert-6/+36
This handles timeouts like 16777216.000000001 correctly; formerly the subsecond part of that timeout was ignored. * bootstrap.conf (gnulib_modules): Add fenv-rounding, signbit. * src/local.mk (src_timeout_LDADD): Append $(FENV_ROUNDING_LIBM). * src/timeout.c: Include fenv.h, math.h. Don’t include xstrtod.h, as xstrtod’s checking now gets in the way. (parse_duration): Round up when calling cl_strtod. Check for -1e-1000. Don’t double-round 1e-9. * tests/timeout/timeout-parameters.sh: Test for -0.1, -1e-1000, 1e-1000.
2025-04-04maint: ensure that new "make syntax-check"-run sc_codespell passesCollin Funk-2/+2
* cfg.mk (codespell_ignore_words_list): Ignore false-positives. (exclude_file_name_regexp--sc_codespell): Skip some file names. * doc/coreutils.texi (mktemp invocation): Use "alphanumeric" which is consistent with the rest of the documentation. * src/expand-common.c: Fix typo. * src/ls.c: Likewise. * tests/split/l-chunk-root.sh: Likewise.
2025-04-04timeout: ensure infinitesimal timeouts timeout quicklyPádraig Brady-0/+4
* src/timeout.c (parse_duration): Clamp infinitesimal values to 1ns. * tests/timeout/timeout-large-parameters.sh: Add a test case. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/77535
2025-03-31ls: suppress ENOENT errors when reading ACL infoPádraig Brady-2/+8
* src/ls.c (gobble_file): Indicating unknown ACL info with '?' suffices for the edge case of a file being removed while reading, or older cygwin when reading through dangling symlinks. Reported by Corinna Vinschen.
2025-03-30ls: print correct xattr error on all platformsPádraig Brady-1/+1
* src/ls.c (gobble_file): Output errno, as u.err is not populated by file_has_aclinfo() on all platforms. * NEWS: Mention the bug fix.
2025-03-22doc: id: be direct about valid options with -nrPádraig Brady-1/+1
* src/id.c (usage): State what options are valid with -nr, rather than just stating the default format is invalid. Fixes https://bugs.gnu.org/77163
2025-03-22doc: id: make option combinations more searchablePádraig Brady-2/+2
* src/id.c (usage): Add commas to make options more searchable. Don't add spaces since that would overflow 80 cols. Fixes https://bugs.gnu.org/77162
2025-03-21ls: fix crash on systems with SELinux but without xattr supportPádraig Brady-1/+2
This was seen on termux on Android with ./configure --disable-xattr where listxattr() and getxattr() returned ENOTSUP. Then the valid security context obtained by file_has_aclinfo() was discounted, and problematically then freed multiple times. Reported at https://github.com/termux/termux-packages/issues/23752 * src/ls.c (file_has_aclinfo_cache): Only discount the returned acl info when all components are defaulted due to being unsupported.
2025-03-15dircolors: add vt220 as a color capable terminalPádraig Brady-0/+1
This isn't strictly historically accurate but most practical these days, especially since systemd uses this as its default TERM type. See https://github.com/coreutils/coreutils/issues/96 Tested with: $ LS_COLORS= COLORTERM= TERM=vt220 src/ls --color $ COLORTERM= TERM=vt220 src/dircolors * src/dircolors.hin: Add vt220.
2025-03-10dd: fix error detection with "nocache" flagFrédéric Yhuel-2/+4
* NEWS: Mention the bug fix. * src/dd.c (invalidate_cache): Adjust to the unusual error propagation sematics of posix_fadvise().
2025-02-24who: fix -m with guessed tty namesLukáš Zaoral-1/+1
* who.c (scan_entries): Account for guessed tty names (e.g. 'sshd pts/1') from the readutmp module when using the systemd backend. * bootstrap.conf (gnulib_modules): Add str_endswith. * News: Mention the bug fix. Addresses https://bugzilla.redhat.com/2343998
2025-02-20build: update gnulib submodule to latestPádraig Brady-6/+0
* gnulib: Update to 757345e8. * src/who.c: Adjust to new defines.
2025-02-20maint: fix sc_tight_scope failurePádraig Brady-37/+37
This reverts commit 83fb600a21c6bad362b5739e7a9a9780639fa550.
2025-02-20maint: fix sc_preprocessor_indentation failurePádraig Brady-3/+3
* src/cksum.h: Indent appropriately.
2025-02-19sort: improve -u brief docPaul Eggert-3/+2
* src/sort.c (usage): Reword -u help (Bug#76290).
2025-02-18du: update debug option setupPaul Eggert-11/+11
Current Gnulib arranges for fts debugging if GNULIB_FTS_DEBUG is defined, so key off that rather than off DU_DEBUG. * src/du.c (fts_debug): Remove decl, as Gnulib does this now. (FTS_CROSS_CHECK): Remove; all uses removed. (FTS_DEBUG) [!GNULIB_FTS_DEBUG]: Remove. (long_options) [GNULIB_FTS_DEBUG]: Add a ---debug option. (du_files): Call fts_cross_check only if fts_debug and GNULIB_FTS_DEBUG. (main): Set fts_debug if GNULIB_FTS_DEBUG, not DU_DEBUG.
2025-02-18maint: omit function defn externPaul Eggert-37/+37
* src/chown-core.c, src/copy.c, src/cp-hash.c, src/csplit.c: * src/expand-common.c, src/find-mount-point.c, src/force-link.c: * src/group-list.c, src/iopoll.c, src/operand2sig.c: * src/show-date.c, src/wc_avx2.c: Omit unnecessary ‘extern ’ at the start of function defns. This is less wordy, makes it a bit easier to grep for issues such as the missing consistency checking in cksum.
2025-02-18cksum: check API betterPaul Eggert-26/+8
* src/cksum_avx2.c, src/cksum_avx512.c, src/cksum_pclmul.c: * src/cksum_vmull.c: Include cksum.h instead of copying its decls/includes by hand. This is a better way to ensure consistency among defns and uses.
2025-02-18cksum: minor crctab generation cleanupsPaul Eggert-33/+25
* src/cksum.c [CRCTAB]: Include only config.h and stdio.h, to simplify the crctab-generating code. [!CRCTAB]: Do not include stdint.h or stdio.h, as cksum.h does it now. (BIT, r, crc_remainder, main) [CRCTAB]: Use unsigned int, not uint_fast32_t or uint32_t, as this is good enough for GNU where unsigned int is guaranteed to be at least 32 bits, and this way we needn’t worry about mismatches between %08x formats and uint_fast32_t. (main) [CRCTAB]: Prefer more-local decls. Do not output unnecessary directives to include stdint.h or stdio.h. No need for ‘return EXIT_SUCCESS;’ nowadays. * src/crctab.c: Regenerate.
2025-02-18cksum: make cksum.h standalonePaul Eggert-1/+20
* src/cksum.h: Include stdint.h, stdio.h so that this file can be included in any order, after config.h. Add a copyright notice.
2025-02-17cksum: port to 32-bit uint_fast32_tPaul Eggert-2/+5
* src/cksum_vmull.c (cksum_vmull): Don’t assume uint_fast32_t can hold 64 bits. Problem reported by Alyssa Ross (Bug#76360).
2025-02-15dircolors: recognize “jxl” (JPEG XL) filesMike Swanson-0/+1
2025-02-14cat: fix plain ‘cat’ bugPaul Eggert-13/+13
* src/cat.c (main): Do not fail with plain ‘cat’ where input and output are both /dev/tty, if the output happens to have O_APPEND set. Problem reported by lilydjwg <https://bugs.gnu.org/76255>. Also, don’t report an error if the seek position is at or after EOF, even if O_APPEND is set.
2025-02-14cat: omit unnecessary lseekPaul Eggert-1/+2
* src/cat.c (main): Don’t bother to try lseek on a fifo or socket, as it will fail.
2025-02-14cat: port to platforms with shm, tmoPaul Eggert-3/+11
* src/cat.c (main): Work even on platforms that have shared memory objects and typed memory objects, which means st_dev and st_ino do not work.
2025-02-02maint: pacify ‘gcc -Wswitch-enum’Paul Eggert-28/+45
I thought of a way to pacify -Wswitch-enum without much trouble. Either add all the enums, or if that’s too verbose use ‘switch (+E)’ to indicate to the reader that there need not be a case for every enum value. Since this approach improves static checking, make the change everywhere and check it with -Wswitch-enum. * configure.ac: Compile with -Wswitch-enum if it works and --enable-gcc-warnings. No need to remove -Wswitch-default since Gnulib no longer adds it. * src/chmod.c (describe_change): * src/chown-core.c (describe_change): * src/copy.c (copy_debug_string, copy_debug_sparse_string): * src/df.c (decode_output_arg, get_dev): * src/du.c (main): * src/factor.c (print_factors): * src/head.c (diagnose_copy_fd_failure): * src/ls.c (time_type_to_statx, calc_req_mask) (decode_line_length, get_funky_string, parse_ls_color) (gobble_file, print_long_format): * src/split.c (main): * src/sync.c (sync_arg): * src/tr.c (is_char_class_member): * src/wc.c (main): Add switch cases to pacify -Wswitch-enum. * src/copy.c (copy_debug_string, copy_debug_sparse_string): Add unreachable () for unreachable cases. * src/digest.c (main): * src/od.c (decode_one_format): * src/tr.c (get_next, get_spec_stats): switch (E) → switch (+E). * src/digest.c (main): * src/tr.c (get_next): Omit unnecessary ‘default: break;’ that merely pacified GCC, as the new pacification style is better. * src/ls.c (decode_line_length): Add default unreachable case to prevent warning that function might not return a value. (gobble_file): Distinguish DEREF_NEVER from unreachable cases.
2025-01-29doc: ls: clarify --format optionsPádraig Brady-2/+2
* src/ls.c (usage): Use parentheses to be less ambiguous as to what are WORDs and equivalent short options. This is also consistent with the description of --sort and --indicator-style. Fixes https://bugs.gnu.org/75916
2025-01-28doc: support --with-packager-bug-reportsPádraig Brady-0/+7
* src/system.h (emit_ancillary_info): Output PACKAGE_PACKAGER_BUG_REPORTS if the build is configured --with-packager-bug-reports. Reported by Bruno Haible.
2025-01-22sort: drop "note" from a --debug messagePádraig Brady-2/+1
* src/sort.c (key_warnings): Remove "note " from the start of a usually informational message, as this simplifies translation. * tests/sort/sort-debug-warn.sh": Adjust accordingly. Fixes https://bugs.gnu.org/75763
2025-01-18ls: fix crash with --contextPádraig Brady-5/+5
* src/ls.c (main): Flag that we need to stat() if we're going to get security context (call file_has_aclinfo_cache). (file_has_aclinfo_cache): Be defensive and only lookup the device for the file if the stat has been performed. (has_capability_cache): Likewise. * tests/ls/selinux-segfault.sh: Add a test case. * NEWS: Mention the bug fix. Reported by Bruno Haible.
2025-01-16ls: Fix compilation error on CentOS 6Bruno Haible-0/+3
* src/ls.c (XATTR_NAME_CAPS): Define fallback.
2025-01-16sort: fix --debug buffer overrunPaul Eggert-1/+5
* src/sort.c (debug_key): Fix undefined behavior when a key ends before it starts. Problem reported by Bruno Haible <https://bugs.gnu.org/75606>.
2025-01-15yes: avoid failure on CHERI protected systemsPádraig Brady-0/+5
* src/yes.c (main): Don't reuse the argv array as CHERI's capability bounds do not allow for that, failing like: $ yes $(seq 156) | head -n1 In-address space security exception (core dumped)
2025-01-15tac: avoid out of bounds accessPádraig Brady-1/+1
This was flagged on CheriBSD on ARM Morello with the error: "In-address space security exception (core dumped)" triggered with: tac -s '' /dev/null * src/tac.c (main): Ensure we don't read beyond the end of the supplied optarg.
2025-01-15maint: avoid syntax-check failurePádraig Brady-4/+4
* src/cksum.c: Use spaces to indent, not tabs.
2025-01-14cksum: port to Oracle Developer Studio 12.6Paul Eggert-38/+36
* src/cksum.c (cksum_fp_t): New typedef. (pclmul_supported, avx2_supported, avx512_supported) (vmull_supported): Return this new type instead of bool. All callers changed. That way, callers do not need to refer to functions like cksum_avx512 that might not exist on this platform. Although GCC optimizes such references away, the C standard does not require this optimization.
2025-01-13ls: readdir errno fixesPaul Eggert-7/+11
* src/ls.c (print_dir): Fix bug: file_failure can set errno to something other than EOVERFLOW but the code assumed it didn’t. Also, omit ENOENT bug workaround with glibc 2.3 and later, for consistency with Gnulib.
2025-01-13tail: fix regression in open() flags usedPádraig Brady-2/+1
* src/tail.c (tail_file): Fix precedence issue introduced in commit v9.5-231-g177fcec66 so that we pass correct flags to open(). Effectively this meant we would have dropped the O_BINARY flag on windows, since O_RDONLY is generally 0. Issue spotted by coverity.
2025-01-10csplit: avoid extraenous output files given empty inputPádraig Brady-4/+7
* src/csplit.c (get_first_line_in_buffer): Don't exit here upon empty input, rather indicate no input in the return to let callers handle in a more consistent fashion. * NEWS: Mention the bug fix. * tests/csplit/csplit.sh: Add a test case. Reported by Daniel Hofstetter.
2025-01-10ls: suppress "Permission denied" errors on NFSPádraig Brady-2/+11
NFS (on Linux 6.12 at least) was seen to return EACCES from listxattr() for files without read access. We started using listxattr() in coreutils 9.4. * src/ls.c (gobble_file): Map EACCES from file_has_aclinfo() to '?', rather than displaying the error. * doc/coreutils.texi (ls invocation): Document the '?' flag. * NEWS: Mention the bug fix. Addresses https://bugs.gnu.org/74692
2025-01-08ls: update commentPaul Eggert-1/+1
* src/ls.c (file_has_aclinfo_cache): Fix comment.
2025-01-08tail: honor --pid with fifosPádraig Brady-5/+9
* src/tail.c (tail_file): Open files with O_NONBLOCK if we might need async processing. (pipe_bytes): Ignore EAGAIN read() errors. (pipe_lines): Likewise. * tests/tail/pid-pipe.sh: Add a new test. * tests/local.mk: Reference the new test. * NEWS: Mention the bug fix. Reported by Berhard Voelker.
2025-01-07cp,mv: decouple --update from -f,-i,-n optionsPádraig Brady-115/+48
* src/copy.h: Change update member from bool to enum. * src/copy.c: s/interactive == I_ALWAYS_NO/update == UPDATE_NONE_FAIL/; s/interactive == I_ALWAYS_SKIP/update == UPDATE_NONE/; s/update/update == UPDATE_OLDER/; * src/install.c: Init with UPDATE_ALL, rather than false. * src/cp.c: Likewise. Simply parse -f,-i,-n to x.interactive, and parse --update to x.update. * src/mv.c: Likewise. * tests/cp/cp-i.sh: Add a test case where -n --update -i honors the --update option, which would previously have been ignored due to the preceding -n.
2025-01-06cp,mv: ensure -i,f are not overridden by -uPádraig Brady-7/+23
Since coreutils 9.3 we had --update={all,older} override -i. In coreutils 9.5 this was expanded to -u (to make it consistent with --update=older). This patch reinstates things so that -i combines with -u instead. I.e. have -i be protective, rather than selective (like -u). The -f option of mv is similarly adjusted in this patch, so now --update does not override any of -f,-i,-n. * NEWS: Mention the bug fix. * src/cp.c (main): Don't have -u disable prompting. * src/mv.c (main): Likewise. * tests/cp/cp-i.sh: Add a test case for -i. * tests/mv/update.sh: Likewise. * tests/mv/i-3.sh. Add a test case for -f. Fixes https://bugs.gnu.org/70887