]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
10 years agotests: fix portability issue in dd/ascii test
Pádraig Brady [Wed, 26 Nov 2014 20:15:15 +0000 (20:15 +0000)] 
tests: fix portability issue in dd/ascii test

Solaris 8 was seen to issue this error:
"printf: `&': illegal format character"

* test/dd/ascii.sh: Use the coreutils printf in this test
rather than the system one, to avoid portability issues.

10 years agobuild: port new rule for coreutils.h to old Bash
Paul Eggert [Wed, 26 Nov 2014 05:16:20 +0000 (21:16 -0800)] 
build: port new rule for coreutils.h to old Bash

Reported by Ted Carr in: http://bugs.gnu.org/19184
* src/local.mk (src/coreutils.h):
Don't assume single_binary_progs is nonempty.

10 years agopaste: fix possible truncated output with large files
Tobias Stoeckmann [Mon, 24 Nov 2014 09:14:44 +0000 (09:14 +0000)] 
paste: fix possible truncated output with large files

If '\n' was present at the size_t boundary of a file,
then that and subsequent data would be discarded.

* src/paste.c (paste_parallel): Avoid the overflow issue
by changing the flag to a boolean rather than a count.
* NEWS: Mention the bug fix.

10 years agodf: only suppress remote mounts of separate exports with --total
Pádraig Brady [Wed, 29 Oct 2014 02:49:17 +0000 (02:49 +0000)] 
df: only suppress remote mounts of separate exports with --total

* src/df.c (filter_mount_list): Separate remote locations are
generally explicitly mounted, so list each even if they share
the same remote device and thus storage.  However with --total
keep the suppression to give a more accurate value for the
total storage available.
(usage): Expand on the new implications of --total and move
it in the options list according to alphabetic order.
doc/coreutils.texi (df invocation): Mention that --total impacts
on deduplication of remote file systems and also move location
according to alphabetic order.
* tests/df/skip-duplicates.sh: Add remote test cases.
* NEWS: Mention the change in behavior.

Reported in http://bugs.debian.org/737399
Reported in http://bugzilla.redhat.com/920806
Reported in http://bugzilla.opensuse.org/866010
Reported in http://bugzilla.opensuse.org/901905

10 years agodf: ensure -a shows all remote file system entries
Pádraig Brady [Mon, 27 Oct 2014 23:37:08 +0000 (23:37 +0000)] 
df: ensure -a shows all remote file system entries

commit v8.22-125-g9d736f8 printed placeholder "-" values
for device names that didn't match the preferred device name
for a particular mount point.  However that was seen to erroneously
suppress values for aliased host names or exports, common with
remote file systems.

* src/df.c (me_for_dev): Rename from devname_for_dev() so that
we can determine the remoteness as well as the name for the
preferred mount entry.
(get_dev): Don't output place holder values when both
current and preferred mount entries are remote.

Reported in http://bugs.debian.org/737399

10 years agotests: add a case verifying mv on case insensitive file systems
Pádraig Brady [Sat, 22 Nov 2014 03:41:55 +0000 (03:41 +0000)] 
tests: add a case verifying mv on case insensitive file systems

* NEWS: Update the recent entry to also mention the avoidance
of incorrectly unlinking a multi-hardlinked "source" file when
presented with source and dest that only differ in case.
* src/copy.c (same_file_ok): Mention the case issue with same_name().
* tests/mv/hardlink-case.sh: Test the issue on HFS+.
* tests/local.mk: Reference the new test case.
* tests/mv/vfat: Remove an old related but unused test case.

10 years agodoc: mention how to avoid newlines impacting ls -1
Pádraig Brady [Fri, 21 Nov 2014 16:20:03 +0000 (16:20 +0000)] 
doc: mention how to avoid newlines impacting ls -1

* src/ls.c (usage): Mention the -b and -q options
in the -1 description.
* doc/coreutils.texi (ls invocation): Likewise.

10 years agotests: chcon: avoid false failure with newer selinux
Pádraig Brady [Fri, 21 Nov 2014 15:27:41 +0000 (15:27 +0000)] 
tests: chcon: avoid false failure with newer selinux

file_t is now mapped to unlabeled_t as per:
http://danwalsh.livejournal.com/68189.html

Therefore use the latter to ensure we match correctly.
This is needed on >= Fedora 21 for example,
while it also works on earlier releases.

10 years agomv: fail when moving a file to a hardlink
Boris Ranto [Tue, 18 Nov 2014 19:20:50 +0000 (20:20 +0100)] 
mv: fail when moving a file to a hardlink

We may run into a race condition if we treat hard links to the same file
as distinct files.  If we do 'mv a b' and 'mv b a' in parallel, both a
and b can disappear from the file system.  The reason is that in this
case the unlink on src is called and the system calls can end up being
run in the order where unlink(a) and unlink(b) are the last two system
calls.  Therefore exit with an error code so that we avoid the potential
data loss.

* src/copy.c (same_file_ok): Don't set unlink_src that was used by mv,
and return false for two hardlinks to a file in move_mode.
*src/copy.c (copy_internal): No longer honor the unlink_src option,
used only by mv.
NEWS: Mention the change in behavior.
* tests/cp/same-file.sh: Augment to cover the `cp -a hlsl1 sl1` case.
* tests/mv/hard-verbose.sh: Remove no longer needed test.
* tests/local.mk: Remove the reference to hard-verbose.sh.
* tests/mv/hard-4.sh: Adjust so we fail in this case.
* tests/mv/i-4.sh: Likewise.
* tests/mv/symlink-onto-hardlink-to-self.sh: Likewise.

10 years agomaint: run strftime syntax check on newer systems
Pádraig Brady [Tue, 18 Nov 2014 03:29:07 +0000 (03:29 +0000)] 
maint: run strftime syntax check on newer systems

* cfg.mk (sc_strftime_check): Adjust regex to handle
newer glibc info formatting with different indentation
and quoting.

10 years agomaint: tests: fix comments about retry_delay_
Pádraig Brady [Wed, 29 Oct 2014 14:32:01 +0000 (14:32 +0000)] 
maint: tests: fix comments about retry_delay_

* tests/tail-2/F-vs-missing.sh: Comment with the correct total delay.
* tests/tail-2/F-vs-rename.shi: Likewise.
* tests/tail-2/flush-initial.sh: Likewise.
* tests/tail-2/inotify-hash-abuse.sh: Likewise.
* tests/tail-2/pipe-f2.sh: Likewise.
* tests/misc/chroot-fail.sh: Initialize can_chroot_root in all cases.

10 years agotests: make inotify-rotate more robust and efficient
Pádraig Brady [Wed, 29 Oct 2014 14:08:05 +0000 (14:08 +0000)] 
tests: make inotify-rotate more robust and efficient

* tests/tail-2/inotify-rotate.sh: Use retry_delay_
to employ an exponential backoff with a total delay of
up to 25.5s.  The 15s delay was seen to trigger a false
failure in http://hydra.nixos.org/build/16546517
Also remove the .1s sleep in each of the 50 iterations
to reduce the running time of the test and thus the
expensive_ tag on this test was removed.
Also ensure that we use the standard exit procedure
upon failure to avoid any erroneous diagnostics due
to persistent files on NFS.

10 years agotests: make du/move-dir-while-traversing more robust
Bernhard Voelker [Wed, 29 Oct 2014 22:21:13 +0000 (23:21 +0100)] 
tests: make du/move-dir-while-traversing more robust

* tests/du/move-dir-while-traversing.sh: Catch failure of retry_delay_
when waiting for the watcher to get ready.

10 years agodoc: mention that df -a includes duplicate file systems
Pádraig Brady [Mon, 27 Oct 2014 11:41:09 +0000 (11:41 +0000)] 
doc: mention that df -a includes duplicate file systems

* src/df.c (usage): Mention that duplicate file systems are shown
with this option, not just dummy file systems.
* doc/coreutils.texi (df invocation): For the --all option, expand
on the class of normally suppressed mount entries that it includes.

Reported in http://bugs.debian.org/737399

10 years agomaint: improve sc_long_lines syntax-check speed
Pádraig Brady [Thu, 23 Oct 2014 09:51:22 +0000 (10:51 +0100)] 
maint: improve sc_long_lines syntax-check speed

sc_long_lines was the slowest syntax check

before$ time make sc_long_lines
        long_lines
        real    0m2.740s

after $ time make sc_long_lines
        long_lines
        real    0m0.677s

* src/cfg.mk (sc_dd_max_sym_length): s/--max-line-length/-L/
for compat with BSDs.
(sc_long_lines): Prefilter with wc -L to only identify lines
in files that have lines longer than 80 characters.

10 years agotests: d_type-check: don't hardcode the C library name
Mike Frysinger [Thu, 23 Oct 2014 02:30:23 +0000 (03:30 +0100)] 
tests: d_type-check: don't hardcode the C library name

* tests/d_type-check: The hardcoded name doesn't hold true for all
Linux/glibc platforms, let alone Linux/non-glibc.
Use ctypes.util.find_library() instead to search for the library.

10 years agotests: avoid false failure when comparing /proc files
Bernhard Voelker [Thu, 16 Oct 2014 10:23:04 +0000 (12:23 +0200)] 
tests: avoid false failure when comparing /proc files

At least the MHz number in /proc/cpuinfo may change, thus leading to
a false positive failure when comparing the expected against the
actual output file.  Use an invariant file instead: /proc/version.

* tests/misc/head-c.sh: s/cpuinfo/version/

10 years agotests: fix test hang with unstable inodes in /proc
Pádraig Brady [Thu, 16 Oct 2014 09:33:46 +0000 (10:33 +0100)] 
tests: fix test hang with unstable inodes in /proc

* cp/proc-zero-len.sh: Search the 'err' file
for the error to ignore, not stdin.

10 years agochroot: call chroot() unconditionally to handle bind mounted "/"
Pádraig Brady [Wed, 15 Oct 2014 17:08:42 +0000 (18:08 +0100)] 
chroot: call chroot() unconditionally to handle bind mounted "/"

* src/chroot.c (is_root): Adjust to compare canonicalized paths
rather than inodes, to handle (return false in) the case where
we have a tree that is constructed by first bind mounting "/"
(thus having the same inode).
(main): Unconditionally call chroot() because it's safer
and of minimal performance benefit to avoid in this case.
This will cause inconsistency with some platforms
not allowing `chroot / true` for non root users.
* tests/misc/chroot-fail.sh: Adjust appropriately.
* NEWS: Mention the bug fixes.
Fixes http://bugs.gnu.org/18736

10 years agocopy: avoid an extraneous error when reporting errors
Pádraig Brady [Tue, 7 Oct 2014 18:48:53 +0000 (19:48 +0100)] 
copy: avoid an extraneous error when reporting errors

* src/copy.c (copy_reg): If sparse_copy() failed, then an
erroneous error about failing to extend the file would be reported.

10 years agocp: read sparse files more efficiently with non regular destination
Pádraig Brady [Mon, 6 Oct 2014 10:02:34 +0000 (11:02 +0100)] 
cp: read sparse files more efficiently with non regular destination

* src.copy.c (copy_reg): Use fiemap to read sparse files, even
if the output is not to a regular file.
* NEWS: Mention the improvement.

10 years agocp: avoid speculative preallocation with --sparse=always
Pádraig Brady [Mon, 6 Oct 2014 09:19:58 +0000 (10:19 +0100)] 
cp: avoid speculative preallocation with --sparse=always

With --sparse=always use fallocate(...PUNCH_HOLE...) to
avoid any permanent allocation due to speculative
preallocation employed by file systems such as XFS.

* m4/jm-macros.m4: Check for <linux/falloc.h> and fallocate().
* src/copy.c (punch_hole): A new function to try and punch
a hole at the specified offset if supported.
(create_hole): Call punch_hole() after requesting a hole.
(extent_copy): Likewise.
* NEWS: Mention the improvement.

10 years agocopy: detect smaller holes than the copy buffer size
Pádraig Brady [Thu, 2 Oct 2014 13:07:42 +0000 (14:07 +0100)] 
copy: detect smaller holes than the copy buffer size

Previously cp would not detect runs of NULs that were
smaller than the buffer size used for I/O (currently 128KiB).

* src/copy.c (copy_reg): Use an independent hole_size, set to
st_blksize, to increase the chances of detecting a representable hole,
in a run of NULs read from the input.
(create_hole): A new function refactored from sparse_copy() and
extent_copy() so we have a single place to handle holes.
(sparse_copy): Adjust to loop over the larger input buffer
in chunks of the passed hole size.  Also adjust to only call
lseek once per hole, rather than at least once per input buffer.
* tests/cp/sparse.sh: Add test cases for various sparse chunk sizes.
* NEWS: Mention the improvement.

10 years agodoc: clarify that timeout limits are not 2038 seconds
Wieland Hoffmann [Thu, 9 Oct 2014 18:38:13 +0000 (20:38 +0200)] 
doc: clarify that timeout limits are not 2038 seconds

* man/timeout.x: The 2038 that the sentence is referring to is the year
2038, not 2038 seconds (the default unit used for timeouts).

10 years agomaint: avoid new signed overflow warning on 32 bit
Pádraig Brady [Wed, 8 Oct 2014 11:35:36 +0000 (12:35 +0100)] 
maint: avoid new signed overflow warning on 32 bit

Prompted by http://hydra.nixos.org/build/15682577
with GCC 4.8.3 on i686

  src/tac.c:557:6: error: assuming signed overflow does not occur
  when simplifying conditional to constant [-Werror=strict-overflow]
     if (bytes_copied < 0)

This happens because copy_to_temp() is inlined in tac_nonseekable(),
thus reducing the comparison to the bytes_copied variable in
copy_to_temp.  Now this can't overflow on either 32 or 64 bit
due to the protection of the preceding fwrite().  We could use a
guard like "if (bytes_copied <= OFF_T_MAX - bytes_read)" to avoid
the warning, but rather than a runtime branch, just use an unsigned
type to avoid apparent signed overflow on systems where the accumulation
is not promoted to unsigned (32 bit size_t, 64 bit off_t).

* src/tac.c (copy_to_temp): Increment an unsigned type to
avoid the subsequent signed overflow warning.

10 years agotests: split/b-chunk.sh: avoid spurious fail on non-Linux
Jim Meyering [Wed, 8 Oct 2014 01:08:25 +0000 (18:08 -0700)] 
tests: split/b-chunk.sh: avoid spurious fail on non-Linux

* tests/split/b-chunk.sh: Skip each file that does not exist.
Some systems lack /proc/version or /sys/kernel/profiling

10 years agomaint: avoid syntax-check failures in previous patch
Pádraig Brady [Wed, 8 Oct 2014 00:14:57 +0000 (01:14 +0100)] 
maint: avoid syntax-check failures in previous patch

* tests/misc/od-j.sh: Non standard comparison order.
* tests/split/b-chunk.sh: Confusing input file name.
* tests/tail-2/tail-c.sh: Redundant require ulimit.

10 years agowc: don't miscount /sys and similar file systems
Paul Eggert [Tue, 7 Oct 2014 23:46:08 +0000 (16:46 -0700)] 
wc: don't miscount /sys and similar file systems

Fix similar problems in head, od, split, tac, and tail.
Reported by George Shuklin in: http://bugs.gnu.org/18621
* NEWS: Document this.
* src/head.c (elseek): Move up.
(elide_tail_bytes_pipe, elide_tail_lines_pipe): New arg
CURRENT_POS.  All uses changed.
(elide_tail_bytes_file, elide_tail_lines_file):
New arg ST and remove arg SIZE.  All uses changed.
* src/head.c (elide_tail_bytes_file):
* src/od.c (skip): Avoid optimization for /sys files, where
st_size is bogus and st_size == st_blksize.
Don't report error at EOF when not optimizing.
* src/head.c, src/od.c, src/tail.c: Include "stat-size.h".
* src/split.c (input_file_size): New function.
(bytes_split, lines_chunk_split, bytes_chunk_extract): New arg
INITIAL_READ.  All uses changed. Use it to double-check st_size.
* src/tac.c (tac_seekable): New arg FILE_POS.  All uses changed.
(copy_to_temp): Return size of temp file.  All uses changed.
* src/tac.c (tac_seekable):
* src/tail.c (tail_bytes):
* src/wc.c (wc):
Don't trust st_size; double-check by reading.
* src/wc.c (wc): New arg CURRENT_POS.  All uses changed.
* tests/local.mk (all_tests): Add tests/misc/wc-proc.sh,
tests/misc/od-j.sh, tests/tail-2/tail-c.sh.
* tests/misc/head-c.sh:
* tests/misc/tac-2-nonseekable.sh:
* tests/split/b-chunk.sh:
Add tests for problems with /proc and /sys files.
* tests/misc/od-j.sh, tests/misc/wc-proc.sh, tests/tail-2/tail-c.sh:
New files.

10 years agodoc: document stat's output with the --terse option
Bernhard Voelker [Sat, 4 Oct 2014 15:09:59 +0000 (17:09 +0200)] 
doc: document stat's output with the --terse option

* doc/coreutils.texi (stat invocation): Add a paragraph documenting
stat's output format when the --terse option is specified, both in
normal and in --file-system mode.

Reported by Dan Jacobson <jidanni@jidanni.org>
in http://bugs.gnu.org/18624

10 years agotests: fix false failure for test referencing libdl
Nick Alcock [Thu, 2 Oct 2014 14:26:21 +0000 (15:26 +0100)] 
tests: fix false failure for test referencing libdl

* init.cfg (gcc_shared_): -ldl has to be positioned after the object
files that may rely upon it.  This fixes tests/cp/nfs-removal-race.sh
which references dlsym() from libdl.

10 years agomaint: avoid double semicolon syntax check failure
Bernhard Voelker [Thu, 2 Oct 2014 00:34:48 +0000 (02:34 +0200)] 
maint: avoid double semicolon syntax check failure

A syntax-check recently added to gnulib would trigger a failure
(once gnulib gets updated here) for a statement introduced with
commit v8.23-43-gaf2a4ed:

  src/dd.c:806:  char const *time_fmt = _(", %g s, %s/s\n");;
  maint.mk: Double semicolon detected
  make: *** [sc_prohibit_double_semicolon] Error 1

* src/dd.c (print_xfer_stats): s/;;/;/

10 years agodd: new status=progress level to print stats periodically
Federico Simoncelli [Fri, 26 Sep 2014 17:12:32 +0000 (17:12 +0000)] 
dd: new status=progress level to print stats periodically

* src/dd.c: Report the transfer progress every second when the
new status=progress level is used.  Adjust the handling and
description of the status= option so that they're treated as
mutually exclusive levels, rather than flags with implicit precedence.
* doc/coreutils.texi (dd invocation): Document the new progress
status level.  Reference the new level in the description of SIGUSR1.
* tests/dd/stats.sh: Add new test for status=progress.
* tests/dd/misc.sh: Change so status=none only takes precedence
if it's the last level specified.
* NEWS: Mention the feature.

10 years agodd: use more robust SIGUSR1 handling
Pádraig Brady [Fri, 26 Sep 2014 14:46:28 +0000 (15:46 +0100)] 
dd: use more robust SIGUSR1 handling

* src/dd.c (ifd_reopen): A new wrapper to ensure we
don't exit upon receiving a SIGUSR1 in a blocking open()
on a fifo for example.
(iftruncate): Likewise for ftruncate().
(iread): Process signals also after a short read.
(install_signal_handlers): Install SIGINFO/SIGUSR1 handler
even if set to SIG_IGN, as this is what the parent can easily
set from a shell script that can send SIGUSR1 without the
possiblity of inadvertently killing the dd process.
* doc/coreutils.texi (dd invocation): Improve the example to
show robust usage wrt signal races and short reads.
* tests/dd/stats.sh: A new test for various signal races.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.

10 years agotest: check for Fedora 20 sort key bug
Paul Eggert [Wed, 24 Sep 2014 18:55:20 +0000 (11:55 -0700)] 
test: check for Fedora 20 sort key bug

Problem reported by Göran Uddeborg in: http://bugs.gnu.org/18540
* tests/misc/sort.pl: New test 23.

10 years agomv: use reflink=auto mode by default
David Sterba [Wed, 24 Sep 2014 10:15:05 +0000 (11:15 +0100)] 
mv: use reflink=auto mode by default

On some filesystems (BTRFS), moving a file within the filesystem may
cross subvolume boundaries and we can use a lightweight reflink copy,
similar to what cp(1) can do, which is faster than a full file copy.
This is enabled by default because it's only an optimization for
the fall back copy and does not break user expectations or usability.

* src/mv.c (cp_option_init): Set the reflink mode to AUTO.
* NEWS: Mention the improvement.

10 years agostty: only list supported options in --help and man pages
Pádraig Brady [Fri, 19 Sep 2014 15:15:04 +0000 (16:15 +0100)] 
stty: only list supported options in --help and man pages

* src/stty.c (usage): Exclude unsupported options from --help,
which for example impacts the "dsusp" and "cdtrdsr" options on Linux.
Fixes http://bugs.gnu.org/18506

10 years agodoc: fix use of "e.g." in stdbuf help message
Michal Nazarewicz [Tue, 23 Sep 2014 01:50:14 +0000 (03:50 +0200)] 
doc: fix use of "e.g." in stdbuf help message

"E.g." stands for latin "exempli gratia" which is typically read
as "for example".  "E.g." does not stand for the word "example".
As such, "for e.g." might be read as "for for example".

Fix this usage by simply replacing "e.g." with "example".

10 years agobuild: pass program name to help2man after other options
Bernhard Voelker [Mon, 22 Sep 2014 23:49:47 +0000 (01:49 +0200)] 
build: pass program name to help2man after other options

* man/local.mk (.x.1): Move the program name argument down after
the last option argument when calling $(run_help2man).
While the other way would be accepted for the GNU help2man program,
it is not for the 'dummy-man' script (called as a fallback on
systems lacking perl).
The wrong order was introduced in commit v8.21-119-gb3578fc while
adding the --info-page option.

10 years agobuild: fix argument count check in dummy-man again
Bernhard Voelker [Mon, 22 Sep 2014 23:44:51 +0000 (01:44 +0200)] 
build: fix argument count check in dummy-man again

* man/dummy-man: Fix argument count check, now only permitting
exactly 1 argument, the program name.
Reported by Andreas Schwab <schwab@linux-m68k.org>

10 years agobuild: fix an inverted test breaking dummy-man
Alban Bedel [Mon, 22 Sep 2014 09:53:13 +0000 (11:53 +0200)] 
build: fix an inverted test breaking dummy-man

* man/dummy-man: Fix argument count check,
allowing dummy-man to run (on systems without perl).
Fixes http://bugs.gnu.org/18531

10 years agobuild: fix dependency issues with man page generation
Pádraig Brady [Fri, 19 Sep 2014 15:49:26 +0000 (16:49 +0100)] 
build: fix dependency issues with man page generation

* .gitignore: Remove reference to no longer generated make file.
* configure.ac: Don't bother generating placeholder make file.
* man/local.mk: Hardcode the man page deps list for normal builds
to be compatible with all make implementations and configure options.
Note in SINGLE_BINARY mode, all man pages will be generated on
any change to the coreutils binary, but development will generally
not be done in this mode, so this shouldn't be an issue.

Fixes http://bugs.gnu.org/18055

10 years agomaint: don't trigger gcc-5's new -Wlogical-not-parentheses warning
Jim Meyering [Tue, 16 Sep 2014 18:15:25 +0000 (11:15 -0700)] 
maint: don't trigger gcc-5's new -Wlogical-not-parentheses warning

* src/dircolors.c (main): Parenthesize !VAR as LHS to "<",
to avoid triggering gcc's new -Wlogical-not-parentheses warning.

10 years agocp: fix handling of -H with multiply specified source dirs
Pádraig Brady [Thu, 18 Sep 2014 10:31:22 +0000 (11:31 +0100)] 
cp: fix handling of -H with multiply specified source dirs

Following on from commit v5.92-729-g130dd06, also avoid
the erroneous directory hardlink warning with -H.

* src/copy.c (copy_internal): Also handle the -H case
for command line arguments.
* tests/cp/duplicate-sources.sh: Augment the test case.
* NEWS: Augment the news entry.

10 years agocp: issue correct warning and ignore duplicate source dirs
Pádraig Brady [Wed, 17 Sep 2014 17:50:08 +0000 (18:50 +0100)] 
cp: issue correct warning and ignore duplicate source dirs

* src/copy.c (copy_internal): Handle the case where we have the
same destination directory as already encountered, which can only
be due to the corresponding source directory being specified multiple
times.
* tests/cp/duplicate-sources.sh: Add a test for the new multiply
specified directory case, and the existing multiply specified file case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.

10 years agodoc: output correct --help references with --program-prefix
Pádraig Brady [Thu, 18 Sep 2014 13:50:47 +0000 (14:50 +0100)] 
doc: output correct --help references with --program-prefix

* src/system.h (emit_ancillary_info): Take the invariant PROGRAM_NAME
as a parameter, so that consistent references are made to online docs
and texinfo nodes, when a --program-prefix is in place.  Note the
man pages don't need this fix as they're generated before the program
prefix is used.
* NEWS: Mention the improvements in references to online documentation.

10 years agodoc: ensure the correct texinfo nodes are referenced in --help
Pádraig Brady [Thu, 18 Sep 2014 13:37:37 +0000 (14:37 +0100)] 
doc: ensure the correct texinfo nodes are referenced in --help

* src/system.h (emit_ancillary_info): For commands that don't have
a 1:1 mapping with the texinfo node names, provide a mapping to
the correct node.
* doc/coreutils.texi: Add some extra cross references noticed while
checking this.
Fixes http://bugs.debian.org/762092

10 years agotests: fix false du failure on newer XFS
Bernhard Voelker [Tue, 16 Sep 2014 16:50:29 +0000 (18:50 +0200)] 
tests: fix false du failure on newer XFS

On XFS, when creating the ~2G test file 'big' in a for-loop by
appending 20M each time, the file ends up using ~4G - visible in
'st_blocks'.  The unused space would be reclaimed later.
This feature is called "speculative preallocation" which aims at
avoiding fragmentation.
According to the XFS FAQ [1], there are two particular aspects of
XFS speculative preallocation that are triggering this:

  1. "Applications that repeatedly trigger preallocation and reclaim
     cycles [after file close] can cause fragmentation.
     Therefore, this pattern is detected and causes the preallocation
     to persist beyond the lifecycle of the file descriptor."

  2. "Preallocation sizes grow as files grow larger."

[1] http://xfs.org/index.php/XFS_FAQ

Avoid one of the above by only doing a single close (reclaim cycle).

* tests/du/2g.sh: Similar to the fix for a dd test (see commit
v8.22-65-g7c03fe2), avoid speculative preallocation by creating
the 'big' file in one go instead of appending to it in the loop.
Remove debugging statements as the output with 'set -x' is
sufficient nowadays.

10 years agocat: allow copying empty files to themselves
Paul Eggert [Thu, 11 Sep 2014 15:45:32 +0000 (08:45 -0700)] 
cat: allow copying empty files to themselves

Problem reported by Vincent Lefevre in: http://bugs.gnu.org/18449
* src/cat.c (main): Allow copying an empty file to itself.
* tests/misc/cat-self.sh: New test.
* tests/local.mk (all_tests): Add it.

10 years agodoc: reference online info pages directly from man pages
Pádraig Brady [Wed, 10 Sep 2014 10:53:50 +0000 (11:53 +0100)] 
doc: reference online info pages directly from man pages

* src/system.h (emit_ancillary_info): Add a direct reference
to the corresponding online info documentation.  Corresponding
redirects were put in place on www.gnu.org to allow for concise links.
* help2man: Adjust to add the "online help" link (and subsequent
translation bugs link) to a "REPORTING BUGS" section.
Also add the concise links for further information in --help
to the "SEE ALSO" section, and dispense with the more verbose
default for that.

10 years agodoc: adjust reference to info nodes in man pages
Pádraig Brady [Tue, 9 Sep 2014 01:05:45 +0000 (02:05 +0100)] 
doc: adjust reference to info nodes in man pages

old form: coreutils '$cmd invocation'
new form: '(coreutils) $cmd invocation'

The old form erroneously referenced the node for the 'coreutils'
multi-call program.  Now that problematic node name was renamed
in commit v8.23-18-g72e470b, but the newer less ambiguous form
also has the advantage of working with the pinfo viewer for example.
Full discussion at http://bugs.gnu.org/18428

* man/local.mk: Adjust man page references to texinfo nodes.
* src/system.h: Adjust --help references to texinfo nodes.

10 years agomaint: include libstdbuf.c in extraneous headers check
Pádraig Brady [Sat, 23 Aug 2014 00:14:36 +0000 (01:14 +0100)] 
maint: include libstdbuf.c in extraneous headers check

* cfg.mk (sc_system_h_headers): Don't exclude libstdbuf.c.
* src/libstdbuf.c: Remove headers already included in system.h.

10 years agobuild: adjust previous transformations on libstdbuf name
Pádraig Brady [Wed, 10 Sep 2014 22:43:00 +0000 (23:43 +0100)] 
build: adjust previous transformations on libstdbuf name

* src/local.mk (transform): commit v8.23-22-g6f9b018 discarded all
transformations on the libstdbuf.so name.  Be more conservative and
only exclude the $(program_transform_name) portion for libstdbuf.

10 years agobuild: avoid name transformations on libstdbuf
Pádraig Brady [Tue, 9 Sep 2014 14:50:07 +0000 (15:50 +0100)] 
build: avoid name transformations on libstdbuf

* src/local.mk (transform): Skip the transformation for libstdbuf
since that should not be subject to name clashes, and we need
to reference the name directly in LD_PRELOAD etc.
* configure.ac: Add a comment on the coupling of pkglibexec_PROGRAMS
to $(transform).
Issue reported at https://trac.macports.org/ticket/44922
Improved by Nick Bowler

10 years agomaint: fix syntax-check issues in recent commit
Pádraig Brady [Tue, 9 Sep 2014 09:25:39 +0000 (10:25 +0100)] 
maint: fix syntax-check issues in recent commit

Avoid 2 new syntax-check failures introduced in commit v8.23-19-g8defcee

* cfg.mk (sc_some_programs_must_avoid_exit_failure): s/exit/return/.
* src/whoami.c (main): Reinstate translation marker for diagnostic.

10 years agomaint: avoid file-scope names of the form _[a-z]*
Paul Eggert [Tue, 9 Sep 2014 03:41:44 +0000 (20:41 -0700)] 
maint: avoid file-scope names of the form _[a-z]*

The C standard says this isn't portable, if you include
standard include files.
* build-aux/gen-single-binary.sh:
* src/coreutils-arch.c (single_binary_main_arch)
(single_binary_main_uname):
* src/coreutils-dir.c (single_binary_main_ls)
(_single_binary_main_dir):
* src/coreutils-vdir.c (single_binary_main_ls)
(_single_binary_main_vdir):
* src/coreutils.c (SINGLE_BINARY_PROGRAM):
Remove leading _ from single_binary prefix.
* src/numfmt.c (round_style): Rename from _round.  All uses changed.
(inval_style): Rename from _invalid.  All uses changed.

10 years agomaint: prefer 'return status;' to 'exit (status);' in 'main'
Paul Eggert [Mon, 8 Sep 2014 23:31:14 +0000 (16:31 -0700)] 
maint: prefer 'return status;' to 'exit (status);' in 'main'

* build-aux/gen-single-binary.sh: Don't use ATTRIBUTE_NORETURN
for main functions.
* src/base64.c, src/basename.c, src/cat.c, src/chcon.c, src/chgrp.c:
* src/chmod.c, src/chown.c, src/chroot.c, src/cksum.c, src/comm.c:
* src/cp.c, src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c:
* src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c:
* src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c:
* src/getlimits.c, src/groups.c, src/head.c, src/hostid.c:
* src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c:
* src/link.c, src/ln.c, src/logname.c, src/ls.c, src/make-prime-list.c:
* src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mktemp.c:
* src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/nproc.c:
* src/numfmt.c, src/od.c, src/paste.c, src/pathchk.c, src/pinky.c:
* src/pr.c, src/printenv.c, src/printf.c, src/ptx.c, src/pwd.c:
* src/readlink.c, src/realpath.c, src/rm.c, src/rmdir.c, src/runcon.c:
* src/seq.c, src/shred.c, src/shuf.c, src/sleep.c, src/sort.c:
* src/split.c, src/stat.c, src/stdbuf.c, src/stty.c, src/sum.c:
* src/sync.c, src/tac.c, src/tail.c, src/tee.c, src/timeout.c:
* src/touch.c, src/tr.c, src/true.c, src/truncate.c, src/tsort.c:
* src/tty.c, src/uname.c, src/unexpand.c, src/uniq.c, src/unlink.c:
* src/uptime.c, src/users.c, src/wc.c, src/who.c, src/whoami.c:
In 'main' functions, Prefer 'return status;' to 'exit (status);'.
* src/coreutils-arch.c (_single_binary_main_uname)
(_single_binary_main_arch):
* src/coreutils-dir.c, src/coreutils-vdir.c (_single_binary_main_ls)
(_single_binary_main_dir, _single_binary_main_vdir):
Omit ATTRIBUTE_NORETURN.  Return a value.
* src/coreutils.c (SINGLE_BINARY_PROGRAM): Omit ATTRIBUTE_NORETURN.
(launch_program): Now static.
* src/dd.c (finish_up): New function.
(quit, main): Use it.
* src/getlimits.c (main): Return a proper exit status.
* src/test.c (test_main_return): New macro.
(main): Use it.
* src/logname.c, src/nohup.c, src/whoami.c:
Use 'error' to simplify exit status in 'main' function.
* src/yes.c (main): Use 'return' rather than 'error' to exit,
so that GCC doesn't suggest ATTRIBUTE_NORETURN.

10 years agodoc: rename "coreutils invocation" to "Multi-call invocation"
Paul Eggert [Mon, 8 Sep 2014 19:51:14 +0000 (12:51 -0700)] 
doc: rename "coreutils invocation" to "Multi-call invocation"

This supports longstanding shell commands like
'info coreutils "touch invocation"'.
Problem reported by Vincent Lefevre via Bob Proulx in:
http://bugs.gnu.org/18428
* doc/coreutils.texi (Multi-call invocation):
Rename from "coreutils invocation".

10 years agodoc: mention which commands are optional
Paul Eggert [Mon, 8 Sep 2014 18:40:39 +0000 (11:40 -0700)] 
doc: mention which commands are optional

* doc/coreutils.texi (coreutils invocation, df invocation)
(stty invocation, whoami invocation, nproc invocation)
(arch invocation, hostname invocation, hostid invocation)
(uptime invocation, chroot invocation, nice invocation)
(stdbuf invocation): Document that the command is installed
optionally.

10 years agodoc: fix typos
Bernhard Voelker [Sat, 6 Sep 2014 23:35:52 +0000 (01:35 +0200)] 
doc: fix typos

* doc/coreutils.texi: Fix normal typos:
s/pseudorandom/pseudo-random/;
s/behaviour/behavior/;
s/linux-based/Linux-based/;
s/nonnegative/non-negative/.
Fix IEC's long name: s/Electronical/Electrotechnical/.
Wrap 'getopt' into the @code{} macro.
Fix a grammatical error (from myself): s/splitted/split/.

10 years agodoc: spell "indeterminate" correctly
Paul Eggert [Wed, 3 Sep 2014 16:52:38 +0000 (09:52 -0700)] 
doc: spell "indeterminate" correctly

* doc/coreutils.texi (timeout invocation): Fix misspelling.
Reported by Yureruchihirosan via OKANO Takayoshi in:
http://bugs.gnu.org/18394

10 years agomaint: ensure fiemap extents flags are compared correctly
Pádraig Brady [Sat, 23 Aug 2014 00:18:58 +0000 (01:18 +0100)] 
maint: ensure fiemap extents flags are compared correctly

* src/extent-scan.c (extent_scan_read): Following on from the flags size
adjustment in commit v8.23-13-g1505b37, verify that the internal
representation of the flags is never truncated which could happen in the
unlikely case on 32 bit if the kernel flags ever expanded to 64 bits
which is theoretically possible given the reserved space.

10 years agomaint: avoid int64_t and similar types unless they're needed
Paul Eggert [Fri, 22 Aug 2014 19:07:11 +0000 (12:07 -0700)] 
maint: avoid int64_t and similar types unless they're needed

C11 doesn't require them, even POSIX doesn't strictly require the
64-bit versions, and it makes the code a bit clearer if they're
used only when needed.
* src/copy.c (write_zeros, extent_copy):
* src/extent-scan.h (struct extent_info.ext_length):
Use off_t, not uint64_t, for a value derived from a file offset.
* src/extent-scan.h (struct extent_info.ext_flags)
Prefer plain unsigned int to uint32_t where either will do.
(struct extent_scan.ei_count):
Use size_t, not uint32_t, for a value bounded by SIZE_MAX.
* src/factor.c (MAGIC64, MAGIC63, MAGIC65):
Remove unnecessary casts to uint64_t.

10 years agomaint: refactor ls QUOTING_STYLE env var handling
Yurij Goncharuk [Thu, 21 Aug 2014 22:44:56 +0000 (23:44 +0100)] 
maint: refactor ls QUOTING_STYLE env var handling

* src/ls.c (main): As per the FIXME comment, move the
QUOTING_STYLE handling to a separate function.

10 years agodoc: clarify that duplicate NFS mounts are skipped by df
Fridolin Pokorny [Thu, 21 Aug 2014 09:45:54 +0000 (11:45 +0200)] 
doc: clarify that duplicate NFS mounts are skipped by df

* doc/coreutils.texi (df invocation): Add a sentence that eliding
duplicate entries for the same file system is not limited to bind
mounts, but also happens for remote file systems like NFS.

10 years agodf: improve mount point selection with inaccurate mount list
Pádraig Brady [Mon, 18 Aug 2014 16:59:26 +0000 (17:59 +0100)] 
df: improve mount point selection with inaccurate mount list

v8.23 has a test failure on Fedora rawhide build servers
in tests/df/skip-duplicate.sh.  This was due to no '/'
entry being output by df.  That was due to an inaccurate
/proc/mounts on the build environment as stat(/mnt/point)
identified all these /proc/mounts entries as having the
same device id:

  /                    rootfs
  /                    /dev/md1
  /dev                 devtmpfs
  /run                 tmpfs
  /boot                /dev/md0
  /proc/filesystems    /dev/md1

Since the device name on the right changes for a given id,
that causes the entries to be continually replaced, thus
resulting in no '/' entry.  I'm guessing this is due to
the mock environment bind mounting unneeded or sensitive
items to a dummy file on the host / (/dev/md1) though
have not looked into those details.

So rather than relying on an accurate /proc/mounts,
the attached patch takes a more conservative replacement
approach and only swaps a new device entry when the
mount point matches.  That should handle all practical
cases while also avoiding this situation.

* src/df.c (filter_mount_list): Only replace entries with
different device names when the mount point also matches.

10 years agocp: remove redundant possibly expensive heap deallocation
Rasmus Borup Hansen [Mon, 11 Aug 2014 14:07:05 +0000 (15:07 +0100)] 
cp: remove redundant possibly expensive heap deallocation

If the hash structures grow sufficiently large so that
the system is actively swapping, then the deallocation
can take a significant amount of time.  Details at:
http://lists.gnu.org/archive/html/coreutils/2014-08/msg00012.html

* src/cp.c (main): Only call hash deallocation routines
when in lint checking mode.
* THANKS.in: Remove as now in the git author list.

11 years agodoc: indicate that FILE arguments are optional with rm -f
Reuben Thomas [Mon, 4 Aug 2014 10:42:45 +0000 (11:42 +0100)] 
doc: indicate that FILE arguments are optional with rm -f

* src/rm.c (usage): s/FILE/[FILE]/.
Fixes http://bugs.gnu.org/18187

11 years agonumfmt: fix misspelling in --debug message
Anders Jonsson [Sun, 3 Aug 2014 20:47:48 +0000 (21:47 +0100)] 
numfmt: fix misspelling in --debug message

* src/numfmt.c (parse_format_string): s/overridding/overriding/.
Fixes http://bugs.gnu.org/18050

11 years agotests: fix typo in tail-2/inotify-race
Paul Eggert [Fri, 1 Aug 2014 19:50:29 +0000 (12:50 -0700)] 
tests: fix typo in tail-2/inotify-race

Reported by Andreas Schwab in: http://bugs.gnu.org/18057
* tests/tail-2/inotify-race.sh (break_src):
Use abs_top_srcdir, not abs_top_builddir.

11 years agochroot: perform chdir("/") again unless new --skip-chdir is specified
Bernhard Voelker [Fri, 1 Aug 2014 00:07:33 +0000 (02:07 +0200)] 
chroot: perform chdir("/") again unless new --skip-chdir is specified

Since commit v8.22-94-g99960ee, chroot(1) skips the chroot(2) syscall
for "/" arguments (and synonyms).  The problem is that it also skips
the following chdir("/") call in that case.  The latter breaks existing
scripts which expect "/" to be the working directory inside the chroot.
While the first part of the change - i.e., skipping chroot("/") - is
okay for consistency with systems where it might succeed for a non-root
user, the second part might be malicious, e.g.

  cd /home/user && chroot '/' bin/foo

In the "best" case, chroot(1) could not execute 'bin/foo' with ENOENT,
but in the worst case, chroot(1) would execute '/home/user/bin/foo' in
the case that exists - instead of '/bin/foo'.

Revert that second part of the patch, i.e., perform the chdir("/)
in the common case again - unless the new --skip-chdir option is
specified.  Restrict this new option to the case of "/" arguments.

* src/chroot.c (SKIP_CHDIR): Add enum.
(long_opts): Add entry for the new --skip-chdir option.
(usage): Add --skip-chdir option, and while at it, move the other
to options into alphabetical order.
(main): Accept the above new option, allowing it only in the case
when NEWROOT is the old "/".
Move down the chdir() call after the if-clause to ensure it is
run in any case - unless --skip-chdir is specified.
Add a 'newroot' variable for the new root directory as it is used
in a couple of places now.
* tests/misc/chroot-fail.sh: Invert the last tests which check the
working directory of the execvp()ed program when a "/"-like
argument was passed: now expect it to be "/" - unless --skip-chdir
is given.
* doc/coreutils.texi (chroot invocation): Document the new option.
Document that chroot(1) usually calls chdir("/") unless the new
--skip-chdir option is specified.  Sort options.
* NEWS (Changes in behavior): Mention the fix.
(New features): Mention the new option.
* init.cfg (nonroot_has_perm_): Add chroot's new --skip-chdir option.
* tests/cp/preserve-gid.sh (t1): Likewise.
* tests/cp/special-bits.sh: Likewise.
* tests/id/setgid.sh: Likewise.
* tests/misc/truncate-owned-by-other.sh: Likewise.
* tests/mv/sticky-to-xpart.sh: Likewise.
* tests/rm/fail-2eperm.sh: Likewise.
* tests/rm/no-give-up.sh: Likewise.
* tests/touch/now-owned-by-other.sh: Likewise.

Reported by Andreas Schwab in http://bugs.gnu.org/18062

11 years agobuild: avoid building stdbuf on cygwin
Pádraig Brady [Wed, 16 Jul 2014 15:47:50 +0000 (16:47 +0100)] 
build: avoid building stdbuf on cygwin

* configure.ac: Don't add stdbuf to the list of programs to build
if EXEEXT is set, as that is not handled in configure.ac for
libstdbuf.so yet (see bin_PRGRAMS handling in configure.ac).
Also the LD_PRELOAD mechanism will need to be adjusted to support
cygwin in any case, so avoid stdbuf completely in this case for now.
Problem reported by Eric Blake.

11 years agodoc: clarify that floating point parses "inf"
Eric Blake [Tue, 29 Jul 2014 22:57:55 +0000 (16:57 -0600)] 
doc: clarify that floating point parses "inf"

* doc/coreutils.texi (Floating point): Document handling of "inf",
"infinity", "NaN", and so on.

11 years agomaint: fix message translation glitches
Paul Eggert [Sat, 19 Jul 2014 14:55:41 +0000 (07:55 -0700)] 
maint: fix message translation glitches

Problem reported by Sebastian Rasmussen in: http://bugs.gnu.org/18054
* gl/lib/randread.c (randread_error): Don't put multiple string
literals inside _(...), as xgettext doesn't support that.
* src/chroot.c (main): In diagnostics, don't bother to distinguish
between setting the number of supplemental group IDs to a zero or
to a nonzero value, as the underlying system call is the same
either way.  This also makes the string easier to translate correctly.

11 years agomaint: post-release administrivia
Pádraig Brady [Fri, 18 Jul 2014 22:22:56 +0000 (23:22 +0100)] 
maint: post-release administrivia

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

11 years agoversion 8.23 v8.23
Pádraig Brady [Fri, 18 Jul 2014 22:07:21 +0000 (23:07 +0100)] 
version 8.23

* NEWS: Record release date.

11 years agobuild: port new bootstrap script to POSIX shells
Pádraig Brady [Fri, 18 Jul 2014 20:55:19 +0000 (21:55 +0100)] 
build: port new bootstrap script to POSIX shells

* build-aux/gen-single-binary.sh: Avoid bash only constructs.
Reported by Assaf Gordon

11 years agotests: fix false failure with spaces in the test directory
Pádraig Brady [Fri, 18 Jul 2014 17:59:29 +0000 (18:59 +0100)] 
tests: fix false failure with spaces in the test directory

* tests/misc/env.sh: Skip if we can't execute the generated shebang,
which would be the case if there are spaces in the directory hierarchy.
This is triggered by `make distcheck`

11 years agobuild: don't distribute generated coreutils.h
Pádraig Brady [Fri, 18 Jul 2014 13:21:19 +0000 (14:21 +0100)] 
build: don't distribute generated coreutils.h

This issue was identified by the manifest comparisons
done by `make distcheck`

* src/local.mk (noinst_HEADERS): Remove coreutils.h from this always
distributed list.
(nodist_src_coreutils_SOURCES): Add coreutils.h as its contents
are determined at configure time, so pointless to distribute.
(src_coreutils_SOURCES): Define explicitly so that the corresponding
nodist_ variable is honored.
(DISTCLEANFILES): Add coreutils.h to this rather than CLEANFILES,
as its contents are determined at configure time.

11 years agotests: fix false failure in cp --preserve=context test
Pádraig Brady [Fri, 18 Jul 2014 11:43:48 +0000 (12:43 +0100)] 
tests: fix false failure in cp --preserve=context test

With libselinux-2.2.1-6.fc20.x86_64, kernel-3.12.6-300.fc20.x86_64
`cp --preserve=context src dst` was seen to succeed when src and
dst where on the same fixed context file system, as lsetfilecon()
returned success in this case when the context wasn't being changed.

* tests/cp/cp-a-selinux.sh: Copy from a different file system to
most likely have a different context that will test context
setting logic correctly.

11 years agomaint: avoid a syntax-check warning in previous commit
Pádraig Brady [Fri, 18 Jul 2014 03:34:28 +0000 (04:34 +0100)] 
maint: avoid a syntax-check warning in previous commit

* cfg.mk: Avoid warning for @AMDEP_TRUE@ usage in man/local.mk

11 years agobuild: port to non-GNU make
Paul Eggert [Thu, 17 Jul 2014 20:08:36 +0000 (13:08 -0700)] 
build: port to non-GNU make

This fixes a problem with native Solaris 'make', which does not
grok '-include' lines (a GNU extension to POSIX 'make').
* configure.ac (man/dynamic-deps.mk): Create it, with an old
time stamp, if doing dynamic dependency tracking.
* man/local.mk (DISTCLEANFILES): Put man/dynamic-deps.mk here,
rather than in CLEANFILES.
(man/dynamic-deps.mk): Don't create it read-only, so that we
can easily touch it later.
Include it with '@AMDEP_TRUE@@am__include@', not with '-include',
as '-include' does not work with native Solaris 'make'.

11 years agonumfmt: fix isblank() usage for some unibyte locales
Assaf Gordon [Tue, 15 Jul 2014 16:25:03 +0000 (12:25 -0400)] 
numfmt: fix isblank() usage for some unibyte locales

* src/numfmt.c (simple_strtod_int): Replace isdigit() with c_isdigit()
to avoid locale concerns and -Wchar-subscripts warnings on cygwin.
Remove the now redundant locale guard.
(simple_strtod_human): Cast characters to unsigned so that the promoted
int value passed to isblank() is positive, allowing it to work correctly
for all characters in unibyte locales.  Previously character 0xA0,
i.e. non-breaking space, would be misclassified for example.
(process_suffixed_number): Likewise.
(skip_fields): Likewise.
Both issues were triggered by the -Wchar-subscripts warning on GCC 4.8.3
on cygwin, due to the is*() implementations used there, but the issue
is present on all platforms defaulting to signed chars.
* NEWS: Mention the bug fix.

Reported by Eric Blake

11 years agotests: fix portabilitiy issue in new od-endian test
Pádraig Brady [Mon, 14 Jul 2014 01:49:47 +0000 (02:49 +0100)] 
tests: fix portabilitiy issue in new od-endian test

* tests/misc/od-endian.sh: '\n' is not generally supported
in the replacement, so use the more portable "\\$NL".

11 years agotests: fix portability issue in new dd/ascii test
Pádraig Brady [Mon, 14 Jul 2014 01:19:31 +0000 (02:19 +0100)] 
tests: fix portability issue in new dd/ascii test

* tests/dd/ascii.sh: Quote so that '\\' is passed
to printf rather than a single '\', as that's not portable.
bash, dash, zsh and external solaris printf were seen to support
  printf '\%03o' 1 2
while ksh, freebsh shell and external GNU printf need the more portable
  printf '\\%03o' 1 2
Note we don't use env here to call the coreutils printf implementation,
as there are many printf calls, so relying on portable shell
implementations will be faster.

11 years agotests: avoid hang when files created with wrong permissions
Pádraig Brady [Sun, 13 Jul 2014 22:48:38 +0000 (23:48 +0100)] 
tests: avoid hang when files created with wrong permissions

* tests/split/b-chunk.sh: Never show the rm prompt which would
hang the test suite.  This was seen when split erroneously
created files with no persmissions, which was triggered by
this compiler bug in clang 3.4:
http://llvm.org/bugs/show_bug.cgi?id=18346

11 years agomaint: avoid clang -Wint-to-pointer-cast warning
Pádraig Brady [Sun, 13 Jul 2014 22:45:49 +0000 (23:45 +0100)] 
maint: avoid clang -Wint-to-pointer-cast warning

* src/chroot.c: Explicitly cast int to pointer type.

11 years agobuild: update gnulib submodule to latest
Pádraig Brady [Thu, 10 Jul 2014 23:33:36 +0000 (00:33 +0100)] 
build: update gnulib submodule to latest

* gnulib: Sync recent cleanups and the fix for
missing df entries in the presence of bind mounts:
http://bugs.gnu.org/17833
* NEWS: Detail the df bug fix.

11 years agosort: avoid undefined operation with destroying locked mutex
Pádraig Brady [Fri, 11 Jul 2014 15:11:22 +0000 (16:11 +0100)] 
sort: avoid undefined operation with destroying locked mutex

This didn't seem to cause any invalid operation on GNU/Linux at least,
but depending on the implementation, mutex deadlocks could occur.
For example this might be the cause of lockups seen on Solaris:
http://lists.gnu.org/archive/html/coreutils/2013-03/msg00048.html

This was identified with valgrind 3.9.0 with this setup:

  seq 200000 > file.sort
  valgrind --tool=drd src/sort file.sort -o file.sort

With that, valgrind would _intermittently_ report the following:

 Destroying locked mutex: mutex 0x5419548, recursion count 1, owner 2.
    at 0x4C2E3F0: pthread_mutex_destroy(in vgpreload_drd-amd64-linux.so)
    by 0x409FA2: sortlines (sort.c:3649)
    by 0x409E26: sortlines (sort.c:3621)
    by 0x40AA9E: sort (sort.c:3955)
    by 0x40C5D9: main (sort.c:4739)
 mutex 0x5419548 was first observed at:
    at 0x4C2DE82: pthread_mutex_init(in vgpreload_drd-amd64-linux.so)
    by 0x409266: init_node (sort.c:3276)
    by 0x4092F4: init_node (sort.c:3286)
    by 0x4090DD: merge_tree_init (sort.c:3234)
    by 0x40AA5A: sort (sort.c:3951)
    by 0x40C5D9: main (sort.c:4739)

 Thread 2:
 The object at address 0x5419548 is not a mutex.
    at 0x4C2F4A4: pthread_mutex_unlock(in vgpreload_drd-amd64-linux.so)
    by 0x4093CA: unlock_node (sort.c:3323)
    by 0x409C85: merge_loop (sort.c:3531)
    by 0x409F8F: sortlines (sort.c:3644)
    by 0x409CE3: sortlines_thread (sort.c:3574)
    by 0x4E44F32: start_thread (in /usr/lib64/libpthread-2.18.so)
    by 0x514EEAC: clone (in /usr/lib64/libc-2.18.so)

* src/sort.c (sortlines): Move pthread_mutex_destroy() out to
merge_tree_destroy(), so that we don't overlap mutex destruction
with threads still operating on the nodes.
(sort): Call the destructors only with "lint" defined, as the
memory used will be deallocated implicitly at process end.
* NEWS: Mention the bug fix.

11 years agosort: fix two threading issues reported by valgrind
Shayan Pooya [Sat, 25 Jan 2014 00:37:12 +0000 (00:37 +0000)] 
sort: fix two threading issues reported by valgrind

Neither issue impacts on the correct operation of sort.
The issues were detected by both valgrind 3.8.1 and 3.9.0 using:

  seq 200000 > file.sort
  valgrind --tool=drd src/sort file.sort -o file.sort

For tool usage and error details see:
 http://valgrind.org/docs/manual/drd-manual.html

* src/sort.c (queue_insert): Unlock mutex _after_ signalling the
associated condition variable.  Valgrind flags this with:
  "Probably a race condition: condition variable 0xffeffffb0 has been
   signaled but the associated mutex 0xffeffff88 is not locked by the
   signalling thread."
The explanation at the above URL is:
  "Sending a signal to a condition variable while no lock is held on
   the mutex associated with the condition variable.  This is a common
   programming error which can cause subtle race conditions and
   unpredictable behavior."
This should at least give more defined scheduling behavior.

(merge_tree_destroy): Make symmetrical with merge_tree_init() thus
destroying the correct mutex.  Valgrind flags this with:
  "The object at address 0x5476cf8 is not a mutex."

11 years agomaint: avoid an inconsequential mem leak
Pádraig Brady [Sun, 13 Jul 2014 18:16:42 +0000 (19:16 +0100)] 
maint: avoid an inconsequential mem leak

* src/df.c (get_disk): Avoid an inconsequential mem leak
spotted by coverity.  Also s/duplicities/duplicates/.

11 years agobuild: adjust new rule not to depend on bash-4.x
Jim Meyering [Sun, 13 Jul 2014 17:24:33 +0000 (10:24 -0700)] 
build: adjust new rule not to depend on bash-4.x

* man/local.mk (man/dynamic-deps.mk): Use the same code to
derive FOO from man/FOO.1 as in the .x.1 rule below.
Using the more concise "name=$${man:4: -2}" is not portable enough.

11 years agobuild: support building all tools in a single binary
Alex Deymo [Fri, 6 Jun 2014 02:50:32 +0000 (19:50 -0700)] 
build: support building all tools in a single binary

Add the --enable-single-binary option to the configure file.
When enabled, this option builds a single binary file containing
the selected tools.  Which tool gets executed depends on the value
of argv[0] which can be set implicitly through symlinks to the
single program.

This setup reduces significantly the size of a complete coreutils
install, since code from lib/libcoreutils.a is not duplicated in
every one of the more than 100 binaries.  Runtime overhead is
increased due to more dynamic libraries being loaded, and extra
initialization being performed for all utils.  Also initially
a larger binary is loaded from storage, though this is usually
alleviated due to caching and lazy mmaping of unused blocks,
and in fact the single binary should have better caching
characteristics.

Comparing the size of the individual versus single binary on x86_64:
  $ cd src
  $ size coreutils
  $ size -t $(../build-aux/gen-lists-of-programs.sh --list-progs |
              grep -Ev '(coreutils|libstdbuf)') | tail -n1
     text    data     bss     dec     hex filename
  1097416    5388   88432 1191236  122d44 src/coreutils
  4901010  124964  163768 5189742  4f306e (TOTALS)

Storage requirements are reduced similarly:
  $ cd src
  $ du -h coreutils
  $ du -ch $(../build-aux/gen-lists-of-programs.sh --list-progs |
             grep -Ev '(coreutils|libstdbuf)') | tail -n1
  1.2M    coreutils
  5.3M    total

When installing, the makefile will create either symlinks or
shebangs based on the --enable-single-binary setting, for
each configured tool. In this way, all the tools are still
callable individually, but they are all implemented by the same
"coreutils" binary installed on the same directory.

* .gitignore: Add new generated files.
* Makefile.am: New rules to generate build-aux/gen-single-binary.sh
  and install symlinks.
* NEWS: Mention the new feature.
* README: Add "coreutils" to the list of utils.
* bootstrap.conf: Regenerate src/single-binary.mk
* build-aux/gen-lists-of-programs.sh: New --list-progs option.
* build-aux/gen-single-binary.sh: Regenerate
* configure.ac: New --enable-single-binary option and other variables.
Disallow --enable-single-binary=symlinks with --program-prefix et. al.
* man/coreutils.x: Manpage hook.
* man/local.mk: Add manpage hook and fix dependencies.
* src/coreutils.c: Multicall implementation.
* src/local.mk: New rules for the single binary option.
* tests/local.mk: Add $single_binary_progs to support
require_built_() from init.cfg
* tests/misc/env.sh: Avoid the use of symlink to echo.
* tests/misc/help-version.sh: Add exception for coreutils.
* tests/install/basic-1.sh: Really avoid using ginstall strip
functionality if there is an issue with the independent strip command.
* src/kill.c: Changes to call exit() in main.
* src/readlink.c: Likewise.
* src/shuf.c: Likewise.
* src/timeout.c: Likewise.
* src/truncate.c: Likewise.

11 years agomaint: simplify parsing df's output in shell scripts
Bernhard Voelker [Thu, 3 Jul 2014 23:54:45 +0000 (01:54 +0200)] 
maint: simplify parsing df's output in shell scripts

Avoid complicated and error-prone parsing of df's output via
sed(1), cut(1), etc., and instead use df's more modern --output
option.

* src/ioblksize.h (in a comment): Simplify the extraction of the
device name of the mounted file system from df's output.
* tests/dd/skip-seek-past-dev.sh: Likewise.
* tests/du/2g.sh: Likewise for the 'avail' column here.
Also avoid the deprecated use of "tail -NUM".
* tests/misc/stat-mount.sh: While at it, remove the determination
of the mount point of "." via df(1) plus sed(1) as it is unused
since commit v8.5-159-gf57cb37 anyway.  Instead, improve this test
by verifying that the output of "stat -c%m ." at least starts with
a slash '/'.

11 years agopwd: revert default mode back to -P
Pádraig Brady [Wed, 2 Jul 2014 10:28:05 +0000 (11:28 +0100)] 
pwd: revert default mode back to -P

Revert commit v8.22-131-g3e89d5b as even though POSIX
states that the default mode should be -L,
common practice for stand-alone pwd implementations
is to default to -P.

* src/pwd.c (usage): Retain mention of the default mode of operation.

Suggested by Bob Proulx

11 years agotests: avoid false failure with spaces in mount point paths
Pádraig Brady [Wed, 2 Jul 2014 13:39:04 +0000 (14:39 +0100)] 
tests: avoid false failure with spaces in mount point paths

* tests/ls/readdir-mountpoint-inode.sh: Quote appropriately
to process mount points with spaces in the path.
Previously items like these would usually be skipped,
though if the path also contained a '-' for example,
that would stat stdin, thus producing a wrong inode
and a false failure.
Fixes http://bugs.gnu.org/17863

11 years agotests: avoid errors on systems without getmntent
Pádraig Brady [Wed, 2 Jul 2014 09:16:04 +0000 (10:16 +0100)] 
tests: avoid errors on systems without getmntent

* tests/df/no-mtab-status.sh: Skip if getmntent() not available.
* tests/df/skip-duplicates.sh: Likewise.
Fixes http://bugs.gnu.org/17863

11 years agotests: use "env builtin" in place of "$abs_top_builddir/src/builtin"
Jim Meyering [Tue, 1 Jul 2014 16:40:50 +0000 (09:40 -0700)] 
tests: use "env builtin" in place of "$abs_top_builddir/src/builtin"

This works for any program that might also be a shell built-in.
It is more concise.  In addition, it makes output more reproducible:
some diagnostics include argv[0], which will now be just the program
name, rather than the full absolute name of the executable.
* tests/misc/sort-compress.sh: Use env kill, rather than absolute name.
* tests/install/trap.sh: Likewise.
* tests/misc/timeout.sh: Likewise.
* tests/touch/no-dereference.sh: Do the same for two uses of "test".
* tests/touch/no-create-missing.sh: Likewise.

11 years agomaint: fix context_t init warning on systems without selinux
Alex Deymo [Wed, 2 Jul 2014 05:52:32 +0000 (22:52 -0700)] 
maint: fix context_t init warning on systems without selinux

On systems without libselinux, context_t is defined as an int type,
but defined as a pointer type by SELinux.

* src/chcon.c: Init with 0 rather than NULL to avoid warning.

11 years agotests: adapt tests to change in pwd's default
Jim Meyering [Tue, 1 Jul 2014 15:32:57 +0000 (08:32 -0700)] 
tests: adapt tests to change in pwd's default

* tests/misc/pwd-option.sh (base): Initialize with -P,
now that -L is the default, to accommodate an initial
working directory with a symlink component.
* tests/misc/readlink-fp-loop.sh: Use $(env pwd -P) to get the
absolute working directory.  Using "env" ensures we do not invoke
any shell built-in, and PATH ensures we invoke the one from coreutils.
* tests/readlink/can-e.sh: Likewise.
* tests/readlink/can-f.sh: Likewise.
* tests/readlink/can-m.sh: Likewise.

11 years agomaint: fix const correctness warnings with security_context_t
Pádraig Brady [Tue, 1 Jul 2014 01:44:10 +0000 (02:44 +0100)] 
maint: fix const correctness warnings with security_context_t

The security_context_t type was always an artificial separation
from a standard char* string, and various libselinux using code
assumed both were synonymous.  In addition, prior to libselinux 2.3
function declarations were incorrect wrt constness of this type.
Here we replace security_context_t with char*, and also
provide a wrapper function to cater for the const issue on
older libselinux.

* src/system.h (se_const): A new function to avoid and identify
the const issue on older libselinux.
* src/copy.c: s/security_context_t/char */.
* src/cp.c: Likewise.
* src/id.c: Likewise.
* src/install.c: Likewise.
* src/ls.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/runcon.c: Likewise.
* src/selinux.c: Likewise.
* tests/cp/no-ctx.sh: Likewise.
* src/chcon.c: Likesize.