]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
4 years agorm: do not skip files upon failure to remove an empty dir
Nishant Nayan [Thu, 26 Nov 2020 14:35:17 +0000 (14:35 +0000)] 
rm: do not skip files upon failure to remove an empty dir

When removing a directory fails for some reason, and that directory
is empty, the rm_fts code gets the return value of the excise call
confused with the return value of its earlier call to prompt,
causing fts_skip_tree to be called again and the next file
that rm would otherwise have deleted to survive.

* src/remove.c (rm_fts): Ensure we only skip a single fts entry,
when processing empty dirs.  I.e. only skip the entry
having successfully removed it.
* tests/rm/empty-immutable-skip.sh: New root-only test.
* tests/local.mk: Add it.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/44883

4 years agomaint: mention in NEWS about new df remote fs types
Pádraig Brady [Thu, 26 Nov 2020 14:29:57 +0000 (14:29 +0000)] 
maint: mention in NEWS about new df remote fs types

* NEWS: Mention new remote file system types
recognized since gnulib commit dd1fc46b.

4 years agomaint: remove no longer needed se_const helper
Pádraig Brady [Mon, 23 Nov 2020 15:13:05 +0000 (15:13 +0000)] 
maint: remove no longer needed se_const helper

This was needed before libselinux-2.3 (May 2014),
but modern releases have the correct const declarations.

* src/chcon.c: Remove se_const() wrapper.
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/system.h: Likewise.
* gnulib: update to pick up const correctness fixes in selinux stubs.

4 years agomaint: fix syntax-check failure
Pádraig Brady [Mon, 23 Nov 2020 14:09:51 +0000 (14:09 +0000)] 
maint: fix syntax-check failure

* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.

4 years agoinstall: suppress "Operation not supported" false alarms
Paul Eggert [Mon, 23 Nov 2020 09:48:15 +0000 (01:48 -0800)] 
install: suppress "Operation not supported" false alarms

At least, I *think* they are false alarms.  An SELinux expert eye
would be welcome.
* src/install.c (setdefaultfilecon): If selabel_lookup fails
due to either ENOTSUP or ENODATA, don’t diagnose the issue.
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/coreutils/2020-11/msg00050.html

4 years agomaint: propagate errno better in selinux.c
Paul Eggert [Mon, 23 Nov 2020 08:52:00 +0000 (00:52 -0800)] 
maint: propagate errno better in selinux.c

* src/selinux.c: Don’t include die.h; no longer needed.
(computecon, defaultcon, restorecon): Propagate errno.
(defaultcon, restorecon): Don’t diagnose errors or exit, as that’s
the caller’s responsibility.

4 years agomaint: use absolute paths with selabel_lookup
Pádraig Brady [Sun, 22 Nov 2020 17:46:52 +0000 (17:46 +0000)] 
maint: use absolute paths with selabel_lookup

* src/selinux.c: selabel_lookup requires absolute paths
(while only older matchpathcon before libselinux < 2.1.5 2011-0826 did).
* po/POTFILES.in: Readd src/selinux.c since we now have
a translatable error message.

4 years agomaint: minor cleanup
Bernhard Voelker [Sun, 22 Nov 2020 12:05:29 +0000 (13:05 +0100)] 
maint: minor cleanup

The previous commit introduced a couple of syntax-check failures.

* .gitignore (/lib/se-label.h): Add entry to silence the
sc_gitignore_missing check.  Sort entries in C locale.
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
* src/mv.c: Replace tabs by spaces to avoid complaints by
sc_prohibit_tab_based_indentation.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 22 Nov 2020 03:05:16 +0000 (19:05 -0800)] 
build: update gnulib submodule to latest

4 years agomaint: port from matchpathcon to selabel_lookup
Paul Eggert [Sun, 22 Nov 2020 00:59:25 +0000 (16:59 -0800)] 
maint: port from matchpathcon to selabel_lookup

Ubuntu 20.10 is using a newer version of libselinux that
complains that matchpathcon is obsolete.  Rewrite the code
that it uses the recommended selabel_lookup instead.
* m4/jm-macros.m4 (coreutils_MACROS): Do not check for
matchpathcon_init_prefix, as it is no longer used.
* src/copy.c (set_file_security_ctx): Omit process_local arg,
as it is equivalent to !x->set_security_context.  All callers changed.
* src/copy.h (struct cp_options): set_security_context is now of
type struct selabel_handle *, not bool.  All uses changed.
* src/cp.c, src/install.c, src/mkdir.c, src/mkfifo.c, src/mknod.c:
* src/mv.c: Include selinux/label.h.
(main): Use selabel_open for set_security context.
* src/install.c (matchpathcon_init_prefix): Remove; now unused.
(get_labeling_handle): New static function.
(setdefaultfilecon, main): Use it.
(setdefaultfilecon): Do something regardless of
ENABLE_MATCHPATHCON, which seems to be a revenant macro.
(setdefaultfilecon): Use selabel_lookup instead of the obsolescent
matchpathcon.  Report an error unless it fails due to ENOENT.
* src/local.mk (src_ginstall_CPPFLAGS): Remove.
* src/selinux.c: Include selinux/label.h
Do not include die.h, error.h, canonicalize.h.
(defaultcon, restorecon_private, restorecon):
New arg HANDLE.  All callers changed.
Use selabel_lookup rather than matchpathcon.
(restorecon_private, restorecon): Don’t lose track of errno.
* src/selinux.c, src/selinux.h:
(restorecon): Don’t call ‘error’; that’s the caller’s job.
Use HAVE_SELINUX_LABEL_H, not HAVE_SELINUX_SELINUX_H,
in case there is some weird system with the former but not the latter.
* src/selinux.h (struct selinux_handle): Add forward decl.

4 years agobuild: port to Solaris 10
Paul Eggert [Sat, 21 Nov 2020 21:18:55 +0000 (13:18 -0800)] 
build: port to Solaris 10

* src/local.mk (src_ln_LDADD, src_mktemp_LDADD, src_tac_LDADD):
Add $(LIB_CLOCK_GETTIME), since these use tempname which uses
clock_gettime if getrandom fails.  On platforms like Solaris 10,
clock_gettime is not in the standard C library.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 21 Nov 2020 20:59:09 +0000 (12:59 -0800)] 
build: update gnulib submodule to latest

4 years agodoc: mention that sort -g supports hex numbers
Pádraig Brady [Wed, 18 Nov 2020 14:00:43 +0000 (14:00 +0000)] 
doc: mention that sort -g supports hex numbers

* doc/coreutils.texi (sort invocation): Mention explicitly
that --general-numeric-sort supports arbitrary format hex numbers,
but also mention that consistent case/width hex numbers can
be sorted faster with a standard sort.

4 years agotr: fix crash validating -c with some case char classes
Pádraig Brady [Sat, 14 Nov 2020 16:47:05 +0000 (16:47 +0000)] 
tr: fix crash validating -c with some case char classes

This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v8.5-163-g3f48829c2

* src/tr.c (validate_case_classes): Don't apply these
extra case alignment checks in the --complement case,
which is even more restrictive as to the contents of SET2.
* tests/misc/tr-case-class.sh: Add a test case,
for a large SET1, which caused the length adjustment
in validate_case_classes to underflow and trigger the assert.
* NEWS: Mention the bug fix.

4 years agodoc: clarify in texinfo that `test == ...` is non portable
Ben Pfaff [Thu, 12 Nov 2020 18:59:31 +0000 (18:59 +0000)] 
doc: clarify in texinfo that `test == ...` is non portable

* doc/coreutils.texi (test invocation): Mention non portability
of the double equals form.

4 years agols: fix crash printing SELinux context for unstatable files
Pádraig Brady [Wed, 11 Nov 2020 17:22:33 +0000 (17:22 +0000)] 
ls: fix crash printing SELinux context for unstatable files

This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v6.9.90-11-g4245876e2

* src/ls.c (gobble_file): Ensure scontext is initialized
in the case where files are not statable.
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
and added test case for broken symlinks.
* tests/local.mk: Adjust for the renamed test.
* NEWS: Mention the bug fix.

4 years agotimeout: support sub-second timeouts on macOS
Pádraig Brady [Sat, 7 Nov 2020 21:35:01 +0000 (21:35 +0000)] 
timeout: support sub-second timeouts on macOS

* m4/jm-macros.m4: Check for setitimer.
* src/timeout.c: Use setitimer if timer_settime is not available.
* NEWS: Mention the improvement.

4 years agomaint: avoid strncat warning on GCC
Pádraig Brady [Sat, 7 Nov 2020 21:04:12 +0000 (21:04 +0000)] 
maint: avoid strncat warning on GCC

GCC 10.1.1 without optimization gives:

  error: ‘strncat’ argument 2 declared attribute ‘nonstring’
    [-Werror=stringop-overflow=]
    strncat (comment, UT_ID (utmp_ent), utmpsize);

Note the strncat man page says that:
  "src does not need to be null-terminated
   if it contains n or more bytes."
And the POSIX spec says that the second (source) parameter
is an array not a string.
So I think it's incorrect for strncat to require src be a string type.
This constraint seems to be being added to the gcc builtin strncat,
as specifiying -fno-builtin also avoids the warning.
Note specifying any optimization level also avoids the warning.

* src/who.c (make_id_equals_comment): Avoid the issue by using
stpcpy + stzncpy, instead of strcpy + strncat.
This pattern is used elsewhere in who.c

4 years agostat,tail: sync file system constants from the linux kernel
Pádraig Brady [Tue, 27 Oct 2020 20:15:43 +0000 (20:15 +0000)] 
stat,tail: sync file system constants from the linux kernel

* src/stat.c: Add magic constants for "devmem", and
"zonefs" file systems.
* NEWS: Mention the improvement.

4 years agomaint: cleanup operation of fs-magic-compare
Pádraig Brady [Tue, 27 Oct 2020 20:00:43 +0000 (20:00 +0000)] 
maint: cleanup operation of fs-magic-compare

* src/local.mk: Ensure we map 2 hex digits to 4,
so that we don't output already handled Z3FOLD file system (0x33).
Also hide the generation command for src/fs.h.

4 years agodoc: make blank lines before --help consistent
Pádraig Brady [Tue, 27 Oct 2020 14:10:14 +0000 (14:10 +0000)] 
doc: make blank lines before --help consistent

* src/basenc.c (usage): Remove extraneous blank line,
to be consistent with other utilities that have options.
* src/realpath.c: Likewise.
* src/runcon.c: Likewise.
Addresses https://bugs.gnu.org/44248

4 years agomaint: avoid new sort.c warning from upcoming GCC11
Jim Meyering [Sun, 25 Oct 2020 17:04:19 +0000 (10:04 -0700)] 
maint: avoid new sort.c warning from upcoming GCC11

gcc version 11.0.0 20201025 (experimental) warns that
src/sort.c:1655:1: warning: function might be candidate for attribute \
  'pure' if it is known to return normally [-Wsuggest-attribute=pure]
* src/sort.c (limfield): Mark as pure.

4 years agodd: drop old workaround for lseek() bug in Linux kernel
Kamil Dudka [Mon, 26 Oct 2020 10:44:44 +0000 (11:44 +0100)] 
dd: drop old workaround for lseek() bug in Linux kernel

The workaround triggers warnings from newer kernel versions in case
a user does not have sufficient privileges for the MTIOCGET ioctl.

* src/dd.c (skip_via_lseek): Drop wrapper function no longer needed.
(skip): Use lseek() directly.
(advance_input_after_read_error): Likewise.

Reported-by: Nir Soffer at https://bugzilla.redhat.com/1876840
Fixes https://bugs.gnu.org/44235

4 years agonl: support a negative --line-increment
KOBAYASHI Takashi [Sun, 25 Oct 2020 17:09:04 +0000 (17:09 +0000)] 
nl: support a negative --line-increment

* src/nl.c (main): Allow -i to accept down to INTMAX_MIN.
* tests/misc/nl.sh: Add test cases.
* NEWS: Mention the new feature.

4 years agonl: only fail if need to output overflowed numbers
Pádraig Brady [Sun, 25 Oct 2020 16:40:35 +0000 (16:40 +0000)] 
nl: only fail if need to output overflowed numbers

Previously we would have failed immediately upon internal overflow,
which didn't output the full line being processed, and assumed
there would be another numbered line.

* src/nl.c (line_no_overflow): A new global to track overflow.
(print_lineno): Only fail if about to output an overflowed number.
(reset_lineno): A new function to refactor resetting of the number,
and which also clears line_no_overflow.
* tests/misc/nl.sh: Add a test case.

4 years agomaint: add lib/parse-datetime-gen.h to .gitignore
Pádraig Brady [Sun, 25 Oct 2020 13:35:40 +0000 (13:35 +0000)] 
maint: add lib/parse-datetime-gen.h to .gitignore

* .gitignore: update to ignore new file
generated by the latest gnulib update.

4 years agomaint: sync help2man to latest version
Pádraig Brady [Sun, 25 Oct 2020 13:10:32 +0000 (13:10 +0000)] 
maint: sync help2man to latest version

* man/help2man: sync to changes from version 1.47.16.
Note this doesn't materially change the generated man pages.
Addresses https://bugs.gnu.org/44105

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 19 Oct 2020 17:47:32 +0000 (10:47 -0700)] 
build: update gnulib submodule to latest

* gl/lib/randperm.c, src/cp-hash.c, src/ls.c, src/sort.c, src/tail.c:
Change all instaces of hash_delete to hash_remove to accommodate
change to Gnulib API.

4 years agomaint: remove already handled FIXME in tail.c
Grigorii Sokolik [Sat, 17 Oct 2020 15:54:17 +0000 (16:54 +0100)] 
maint: remove already handled FIXME in tail.c

* src/tail.c: Remove FIXME to follow a file name in a recreated
directory. The comment was added in commit v8.5-191-g61b77891c
while the fix (albeit not using inotify) was added in
commit v8.27-21-gba5fe2d4b

4 years agomaint: update docs for build prerequisites
Grigorii Sokolik [Sat, 17 Oct 2020 15:52:17 +0000 (16:52 +0100)] 
maint: update docs for build prerequisites

* README-prereq: Explicitly pull tags,
and update the xz git repo url.

4 years agodoc: fix punctuation in stat --help
Benno Schulenberg [Tue, 29 Sep 2020 12:31:52 +0000 (14:31 +0200)] 
doc: fix punctuation in stat --help

* src/stat.c (usage): Replace a mistaken semicolon with a colon,
and replace mistaken backticks with single quotes.  Also reorder
some words, for clarity.
Fixes https://bugs.gnu.org/43707

4 years agodoc: clarify timeout --foreground description
Pádraig Brady [Wed, 12 Aug 2020 17:40:04 +0000 (18:40 +0100)] 
doc: clarify timeout --foreground description

* doc/coreutils.texi (timeout invocation): Avoid any implication
that `timeout --foreground` could be used to retroactively
timeout commands not already invoked by timeout(1).
Fixes bug https://bugs.gnu.org/42831

4 years agocsplit: fix regex suppression with specific match count
Emanuele Giacomelli [Sat, 8 Aug 2020 20:29:13 +0000 (21:29 +0100)] 
csplit: fix regex suppression with specific match count

* src/csplit.c (process_regexp): Process the line suppression
in all invocations so that the last match is suppressed.
Previously with a non infinite match count,
the last regex pattern was not suppressed.
* NEWS: Mention the bug fix.
* tests/misc/csplit-suppress-matched.pl: Add a test case.
Fixes https://bugs.gnu.org/42764

5 years agotests: skip some parts of 'tests/rmdir/ignore.sh' if run as root
Bernhard Voelker [Fri, 31 Jul 2020 17:49:35 +0000 (19:49 +0200)] 
tests: skip some parts of 'tests/rmdir/ignore.sh' if run as root

Parts of this test expect that the rmdir syscall returns with EPERM,
but the root user does not see that.

* tests/rmdir/ignore.sh: Add uid_is_privileged_ guards around parts
of the test which expect rmdir() to fail with EPERM.

Reported by Nick Alcock <nix@esperi.org.uk> in
https://bugs.gnu.org/42633

5 years agodoc: show version in title of HTML manual
Bernhard Voelker [Tue, 28 Jul 2020 21:28:45 +0000 (23:28 +0200)] 
doc: show version in title of HTML manual

* doc/coreutils.texi (@include version.texi): Move before ...
(@settitle): ... this.  Add the version after the package name.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-07/msg00021.html

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 27 Jul 2020 21:06:10 +0000 (14:06 -0700)] 
build: update gnulib submodule to latest

* src/local.mk (src_expr_LDADD, src_factor_LDADD):
Adjust to Gnulib renaming of LIB_GMP to LIBGMP.

5 years agodoc: fix typo in env --split-string documentation
Pádraig Brady [Mon, 27 Jul 2020 12:10:55 +0000 (13:10 +0100)] 
doc: fix typo in env --split-string documentation

* doc/coreutils.texi: Fix grammar.

5 years agodate: clarify the Epoch
Paul Eggert [Fri, 24 Jul 2020 20:33:09 +0000 (13:33 -0700)] 
date: clarify the Epoch

* src/date.c (usage): Mention the Epoch under %s for clarity,
and capitalize.

5 years agodoc: modernize date examples
Paul Eggert [Fri, 24 Jul 2020 20:31:10 +0000 (13:31 -0700)] 
doc: modernize date examples

* doc/coreutils.texi: Use more-modern date examples.
Capitalize “Epoch” to be consistent with POSIX.

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 24 Jul 2020 19:22:29 +0000 (12:22 -0700)] 
build: update gnulib submodule to latest

* bootstrap.conf (gnulib_modules): Add hash-triple.

5 years agodoc: clarify 'timeout -k' behavior
Bernhard Voelker [Sat, 4 Jul 2020 23:20:10 +0000 (01:20 +0200)] 
doc: clarify 'timeout -k' behavior

* doc/coreutils.texi (timeout invocation): Document that the the
duration of --kill-after=DURATION begins when sending the initial
signal.  Also mention that -k does not have any effect if timeout's
duration is 0.

Suggested by Jonny Grant <jg@jguk.org>.

5 years agofactor: port to --without-libgmp
Paul Eggert [Sun, 19 Jul 2020 01:45:06 +0000 (18:45 -0700)] 
factor: port to --without-libgmp

* src/factor.c (mp_factor_using_division): Use mpz_fdiv_q_2exp
instead of its no-longer-documented mpz_div_2exp alias.
(print_factors): Use mpz_out_str instead of gmp_printf.

5 years agobuild: be less aggressive about -fanalyzer
Paul Eggert [Fri, 10 Jul 2020 22:54:51 +0000 (15:54 -0700)] 
build: be less aggressive about -fanalyzer

* configure.ac: Don’t enable -fanalyzer unless configured with the
new --enable-gcc-warnings=expensive option.  See thread at:
https://lists.gnu.org/r/coreutils/2020-07/msg00011.html

5 years agofactor: explain why non-GMP code (Bug#42269)
Paul Eggert [Thu, 9 Jul 2020 01:58:18 +0000 (18:58 -0700)] 
factor: explain why non-GMP code (Bug#42269)

* doc/coreutils.texi (factor invocation):
* src/factor.c: Explain why the two-word algorithm is useful.

5 years agodoc: mention expr and factor bignums
Paul Eggert [Wed, 8 Jul 2020 15:09:31 +0000 (08:09 -0700)] 
doc: mention expr and factor bignums

* NEWS:
* doc/coreutils.texi (expr invocation, factor invocation):
Mention bignum support on all platforms.  Modernize timings.

5 years agofactor: treat ' +bignum' like non-bignum
Paul Eggert [Wed, 8 Jul 2020 15:05:06 +0000 (08:05 -0700)] 
factor: treat ' +bignum' like non-bignum

* src/factor.c (strto2uintmax): Instead of here ...
(print_factors): ... skip spaces and '+' here, so that
bignums are treated like non-bignums.
* tests/misc/factor.pl (bug-gmp-plus_2_sup_128_plus_1): New test.

5 years agotests: simplify since expr now works on bignums
Paul Eggert [Wed, 8 Jul 2020 14:45:05 +0000 (07:45 -0700)] 
tests: simplify since expr now works on bignums

* cfg.mk (sc_prohibit_expr_unsigned): Remove.
* tests/dd/skip-seek-past-dev.sh (DEV_OFLOW):
* tests/id/setgid.sh (gp1):
* tests/misc/cut-huge-range.sh (CUT_MAX):
* tests/misc/expr.pl:
* tests/misc/sort-discrim.sh:
Assume expr works on bignums.
* tests/misc/cut-huge-range.sh (subtract_one):
Remove; no longer needed.

5 years agofactor: simplify tests by assuming libgmp
Paul Eggert [Wed, 8 Jul 2020 06:48:53 +0000 (23:48 -0700)] 
factor: simplify tests by assuming libgmp

* tests/misc/factor.pl: Test bignums even if !HAVE_GMP.

5 years agomaint: use Gnulib libgmp module
Paul Eggert [Tue, 7 Jul 2020 17:39:10 +0000 (10:39 -0700)] 
maint: use Gnulib libgmp module

This lets use assume multiple-precision arithmetic on all
platforms, simplifying the code.
* bootstrap.conf (gnulib_modules): Add libgmp.
* configure.ac: Don’t call cu_GMP, as this is now done by Gnulib.
* m4/gmp.m4: Remove.
* src/expr.c, src/factor.c: Use gmp.h unconditionally.
* src/factor.c: Use the simpler ‘#ifndef mpz_inits’ to
determine whether there is an mpz_inits macro.

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 7 Jul 2020 03:35:25 +0000 (20:35 -0700)] 
build: update gnulib submodule to latest

5 years agodoc: add timeout examples
Bernhard Voelker [Fri, 3 Jul 2020 22:19:31 +0000 (00:19 +0200)] 
doc: add timeout examples

* doc/coreutils.texi (timeout invocation): Add examples.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-06/msg00018.html

5 years agotests: avoid spurious testsuite failure
Andreas Schwab [Tue, 30 Jun 2020 11:05:55 +0000 (13:05 +0200)] 
tests: avoid spurious testsuite failure

* tests/dd/stats.sh: Increase timeout.
Fixes https://bugs.gnu.org/42135

5 years agotests: fix false failure with valgrind and reflink
Pádraig Brady [Fri, 26 Jun 2020 18:57:09 +0000 (19:57 +0100)] 
tests: fix false failure with valgrind and reflink

* tests/cp/fiemap-FMR.sh: Avoid FICLONE ioctl,
which would avoid the point of the test (fiemap testing).
Also it avoids a valgrind bug with this ioctl:
https://bugs.kde.org/show_bug.cgi?id=397605

5 years agocp: use copy_file_range if available
Paul Eggert [Fri, 26 Jun 2020 00:34:23 +0000 (17:34 -0700)] 
cp: use copy_file_range if available

* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add copy-file-range.
* src/copy.c (sparse_copy): Try copy_file_range if not
looking for holes.

5 years agocp: use SEEK_DATA/SEEK_HOLE if available
Paul Eggert [Thu, 25 Jun 2020 23:31:44 +0000 (16:31 -0700)] 
cp: use SEEK_DATA/SEEK_HOLE if available

If it works, prefer lseek with SEEK_DATA and SEEK_HOLE to FIEMAP,
as lseek is simpler and more portable (will be in next POSIX).
Problem reported in 2011 by Jeff Liu (Bug#8061).
* NEWS: Mention this.
* src/copy.c (lseek_copy) [SEEK_HOLE]: New function.
(enum scantype): New constants ERROR_SCANTYPE, LSEEK_SCANTYPE.
(union scan_inference): New type.
(infer_scantype): Last arg is now union scan_inference *,
not struct extent_scan *.  All callers changed.
Prefer SEEK_HOLE to FIEMAP if both work, since
SEEK_HOLE is simpler and more portable.
(copy_reg): Do the fdadvise after initial scan, in case the scan
fails.  Report an error if the initial scan fails.
(copy_reg) [SEEK_HOLE]: Use lseek_copy if scantype says so.

5 years agocp: avoid copy_reg goto
Paul Eggert [Thu, 25 Jun 2020 00:05:20 +0000 (17:05 -0700)] 
cp: avoid copy_reg goto

* src/copy.c (copy_reg): Redo to avoid label and goto.

5 years agocp: refactor extent_copy
Paul Eggert [Wed, 24 Jun 2020 02:18:04 +0000 (19:18 -0700)] 
cp: refactor extent_copy

* src/copy.c (extent_copy): New arg SCAN, replacing
REQUIRE_NORMAL_COPY.  All callers changed.
(enum scantype): New type.
(infer_scantype): Rename from is_probably_sparse and return
the new type.  Add args FD and SCAN.  All callers changed.

5 years agomaint: typo fix
Paul Eggert [Fri, 26 Jun 2020 01:10:49 +0000 (18:10 -0700)] 
maint: typo fix

* NEWS: Fix typo.

5 years agochmod: man page fixes
Paul Eggert [Tue, 23 Jun 2020 15:41:20 +0000 (08:41 -0700)] 
chmod: man page fixes

* man/chmod.x: Mention -6000 too.  Use .BR to fix trailing period.

5 years agodoc: fix punctuation in man pages
Pádraig Brady [Sat, 20 Jun 2020 17:20:04 +0000 (18:20 +0100)] 
doc: fix punctuation in man pages

* man/chmod.x: Add missing punctuation.
* src/expand-common.c: Likewise.
* src/numfmt.c: Likewise.
* src/rm.c: Likewise.

Fixes https://bugs.gnu.org/41962

5 years agostat,tail: add support for the VBOXSF file system
Bernhard Voelker [Fri, 19 Jun 2020 18:33:55 +0000 (20:33 +0200)] 
stat,tail: add support for the VBOXSF file system

* src/stat.c (human_fstype): Add case for the 'vboxsf' file system type
which is used for VirtualBox Shared Folders mounted in VirtualBox guest
VMs.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/41935

5 years agocp: default to COW
Paul Eggert [Fri, 19 Jun 2020 05:16:24 +0000 (22:16 -0700)] 
cp: default to COW

Likewise for ‘install’.  Proposed in Bug#24400, and long past due.
* NEWS:
* doc/coreutils.texi (cp invocation):
* src/copy.h (enum Reflink_type): Document this.
* src/cp.c (cp_option_init):
* src/install.c (cp_option_init): Implement this.

5 years agomaint: avoid signed integer overflows
Tobias Stoeckmann [Sun, 14 Jun 2020 12:47:11 +0000 (14:47 +0200)] 
maint: avoid signed integer overflows

Since -LONG_MIN results in LONG_MIN again, the operation itself is
a signed integer overflow.

This can be observed with the following calls (best if compiled
with -ftrapv or -fsanitize=undefined):

  $ numfmt --padding=-9223372036854775808
  $ seq 1e-9223372036854775808

Technically, the change in seq "reduces" the precision, but a double
or long double that small would be represented as 0 anyway.

* src/numfmt.c: Explicitly disallow --padding=LONG_MIN.
* src/seq.c: Treat 1e$LONG_MIN as 1e-$LONG_MAX.
* tests/misc/numfmt.pl: Add a test case.
* tests/misc/seq-precision.sh: Likewise.

Fixes https://bugs.gnu.org/41850

5 years agodoc: timeout: improve documentation of the exit status
Bernhard Voelker [Sun, 7 Jun 2020 11:58:14 +0000 (12:58 +0100)] 
doc: timeout: improve documentation of the exit status

* doc/coreutils.texi (timeout invocation): Document that the exit
status is 137 when the KILL signal is used, regardless of whether that
signal is sent to COMMAND or timeout.
* src/timeout.c (usage): Likewise. Also split out and expand
on the possible exit status values to a separate table.

Discussed at https://bugs.gnu.org/41634

5 years agomaint: use getrandom, not getentropy
Paul Eggert [Mon, 1 Jun 2020 22:53:27 +0000 (15:53 -0700)] 
maint: use getrandom, not getentropy

This makes for one Gnulib module less, and at runtime there’s
typically just one getrandom syscall instead of several for large
nonces.
* gl/lib/randread.c: Include sys/random.h instead of sys/time.h
and unistd.h.
(get_nonce): Use getrandom, not getentropy.
* gl/modules/randread (Depends-on):
Depend on getrandom, not getentropy.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Say "getrandom" rather than "getentropy" in (unlikely) diagnostic.

5 years agomaint: use getentropy and new tempname modules
Paul Eggert [Mon, 1 Jun 2020 05:21:34 +0000 (22:21 -0700)] 
maint: use getentropy and new tempname modules

Update gnulib submodule to latest and use its new features.
Gnulib’s new getentropy module means coreutils can now assume
getentropy instead of approximating it, badly in some cases.
Gnulib’s improvements to the tempname module mean coreutils no
longer needs to maintain private patches.
* bootstrap.conf (gnulib_modules): Remove gettimeofday.
* gl/lib/randread.c (NAME_OF_NONCE_DEVICE): Remove.
(get_nonce): Return success indicator.  Remove bytes_bound arg.
All callers changed.  Rewrite by using getentropy instead of
reading the nonce device and falling back on gettimeofday.
Fail if getentropy fails.
(randread_new): Return NULL (setting errno) if get_nonce fails.
All callers changed.
* gl/lib/tempname.c.diff, gl/lib/tempname.h.diff:
* gl/modules/tempname.diff: Remove.
* gl/modules/randread (Depends-on):
Depend on getentropy, not gettimeofday.
* src/ptx.c (swallow_file_in_memory):
* src/shuf.c (read_input):
Adjust to read_file changes in Gnulib.
* src/shred.c (main):
* src/shuf.c (main):
* src/sort.c (random_md5_state_init):
Diagnose the new form of randread_new failures: randread_new can
fail now when !random_source, meaning getentropy failed.

5 years agoecho: pacify Oracle Studio 12.6
Paul Eggert [Mon, 1 Jun 2020 05:20:34 +0000 (22:20 -0700)] 
echo: pacify Oracle Studio 12.6

* src/echo.c (main): Don’t assign pointer to bool.
This is well-defined in C99, but is arguably bad style
and Oracle Studio 12.6 complains.

5 years agomaint: copy FDL from gnulib instead of using it as module
Bernhard Voelker [Mon, 25 May 2020 14:31:08 +0000 (16:31 +0200)] 
maint: copy FDL from gnulib instead of using it as module

Since the previous gnulib update, bootstrap outputs this warning:

  Notice from module fdl:
    Don't use this module! Instead, copy the referenced license file \
    into your version control repository.

See gnulib commit:
  https://git.sv.gnu.org/cgit/gnulib.git/commit/?id=88fc5afbccc9

* bootstrap.conf (gnulib_modules): Remove 'fdl'.
* doc/fdl.texi: Add file as a copy of 'gnulib/doc/fdl.texi'.
* doc/.gitignore (/fdl.texi): Remove entry.
* cfg.mk (FILTER_LONG_LINES): Add pattern for the 'fdl.texi' file.

5 years agomaint: fix syntax-check failure from recent adjustment
Bernhard Voelker [Sat, 23 May 2020 01:53:59 +0000 (03:53 +0200)] 
maint: fix syntax-check failure from recent adjustment

* cfg.mk (old_NEWS_hash): Regenerate after commit v8.32-15-g6d0107a37

5 years agotests: fix removed-directory test
Bernhard Voelker [Sat, 23 May 2020 00:46:22 +0000 (02:46 +0200)] 
tests: fix removed-directory test

The previous attempt to skip that test on NFS (commit 4181fc518362)
made the test fail; it introduced two problems:
a) In the good case, i.e., when the subshell returns with exit status 0,
the test ran into framework_failure_.
b) As the subshell also runs with 'set -x', the later comparison of
/dev/null with 'err' would fail.

* tests/ls/removed-directory.sh: Revert to the style without subshell,
and add 'test -d .' to verify that 'ls' can read the removed dir.

5 years agodate: document +%-N change
Paul Eggert [Thu, 21 May 2020 00:31:18 +0000 (17:31 -0700)] 
date: document +%-N change

Suggested by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00205.html
* NEWS: Mention the change for coreutils 8.23.
* doc/coreutils.texi (Padding and other flags):
Document it.

5 years agols: port removed-directory test to NFS
Paul Eggert [Thu, 21 May 2020 00:09:03 +0000 (17:09 -0700)] 
ls: port removed-directory test to NFS

* tests/ls/removed-directory.sh:
Port test to NFS, where one gets a stale file handle
when looking at a removed directory.

5 years agodd: omit unnecessary vars when !lint
Paul Eggert [Wed, 20 May 2020 23:47:49 +0000 (16:47 -0700)] 
dd: omit unnecessary vars when !lint

* src/dd.c (real_ibuf, real_obuf) [!lint]:
Remove, as they're needed only when lint checking.
All uses removed when 'lint' is not defined.

5 years agomaint: omit unnecessary pragmas and fix tsort.c
Paul Eggert [Wed, 20 May 2020 23:40:26 +0000 (16:40 -0700)] 
maint: omit unnecessary pragmas and fix tsort.c

* src/chown-core.c, src/comm.c:
* src/tsort.c (record_relation):
Remove GCC 10 pragmas that are not needed in GCC 10.1.0 (the first
public GCC 10 release) and that in some cases cause diagnostics
with GCC 10.1.0.  The tsort.c change fixes a bug that was
inadvertantly introduced when these pragmas were added.

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Wed, 20 May 2020 22:50:38 +0000 (15:50 -0700)] 
build: update gnulib submodule to latest

5 years agomaint: avoid warnings from GCC's -fanalyzer
Pádraig Brady [Sun, 10 May 2020 13:22:06 +0000 (14:22 +0100)] 
maint: avoid warnings from GCC's -fanalyzer

* src/env.c (build_argv): Add an assert() to avoid:
  warning: use of NULL 'n' where non-null expected
  [CWE-690] [-Wanalyzer-null-argument]
  note: argument 1 of 'getenv' must be non-null
* src/dd.c (alloc_ibuf): Don't discard the allocated pointer, to avoid:
  [CWE-401] [-Wanalyzer-malloc-leak]
(alloc_obuf): Likewise.
(cleanup): Deallocate the now tracked buffers which
also avoids "possibly lost" warnings from valgrind.
* src/tsort.c (search_item): Add asserts to avoid:
  [CWE-690] [-Wanalyzer-null-dereference]
(record_relation): An assert doesn't suffice here,
so disable the warning for this function.
* src/comm.c: Suppress the following false positive for the whole file:
  [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
* src/chown-core.c: Suppress the following false positive for the file:
  [CWE-415] [-Wanalyzer-double-free]

5 years agols: allow --classify to be ignored for non tty output
Jason Kim [Sun, 19 Apr 2020 08:40:16 +0000 (01:40 -0700)] 
ls: allow --classify to be ignored for non tty output

Have the `ls` `--classify` option take an optional argument for when to
classify ("always", "auto", "never"), just like the optional argument
for `--color`.  When the optional argument is not specified, default to
"always" for backwards compatibility.

* src/ls.c (usage): Update help text.
(decode_switches): Support an optional argument for --classify.
* tests/ls/classify.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

5 years agobuild: update gnulib to latest - to avoid du(1) crash on XFS
Bernhard Voelker [Tue, 21 Apr 2020 21:00:43 +0000 (23:00 +0200)] 
build: update gnulib to latest - to avoid du(1) crash on XFS

Pull in a fix for FTS to avoid a crash when traversing a heavily
changed XFS file system:

> fts: remove NOSTAT_LEAF_OPTIMIZATION

* NEWS (Bug fixes): Mention the fix.
* gnulib: Update to latest.
* bootstrap: Sync from gnulib/build-aux/bootstrap.

Discussed at:
<https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html>

5 years agomaint: clean up recently added test
Pádraig Brady [Thu, 2 Apr 2020 15:10:05 +0000 (16:10 +0100)] 
maint: clean up recently added test

* tests/misc/uniq-collate.sh: Remove logic that
was already refactored into gen_input().

5 years agocp: ensure --attributes-only doesn't remove files
Pádraig Brady [Wed, 1 Apr 2020 11:51:34 +0000 (12:51 +0100)] 
cp: ensure --attributes-only doesn't remove files

* src/copy.c (copy_internal): Ensure we don't unlink the destination
unless explicitly requested.
* tests/cp/attr-existing.sh: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/40352

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 28 Mar 2020 19:16:18 +0000 (12:16 -0700)] 
build: update gnulib submodule to latest

* src/selinux.c: Do not include dosname.h; not needed, since
system.h does that for us via dirname.h.

5 years agomaint: add texi2dvi build directory to doc/.gitignore
Bernhard Voelker [Sun, 15 Mar 2020 10:20:41 +0000 (11:20 +0100)] 
maint: add texi2dvi build directory to doc/.gitignore

* doc/.gitignore (/coreutils.t2p/): Add entry for the build directory
left behind after 'make pdf'.
While at it, sort the file.

5 years agols: improve removed-directory test
Paul Eggert [Sat, 7 Mar 2020 18:29:51 +0000 (10:29 -0800)] 
ls: improve removed-directory test

* tests/ls/removed-directory.sh: Remove host_triplet test.
Skip this test if one cannot remove the working directory.
From a suggestion by Bernhard Voelker (Bug#39929).

5 years agols: restore 8.31 behavior on removed directories
Paul Eggert [Fri, 6 Mar 2020 01:25:29 +0000 (17:25 -0800)] 
ls: restore 8.31 behavior on removed directories

* NEWS: Mention this.
* src/ls.c: Do not include <sys/sycall.h>
(print_dir): Don't worry about whether the directory is removed.
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
behavior.

5 years agomaint: post-release administrivia
Pádraig Brady [Thu, 5 Mar 2020 14:04:42 +0000 (14:04 +0000)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

5 years agoversion 8.32 v8.32
Pádraig Brady [Thu, 5 Mar 2020 13:23:50 +0000 (13:23 +0000)] 
version 8.32

* NEWS: Record release date.

5 years agotests: don't rely on system env(1) being present
Pádraig Brady [Wed, 4 Mar 2020 15:56:52 +0000 (15:56 +0000)] 
tests: don't rely on system env(1) being present

* tests/misc/env-S.pl: `env -i env` will call the system env
due to the path being cleared, so pass the absolute path
of our env binary under test to avoid that.  This was seen
to be an issue on Guix where /usr/bin/env was not available.

5 years agobasenc: avoid undefined behaviour in z85 processing
Pádraig Brady [Wed, 4 Mar 2020 12:24:49 +0000 (12:24 +0000)] 
basenc: avoid undefined behaviour in z85 processing

* src/basenc.c (z85_decode_ctx_init): Ensure we're working
with unsigned, as otherwise ubsan triggers with:
  src/basenc.c:767:18: runtime error: signed integer overflow:
  43 * 52200625 cannot be represented in type 'int'
(z85_encode): Likewise to avoid the usban error:
  src/basenc.c:630:26: runtime error:
  left shift of 134 by 24 places cannot be represented in type 'int'

5 years agotests: avoid a false failure on OpenIndiana 11
Pádraig Brady [Sun, 1 Mar 2020 22:28:29 +0000 (22:28 +0000)] 
tests: avoid a false failure on OpenIndiana 11

* tests/misc/timeout-parameters.sh: Split the large timeout
handling to ...
* tests/misc/timeout-large-parameters.sh: ... here, so that
the 3 second delay is contained in its own test, and if
the test is skipped due invalid handling within timeout(1),
it will be more apparent.
Also adjust the check so we skip whenever the kernel timer
fires immediately, to handle the buggy OpenIndiana 11 kernel also.
Reported by Bruno Haible.

5 years agotests: avoid a hang on GNU/Hurd from 2019
Pádraig Brady [Sun, 1 Mar 2020 22:03:38 +0000 (22:03 +0000)] 
tests: avoid a hang on GNU/Hurd from 2019

* tests/du/8gb.sh: Add a timeout around:
`dd bs=1 seek=8G of=big < /dev/null`

5 years agotests: use bash in some scripts to avoid false failures
Pádraig Brady [Sun, 1 Mar 2020 21:49:16 +0000 (21:49 +0000)] 
tests: use bash in some scripts to avoid false failures

* init.cfg (require_bash_as_SHELL_): A new function to replace
SHELL for the current test, with bash if available.
This is useful on OpenIndiana 11 where /bin/sh was seen
to have races in handling of SIGPIPE.
* tests/misc/seq-epipe.sh: Use the new function to enforce bash.
* tests/misc/env-signal-handler.sh: Likewise.
Reported by Bruno Haible

5 years agotests: improve test coverage for ls stat checks
Pádraig Brady [Sun, 1 Mar 2020 12:36:35 +0000 (12:36 +0000)] 
tests: improve test coverage for ls stat checks

* tests/ls/stat-free-color.sh: Check for the availability
of various stat calls individually, and add statx() and fstatat64()
to the list to check.  Fix the stat counting logic to
ignore lines like "+++ exited with 0 +++".
* tests/ls/stat-free-symlinks.sh: Check syscalls other than stat().

5 years agotests: enable 4 more tests to be executed on FreeBSD
Bruno Haible [Sun, 1 Mar 2020 02:03:59 +0000 (03:03 +0100)] 
tests: enable 4 more tests to be executed on FreeBSD

* init.cfg (gcc_shared_libs_): New variable.
(gcc_shared_): Use it, instead of hardcoding -ldl.
(require_gcc_shared_): Determine the suitable value
for gcc_shared_libs_.

5 years agotests: fix incorrect `|| fail` pattern in tests
Pádraig Brady [Sat, 29 Feb 2020 20:48:58 +0000 (20:48 +0000)] 
tests: fix incorrect `|| fail` pattern in tests

* tests/ls/stat-free-symlinks.sh: s/|| fail/|| fail=1/.
* tests/misc/tee.sh: Likewise.
* tests/touch/relative.sh: Likewise.
* cfg.mk (sc_prohibit_or_fail): A new syntax-check to avoid this.

5 years agotests: avoid false failures on darwin 19.2.0
Pádraig Brady [Sat, 29 Feb 2020 20:23:44 +0000 (20:23 +0000)] 
tests: avoid false failures on darwin 19.2.0

With these adjustments, all tests pass on macOS Catalina.

* tests/dd/sparse.sh: Adjust so that systems like apfs that
don't create holes < 16 MiB do not fail erroneously.
* tests/touch/trailing-slash.sh: Darwin was seen to dereference
symlinks to files when given a trailing slash, so avoid
that particular case.

5 years agotests: fix test failure on FreeBSD 12
Bruno Haible [Sat, 29 Feb 2020 21:33:04 +0000 (22:33 +0100)] 
tests: fix test failure on FreeBSD 12

* tests/misc/csplit-io-err.sh: Limit the effect of the fwrite
override to streams != stderr, as fwrite is in the error() path there.

5 years agobuild: once again distribute .tar.gz files
Jan Nieuwenhuizen [Thu, 27 Feb 2020 21:40:23 +0000 (21:40 +0000)] 
build: once again distribute .tar.gz files

* configure.ac: Reenable distribution of gzip-compressed
tarballs, for Guix bootstrapping reasons as discussed at:
https://lists.gnu.org/r/coreutils/2020-02/msg00042.html
* THANKS.in: Remove me, as now a committer.
* NEWS (Build-related): Mention this.

5 years agomaint: ensure .deps/ in the project root is ignored by git
Pádraig Brady [Thu, 27 Feb 2020 16:44:03 +0000 (16:44 +0000)] 
maint: ensure .deps/ in the project root is ignored by git

* .gitignore: s|*/.deps/|.deps|

5 years agodoc: remove older ChangeLog items
Pádraig Brady [Thu, 27 Feb 2020 16:11:42 +0000 (16:11 +0000)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.23 which is now about 5 years old.

5 years agols: issue error message on removed directory
Colin Watson [Tue, 11 Feb 2020 10:45:46 +0000 (10:45 +0000)] 
ls: issue error message on removed directory

If the current directory has been removed, then "ls" confusingly
produced no output and no error message, indistinguishable from
running on an empty directory.

* src/ls.c (print_dir): Report ENOENT on GNU/Linux if readdir
finds no directory entries at all, not even "." or "..",
and a recheck with the getdents syscall returns ENOENT.
We recheck with getdents() as POSIX states that
"The directory entries for dot and dot-dot are optional".
* tests/ls/removed-directory.sh: New file.
* tests/local.mk (all_tests): Add new test.
* NEWS: Mention the change in behavior.
Reported by Owen Thomas.