]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 17 Jul 2021 20:47:56 +0000 (15:47 -0500)] 
build: update gnulib submodule to latest

4 years agomaint: fix white space
Paul Eggert [Sun, 18 Jul 2021 05:12:29 +0000 (00:12 -0500)] 
maint: fix white space

4 years agoenv: fix usage typo
Paul Eggert [Sat, 17 Jul 2021 20:07:29 +0000 (15:07 -0500)] 
env: fix usage typo

* src/env.c (usage): Fix pluralization typo.

4 years agodf: fix duplicated remote entries due to bind mounts
Kamil Dudka [Wed, 30 Jun 2021 15:53:22 +0000 (17:53 +0200)] 
df: fix duplicated remote entries due to bind mounts

As originally reported in <https://bugzilla.redhat.com/1962515>,
df invoked without -a printed duplicated entries for NFS mounts
of bind mounts.  This is a regression from commit v8.25-54-g1c17f61ef99,
which introduced the use of a hash table.

The proposed patch makes sure that the devlist entry seen the last time
is used for comparison when eliminating duplicated mount entries.  This
way it worked before introducing the hash table.

Patch co-authored by Roberto Bergantinos.

* src/ls.c (struct devlist): Introduce the seen_last pointer.
(devlist_for_dev): Return the devlist entry seen the last time if found.
(filter_mount_list): Remember the devlist entry seen the last time for
each hashed item.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/49298

4 years agotail: use poll, not select
Paul Eggert [Sun, 27 Jun 2021 01:23:52 +0000 (18:23 -0700)] 
tail: use poll, not select

This fixes an unlikely stack out-of-bounds write reported by
Stepan Broz via Kamil Dudka (Bug#49209).
* bootstrap.conf (gnulib_modules): Replace select with poll.
* src/tail.c: Do not include <sys/select.h>.
[!_AIX]: Include poll.h.
(check_output_alive) [!_AIX]: Use poll instead of select.
(tail_forever_inotify): Likewise.  Simplify logic, as there is no
need for a ‘while (len <= evbuf_off)’ loop.

4 years agotail: fix abuse2 test race
Paul Eggert [Sun, 27 Jun 2021 01:23:52 +0000 (18:23 -0700)] 
tail: fix abuse2 test race

* tests/tail-2/inotify-hash-abuse2.sh (fastpoll):
Fix race where tailed file ‘f’ temporarily did not exist.

4 years agomaint: while (1) → while (true)
Paul Eggert [Sun, 27 Jun 2021 01:23:52 +0000 (18:23 -0700)] 
maint: while (1) → while (true)

4 years agomaint: remove redundant checks on buffer sizes in tail
Nikolay Nechaev [Sun, 20 Jun 2021 14:54:01 +0000 (17:54 +0300)] 
maint: remove redundant checks on buffer sizes in tail

* src/tail.c: remove redundant size checks before calls to
`xwrite_stdout`

4 years agostat: use decomposed decimal device numbers by default
Pádraig Brady [Sun, 20 Jun 2021 20:26:21 +0000 (21:26 +0100)] 
stat: use decomposed decimal device numbers by default

* src/stat.c (default_format): Use decomposed decimal
representation (major,minor) in the default format.
This is least ambiguous for human interpretation,
and more consistent with ls for example.
Fixes https://bugs.gnu.org/48960

4 years agostat: support more device number representations
Pádraig Brady [Sun, 20 Jun 2021 14:16:49 +0000 (15:16 +0100)] 
stat: support more device number representations

In preparation for changing the default device number
representation (to decomposed decimal), provide more
formatting options for device numbers.

These new (FreeBSD compat) formatting options are added:

   %Hd  major device number in decimal (st_dev)
   %Ld  minor device number in decimal (st_dev)
   %Hr  major device type in decimal (st_rdev)
   %Lr  minor device type in decimal (st_rdev)
   %r   (composed) device type in decimal (st_rdev)
   %R   (composed) device type in hex (st_rdev)

* doc/coreutils.texi (stat invocation): Document new formats.
* src/stat.c (print_it): Handle the new %H and %L modifiers.
(print_statfs): Adjust to passing the format as two chars
rather than an int.  Using an int was introduced in commit db42ae78,
but using separate chars is cleaner and more extensible.
(print_stat): Likewise.  Handle any modifiers and the new 'r' format.
(usage): Document the new formats.
* tests/misc/stat-fmt.sh: Add a test case for new modifiers.
Addresses https://bugs.gnu.org/48960

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 12 Jun 2021 00:41:37 +0000 (17:41 -0700)] 
build: update gnulib submodule to latest

Coreutils mistakenly did not list xstrndup as a module
that it depends on directly.  When the latest Gnulib removed
the dirname module's dependency on xstrndup, this mistake
caused coreutils to not build.  Since all of Coreutils's
uses of xstrndup know the string length, xmemdup0 is a better
match for what's needed.  Since the size args are typically
signed or derived from subtracting pointers, the new Gnulib
ximemdup0 function is a better match yet.
So, use ximemdup0 instead of xstrndup.
* src/cut.c, src/dircolors.c, src/expand-common.c, src/expand.c:
* src/numfmt.c, src/set-fields.c, src/unexpand.c:
Do not include xstrndup.h; no longer needed.
* src/dircolors.c (parse_line):
* src/expand-common.c (parse_tab_stops):
* src/numfmt.c (parse_format_string):
* src/set-fields.c (set_fields):
Use ximemdup0 instead of xstrndup.

4 years agomaint: bootstrap: remove reference to unused hash-pjw module
Jim Meyering [Thu, 26 Nov 2020 01:08:59 +0000 (15:08 -1000)] 
maint: bootstrap: remove reference to unused hash-pjw module

* bootstrap.conf (gnulib_modules): Remove hash-pjw. No longer used.

4 years agobuild: update gnulib submodule to latest
Pádraig Brady [Sat, 15 May 2021 19:33:26 +0000 (20:33 +0100)] 
build: update gnulib submodule to latest

Fixes a false test failure with MALLOC_CHECK_ set.

* gnulib: Update to latest.

4 years agocopy: remove fiemap logic
Pádraig Brady [Sat, 15 May 2021 11:40:45 +0000 (12:40 +0100)] 
copy: remove fiemap logic

This is now only used on 10 year old linux kernels,
and performs a sync before each copy.

* src/copy.c (extent_copy): Remove function and all callers.
* src/extent-scan.c: Remove.
* src/extent-scan.h: Remove.
* src/fiemap.h: Remove.
* src/local.mk: Adjust for removed files.
* NEWS: Adjust to say fiemap is removed.

4 years agocopy: disallow copy_file_range() on Linux kernels before 5.3
Pádraig Brady [Wed, 12 May 2021 22:47:38 +0000 (23:47 +0100)] 
copy: disallow copy_file_range() on Linux kernels before 5.3

copy_file_range() before Linux kernel release 5.3 had many issues,
as described at https://lwn.net/Articles/789527/, which was
referenced from https://lwn.net/Articles/846403/; a more general
article discussing the generality of copy_file_range().
Linux kernel 5.3 was released in September 2019, which is new enough
that we need to actively avoid older kernels.

* src/copy.c (functional_copy_file_range): A new function
that returns false for Linux kernels before version 5.3.
(sparse_copy): Call this new function to gate use of
copy_file_range().

4 years agotests: fix tests/cp/sparse-2.sh false failure on some systems
Pádraig Brady [Sun, 9 May 2021 22:41:00 +0000 (23:41 +0100)] 
tests: fix tests/cp/sparse-2.sh false failure on some systems

* tests/cp/sparse-2.sh: Double check cp --sparse=always,
with dd conv=sparse, in the case where the former didn't
create a sparse file.  Now that this test is being newly run
on macos, we're seeing a failure due to seek() not creating
holes on apfs unless the size is >= 16MiB.

4 years agotests: ensure we test SEEK_DATA where used
Pádraig Brady [Sun, 9 May 2021 13:29:01 +0000 (14:29 +0100)] 
tests: ensure we test SEEK_DATA where used

fiemap is no longer the default copy implementation,
so check for SEEK_DATA support instead as that's preferred.
This will ensure better test coverage on systems without fiemap.

* init.cfg: Replace fiemap_capable_ with seek_data_capable_.
This is best supported with python 3 so prefer that.
* tests/seek-data-capable: A new test script checking for
SEEK_DATA support on the passed file name,
called from seek_data_capable_.
* tests/fiemap-capable: Remove no longer used probing script.
* tests/cp/fiemap-perf.sh: Renamed to tests/cp/sparse-perf.sh
* tests/cp/fiemap-2.sh: Renamed to tests/cp/sparse-2.sh
* tests/cp/fiemap-extents.sh: Renamed to tests/cp/sparse-extents.sh
* tests/cp/sparse-fiemap.sh: Renamed to tests/cp/sparse-extents-2.sh
* tests/cp/fiemap-FMR.sh: Renamed to tests/cp/copy-FMR.sh
* tests/local.mk: Reference the renamed tests.

4 years agocopy: handle system security config issues with copy_file_range()
Pádraig Brady [Sat, 8 May 2021 18:23:20 +0000 (19:23 +0100)] 
copy: handle system security config issues with copy_file_range()

* src/copy.c (sparse_copy): Upon EPERM from copy_file_range(),
fall back to a standard copy, which will give a more accurate
error as to whether the issue is with the source or destination.
Also this will avoid the issue where seccomp or apparmor are
not configured to handle copy_file_range(), in which case
the fall back standard copy would succeed without issue.
This specific issue with seccomp was noticed for example in:
https://github.com/golang/go/issues/40900

4 years agocopy: handle EOPNOTSUPP from SEEK_DATA
Pádraig Brady [Sun, 9 May 2021 20:55:22 +0000 (21:55 +0100)] 
copy: handle EOPNOTSUPP from SEEK_DATA

* src/copy.c (infer_scantype): Ensure we don't error out
if SEEK_DATA returns EOPNOTSUPP, on systems where this value
is distinct from ENOTSUP.  Generally both of these should be checked.

4 years agocopy: handle ENOTSUP from copy_file_range()
Pádraig Brady [Sat, 8 May 2021 16:18:54 +0000 (17:18 +0100)] 
copy: handle ENOTSUP from copy_file_range()

* src/copy.c (sparse_copy): Ensure we fall back to
a standard copy if copy_file_range() returns ENOTSUP.
This generally is best checked when checking ENOSYS,
but it also seems to be a practical concern on Centos 7,
as a quick search gave https://bugzilla.redhat.com/1840284

4 years agobuild: update gnulib submodule to latest
Pádraig Brady [Mon, 10 May 2021 16:43:03 +0000 (17:43 +0100)] 
build: update gnulib submodule to latest

Fixes a bits/long-double.h include build issue on some systems.

* bootstrap: Sync new --version option from gnulib.
* gnulib: Update to lastest.
Reported by Carl Edquist

4 years agobuild: fix __get_cpuid_count check to catch link failure
Carl Edquist [Mon, 10 May 2021 10:22:11 +0000 (05:22 -0500)] 
build: fix __get_cpuid_count check to catch link failure

The test program will compile successfully even if __get_cpuid_count
is not declared.  The error for the missing symbol will only show up
at link time.  Thus, use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE.

* configure.ac (__get_cpuid_count check): Use C_LINK_IFELSE instead
of AC_COMPILE_IFELSE.
(__get_cpuid check): Likewise.

4 years agomaint: consistently free hash structures in dev mode
Pádraig Brady [Mon, 3 May 2021 17:11:04 +0000 (18:11 +0100)] 
maint: consistently free hash structures in dev mode

Ensure we call hash_free() to avoid valgrind and leak_sanitizer
"definitely lost" warnings.  These were not real leaks as
we terminate immediately after, but we should avoid these
"definitely lost" warnings where possible.

* src/copy.c: Add dest_info_free() and src_info_free().
* src/copy.h: Declare the above.
* src/cp-hash.c: Don't define unless "lint" is defined.
* src/install.c: Call dest_info_free() in dev mode.
* src/mv.c: Likewise.
* src/cp.c: Likewise. Also call src_info_free().
* src/ln.c: Call hash_free() in dev mode.
* src/tail.c: Call hash_free() even if about to exit, in dev mode.

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

4 years agomaint: fix sc_space_before_open_paren failure
Bernhard Voelker [Thu, 6 May 2021 21:38:53 +0000 (23:38 +0200)] 
maint: fix sc_space_before_open_paren failure

* src/copy.c (dest_info_init): Add space before parens.
(src_info_init): Likewise.
Syntax-check failure introduced in the previous commit.

4 years agocopy: exit immediately upon failure to allocate hash memory
Pádraig Brady [Mon, 3 May 2021 17:53:35 +0000 (18:53 +0100)] 
copy: exit immediately upon failure to allocate hash memory

* src/copy.c (dest_info_init, src_info_init): Terminate immediately
upon memory exhaustion.

4 years agocopy: ensure we enforce --reflink=never
Pádraig Brady [Sun, 2 May 2021 20:27:17 +0000 (21:27 +0100)] 
copy: ensure we enforce --reflink=never

* src/copy.c (sparse_copy): Don't use copy_file_range()
with --reflink=never as copy_file_range() may implicitly
use acceleration techniques like reflinking.
(extent_copy): Pass through whether we allow reflinking.
(lseek_copy): Likewise.
Fixes https://bugs.gnu.org/48164

4 years agowc: add --debug to diagnose which implementation used
Pádraig Brady [Sat, 1 May 2021 19:02:02 +0000 (20:02 +0100)] 
wc: add --debug to diagnose which implementation used

* src/wc.c: (main): Handle the new --debug option.
Only call avx2_supported if needed.
(avx2_supported): Diagnose various failures and attempts.
* NEWS: Mention the new wc improvement and --debug option.

4 years agowc: use avx2 optimization when counting only lines
Kristoffer Brånemyr [Sat, 20 Feb 2021 11:27:17 +0000 (12:27 +0100)] 
wc: use avx2 optimization when counting only lines

Use cpuid to detect CPU support for avx2 instructions.
Performance was seen to improve by 5x for a file with only newlines,
while the performance for a file with no such characters is unchanged.

* configure.ac [USE_AVX2_WC_LINECOUNT]: A new conditional,
set when __get_cpuid_count() and avx2 compiler intrinsics are supported.
* src/wc.c (avx2_supported): A new function using __get_cpuid_count()
to determine if avx2 instructions are supported.
(wc_lines): A new function refactored from wc(),
which implements the standard line counting logic,
and provides the fallback implementation for when avx2 is not supported.
* src/wc_avx2.c: A new module to implement using avx2 intrinsics.
* src/local.mk: Reference the new module.  Note we build as a separate
lib so that it can be portably built with separate -mavx2 etc. flags.

4 years agotouch: fix wrong diagnostic (Bug#48106)
Paul Eggert [Sat, 1 May 2021 22:19:16 +0000 (15:19 -0700)] 
touch: fix wrong diagnostic (Bug#48106)

Problem reported by Roland (Bug#48106).
* src/touch.c (touch): Take more care when deciding whether
to use open_errno or utime_errno in the diagnostic.
Stop worrying about SunOS 4 (which as part of the problem),
as it’s long obsolete.  For Solaris 10, verify that EINVAL
really means the file was a directory.

4 years agomaint: port to Autoconf 2.71
Paul Eggert [Tue, 27 Apr 2021 06:27:59 +0000 (23:27 -0700)] 
maint: port to Autoconf 2.71

* configure.ac: Use AC_PROG_CC, not AC_PROG_CC_STDC.
* gl/modules/smack (configure.ac):
* m4/jm-macros.m4 (coreutils_MACROS):
* m4/xattr.m4 (gl_FUNC_XATTR):
Use AS_HELP_STRING, not AC_HELP_STRING.
* m4/check-decl.m4 (gl_CHECK_DECLS):
Do not require AC_HEADER_TIME; we no longer care about it directly.
* m4/jm-macros.m4 (coreutils_MACROS):
Do not require AC_ISC_POSIX, which became obsolete in 2006.
Use AC_LINK_IFELSE instead of AC_TRY_LINK.

4 years agocsplit: size_t overflow check
Paul Eggert [Tue, 27 Apr 2021 03:04:19 +0000 (20:04 -0700)] 
csplit: size_t overflow check

* src/csplit.c (get_new_buffer): Fix unlikely size_t overflow.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 27 Apr 2021 01:02:16 +0000 (18:02 -0700)] 
build: update gnulib submodule to latest

* src/csplit.c (load_buffer):
* src/pinky.c (create_fullname):
Use intprops-based checks rather than xalloc_oversized,
since Gnulib xalloc.h no longer includes xalloc-oversized.h.

4 years agocopy: do not refuse to copy a swap file
Zorro Lang [Mon, 26 Apr 2021 15:25:18 +0000 (17:25 +0200)] 
copy: do not refuse to copy a swap file

* src/copy.c (sparse_copy): Fallback to read() if copy_file_range()
fails with ETXTBSY.  Otherwise it would be impossible to copy files
that are being used as swap.  This used to work before introducing
the support for copy_file_range() in coreutils.  (Bug#48036)

4 years agotests: fix FP in ls/stat-free-color.sh
Bernhard Voelker [Tue, 20 Apr 2021 22:12:00 +0000 (00:12 +0200)] 
tests: fix FP in ls/stat-free-color.sh

On newer systems like Fedora 34 and openSUSE Tumbleweed, ls(1) calls
newfstatat(STDOUT_FILENO, ...), but only when there is something to
output.

* tests/ls/stat-free-color.sh: Add -a option to the reference invocation
of ls, thus enforcing something gets output.

4 years agodoc: clarify that ln --relative requires --symbolic to be specified
Pádraig Brady [Sun, 11 Apr 2021 14:17:02 +0000 (15:17 +0100)] 
doc: clarify that ln --relative requires --symbolic to be specified

* doc/coreutils.texi (ln invocation): State --symbolic is required.
* src/ln.c (usage): Explicitly state -s is not implied.
Fixes https://bugs.gnu.org/47703

4 years agodoc: clarify what's counted by wc
Pádraig Brady [Sun, 11 Apr 2021 15:24:07 +0000 (16:24 +0100)] 
doc: clarify what's counted by wc

* src/wc.c (usage): State that only printable characters are considered
when counting words.  This also disambiguates wether we're talking
about bytes or characters in this context.
* doc/coreutils.texi (wc invocation): Likewise.  Also clarify
that --characters counts valid locale aware characters,
and that --lines does not count a trailing "line" unless
it ends with a newline character.
Fixes https://bugs.gnu.org/47702

4 years agomaint: use "char const *" rather than "const char *"
Pádraig Brady [Sun, 11 Apr 2021 17:23:21 +0000 (18:23 +0100)] 
maint: use "char const *" rather than "const char *"

* cfg.mk (sc_prohibit-const-char): Add a new syntax-check to
enforce this style.
* *.[ch]: sed -i 's/const char \*/char const */g'

4 years agols: cache name width determination
Pádraig Brady [Sat, 10 Apr 2021 15:54:03 +0000 (16:54 +0100)] 
ls: cache name width determination

This is especially important now for --sort=width,
as that can greatly increase how often this
expensive quote_name_width() function is called per file.

This also helps the default invocation of ls,
or specifically the --format={across,vertical} cases
(when --width is not set to 0),
to avoid two calls to this function per file.

Note the only case where we later compute the width,
is for --format=commas.  That's only done once though,
so we leave the computation close to use to
maximize hardware caching.

* src/ls.c (struct fileinfo): Add a WIDTH member to cache
the screen width of the file name.
(update_current_files_info): Set the WIDTH members for cases
they're needed multiple times.  Note we do this explicitly here,
rather than caching at use, so that the fileinfo
structures can remain const in the sorting and presentation functions.
(sort_files): Call the new update_current_files_info() in this
initialization function.
(fileinfo_name_width): Renamed from fileinfo_width,
and adjusted to return the cached value if available.

4 years agols: add --sort=width option to sort by file name width
Carl Edquist [Fri, 26 Mar 2021 09:27:54 +0000 (04:27 -0500)] 
ls: add --sort=width option to sort by file name width

This helps identify the outliers for long filenames, and also produces
a more compact display of columns when listing a directory with many
entries of various widths.

* src/ls.c (sort_type, sort_types, sort_width): New sort_width sort
type.
(sort_args): Add "width" sort arg.
(cmp_width, fileinfo_width): New sort function and helper for file name
width.
(quote_name_width): Add function prototype declaration.
(usage): Document --sort=width option.
* doc/coreutils.texi: Document --sort=width option.
* tests/ls/sort-width-option.sh: New test for --sort=width option.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.

4 years agoenv: simplify --split-string memory management
Paul Eggert [Tue, 30 Mar 2021 04:42:44 +0000 (21:42 -0700)] 
env: simplify --split-string memory management

* bootstrap.conf (gnulib_modules): Add idx.
* src/env.c: Include idx.h, minmax.h.
Prefer idx_t to ptrdiff_t when values are nonnegative.
(valid_escape_sequence, escape_char, validate_split_str)
(CHECK_START_NEW_ARG):
Remove; no longer needed now that we validate as we go.
(struct splitbuf): New type.
(splitbuf_grow, splitbuf_append_byte, check_start_new_arg)
(splitbuf_finishup): New functions.
(build_argv): New arg ARGC.  Validate and process in one go, using
the new functions; this is simpler and more reliable than the old
approach (as witness the recent bug).  Avoid integer overflow in
the unlikely case where the string contains more than INT_MAX
arguments.
(parse_split_string): Simplify by exploiting the new build_argv.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 29 Mar 2021 03:28:01 +0000 (20:28 -0700)] 
build: update gnulib submodule to latest

4 years agotests: add a test case for recent env fix
Pádraig Brady [Mon, 29 Mar 2021 14:47:20 +0000 (15:47 +0100)] 
tests: add a test case for recent env fix

* tests/misc/env-S.pl: Add a test case for recent commit ec6904f0.

4 years agomaint: ignore all .a files in .gitignore
Pádraig Brady [Mon, 29 Mar 2021 13:02:20 +0000 (14:02 +0100)] 
maint: ignore all .a files in .gitignore

* .gitignore: Rather than add the new src/libcksum_pclmul.a,
just ignore any such libs.
* src/.gitignore: Likewise.
Reported by Kristoffer Brånemyr.

4 years agoenv: prefer ptrdiff_t
Paul Eggert [Fri, 26 Mar 2021 21:56:36 +0000 (14:56 -0700)] 
env: prefer ptrdiff_t

* src/env.c (usvars_used, vnlen, unset_envvars, expansion)
(build_argv): Prefer ptrdiff_t to size_t when either will do.

4 years agoenv: improve whitespace warning
Paul Eggert [Fri, 26 Mar 2021 21:51:55 +0000 (14:51 -0700)] 
env: improve whitespace warning

* src/env.c (main): Issue -S warning for any whitespace,
not just space.

4 years agoenv: use GNU coding style
Paul Eggert [Fri, 26 Mar 2021 21:47:03 +0000 (14:47 -0700)] 
env: use GNU coding style

* src/env.c: Use GNU coding style for recentish changes.

4 years agoenv: remove asserts
Paul Eggert [Fri, 26 Mar 2021 21:06:26 +0000 (14:06 -0700)] 
env: remove asserts

The assertions didn’t help catch the most recent bug which
was in their area, and kind of get in the way.
* src/env.c: Do not include <assert.h>, and remove all assertions.
These seem to have been put in to pacify gcov, but surely there’s
a better way.
(escape_char): Pacify GCC with 'assume' instead.

4 years agodoc: document env fix
Paul Eggert [Fri, 26 Mar 2021 21:00:37 +0000 (14:00 -0700)] 
doc: document env fix

* NEWS, doc/coreutils.texi (env invocation): Document recent change.

4 years agoenv: fix address violation with '\v' in -S
Paul Eggert [Fri, 26 Mar 2021 20:49:49 +0000 (13:49 -0700)] 
env: fix address violation with '\v' in -S

Problem reported by Frank Busse (Bug#47412).
* src/env.c (C_ISSPACE_CHARS): New macro.
(shortopts, build_argv, main): Treate all C-locale space
characters like space and tab, for compatibility with FreeBSD.
(validate_split_str, build_argv, parse_split_string):
Use the C locale, not the current locale, to determine whether a
byte is a space character.

4 years agohostname: pacify valgrind
Paul Eggert [Thu, 25 Mar 2021 18:20:18 +0000 (11:20 -0700)] 
hostname: pacify valgrind

* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).

4 years agohostname: use puts
Paul Eggert [Thu, 25 Mar 2021 16:16:36 +0000 (09:16 -0700)] 
hostname: use puts

* src/hostname.c (main): Prefer puts to printf "%s\n".

4 years agomaint: indenting
Paul Eggert [Thu, 25 Mar 2021 16:15:50 +0000 (09:15 -0700)] 
maint: indenting

* src/ln.c: Fix indenting.

4 years agoln: fix memory leaks in do_link
Kamil Dudka [Thu, 25 Mar 2021 10:57:56 +0000 (11:57 +0100)] 
ln: fix memory leaks in do_link

* src/ln.c (do_link): Free memory allocated by convert_abs_rel
on all code paths (Bug#47373).

4 years agostdbuf: port lib to macOS
Paul Eggert [Wed, 24 Mar 2021 23:59:40 +0000 (16:59 -0700)] 
stdbuf: port lib to macOS

* src/libstdbuf.c (fprintf, free, strtoumax): Undef these too,
since Gnulib might replace them.

4 years agocksum: port recent changes to macOS
Paul Eggert [Wed, 24 Mar 2021 23:43:05 +0000 (16:43 -0700)] 
cksum: port recent changes to macOS

* src/cksum.c (cksum_slice8): Fix bug on little-endian
platforms lacking __bswap_32: the SWAP macro evaluates
its argument multiple times, but the macro has a side effect.

4 years agomaint: update bootstrap from gnulib
Bernhard Voelker [Mon, 22 Mar 2021 22:45:30 +0000 (23:45 +0100)] 
maint: update bootstrap from gnulib

* bootstrap: Sync from gnulib/build-aux/bootstrap; the previous gnulib
update (commit 1a3eb6c30) missed to update that file.

4 years agoptx: remove use of diacrit module
Paul Eggert [Sun, 21 Mar 2021 21:00:26 +0000 (14:00 -0700)] 
ptx: remove use of diacrit module

The diacrit module is obsolete, and ptx’s use of it is obsolete
too; it assumes an 8-bit locale (not that common these days) and
that TeX cannot process the 8-bit characters (nowadays, it can).
* NEWS, doc/coreutils.texi (Charset selection in ptx): Document this.
* bootstrap.conf (gnulib_modules): Remove diacrit.
* src/ptx.c: Do not include diacrit.h.
(print_field, fix_output_parameters): Remove obsolete support
for 8-bit diacritics.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 21 Mar 2021 07:03:28 +0000 (00:03 -0700)] 
build: update gnulib submodule to latest

4 years agocksum: don't exit immediately if a single file overflows
Pádraig Brady [Mon, 15 Mar 2021 13:08:26 +0000 (13:08 +0000)] 
cksum: don't exit immediately if a single file overflows

This behavior was introduced in commit FILEUTILS-4_0_44-4-g519b707b4.

* src/cksum.c (cksum_slice8): Only report the overflow, and continue.
* src/cksum_pclmul.c (cksum_pclmul): Likewise.

4 years agocksum: add --debug to diagnose which implementation used
Pádraig Brady [Sat, 13 Mar 2021 18:10:12 +0000 (18:10 +0000)] 
cksum: add --debug to diagnose which implementation used

* src/cksum.c: (main): Use getopt_long to parse options,
and handle the new --debug option.
(pclmul_supported): Diagnose various failures and attempts.
* NEWS: Mention the new option.

4 years agocksum: use pclmul hardware instruction for CRC32 calculation
Kristoffer Brånemyr [Wed, 3 Feb 2021 09:35:22 +0000 (10:35 +0100)] 
cksum: use pclmul hardware instruction for CRC32 calculation

Use cpuid to detect CPU support for hardware instruction.
Fall back to slice by 8 algorithm if not supported.
A 500MiB file improves from 1.40s to 0.67s on an i3-2310M

* configure.ac [USE_PCLMUL_CRC32]: A new conditional,
set when __get_cpuid() and clmul compiler intrinsics are supported.
* src/cksum.c (pclmul_supported): A new function using __get_cpuid()
to determine if pclmul instructions are supported.
(cksum): A new function refactored from cksum_slice8(),
which calls pclmul_supported() and then cksum_slice8()
or cksum_pclmul() as appropriate.
* src/cksum.h: Export the crctab array for use in the new module.
* src/cksum_pclmul.c: A new module to implement using pclmul intrinsics.
* po/POTFILES.in: Reference the new cksum_pclmul module.
* src/local.mk: Likewise.  Note we build it as a separate library
so that it can be portably built with separate -mavx etc. flags.
* tests/misc/cksum.sh: Add new test modes for pertinent buffer sizes.

4 years agomaint: propagate DEPENDENCIES to libs in single binary mode
Pádraig Brady [Sun, 14 Mar 2021 22:43:42 +0000 (22:43 +0000)] 
maint: propagate DEPENDENCIES to libs in single binary mode

build-aux/gen-single-binary.sh (override_single): A new function
to refactor the existing mappings for dir, vdir, and arch.
This function now also sets the DEPENDENCIES variable so that these
dependencies can be maintained later in the script, where
we now propagate the automake generated $(src_$cmd_DEPENDENCIES)
to our equivalent src_libsinglebin_$cmd_a_DEPENDENCIES.
This will ensure that any required libs are built,
which we require in a following change to cksum that
builds part of it as a separate library.

4 years agormdir: diagnose non following of symlinks with trailing slash
Pádraig Brady [Tue, 16 Feb 2021 05:07:40 +0000 (05:07 +0000)] 
rmdir: diagnose non following of symlinks with trailing slash

GNU/Linux is unusual here in that rmdir("symlink/") returns ENOTDIR,
whereas Solaris and FreeBSD at least, will follow the symlink
and remove the target directory.  We don't make the behavior
on Linux kernels consistent, but at least clarify
the confusing error message.

* src/rmdir (main): Output a specific error message for the above case.
(remove_parents): In the error message, don't assume intermediate paths
are directories, as they could be symlinks.
* tests/rmdir/symlink-errors.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.

4 years agostat,tail: add support for the exfat file system
Kamil Dudka [Thu, 18 Feb 2021 10:18:04 +0000 (11:18 +0100)] 
stat,tail: add support for the exfat file system

Bug: https://bugzilla.redhat.com/1921427

* src/stat.c (human_fstype): Add case for the 'exfat' file system type.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/46613

4 years agopr: fix alignment of input tabs to multiple columns
Erik Auerswald [Mon, 15 Feb 2021 21:21:17 +0000 (21:21 +0000)] 
pr: fix alignment of input tabs to multiple columns

This regression was introduced in commit COREUTILS-6_8-58-g553d347d3

* src/pr.c (init_parameters): Process tabs for multiple columns.
* tests/pr/pr-tests.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46422

4 years agocat: extend --show-ends to show \r\n as ^M$
Pádraig Brady [Tue, 9 Feb 2021 23:01:34 +0000 (23:01 +0000)] 
cat: extend --show-ends to show \r\n as ^M$

  - \r\n is common a line end combination
  - catting such a file without options causes it to display normally
  - overwriting the first char with $, loses info

* src/cat.c (cat): Convert \r preceeding a \n to ^M.
* tests/misc/cat-E.sh: New test.
* tests/local.mk: Reference new test.
* tests/misc/cat-proc.sh: Fix typo.
* doc/coreutils.texi (cat invocation): Mention the new behavior.
* NEWS: Mention the improvement.

4 years agoexpr: fix bug with unmatched \(...\)
Paul Eggert [Tue, 26 Jan 2021 17:23:54 +0000 (09:23 -0800)] 
expr: fix bug with unmatched \(...\)

Problem reported by Qiuhao Li.
* NEWS: Mention this.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.

4 years agosplit: fix --number=K/N to output correct part of file
Pádraig Brady [Mon, 25 Jan 2021 14:12:48 +0000 (14:12 +0000)] 
split: fix --number=K/N to output correct part of file

This functionality regressed with the adjustments
in commit v8.25-4-g62e7af032

* src/split.c (bytes_chunk_extract): Account for already read data
when seeking into the file.
* tests/split/b-chunk.sh: Use the hidden ---io-blksize option,
to test this functionality.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46048

4 years agodoc: rmdir --recursive substitutes
Paul Eggert [Tue, 19 Jan 2021 05:08:39 +0000 (21:08 -0800)] 
doc: rmdir --recursive substitutes

* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.

4 years agomkdir: fix bug when -m's more generous than umask
Paul Eggert [Fri, 15 Jan 2021 10:57:59 +0000 (02:57 -0800)] 
mkdir: fix bug when -m's more generous than umask

Problem reported by David McCall (Bug#45886).
I introduced this problem when fixing Bug#14371.
* NEWS: Mention the fix.
* src/mkdir.c (struct mkdir_options): New members umask_ancestor,
umask_self, replacing umask_value.
(make_ancestor): Use them when temporarily adjusting umask.
(main): Set them, and set the umask to umask_self instead
of leaving it alone.
* tests/mkdir/perm.sh (tests): Add test case for bug.

4 years agodoc: modernize and fix regexp xref
Paul Eggert [Sat, 9 Jan 2021 21:04:40 +0000 (13:04 -0800)] 
doc: modernize and fix regexp xref

* doc/coreutils.texi: Fix regexp cross-reference that had become
out-of-date (Bug#45749).  Also, fix some obsolete references to
SunOS and to /usr/dict/words, and change “Linux” to “GNU/Linux”
where appropriate.  Unfortunately the pipeline example gets more
complicated since /usr/share/dict/words is not sorted the way that
‘comm’ wants.

4 years agodoc: make formatting of SEE ALSO in cat.1 and tac.1 consistent
Bernhard Voelker [Sat, 2 Jan 2021 13:57:03 +0000 (14:57 +0100)] 
doc: make formatting of SEE ALSO in cat.1 and tac.1 consistent

None of the coreutils man pages - but the two above - are using bold
setting for the references to other man pages in the SEE ALSO section.

* man/cat.x (SEE ALSO): Remove '\fB...\fP' setting.
* man/tac.x: Likewise, and add a reference to cat(1).

4 years agomaint: exempt 'doc/fdl.texi' from 'make update-copyright'
Bernhard Voelker [Sat, 2 Jan 2021 00:36:19 +0000 (01:36 +0100)] 
maint: exempt 'doc/fdl.texi' from 'make update-copyright'

This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for the above file.
* doc/fdl.texi: Revert the previous change.

4 years agomaint: update all copyright year number ranges
Pádraig Brady [Fri, 1 Jan 2021 16:36:09 +0000 (16:36 +0000)] 
maint: update all copyright year number ranges

Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.

4 years agotests: add a test for cksum
Pádraig Brady [Mon, 28 Dec 2020 15:04:54 +0000 (15:04 +0000)] 
tests: add a test for cksum

* tests/misc/cksum.sh: Test basic operation.
* tests/local.mk: Reference the new test.

4 years agocksum: use more efficient slice by 8 algorithm
Kristoffer Brånemyr [Sat, 26 Dec 2020 23:40:10 +0000 (23:40 +0000)] 
cksum: use more efficient slice by 8 algorithm

A 100MB file improves from 2.50s to 1.80s on a Sparc T5220
A 100MB file improves from 0.54s to 0.13s on an i3-2310M

* bootstrap.conf: Explicitly depend on byteswap,
since now used directly by coreutils.
* src/cksum.c (cksum): Process in multiples of 8 bytes.
(main): Adjust for generation of expanded crctab.
* src/cksum.h: Split now larger crctab to separate header.
* src/local.mk: Reference the new header.
* NEWS: Mention the improvement.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 25 Dec 2020 04:58:22 +0000 (20:58 -0800)] 
build: update gnulib submodule to latest

* src/make-prime-list.c (free): Undef, since Gnulib's free-posix
module now defines this to rpl_free on some platforms.

4 years agodoc: remove extraneous ./src/ prefix from examples
Pádraig Brady [Fri, 18 Dec 2020 14:58:59 +0000 (14:58 +0000)] 
doc: remove extraneous ./src/ prefix from examples

* doc/coreutils.texi (numfmt invocation): s|./src/numfmt|numfmt|

4 years agodoc: add `seq inf` and `sleep inf` examples to texinfo
Pádraig Brady [Fri, 18 Dec 2020 14:49:27 +0000 (14:49 +0000)] 
doc: add `seq inf` and `sleep inf` examples to texinfo

* doc/coreutils.texi (seq invocation): Mention "inf" is supported,
and describe that it's handled specially to generate infinite
whole integer sequences.  Also mention that such infinite generation
is supported for integer steps up to 200.
(sleep invocation): Give `sleep inf` as an example to sleep forever.
* src/seq.c: Add a comment on SEQ_FAST_STEP_LIMIT, to say it's
reflected in the texinfo description.

4 years agodoc: document mkdir -m -p better
Paul Eggert [Tue, 15 Dec 2020 19:52:19 +0000 (11:52 -0800)] 
doc: document mkdir -m -p better

Chris Colohan wrote that the man page did not do enough to dispel
a common misunderstanding that “contributed to one of the scariest
outages Google has ever seen” (Bug#45258).
* doc/coreutils.texi (mkdir invocation):
* src/mkdir.c (usage): Document -m vs -p better.

4 years agonl: fix --section-delimiter handling of single characters
KOBAYASHI Takashi [Mon, 14 Dec 2020 16:17:10 +0000 (16:17 +0000)] 
nl: fix --section-delimiter handling of single characters

* src/nl.c (main): Enforce the POSIX specified
behavior of assuming ':' is specified after a single
character argument to -d.
* tests/misc/nl.sh: Add a test case.
* NEWS: Mention the bug fix.

4 years agodoc: mention the GNU extensions to nl --section-delimiter
Pádraig Brady [Tue, 15 Dec 2020 01:06:50 +0000 (01:06 +0000)] 
doc: mention the GNU extensions to nl --section-delimiter

* doc/coreutils.texi (nl invocation): Mention the GNU extensions
of allowing arbitrary length and empty delimiter strings.
* src/nl.c (usage): Likewise.
* tests/misc/nl.sh: Add test cases for the GNU extensions.

4 years agomaint: refactor nl section delimiter handling
Pádraig Brady [Tue, 15 Dec 2020 01:02:32 +0000 (01:02 +0000)] 
maint: refactor nl section delimiter handling

* src/nl.c (main): Update the default delimiter characters
when passed two characters with --section-delimiter.
Avoid redundant copies for the body and footer delimiter strings,
and instead, just offset into the header string.
(check_section): Avoid redundant comparing of 2 bytes of memory
for an empty delimiter.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 12 Dec 2020 02:15:34 +0000 (18:15 -0800)] 
build: update gnulib submodule to latest

4 years agochroot,comm,join: fix usage options style
Arman Absalan [Mon, 7 Dec 2020 21:18:57 +0000 (00:48 +0330)] 
chroot,comm,join: fix usage options style

* src/chroot.c (usage): Fix indentation of options.
* src/comm.c: Likewise.
* src/join.c: Likewise.

4 years agodate: with --debug, show the output format
Pádraig Brady [Mon, 30 Nov 2020 19:06:59 +0000 (19:06 +0000)] 
date: with --debug, show the output format

The format can be determined from --options or the locale,
so it's useful to output the format string being used.

* src/date.c (show_date): Show the output format
along with the date being shown.
* tests/misc/date-debug.sh: Adjust accordingly.
Addresses https://bugs.gnu.org/44960

4 years agomaint: fix typo, characteres -> characters
Tim Gates [Fri, 27 Nov 2020 19:56:02 +0000 (19:56 +0000)] 
maint: fix typo, characteres -> characters

* src/expr.c: Fix typo in comment.

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.