]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
11 years agotests: avoid problematic $(< file) shell construct
Pádraig Brady [Sat, 7 Dec 2013 15:36:33 +0000 (15:36 +0000)] 
tests: avoid problematic $(< file) shell construct

* tests/cp/link-deref.sh: This was seen to cause an issue
with dash v0.5.6 at least, so change to a simpler expression.

11 years agotests: fix false failure on platforms using newfstatat
Pádraig Brady [Sat, 7 Dec 2013 15:00:06 +0000 (15:00 +0000)] 
tests: fix false failure on platforms using newfstatat

* tests/ls/stat-free-color.sh: Add newfstatat to the list
of syscalls to trace.  Also add all "stat" syscalls to the
list of syscalls that we verify that strace supports.
Also only create a single dangling symlink to check, since
we already only check for a single "stat" call.
Fixes http://bugs.gnu.org/16075 seen on AArch64

11 years agotests: avoid a false memory leak test failure
Pádraig Brady [Sat, 7 Dec 2013 16:14:40 +0000 (16:14 +0000)] 
tests: avoid a false memory leak test failure

* tests/misc/shuf-reservoir.sh: Restrict the valgrind
"exit on leak" behavior to developer environments where
specific "lint" code is enabled to avoid inconsequential leaks.

11 years agotests: fix shuf test verifying that -i and -e can not be combined
Bernhard Voelker [Fri, 6 Dec 2013 19:24:38 +0000 (20:24 +0100)] 
tests: fix shuf test verifying that -i and -e can not be combined

Previously, the test triggered another error diagnostic:
  shuf: invalid input range ‘-e’
and therefore eclipsed the expected one:
  shuf: cannot combine -e and -i options

While at it, reindent a line with more than 80 characters, present
since the previous commit to silence sc_long_lines.

* tests/misc/shuf.sh: Pass a valid range to the -i option.

11 years agoshuf: --repeat, not --repetitions; default --head-count is infinity
Paul Eggert [Fri, 6 Dec 2013 17:55:17 +0000 (09:55 -0800)] 
shuf: --repeat, not --repetitions; default --head-count is infinity

Original problem reported by Philipp Thomas in
<http://bugs.gnu.org/16061>.
* NEWS: shuf --repeat, not shuf --repetitions.
* doc/coreutils.texi (shuf invocation):
* src/shuf.c (usage, long_opts, main):
* tests/misc/shuf.sh:
Likewise.  Also, the default head-count is infinity.

11 years agodoc: clarify that df now generally processes special files correctly
Bernhard Voelker [Thu, 5 Dec 2013 23:59:36 +0000 (00:59 +0100)] 
doc: clarify that df now generally processes special files correctly

Since v8.21-172-g33660b4, df not only treats symbolic link arguments
differently, as stated there, but now generally processes special file
arguments in a non-canonicalized form correctly:

  $ cd /dev && df-old sdb
  Filesystem     1K-blocks  Used Available Use% Mounted on
  devtmpfs         1014572    48   1014524   1% /dev

  $ cd /dev && df-new sdb
  Filesystem     1K-blocks    Used Available Use% Mounted on
  /dev/sdb        10190136 6039532   3609932  63% /home

Document df's new behavior.

* doc/coreutils.texi (df invocation): In the paragraph describing
df's behavior regarding special file arguments, relax the condition
for such special files from "... is an absolute name of ..." to
"... resolves to ...".
* NEWS (Bug fixes): Mention the new behavior also here.

11 years agotests: fix false failure with disabled SELinux support
Pádraig Brady [Thu, 5 Dec 2013 00:02:41 +0000 (00:02 +0000)] 
tests: fix false failure with disabled SELinux support

This could trigger on SELinux systems where we build --qithout-selinux
or where the SELinux development libraries are not installed.

* init.cfg (require_selinux_enforcing_): Call require_selinux_()
to determine if the current build supports SELinux.  This avoids
a false failure in tests/mkdir/selinux.sh where only mkdir would
determine that SELinux was disabled and thus ignore invalid contexts.
(require_selinux_): Refactor a little to distinguish whether it's
the build or the (file) system that doesn't support SELinux.

11 years agoselinux: fix --context=CTX for cp and diagnose defaultcon() errors
Pádraig Brady [Wed, 4 Dec 2013 19:10:37 +0000 (19:10 +0000)] 
selinux: fix --context=CTX for cp and diagnose defaultcon() errors

* src/selinux.h (ignorable_ctx_err): A new function used
to determine if a warning should be given after a call
to defaultcon() or restorecon().
* src/cp.c (main): Fix the setfscreatecon() call to use
the argument passed by the user.
* src/mkdir.c (make_ancestor): Show all but "ignoreable" errors
from defaultcon() and restorecon().
* tests/misc/selinux.sh: Add a test run as root in selinux enforcing
mode, to ensure cp --context=invalid is honored and fails immediately.

11 years agomd5sum, sha*sum: use libcrypto where available
Pádraig Brady [Tue, 3 Dec 2013 03:51:52 +0000 (03:51 +0000)] 
md5sum, sha*sum: use libcrypto where available

libcrypto is generally available and has well optimized
crypto hash routines particular to various systems.
For example, testing sha1sum with openssl-1.0.0j
on an i3-2310M, gives a performance boost of about 40%:

$ time sha1sum.old --tag ~/test.iso
SHA1 (/home/padraig/test.iso) = 3c27f7ed01965fd2b89e22128fd62dc51a3bef30
real    0m4.692s
user    0m4.499s
sys     0m0.162s

$ time sha1sum.new --tag ~/test.iso
SHA1 (/home/padraig/test.iso) = 3c27f7ed01965fd2b89e22128fd62dc51a3bef30
real    0m2.685s
user    0m2.512s
sys     0m0.170s

* configure.ac: By default, enable use of libcrypto if available.
* src/local.mk: Link with libcrypto.
* NEWS: Mention the md5sum and sha*sum improvements.

11 years agodf: handle bind mounts when processing device nodes
Pádraig Brady [Wed, 4 Dec 2013 00:50:10 +0000 (00:50 +0000)] 
df: handle bind mounts when processing device nodes

* src/df.c (get_disk): Use the same heuristic used in
get_point() to select the shortest file system mount point,
in an attempt to show the base mounted file system.
* NEWS: Mention the bug fix.

11 years agodf: dereference symlinks to disk device nodes
Pádraig Brady [Tue, 3 Dec 2013 23:36:02 +0000 (23:36 +0000)] 
df: dereference symlinks to disk device nodes

This is so the matching for the device is done on the canonical name
of the disk node, rather than on the path of the symlink.
In any case the user will generally want to use the symlink target.

* src/df.c (get_disk): Canonicalize the passed file,
before matching against the list of mounted file system devices.
Note we pass the original symlink name to the "file" output field,
as the symlink target is usually available through the "source" field.
* tests/df/df-symlink.sh: Test the dereferencing operation.
* tests/local.mk: Mention the new test.
* NEWS: Mention the fix.
Reported by Ondrej Oprala

11 years agobuild: update gnulib submodule to latest
Pádraig Brady [Wed, 4 Dec 2013 13:06:45 +0000 (13:06 +0000)] 
build: update gnulib submodule to latest

Note tests/init.sh and bootstrap are still in sync with gnulib.

* gnulib: Sync two configure check fixes.
- Avoid generating core dumps from regex configure check
- Fix compile error in getcwd configure check

11 years agobuild: update gnulib submodule to latest
Pádraig Brady [Wed, 4 Dec 2013 02:00:55 +0000 (02:00 +0000)] 
build: update gnulib submodule to latest

Note tests/init.sh and bootstrap are still in sync with gnulib.

* gnulib: Sync many fixes/changes, including the base64
encoding speedup mentioned in commit v8.21-145-g9120845
Also included is support for enabling use of libcrypto hash routines
which are generally well optimized for particular systems.

11 years agomaint: avoid '%s' quoting notation in diagnostic messages
Bernhard Voelker [Tue, 3 Dec 2013 07:02:57 +0000 (08:02 +0100)] 
maint: avoid '%s' quoting notation in diagnostic messages

Add a new rule to ensure the use of quote() instead of '%s' or `%s'
in format strings of diagnostics messages.

* cfg.mk (sc_prohibit_quotes_notation): Add rule.
* TODO: Remove the entry regarding the '%s' notation.
* src/mkfifo.c (main): Remove the offending and in this case even
duplicate quoting in the format string of the error diagnostic.
* src/mknod.c (main): Likewise.
* src/df.c (decode_output_arg): Change two invocations of error()
according to the above new rule.
* src/numfmt.c: Fix numerous wrong quote notations to fit the above
new rule, mostly in internal debugging diagnostic messages.

11 years agodoc: remove obsolete info on terminal alignment bugs
Pádraig Brady [Sun, 1 Dec 2013 12:15:34 +0000 (12:15 +0000)] 
doc: remove obsolete info on terminal alignment bugs

* doc/coreutils.texi (ls invocation): Remove the note about
OSX terminals not aligning properly as this is no longer the case.
Tested by: Philipp Thomas

11 years agobuild: fix potential factor build failure on arm and powerpc
Pádraig Brady [Fri, 29 Nov 2013 04:13:11 +0000 (04:13 +0000)] 
build: fix potential factor build failure on arm and powerpc

* src/longlong.h: Sync with the latest longlong.h from libgmp to:
- avoid arm asm when being compiled for the thumb instruction [sub]set
- avoid old powerpc assembly that is incompatible with newer GCC
- add arm64 optimized count_trailing_zeros()
- add sparc64 optimized add_ssaaaa() and umul_ppmm()

11 years agotests: add a test for rm -r "/"
Bernhard Voelker [Fri, 29 Nov 2013 08:20:22 +0000 (09:20 +0100)] 
tests: add a test for rm -r "/"

* tests/rm/r-root.sh: Add a non-root test.
* tests/local.mk (all_tests): Mention the test.

11 years agomaint: remove various FIXME comments
Bernhard Voelker [Fri, 29 Nov 2013 11:18:06 +0000 (12:18 +0100)] 
maint: remove various FIXME comments

* src/extent-scan.c (extent_need_sync): Remove the FIXME comment about
removing the work around.  As discussed in [1], the needed FIEMAP fix
never made it into the Linux kernel.

* src/realpath.c (longopts): Remove the FIXME comment about deprecating
the --strip option as it's a valid alias for --no-symlinks option.
Also discussed in [1].

[1] http://lists.gnu.org/archive/html/coreutils/2013-11/msg00103.html

11 years agodf: remove long-obsolescent --megabytes option
Bernhard Voelker [Fri, 29 Nov 2013 12:07:47 +0000 (13:07 +0100)] 
df: remove long-obsolescent --megabytes option

This option has been undocumented for 12 years [1], and warned
about for a year [2].

[1] commit FILEUTILS-4_1_4-23-gd177203
[2] commit v8.17-43-g453ce92

* src/df.c (MEGABYTES_OPTION): Remove.
(long_options): Remove "megabytes" element.
(main): In the option parsing loop, remove the MEGABYTES_OPTION case.
* NEWS: Mention the change.

11 years agobuild: fix selinux.c build failure on 32 bit
Pádraig Brady [Thu, 28 Nov 2013 02:23:11 +0000 (02:23 +0000)] 
build: fix selinux.c build failure on 32 bit

* src/selinux.c: Don't include the system "fts.h" as
that disallows _FILE_OFFSET_BITS=64 which gnulib auto enables
to support large files on 32 bit systems.  Instead include
our "xfts.h" which includes the less limited gnulib replacement,
and also a checked version of xfts_open().
(restorecon): Use the checked xfts_open() rather than the standard
fts_open().
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/6934169

11 years agobuild: avoid more selinux build failures
Pádraig Brady [Wed, 27 Nov 2013 18:21:48 +0000 (18:21 +0000)] 
build: avoid more selinux build failures

Handle both newer selinux libraries with mode_to_security_class(),
and systems without selinux at all.  We could easily adjust
gnulib to provide the necessary stubs for use by this module,
but it's more efficient to just stub out the module completely,
when not using selinux.

* src/selinux.h: Define stubs for the two module functions,
when SELinux is not available.
* src/selinux.c: Exclude all logic in preference for the stubs
when selinux isn't used.  Also when newer selinux libs are used,
don't use our conflicting static version of mode_to_security_class().
m4/jm-macros.m4: Check for the system mode_to_security_class().

11 years agobuild: avoid build failure on non selinux systems
Pádraig Brady [Wed, 27 Nov 2013 16:35:24 +0000 (16:35 +0000)] 
build: avoid build failure on non selinux systems

* src/selinux.c: This module introduced in commit v8.21-159-gd8e27ab
doesn't need to include <selinux/flask.h>.  That header file
isn't catered for by gnulib, but is not needed as we're not
explicitly referencing any class IDs.
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/6920020

11 years agoselinux: adjust utils to run restorecon with -Z
Pádraig Brady [Wed, 27 Nov 2013 12:26:51 +0000 (12:26 +0000)] 
selinux: adjust utils to run restorecon with -Z

cp, mv, install, mkdir, mkfifo, mknod are adjusted so that:
 -Z no longer accepts an argument.
 -Z or --context without an argument do not warn without SELinux.
 --context with an argument will warn without SELinux.

* src/local.mk: Reference the new selinux module where required.
* src/system.h: Make the argument to --context optional.
* src/mkdir.c: Likewise.  Also handle the SMACK case for --context.
Note we currently silently ignore -Z with SMACK.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/install.c: Likewise.  Note install(1) by default already
set the context for target files to their system default,
albeit with an older method.  Use the -Z option to select between
the old and new context restoration behavior, and document
the differences and details for how context restoration
is done in new and old methods, with a view disabling the
old method entirely in future.
* src/cp.c: Make the argument to --context optional.
Note -Z implies --no-preserve=context.  I.E. -Z overrides
that aspect of -a no matter what order specified.
(struct cp_options): Document the context handling options.
(main): Check/adjust option combinations after all
options are processed, to both simplify processing
and to make handling independent of order of options
on the command line.  Also improve the diagnostics
from a failed call to setfscreatecon().
(set_process_security_ctx): A new function,
refactored to set the default context from the source file,
or with the type adjusted as per the system default for
the destination path.
(set_file_security_ctx): A new function refactored to
set the security context of an existing file, either based on
the process context or the default system context for a path.
(copy_internal): Use the refactored functions to simplify
error handling and consistently fail or warn as needed.
(copy_reg): Likewise.
(copy_internal): With --preserve=context, also copy
context from non regular files.  Note for directories this may
impact the copying of subsequent files to that directory?
(copy_attr): If we're handling SELinux explicitly,
then exclude to avoid the redudant copy with --preserve=context,
and the problematic copy with -Z.  Note SELinux attribute exclusion
also now honors cp -a --no-preserve=context.  Note there was a
very small window over 10 years ago, where attr_copy_file was
available, while attr_copy_check_permissions was not, so we
don't bother adding an explicit m4 check for the latter function.
* src/mv.c: Support --context, but don't allow specifying an argument.
* src/chcon.c: Adjust a comment to be specific to SELinux.
* src/runcon.c: Likewise.
* src/copy.c: Honor the context settings to "restorecon" as appropriate.
* src/copy.h: Add a new setting to select "restorecon" functionality.
* tests/mkdir/selinux.sh: s/-Z/--context=/
* tests/cp/cp-a-selinux.sh: Augment this test with cases
testing basic -Z functionality, and also test the various
invalid option combinations and option precedence.
* tests/mkdir/restorecon.sh: Add a new test for the
more involved mkdir -Z handling, since the directory changing
and non existent directories need to be specially handled.
Also check the similar but simpler handling of -Z by mk{nod,fifo}.
* tests/local.mk: Reference the new test.
* doc/coreutils.texi (cp invocation): Update as per interface changes.
(mv invocation): Likewise.
(install invocation): Likewise.
(mkfifo invocation): Likewise.
(mknod invocation): Likewise.
(mkdir invocation): Likewise.
* NEWS: Mention the new feature and change in behavior.

11 years agoselinux: a new module implementing "restorecon" functionality
Daniel J Walsh [Wed, 27 Nov 2013 12:24:26 +0000 (12:24 +0000)] 
selinux: a new module implementing "restorecon" functionality

* src/selinux.c: A new module implementing "restorecon" functionality.
There are two main functions to adjust the type of the referenced
file system item.  defaultcon() will setup the process context so
that new items will have the required context without races.  This is
the preferred method.  For existing files, the equivalent restorecon()
is available which has two modes.  With the "local" parameter set to
false, restorecon() will adjust the type according to the system
configuration for that file, and set to true will update the context
as per the context for the current process (disregarding type).
* src/selinux.h: Likewise.
* po/POTFILES.in: Reference the new module.

11 years agoshred: provide --remove methods to avoid excessive syncing
Pádraig Brady [Thu, 7 Nov 2013 17:00:56 +0000 (17:00 +0000)] 
shred: provide --remove methods to avoid excessive syncing

A sync operation is very often expensive.  For illustration
I timed the following python script which indicated that
each ext4 dir sync was taking about 2ms and 12ms, on an
SSD and traditional disk respectively.

  import os
  d=os.open(".", os.O_DIRECTORY|os.O_RDONLY)
  for i in range(1000):
     os.fdatasync(d)

So syncing for each character for each file can result
in significant delays.  Often this overhead is redundant,
as only the data is sensitive and not the file name.
Even if the names are sensitive, your file system may
employ synchronous metadata updates, which also makes
explicit syncing redundant.

* tests/misc/shred-remove.sh: Ensure all the new parameters
actually unlink the file.
* doc/coreutils.texi (shred invocation): Describe the new
parameters to the --remove option.
* src/shred.c (Usage): Likewise.
(main): Parse the new options.
(wipename): Inspect the new enum to see which of
the now optional tasks to perform.
* NEWS: Mention the new feature.
* THANKS.in: Add reporter Joseph D. Wagner

11 years agotail: improve inotify handling of symlinks
Pádraig Brady [Fri, 13 Sep 2013 15:31:24 +0000 (17:31 +0200)] 
tail: improve inotify handling of symlinks

Previous behavior failed to read contents of a (re)appearing file,
when symlinked by tail's watched file.  Also we now diagnose other
edge cases when running in inotify mode, where an initially
missing or regular file changes to a symlink.

* src/tail.c (main): If any arg is a symlink, use polling mode.
(recheck): Diagnose the edge case where a symlink appears during
inotify processing.
* tests/tail-2/symlink.sh: Test the fix. Mention the edge cases.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
Reported by: Ondrej Oprala

11 years agodf: add --output=file to directly output specified arguments
Pádraig Brady [Fri, 22 Nov 2013 02:12:34 +0000 (02:12 +0000)] 
df: add --output=file to directly output specified arguments

* src/df.c (usage): Document the new 'file' --output field.
(get_dev): Add a new parameter to pass the specified
argument from the command line through.  Use '-' if a
command line parameter is not being used.
* doc/coreutils.texi (df invocation): Describe the new 'file' field.
* tests/df/df-output.sh: Adjust all fields test, and
add a specific test for --output=file.
* NEWS: Mention the new feature.

11 years agotimeout: avoid unlikely issues with --kill-after
Pádraig Brady [Tue, 26 Nov 2013 14:27:25 +0000 (14:27 +0000)] 
timeout: avoid unlikely issues with --kill-after

* src/timeout.c (cleanup): When calling settimeout() from
this signal handler, ensure we don't call out to error()
or gettext(), which are not async-signal-safe.
Also reset the errno which may be cleared by settimeout().

11 years agotests: ensure factor tests can be regenerated
Pádraig Brady [Tue, 26 Nov 2013 13:37:50 +0000 (13:37 +0000)] 
tests: ensure factor tests can be regenerated

* tests/local.mk (factor-tests:) Add -f to the mv command that
replaces any existing generated tests.  This is required to avoid
prompts when root initially generates the tests, and they subsequently
need to be regenerated by a non root user.

11 years agosort: avoid issues when issuing diagnostics from child processes
Pádraig Brady [Tue, 26 Nov 2013 02:47:36 +0000 (02:47 +0000)] 
sort: avoid issues when issuing diagnostics from child processes

* src/sort.c: (async_safe_die): A new limited version of error(),
that outputs fixed strings and unconverted errnos to stderr.
This is safe to call in the limited context of a signal handler,
or in this particular case, between the fork() and exec() of
a multithreaded process.
(move_fd_or_die): Use the async_safe_die() rather than error().
(maybe_create_temp): Likewise.
(open_temp): Likewise.
Fixes http://bugs.gnu.org/15970

11 years agodoc: clarify the operation of ls -k
Pádraig Brady [Tue, 26 Nov 2013 15:32:39 +0000 (15:32 +0000)] 
doc: clarify the operation of ls -k

* src/ls.c (usage): Mention -k only changes the display
for disk usage (directory total, and ls -s), and imply
that it can be overridden (by --block-size, and -h).
* doc/coreutils.texi (block size): Mention that ls -k
handling is different to other utilities.
Addresses http://bugs.gnu.org/14525

11 years agodircolors: add a new entry to colorize 'lz4' files
John [Sat, 23 Nov 2013 00:01:54 +0000 (00:01 +0000)] 
dircolors: add a new entry to colorize 'lz4' files

* src/dircolors.hin: Add entry for the speed optimized 'lz4' compressor.

11 years agotests: enhance rm test regarding "." and ".."
Bernhard Voelker [Fri, 22 Nov 2013 14:54:06 +0000 (15:54 +0100)] 
tests: enhance rm test regarding "." and ".."

Recent commit 2da7009d changed the error diagnostic of rm(1) trying
to remove "." or "..".  Enhance the corresponding test.

* tests/rm/r-4.sh: Ensure rm(1) outputs the expected error diagnostic.

11 years agomaint: avoid perl warning in sc_check-AUTHORS
Bernhard Voelker [Thu, 21 Nov 2013 11:11:01 +0000 (12:11 +0100)] 
maint: avoid perl warning in sc_check-AUTHORS

With newer perl, "make syntax-check" issues many warnings like:
  -i used with no filenames on the command line, reading from STDIN.

* cfg.mk (sc_check-AUTHORS): Remove the -i flag in the perl
invocation as it is reading from a pipe.

11 years agodoc: enhance diagnostic when rm skips "." or ".." arguments
Bernhard Voelker [Thu, 21 Nov 2013 00:03:15 +0000 (01:03 +0100)] 
doc: enhance diagnostic when rm skips "." or ".." arguments

The error diagnostic
  "rm: cannot remove directory: '.'"
does not give the user a hint for the reason.
Issue a clearer error message.

* src/remove.c (rm_fts): Enhance the error diagnostic in the above
case to emphasize that skipping is done deliberately.
In the corresponding comment, mention that POSIX mandates this
behavior.  Likewise in the subsequent comment for skipping "/".
* doc/coreutils.texi (rm invocation): In the paragraph describing
the above behavior, mention that POSIX mandates it.

11 years agotests: fix false rm -I test failure when run as root
Pádraig Brady [Fri, 15 Nov 2013 18:16:54 +0000 (18:16 +0000)] 
tests: fix false rm -I test failure when run as root

Fix a recent regression introduced in commit v8.21-127-g5ee7d8f

Also related to this is the recent query about root run `rm -I`
ignoring the mode bits of a file: https://bugzilla.redhat.com/1013171

* tests/rm/interactive-once.sh: Avoid the messages and
corresponding file presence checks with write protected files
when running as root.

11 years agostty: add support for mark/space parity
Colin Leitner [Sat, 16 Nov 2013 11:14:18 +0000 (12:14 +0100)] 
stty: add support for mark/space parity

This adds support for using a constant or "stick" parity bit.

* src/stty.c (usage): Mention the new flag.
* tests/misc/stty.sh: Adjust for the new flag.
* NEWS: Mention the improvement.
* docs/coreutils.texi (stty invocation): Mention the new flag.

11 years agobase64: improve encoding I/O efficiency
Pádraig Brady [Mon, 11 Nov 2013 02:51:17 +0000 (02:51 +0000)] 
base64: improve encoding I/O efficiency

Since the I/O overhead is significant to the relatively
simple processing done by this utility, use fputs() rather
than fputc() to output '\n'.
Time to process a 100MiB file was measured to
decrease from 0.417s to 0.383s, i.e. an 8% improvement.

Related to these changes, is a processing improvement in
gnulib, which increases throughput by 60% when processing
full buffers, which improves processing of a 100MiB file
with standard wrapped output, down to 0.256s.
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=43fd1e7b

Also increase the encoding buffer size from 3 to 30KiB.
This was seen to give a further 8% improvement, taking
processing time down to 0.235s in the wrapped output case.
The decoding size buffer is not adjusted,
due to the noted caveat with --ignore-garbage.

* src/base64.c (BLOCKSIZE): Split into ENC_ and DEC_ variants,
with the former increased from 3KiB to 30KiB.
(wrap_write): Use the simpler fputc() rather than fputs()
to output the '\n' character.  Also check against EOF
rather than < 0 for errors.
(do_encode): Likewise.
* NEWS: Mention the large increase in performance, which
with the I/O improvements in coreutils and the processing
improvement in gnulib, amount to about a 60% throughput increase.

11 years agoshred: avoid data write pass with --size=0
Pádraig Brady [Thu, 7 Nov 2013 12:32:29 +0000 (12:32 +0000)] 
shred: avoid data write pass with --size=0

* src/shred.c (dopass): Exit early to avoid redundant heap
allocation, and more importantly avoiding a file sync
when we're writting no data, as this can have side effects.
Also with --verbose, this avoids printing of "pass status"
which could be confusing as to whether data was actually written.
* tests/misc/shred-passes.sh: Ensure the status for data
passes are not written when not doing any data writes.

11 years agoshred: increase I/O block size for periodic pattern case
Pádraig Brady [Thu, 7 Nov 2013 11:57:09 +0000 (11:57 +0000)] 
shred: increase I/O block size for periodic pattern case

* src/shred.c (dopass): In the periodic pattern case increase the
I/O block size from 12KiB to 60KiB (also a multiple of 3 and 4096).
* NEWS: Adjust accordingly.

11 years agoshred: fix direct I/O failures for last write to file
Pádraig Brady [Thu, 7 Nov 2013 13:26:25 +0000 (13:26 +0000)] 
shred: fix direct I/O failures for last write to file

Since direct I/O is now enabled with commit v8.21-139-gebaf961
we must handle the case where we write an odd size at the
end of a file (with --exact), or we specify an odd --size that
is larger than 64KiB, or in the very unlikely case of a device
with an odd size.  This issue was present since direct I/O
support was first added in v5.3.0, but latent since v6.0.
Theoretically this could have also been an issue after that on
systems which didn't have alignment constraints, but did have
size constraints for direct I/O.

* src/shred.c (dopass): On the first pass for a file, always
retry a write that fails with EINVAL, so we handle direct I/O
failure at either the start or end of the file.  Adjust the comment
as the original case is out of date and implicitly handled
by this more general fix.
* tests/misc/shred-exact.sh: Add a test case.
* NEWS: Add a "bug fix" entry for shred since there are
two related issues now fixed.

11 years agocp: fix --link regarding the dereferencing of symbolic links
Gian Piero Carrubba [Thu, 7 Nov 2013 22:35:52 +0000 (23:35 +0100)] 
cp: fix --link regarding the dereferencing of symbolic links

* src/copy.c (create_hard_link): Add a bool 'dereference' parameter,
and pass AT_SYMLINK_FOLLOW as 'flags' to linkat() when dereference
is true.
(should_dereference): Add new 'bool' function to determine if a
file should be dereferenced or not.
(copy_internal): Use the above new should_dereference() and remember
its return value in a new local bool 'dereference' variable.  Use that
in all three calls to create_hard_link().
* src/cp.c (main): after parsing the options, if x.dereference is
still DEFEF_UNDEFINED and the x.recursive is true, then only set
x.dereference to DEREF_NEVER iff --link was not specified.
* doc/coreutils.texi (cp invocation): Mention that cp(1) does not
follow symbolic links in the source when --link is specified.
Likewise in the description of the -R option when used together with
that option.
* tests/cp/same-file.sh: Adapt the expected results for the -fl,
the -bl and the -bfl tests.
* tests/cp/link-deref.sh: Add a new test.
* tests/local.mk (all_tests): Reference the above new test.
* NEWS (Changes in behavior): Mention the change.

This fixes http://bugs.gnu.org/15173

Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
11 years agoshred: write larger chunks when possible
Pádraig Brady [Mon, 4 Nov 2013 23:14:11 +0000 (23:14 +0000)] 
shred: write larger chunks when possible

* src/shred.c (dopass): When not needing to write periodic patterns,
use a 64KiB block size to reduce the number of write system calls.

11 years agoshred: enable direct I/O when possible
Pádraig Brady [Mon, 4 Nov 2013 23:14:10 +0000 (23:14 +0000)] 
shred: enable direct I/O when possible

Commit v5.92-1057-g43d487b introduced a regression
in coreutils 6.0 where it removed the page alignment
of the buffer to write, thus disabling direct I/O.
We want to use direct I/O when possible to avoid
impacting the page cache at least, as we know we don't
want to cache the data we're writing.

* src/shred.c (dopass): Allocate the buffer on the heap,
while using a more general calculation to allow to have
the output size independent from the fillpattern() size
constraint of a multiple of 3.  Also we dispense with the
union as it's no longer needed given we're aligning on
a page boundary and thus don't need to explicitly handle
uint32_t alignment.

11 years agomd5sum, sha*sum: improve help for --check related options
Pádraig Brady [Fri, 1 Nov 2013 10:20:23 +0000 (10:20 +0000)] 
md5sum, sha*sum: improve help for --check related options

* src/md5sum.c (usage): s/three/four/ in the message pertaining
to the --check related options.  Also clarify that --strict
is just significant for the formatting of the checksum lines.
Also since we're changing both strings, move the --strict description
in with the description of the other options and order alphabetically.
* THANKS.in: Added reporter: Daniel Mach

11 years agomaint: simplify printing of md5sum file names
Pádraig Brady [Fri, 1 Nov 2013 16:14:44 +0000 (16:14 +0000)] 
maint: simplify printing of md5sum file names

* src/md5sum.c (main): Add a comment as to why we continue
to escape names that do not have '\n' but do have '\\' chars.
(print_filename): Use the predetermined boolean to decide
whether to escape or not, so that in the common case we
can output the file name directly, rather than inspecting each char.
* tests/misc/md5sum.pl: Add case to show '\\' chars cause escaping.
* tests/misc/sha1sum.pl: Likewise.

11 years agobuild: fix dependencies of man/sha*sum.1
Bernhard Voelker [Fri, 1 Nov 2013 17:59:43 +0000 (18:59 +0100)] 
build: fix dependencies of man/sha*sum.1

Although the above man pages depend on src/md5sum.c as a shared
source, the build of the man pages directly requires their own
executables to exist.

* man/local.mk (man/sha1sum.1): Change the dependency from
'src/md5sum' to 'src/sha1sum'.
(man/sha224sum.1): s/md5sum/sha224sum/
(man/sha256sum.1): s/md5sum/sha256sum/
(man/sha384sum.1): s/md5sum/sha384sum/
(man/sha512sum.1): s/md5sum/sha512sum/

Reported by Pádraig Brady in
http://lists.gnu.org/archive/html/coreutils/2013-11/msg00006.html

11 years agodircolors: add putty-256color terminal type
Mike Frysinger [Tue, 15 Oct 2013 20:04:24 +0000 (16:04 -0400)] 
dircolors: add putty-256color terminal type

* src/dircolors.hin: Add putty-256color
Reported-by: Thomas D. <whissi@whissi.de>, via
http://bugs.gentoo.org/486786
Fixes http://bugs.gnu.org/15624

11 years agomaint: update the instructions for building prerequisites
Pádraig Brady [Tue, 15 Oct 2013 10:05:49 +0000 (11:05 +0100)] 
maint: update the instructions for building prerequisites

* README-prereq: Update as per the latest required versions
in bootstrap.conf.  Also add a missing cd command.
Reported by Aaron Davies
Fixes http://bugs.gnu.org/15612

11 years agocp: correct error message for invalid arguments of '--no-preserve'
Ondřej Vašík [Fri, 11 Oct 2013 16:07:37 +0000 (17:07 +0100)] 
cp: correct error message for invalid arguments of '--no-preserve'

* src/cp.c (decode_preserve_arg):
Correct error message for invalid arguments of '--no-preserve'.
Reported by M.Vadkerti in http://bugzilla.redhat.com/1018206
Fixes http://bugs.gnu.org/15588

11 years agodoc: clarify the example for cp --preserve=links
Pádraig Brady [Thu, 10 Oct 2013 09:13:30 +0000 (10:13 +0100)] 
doc: clarify the example for cp --preserve=links

* doc/coreutils.texi (cp invocation): Give more detail about what's
happening in the example, explicitly calling out the --no-dereference
option required to make the -H and -L options significant.
Also mention the option order significance of the -H and -L options.
Fixes http://bugs.gnu.org/15579

11 years agomktemp: fix incorrect exit status from previous commit
Pádraig Brady [Mon, 7 Oct 2013 10:59:53 +0000 (11:59 +0100)] 
mktemp: fix incorrect exit status from previous commit

* src/mktemp.c (main): Use an exit() strategy consistent with the
previous clauses dealing with optional error messages to ensure
we exit with the correct status in all cases.
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/6412979

11 years agomktemp: with --quiet, only suppress I/O errors
Pádraig Brady [Sun, 6 Oct 2013 16:26:51 +0000 (17:26 +0100)] 
mktemp: with --quiet, only suppress I/O errors

The reason for having a --quiet option is to
suppress only some subset of possible errors.
The most useful separation here is with usage/internal errors,
and errors due to file creation etc. (i.e. I/O errors).

* src/mktemp.c (main): Match the --help and info docs and
only suppress the file/dir creation error messages.
* tests/misc/mktemp.pl: Adjust accordingly.

11 years agomktemp: synchronize the -p option with docs
Pádraig Brady [Sat, 21 Sep 2013 02:33:12 +0000 (03:33 +0100)] 
mktemp: synchronize the -p option with docs

* src/mktemp.c (usage): Synchronize the -p option description with
the logic and info docs.  I.E. that -p is just an alias of --tmpdir.
Also for consistency treat --tmpdir='' the same with or without -t.
I.E. always ignore the --tmpdir option if the param is empty.
Fixes http://bugs.gnu.org/15425

11 years agodoc: expand the texinfo examples for the paste command
Karl Berry [Sun, 6 Oct 2013 15:39:58 +0000 (16:39 +0100)] 
doc: expand the texinfo examples for the paste command

* doc/coreutils.texi (paste invocation): Move the synopsis to the top.
Provide examples for the different type of operations possible.
Add a specific common example to join consecutive lines with a space.

11 years agorm: with -I, prompt before deleting a write protected file
Sergio Durigan Junior [Wed, 25 Sep 2013 10:02:08 +0000 (11:02 +0100)] 
rm: with -I, prompt before deleting a write protected file

This regression was introduced in commit v6.7-71-g0928c24

* src/rm.c (main): Make the -I option behave like --interactive=once.
* tests/rm/interactive-once.sh: Add cases for single and multiple files.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/9308

11 years agomaint: move all id(1) tests to the same directory
Pádraig Brady [Sun, 22 Sep 2013 03:15:34 +0000 (04:15 +0100)] 
maint: move all id(1) tests to the same directory

* tests/misc/id-context.sh -> tests/id/context.sh
* tests/misc/id-setgid.sh -> tests/id/setgid.sh
* tests/misc/id-uid.sh -> tests/id/uid.sh
* tests/misc/id-zero.sh -> tests/id/zero.sh
* tests/local.mk: Reference the renamed tests

11 years agotests: parameterize the "root" username
Pádraig Brady [Sun, 22 Sep 2013 02:59:58 +0000 (03:59 +0100)] 
tests: parameterize the "root" username

* tests/misc/chroot-credentials.sh: Don't assume uid 0
has the "root" name, nor any name for that matter.

11 years agomaint: remove unused parameters to parse_user_spec()
Pádraig Brady [Sun, 22 Sep 2013 02:36:03 +0000 (03:36 +0100)] 
maint: remove unused parameters to parse_user_spec()

* src/chown.c (main): Since "name" parameters to parse_user_spec()
are now optional, just pass NULL for those unused parameters.
* src/chroot.c (main): Likewise.

11 years agoid: support specifying the user by user ID
Pádraig Brady [Fri, 20 Sep 2013 11:38:00 +0000 (12:38 +0100)] 
id: support specifying the user by user ID

* src/id.c (usage): Remove 'name' from the synopsis,
implying that one can also specify by user ID.
(main): Like chown(1), call parse_user_spec() to implement
user name or ID lookup with appropriate precedence.
* doc/coreutils.texi (id invocation): Mention that
a user ID is supported and how '+' affects lookup order.
* tests/misc/id-groups.sh: Remove test now subsumed into...
* tests/misc/id-uid.sh: New test covering new interface.
* tests/local.mk: Rename the test.
* NEWS: Mention the new feature.
Addresses http://bugs.gnu.org/15421

11 years agobuild: update gnulib submodule to latest; also bootstrap to latest
Pádraig Brady [Sat, 21 Sep 2013 15:51:56 +0000 (16:51 +0100)] 
build: update gnulib submodule to latest; also bootstrap to latest

Notes tests/init.sh is still in sync with gnulib.

* bootstrap: Update to latest.
* gnulib: Sync many fixes/changes, including:
a fix for http://bugs.gnu.org/15066
and preparation for http://bugs.gnu.org/15421

11 years agotests: avoid a failure when there isn't a name for all user IDs
Pádraig Brady [Sun, 22 Sep 2013 01:49:40 +0000 (02:49 +0100)] 
tests: avoid a failure when there isn't a name for all user IDs

* tests/misc/id-zero.sh: Don't check exit status when in -n mode.

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/6196762

11 years agoid: add -z, --zero option
Bernhard Voelker [Sat, 21 Sep 2013 12:15:45 +0000 (14:15 +0200)] 
id: add -z, --zero option

* src/group-list.h (print_group_list): Add a parameter for the
delimiter of type char.
* src/group-list.c (print_group_list): Likewise, and use it instead
of a white space character to delimit the group entries.
* src/groups.c (main): Pass white space character to print_group_list().
* src/id.c (longopts):  Add array element for the new long option.
(usage): Document the new option.  While at it, fix the alignment
of the descriptions to match that of HELP_OPTION_DESCRIPTION.
(main): Define the bool flag opt_zero indicating the use of the
new option.  In the getopt_long loop, handle it.
Output an error diagnostic in the case the --zero option has been
specified together with the default format.
In the case of -gG, pass either a NUL or a white space character to
print_group_list() - depending on the above new flag.
Likewise change the printing of the final newline character: output
a NUL instead if the --zero option has been specified.
* doc/coreutils.texi (id invocation): Document the new option.
While at it, move the @exitstatus macro down after the macro
@primaryAndSupplementaryGroups in order to be consistent with
other texinfo documents.
(groups invocation): Move @exitstatus down after the macro
@primaryAndSupplementaryGroups here, too.
* tests/misc/id-zero.sh: Add new test exercising the new option.
* tests/local.mk (all_tests): Reference it.
* NEWS (New features): Mention the new option.
Fixes http://bugs.gnu.org/9987

11 years agomaint: avoid patching help2man
Bernhard Voelker [Wed, 11 Sep 2013 22:02:33 +0000 (00:02 +0200)] 
maint: avoid patching help2man

Commit cde1ea0e separated the coreutils-specific patches from help2man.
Most changes had been made to accommodate to the coreutils style guide,
i.e., to avoid syntax-check failures like sc_long_lines.
Yet 2 changes had to be put into the patch help2man.diff.
But this added the dependency to patch(1) in distribution builds.
Incidentally, the 2 remaining parts of the patch can easily be
done outside of help2man.  Therefore, this commit partly reverts
the recent separation of help2man into 'help2man.in' and
'help2man.diff', and instead uses the original help2man script.

* man/help2man.in: Rename to ...
* man/help2man: ... this file.
* man/help2man.diff: Remove.
* man/local.mk (mandeps): Remove man/help2man.
(man/help2man): Remove recipe.
(.x.1): Add the --info-page option when calling help2man in order
to change the name of the texinfo manual from the default, "info PRG",
to "info coreutils 'PRG invocation'".
Furthermore, use an sed pattern to remove the sentence starting
with "For complete documentation".
* .gitignore (/man/help2man): Remove entry.
* .x-update-copyright: Replace the entries for the files
'man/help2man.diff' and 'man/help2man.in' by 'man/help2man'.
* cfg.mk (sc_long_lines): Instead of 'man/help2man.in', exempt
'man/help2man' from this test.
(sc_po_check): Likewise.
(sc_space_tab): Instead of 'man/help2man.diff', exempt 'man/help2man'
from this test.
(sc_trailing_blank): Likewise.
(sc_prohibit_tab_based_indentation): Instead of 'man/help2man.in' and
'man/help2man.diff', exempt 'man/help2man'.
* man/dummy-man: Recognize the option --info-page=... as no-op.

11 years agomaint: use help2man configured with --disable-nls
Bernhard Voelker [Tue, 10 Sep 2013 05:56:18 +0000 (07:56 +0200)] 
maint: use help2man configured with --disable-nls

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/6038769

The previously committed 'help2man' requires a Perl module
which does not seem to be installed everywhere - and which
is not needed for our purposes:

  Can't locate Locale/gettext.pm in @INC
  BEGIN failed--compilation aborted at ./man/help2man line 28.

This module was pulled in automatically by the default configure call.
Use the NLS-disabled version instead.

* man/help2man.in: Use help2man configured with the --disable-nls
option to avoid the dependency to the above Perl module.
* man/help2man.diff: Adapt the line numbers of the hunks in the
coreutils-specific patch for help2man to apply without fuzz.

Reported by Pádraig Brady.

11 years agobuild: fix corrupted patch causing bootstrap failures
Pádraig Brady [Thu, 5 Sep 2013 16:25:34 +0000 (17:25 +0100)] 
build: fix corrupted patch causing bootstrap failures

The patch was corrupted in commit v8.21-50-g7b65f8e

* gl/modules/tempname.diff: Fix the offsets so that the patch
applies cleanly.  Note that this was only apparent with patch < 2.6.
With patch >= 2.6, patch will not indicate an error applying
the second hunk of the patch and silently ignore it.
I double checked that all patches now apply cleanly by adjusting
gnulib-tool to run patch with --fuzz=0 which might be advisable
going forward, even on a per project basis.
The silent ignoring of hunks by newer patch(1) has been reported.
Fixes http://bugs.gnu.org/15255

11 years agomaint: update help2man to 1.43.3
Bernhard Voelker [Fri, 2 Aug 2013 06:28:50 +0000 (08:28 +0200)] 
maint: update help2man to 1.43.3

Instead of diverging further from the upstream GNU help2man project
(http://www.gnu.org/software/help2man/), hold a copy of the original
script and keep track of our changes in a separate patch file.

The man pages created with the new version show the following,
non-invasive differences:
a) command options in the EXAMPLE sections are no longer in bold format,
b) file names are underlined now consistently.

* man/help2man: Rename to ...
* man/help2man.in: ... this file, and update content from the
upstream GNU help2man project.
* man/help2man.diff: Add patch file for help2man to remove the
sentence "For complete documentation ..." (see commit 5d4f09d8),
and to emit "info coreutils 'PROG invocation'" into the man
pages (77abf69a).
* man/local.mk (mandeps): Add help2man to the dependencies of
the man pages.
(man/help2man): Add rule to generate this script from the upstream
help2man.in file and the help2man.diff patch.
* .gitignore: Add man/help2man as it is no longer version controlled.
* cfg.mk (sc_long_lines): Exempt help2man.in from this check.
(sc_po_check): Likewise.
(sc_space_tab): Likewise.
(sc_trailing_blank): Exempt man/help2man.diff from this check.
(sc_prohibit_tab_based_indentation): Instead of help2man, now exempt
both help2man.in and help2man.diff from this test.
* .x-update-copyright: Add new file and add the above new help2man
files as well as the COPYING file.

11 years agols: fix possible incorrect exit status when recursing directories
FUJIWARA Katsunori [Thu, 5 Sep 2013 01:17:56 +0000 (02:17 +0100)] 
ls: fix possible incorrect exit status when recursing directories

If there is an error reading a directory that was referenced
through recursion, rather than directly on the command line,
then exit with the "less serious" exit code, rather than the
"serious" exit code reserved for command line arguments.
This issue was introduced in commit v5.2.1-1908-gb58dea5

* src/ls.c (print_dir): Ensure that the command_line_arg param
is false for directories being recursed into.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/15249

11 years agomaint: update out of date confusing comments
Pádraig Brady [Sun, 1 Sep 2013 17:40:26 +0000 (18:40 +0100)] 
maint: update out of date confusing comments

* src/copy.c (copy_internal): Change mention of the removed --reply=no
option, to the similar in this context --no-clobber.
* src/sort.c: SI and IEC suffixes can now be mixed when --human-numeric.

11 years agodf: fix "blocks" translation in header
Pádraig Brady [Fri, 9 Aug 2013 04:25:18 +0000 (05:25 +0100)] 
df: fix "blocks" translation in header

* src/df.c (get_header): Get the translation of "blocks" here,
rather than just marking the string for translation.
Fixes http://bugs.gnu.org/15054

11 years agodoc: clarify when seq ends
Bernhard Voelker [Sat, 10 Aug 2013 15:19:06 +0000 (17:19 +0200)] 
doc: clarify when seq ends

* doc/coreutils.texi (seq invocation): Add a sentence clarifying
that seq terminates when LAST becomes smaller than the current number
plus INCREMENT.
* src/seq.c (usage): Likewise.
Fixes http://bugs.gnu.org/15068

12 years agodoc: use more modern file system type examples in df description
Bernhard Voelker [Wed, 7 Aug 2013 18:12:37 +0000 (20:12 +0200)] 
doc: use more modern file system type examples in df description

* doc/coreutils.texi (df invocation): In the example list of common
file system types, exchange the entries which are not so common
anymore (4.2, ufs, efs, hsfs, pcfs) by far more prominent ones
(ext2, ext3, ext4, xfs, btrfs, iso9660, ntfs, fat).

12 years agodoc: fix typo in description of df
Filipus Klutiero [Wed, 7 Aug 2013 08:29:48 +0000 (10:29 +0200)] 
doc: fix typo in description of df

* doc/coreutils.texi (df invocation): s/pseude/pseudo/
* THANKS.in (Filipus Klutiero): Remove entry, now that it will be
automatically included in the generated THANKS file.
Fixes http://bugs.gnu.org/15041

12 years agodoc: more semicolons instead of periods in option descriptions
Benno Schulenberg [Sat, 3 Aug 2013 08:38:12 +0000 (10:38 +0200)] 
doc: more semicolons instead of periods in option descriptions

Also slightly rephrase some descriptions for extra clarity, and
add more consistent indentation.

* src/df.c (usage): Semicolon, no final period.
* src/du.c (usage): Likewise, plus indentation and clarifying words.
* src/ls.c (usage): Semicolon, rephrasings, added parentheses for
clarity, indentation.
* src/rm.c (usage): Semicolons.
* src/tail.c (usage): Adjust -f description to prefer explanatory
language instead of option syntax.

12 years agodoc: clarify that uniq -d outputs a single entry per group
Pádraig Brady [Sat, 3 Aug 2013 09:36:39 +0000 (10:36 +0100)] 
doc: clarify that uniq -d outputs a single entry per group

* src/uniq.c (usage): Clarify the -d option.
Fixes http://bugs.gnu.org/14996

12 years agomaint: update copyright year number ranges of numfmt sources
Bernhard Voelker [Thu, 1 Aug 2013 02:18:00 +0000 (04:18 +0200)] 
maint: update copyright year number ranges of numfmt sources

Run "make update-copyright".

* src/numfmt.c: Update copyright year number range.  This file has
obviously been added to coreutils after and without the annual update.
* tests/misc/numfmt.pl: Likewise.

12 years agodoc: use semicolon instead of period in option descriptions
Benno Schulenberg [Sun, 28 Jul 2013 11:54:20 +0000 (13:54 +0200)] 
doc: use semicolon instead of period in option descriptions

Also do not end option descriptions with a period, properly indent
continuation lines, and make some tiny clarifications.

* src/du.c (usage): Lowercase after semicolon.
* src/ls.c (usage): Semicolons instead of periods, small rephrasing
and two hyphens for clarity, proper indentation.
* src/mktemp.c (usage): Semicolons and lowercase.
* src/od.c (usage): Semicolons.
* src/ptx.c (usage): Use the standard phrase, clarify default option.
* src/setuidgid.c (usage): Properly indent continuation line.
* src/split.c (usage): Semicolons, lowercase, no final period.
* src/stat.c (usage): Semicolons, lowercase.
* src/tail.c (usage): Proper indentation, one shorter rephrasing,
semicolons, no final periods.
* src/timeout.c (usage): Properly indent, semicolons, no final periods.
Fixes http://bugs.gnu.org/14976

12 years agodoc: clarify that cp by default doesn't adjust existing file perms
Pádraig Brady [Mon, 29 Jul 2013 08:51:52 +0000 (09:51 +0100)] 
doc: clarify that cp by default doesn't adjust existing file perms

* doc/coreutils.texi (cp invocation): Mention explicitly what
happens to permissions of existing files when -p is not specified.
Fixes http://bugs.gnu.org/14972

12 years agotests: fix another test failure in test/du/inodes.sh
Bernhard Voelker [Sun, 28 Jul 2013 23:51:55 +0000 (01:51 +0200)] 
tests: fix another test failure in test/du/inodes.sh

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/5584121

du(1) uses the first file object of the two test files linked to the
same inode, 'd/f' and 'd/h', whatever the system returns first.
Use 'd/f' in both the expected and the actual output.

* test/du/inodes.sh: Change the expected output as described above
when returning the --all directory entries (without -l).  Also replace
the name of the hardlink 'd/h' by 'd/f' in the actual output.

12 years agodoc: fix typo
Paul Eggert [Sun, 28 Jul 2013 21:51:32 +0000 (23:51 +0200)] 
doc: fix typo

* doc/coreutils.texi (du invocation): @itemx -> @item.

12 years agomaint: cleanup compare calls in test/du/inodes.sh
Bernhard Voelker [Sun, 28 Jul 2013 16:32:22 +0000 (18:32 +0200)] 
maint: cleanup compare calls in test/du/inodes.sh

* test/du/inodes.sh: In the cases where compare() fails, that function
would show the unified diff automatically.  Therefore, remove the
excess "cat out".
In the cases where expecting an empty file, use compare() again
rather than the simpler "test -s" because possible error reports
will then include the file's content for the same reason as above.

12 years agomaint: avoid clang static analysis issues in csplit
Pádraig Brady [Sun, 28 Jul 2013 01:21:07 +0000 (02:21 +0100)] 
maint: avoid clang static analysis issues in csplit

* src/csplit.c (find_lines): Assert that load_buffer() updates the
global buffers, thus "b" will be non NULL, thus suppressing subsequent
NULL pointer derefence warnings.
(process_regexp): Avoid a redundant assignment of the "line" pointer.
(process_line_count): Likewise.  Also reduce the "line" pointer scope.

12 years agotests: fix intermittent failure in test/du/inodes.sh
Pádraig Brady [Sat, 27 Jul 2013 23:19:45 +0000 (00:19 +0100)] 
tests: fix intermittent failure in test/du/inodes.sh

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/5582213

* test/du/inodes.sh: Due to undefined order in returned directory
entries, the expected output might not match, so sort both expected
and actual output when returning --all directory entries.
Also use a simpler test for ensuring no errors are output.

12 years agodu: add --inodes option
Bernhard Voelker [Sat, 27 Jul 2013 12:25:28 +0000 (14:25 +0200)] 
du: add --inodes option

This new option can be used to find directories with a huge
amount of files.  The GNU find utility has the printf format
"%h" which prints the number of entries in a directory, but
this is non-cumulative and doesn't handle hard links.

* src/du.c (struct duinfo): Add new member for counting inodes.
(duinfo_init): Initialize inodes member with Zero.
(duinfo_set): Set inodes counter to 1.
(duinfo_add): Sum up the 2 given inodes counters.
(opt_inodes): Add new boolean flag to remember if the --inodes
option has been specified.
(INODES_OPTION): Add new enum value to be used ...
(long_options): ... here.
(usage): Add description of the new option.
(print_size): Pass inodes counter or size to print_only_size,
depending on the inodes mode.
(process_file): Adapt threshold handling: with --inodes, print or
elide the entries according to the struct member inodes.
(main): Add a case for accepting the new INODES_OPTION.
Print a warning diagnostic when --inodes is used together with the
option --apparent-size or -b.
Reset the output_block_size to 1 ... and thus ignoring the
options -m and -k.
* tests/du/inodes.sh: Add a new test.
* tests/local.mk (all_tests): Mention it.
* doc/coreutils.texi (du invocation): Document the new option.
* NEWS: Mention the new option.

12 years agomv: replace empty directories in cross file system move
Ken Booth [Tue, 2 Jul 2013 00:06:32 +0000 (01:06 +0100)] 
mv: replace empty directories in cross file system move

src/copy.c (copy_internal): Use rmdir() rather than unlink()
when the source is a directory, so that empty directories
are replaced in the destination as per POSIX.
* tests/mv/part-rename.sh: Augment with various combinations.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/14763

12 years agomaint: use new gnulib function to free mount entries in du
Bernhard Voelker [Mon, 22 Jul 2013 10:11:32 +0000 (12:11 +0200)] 
maint: use new gnulib function to free mount entries in du

* src/du.c (fill_mount_table): Use free_mount_entry() instead
of freeing struct members manually.

12 years agomaint: make some shell and perl scripts executable in 'tests/'
Bernhard Voelker [Sun, 21 Jul 2013 23:07:52 +0000 (01:07 +0200)] 
maint: make some shell and perl scripts executable in 'tests/'

Some newer test scripts - partially ones from me - are not executable.
It does not seem to be a problem, but for consistency and to avoid
future problems on unusual platforms or shells change the permissions
by adding the executable bit.

* cfg.mk (sc_tests_executable): Add new syntax-check rule to ensure
that all test scripts are executable.
* tests/df/df-output.sh: Change file mode from 644 to 755.
* tests/du/threshold.sh: Likewise.
* tests/factor/run.sh: Likewise.
* tests/init.sh: Likewise.
* tests/misc/csplit-suppress-matched.pl: Likewise.
* tests/misc/numfmt.pl: Likewise.
* tests/tail-2/retry.sh: Likewise.

12 years agorm: output number of arguments at the interactive prompt
Rasmus Villemoes [Thu, 18 Jul 2013 21:53:12 +0000 (21:53 +0000)] 
rm: output number of arguments at the interactive prompt

Include the number of arguments which rm received in the "Remove all
arguments?" prompt.  This is useful in the, presumably, common case
where the arguments were not provided by hand, but instead were the
result of various shell expansions.  A simple, if somewhat contrived,
example (assuming rm is aliased to rm -I) could be:

  rm * .o

where the prompt "Remove 120 arguments?" is more likely to make
the user catch the problem.

* src/rm.c (main): Include correctly pluralized n_files
in the output message.  Also remove the now redudant "all".
* tests/rm/interactive-always.sh: Adjust to the new prompt.
* tests/rm/interactive-once.sh: Likewise.

12 years agodd: make status=none suppress all diagnostics
Pádraig Brady [Thu, 18 Jul 2013 17:39:55 +0000 (18:39 +0100)] 
dd: make status=none suppress all diagnostics

* src/dd.c (STATUS_NONE): Simplify the enum so that
it's more general than just suppressing transfer counts.
Then test this in all locations where non fatal diagnostics
are output.
* tests/dd/misc.sh: Ensure the diagnostic about
being unable to skip past the end of input is suppressed.
* NEWS: Mention the change in behavior.
Fixes http://bugs.gnu.org/14897

12 years agohead: avoid redundant allocations when reading empty files
Pádraig Brady [Tue, 9 Jul 2013 17:45:34 +0000 (18:45 +0100)] 
head: avoid redundant allocations when reading empty files

* src/head.c (elide_tail_lines_file): For seekable empty files,
or seekable files where the current offset is after the
end of the file, return immediately.  Previously the short
circuit code could not be reached due to logic error.
Spotted by coverity.

12 years agomaint: avoid a valgrind memory leak warning from pinky
Pádraig Brady [Wed, 10 Jul 2013 00:07:57 +0000 (01:07 +0100)] 
maint: avoid a valgrind memory leak warning from pinky

Similarly to commit v8.21-84-g8d2da3f in src/uptime.c
avoid a "definitely lost" error from valgrind.  Note this
only happens with pinky when compiled without optimization,
in which case certain paths aren't eliminated casuing
valgrind to trigger the message.  Note also that coverity
flags this "resource leak" too.

* src/pinky.c (short_pinky): free utmp_buf for developer builds.

12 years agodf: reduce memory usage when filtering mount entries
Anton Ovchinnikov [Thu, 11 Jul 2013 12:44:24 +0000 (13:44 +0100)] 
df: reduce memory usage when filtering mount entries

Avoid Valgrind reports of "definitely lost" items
and while at it, free all discarded mount entries
to minimize the amount of memory used.

* src/df.c (filter_mount_list): Use the newly exported
free_mount_entry() from gnulib to free all mount entries
as they're discarded.

12 years agobuild: update gnulib submodule to latest
Pádraig Brady [Thu, 11 Jul 2013 11:42:53 +0000 (12:42 +0100)] 
build: update gnulib submodule to latest

12 years agobuild: fix a build warning on 32 bit systems in shuf.c
Pádraig Brady [Thu, 11 Jul 2013 02:20:18 +0000 (03:20 +0100)] 
build: fix a build warning on 32 bit systems in shuf.c

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/5508873

* src/shuf.c (write_random_numbers): Convert to an int type
that matches the prinft format spec.

12 years agoshuf: add --repetition to support repetition in output
Assaf Gordon [Thu, 4 Jul 2013 19:26:45 +0000 (13:26 -0600)] 
shuf: add --repetition to support repetition in output

main(): Process new option.  Replace input_numbers_option_used()
with a local variable.  Re-organize argument processing.
usage(): Describe the new option.
(write_random_numbers): A new function to generate a
permutation of the specified input range with repetition.
(write_random_lines): Likewise for stdin and --echo.
(write_permuted_numbers):  New function refactored from
write_permuted_output().
(write_permuted_lines): Likewise.
* tests/misc/shuf.sh: Add tests for --repetitions option.
* doc/coreutils.texi: Mention --repetitions, add examples.
* TODO: Mention an optimization to avoid needing to
read all of the input into memory with --repetitions.
* NEWS: Mention new shuf option.

12 years agotests: add more tests for shuf option combinations
Assaf Gordon [Fri, 5 Jul 2013 20:59:44 +0000 (14:59 -0600)] 
tests: add more tests for shuf option combinations

* test/misc/shuf.sh: Add tests for erroneous conditions
like multiple '-o' and '--random-source'.

12 years agomaint: adjust indentation in df.c
Pádraig Brady [Tue, 9 Jul 2013 01:47:42 +0000 (02:47 +0100)] 
maint: adjust indentation in df.c

* src/df.c: Adjust indentation and spacing with has
gotten quite out of line in a couple of places.

12 years agodf: fix mount list processing with unstatable mount dirs
Pádraig Brady [Mon, 8 Jul 2013 23:46:39 +0000 (00:46 +0100)] 
df: fix mount list processing with unstatable mount dirs

* src/df.c (filter_mount_list): Initialize devlist->dev_num correctly
when unable to stat() a mount point.  This will avoid possible invalid
deduplication done on the list due to use of uninitialized memory.
* tests/df/skip-duplicates.sh: Ensure this code path is exercised.
Also refactor the test to be table driven.
* NEWS: Mention the bug fix.

12 years agomaint: avoid a valgrind memory leak warning from uptime
Anton Ovchinnikov [Sun, 7 Jul 2013 09:29:27 +0000 (10:29 +0100)] 
maint: avoid a valgrind memory leak warning from uptime

* src/uptime.c (uptime): Free utmp_buf returned from read_utmp,
to avoid a "definitely lost" warning from valgrind.

12 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 7 Jul 2013 00:15:22 +0000 (17:15 -0700)] 
build: update gnulib submodule to latest