platform/upstream/coreutils.git
13 years agoprintf: fix an out-of-bounds memory access
Pádraig Brady [Tue, 17 May 2011 23:01:55 +0000 (00:01 +0100)]
printf: fix an out-of-bounds memory access

* src/printf.c (STRTOX): Don't access memory after a
string containing a single quote character.
* tests/misc/printf: Add tests for various combinations
of single quote characters combined with a numeric format.
* THANKS.in: Add bug reporter.
* NEWS: Mention the fix.

Reported-by: Paul Marinescu <paul.marinescu@imperial.ac.uk>
13 years agodoc: mention that ls time ordering is newest first
Pádraig Brady [Tue, 17 May 2011 06:51:44 +0000 (07:51 +0100)]
doc: mention that ls time ordering is newest first

* src/ls.c (usage): Add the "newest first" info to
the -t and -c options

13 years agotests: refactor more tests to use mkfifo_or_skip_
Pádraig Brady [Tue, 10 May 2011 07:14:16 +0000 (08:14 +0100)]
tests: refactor more tests to use mkfifo_or_skip_

* tests/cp/existing-perm-race: s/mkfifo/mkfifo_or_skip_/
* tests/cp/file-perm-race: Likewise.
* tests/cp/parent-perm-race: Likewise.
* tests/cp/special-f: Likewise.
* tests/dd/reblock: Likewise.
* tests/ls/file-type: Likewise.
* tests/misc/cat-buf: Likewise.
* tests/misc/mknod: Likewise.
* tests/misc/printf-surprise: Likewise.
* tests/misc/selinux: Likewise.
* tests/misc/sort-spinlock-abuse: Likewise.
* tests/misc/stdbuf: Likewise.
* tests/misc/tac-continue: Likewise.
* tests/init.cfg: Improve the error message when skipping.

13 years agoshuf: use memory more efficiently when returning a subset
Pádraig Brady [Fri, 13 May 2011 17:41:42 +0000 (18:41 +0100)]
shuf: use memory more efficiently when returning a subset

* gl/lib/randperm.c (randperm_new): When the number of items
to return H, is much smaller than the total number of items N,
use a hash to represent the sparse permutations of the set N.
This is currently enabled for N > 128K and N/H > 32.
* tests/misc/shuf: Ensure shuf can quickly return 2 numbers
from a large range.
* gl/modules/randperm: Depend on hash.
* NEWS: Mention the change.

13 years agomaint: avoid syntax-check failure due to long line
Jim Meyering [Fri, 13 May 2011 21:37:23 +0000 (23:37 +0200)]
maint: avoid syntax-check failure due to long line

* tests/du/bigtime (future_time): Split long line.

13 years agomaint: add new syntax-check rule to prohibit use of skip_
Jim Meyering [Fri, 13 May 2011 16:57:31 +0000 (18:57 +0200)]
maint: add new syntax-check rule to prohibit use of skip_

* cfg.mk (sc_prohibit_skip_): New rule.
* tests/init.cfg (skip_test_): Add a comment.

13 years agotests: use skip_test_, not skip_
Jim Meyering [Fri, 13 May 2011 16:36:29 +0000 (18:36 +0200)]
tests: use skip_test_, not skip_

skip_test_ emits its diagnostic both to FD 9 (tty), and to
FD 2 (usually the log file), whereas init.sh's skip_ emits
only to FD 9.  Without that, the log is slightly less useful.
* tests/cp/fiemap-2: Use skip_test_, not skip_.
* tests/cp/fiemap-perf: Likewise.
* tests/du/bigtime: Likewise.
* tests/du/files0-from-dir: Likewise.
* tests/du/move-dir-while-traversing: Likewise.
* tests/init.sh: Likewise.
* tests/misc/sort-stale-thread-mem: Likewise.
* tests/misc/stat-nanoseconds: Likewise.
* tests/mv/i-3: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/split/filter: Likewise.
Prompted by a report from Pádraig Brady.

13 years agols: allow stat-free use of --color
Jim Meyering [Wed, 11 May 2011 15:13:53 +0000 (17:13 +0200)]
ls: allow stat-free use of --color

Even on a system with d_type support, the default use of --color
makes ls stat every file in order to be able to honor settings like
EXEC, STICKY, ORPHAN, SETUID, etc., because those settings require
information that is not provided by dirent.d_type.  However, if
for a potentially large performance gain, you are willing to disable
those settings, you can now make ls --color give type-related coloring
and perform no stat calls at all (other than the unavoidable call-per-
command-line argument).  Before this change, even with all of those
attributes disabled, ls --color would still stat every directory.
Now, we're down to the minimum of one stat call per command-line arg.
* src/ls.c (gobble_file): With --color, don't stat a
non-command-line-specified directory when no directory-coloring
attribute is enabled.
* tests/init.cfg (require_dirent_d_type_): New function.
* tests/d_type-check: New script, mostly from Pádraig Brady.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/ls/stat-free-color: New test.
* tests/Makefile.am (TESTS): Add it.
* doc/coreutils.texi (General output formatting): Describe how
to use dircolors to make ls --color refrain from calling stat
on a d_type-enabled file system.
Prompted by a query from Josef Bacik.

13 years agomaint: use <unistd.h>, not "group-member.h"
Jim Meyering [Thu, 12 May 2011 06:23:02 +0000 (08:23 +0200)]
maint: use <unistd.h>, not "group-member.h"

gnulib's group-member module now ensures that the group_member
function is declared in <unistd.h>, just like it is glibc.
* lib/euidaccess-stat.c: Remove inclusion of "group-member.h".
* src/chgrp.c: Likewise.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Wed, 11 May 2011 15:55:02 +0000 (17:55 +0200)]
build: update gnulib submodule to latest

13 years agomaint: remove syntax-checking sc_tight_scope rule
Jim Meyering [Wed, 11 May 2011 15:17:42 +0000 (17:17 +0200)]
maint: remove syntax-checking sc_tight_scope rule

* src/Makefile.am (sc_tight_scope): Remove rule.
Now it's provided via gnulib's maint.mk.
* cfg.mk (sc_tight_scope): Likewise.

13 years agomaint: tail: mark a global variable as static
Jim Meyering [Sun, 8 May 2011 13:50:52 +0000 (15:50 +0200)]
maint: tail: mark a global variable as static

* src/tail.c [HAVE_INOTIFY] (inotify_wd_mask): Declare static.

13 years agomaint: remove -Wmissing-field-initializers workarounds
Pádraig Brady [Tue, 26 Apr 2011 09:30:05 +0000 (10:30 +0100)]
maint: remove -Wmissing-field-initializers workarounds

* configure.ac: Rather than disabling -Wmissing-field-initializers,
use the fact that gnulib now disables it automatically when required
(on versions of GCC older than 4.7).
* src/system.h: Remove the no longer needed DECLARE_ZEROED_AGGREGATE.
* src/ls.c: Likewise.
* src/pathchk.c: Likewise.
* src/shred.c: Likewise.
* src/stty.c: Likewise.
* src/wc.c: Likewise.

13 years agotests: don't fail the split --filter=CMD test if xz is not available
Jim Meyering [Sat, 7 May 2011 05:48:00 +0000 (07:48 +0200)]
tests: don't fail the split --filter=CMD test if xz is not available

* tests/split/filter: Skip if xz is not installed.

13 years agodoc: document split's new --filter=CMD option
Jim Meyering [Sat, 30 Apr 2011 07:52:20 +0000 (09:52 +0200)]
doc: document split's new --filter=CMD option

* doc/coreutils.texi (split invocation): Describe --filter=CMD.
* NEWS (New feature): Mention it.

13 years agotests: test split's new --filter=CMD option
Jim Meyering [Fri, 29 Apr 2011 11:41:19 +0000 (13:41 +0200)]
tests: test split's new --filter=CMD option

* tests/Makefile.am (TESTS): Add split/filter.
* tests/split/filter: New file.

13 years agosplit: accept new output --filter=CMD option
Karl Heuer [Fri, 29 Apr 2011 10:23:27 +0000 (12:23 +0200)]
split: accept new output --filter=CMD option

* src/split.c: Include <signal.h>, <sys/wait.h> and "sig2str.h".
(FILTER_OPTION): New anonymous enum member.
(filter_command, filter_pid): New globals.
(open_pipes, open_pipes_alloc, n_open_pipes): Likewise.
(oldblocked, newblocked): Likewise.
(longopts): Add "filter".
(usage): Document --filter.
(create): Extend to create a pipe and fork "sh -c CMD".
(closeout): Adapt to close a pipe and wait for child process.
(cwrite): Call closeout, not just close.
(lines_chunk_split): FIXME
(bytes_chunk_extract): FIXME
(opid, ofile_open, lines_rr, main): FIXME
(ignorable): New function, to encapsulate EPIPE test.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Thu, 5 May 2011 08:54:03 +0000 (10:54 +0200)]
build: update gnulib submodule to latest

13 years agosort: fix a contradictory --debug warning
Pádraig Brady [Fri, 6 May 2011 07:07:46 +0000 (08:07 +0100)]
sort: fix a contradictory --debug warning

* src/sort.c (key_warn): `sort -k2,1n --debug` would output
warnings about being both "zero width" and "spanning multiple fields".
Suppress the latter one.
* tests/misc/sort-debug-warn: Add a couple of test cases.

13 years agodf: fix crash in mem exhaustion edge case
Pádraig Brady [Thu, 5 May 2011 14:20:13 +0000 (15:20 +0100)]
df: fix crash in mem exhaustion edge case

* src/df.c (print_table): Don't try to output NULL
if ambsalign() can't allocate memory.  Instead just
output the unaligned text.

13 years agomaint: remove use of gnulib's obsolete strtol module
Jim Meyering [Sun, 1 May 2011 12:06:53 +0000 (14:06 +0200)]
maint: remove use of gnulib's obsolete strtol module

* bootstrap.conf (gnulib_modules): Remove now-obsolete "strtol".
Remove use of $obsolete_gnulib_modules: unused since commit edc69f91.

13 years agomaint: remove unnecessary listing of update-copyright in Makefile.am
Jim Meyering [Sun, 1 May 2011 09:25:52 +0000 (11:25 +0200)]
maint: remove unnecessary listing of update-copyright in Makefile.am

* Makefile.am (changelog_etc): Don't list update-copyright here.
It is automatically included via gnulib-tool-generated lib/gnulib.mk.

13 years agodoc: remove a name from THANKS.in that is derived from git log
Jim Meyering [Sun, 1 May 2011 09:12:24 +0000 (11:12 +0200)]
doc: remove a name from THANKS.in that is derived from git log

* THANKS.in: Remove a now-duplicate name.

13 years agocopy: fix my typo
Jim Meyering [Tue, 3 May 2011 08:23:12 +0000 (10:23 +0200)]
copy: fix my typo

* src/copy.c (copy_reg): Fix my typo (mis-applied patch).
The patch by Jeff Liu was fine, but I mis-applied it
and introduced a compilation error in commit efa479c1.

2011-05-03  Jim Meyering  <meyering@redhat.com>

13 years agobuild: avoid bootstrap failure when $GZIP is set
Jim Meyering [Tue, 3 May 2011 08:09:20 +0000 (10:09 +0200)]
build: avoid bootstrap failure when $GZIP is set

Running "GZIP=-9 ./bootstrap" would fail right away, because the
tool-version-checking code would treat the upper-cased program name
as an environment variable name and if that has a value use the
result as the application name.  That works fine for automake,
autoconf, etc. but not for gzip.
* bootstrap (check_versions): Do not treat $GZIP as a program name.
If defined at all, it is supposed to list gzip options.
Reported by Alan Curry in http://debbugs.gnu.org/8609

13 years agocopy: correct misuse of quote in diagnostic
Jeff Liu [Mon, 2 May 2011 14:26:32 +0000 (16:26 +0200)]
copy: correct misuse of quote in diagnostic

* src/copy.c (copy_reg): Multiple uses of quote (s) in an
argument list is erroneous.  Use quote_n, instead.

13 years agomaint: adjust split.c formatting to conform
Jim Meyering [Sat, 30 Apr 2011 05:48:08 +0000 (07:48 +0200)]
maint: adjust split.c formatting to conform

* src/split.c (usage): Correct indentation.
(ofile_open): Likewise.
(create): "char *name", not "char* name".
(struct of_info) [ofile]: Similar.
(parse_chunk): Add spaces around "+".

13 years agobuild: update to latest gnulib
Eric Blake [Thu, 28 Apr 2011 21:17:15 +0000 (15:17 -0600)]
build: update to latest gnulib

* gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Add xgetgroups.

13 years agotests: distribute new file, CuSkip.pm
Jim Meyering [Fri, 29 Apr 2011 08:31:09 +0000 (10:31 +0200)]
tests: distribute new file, CuSkip.pm

Without this, most perl-based tests would fail in "make distcheck".
* tests/Makefile.am (EXTRA_DIST): Add CuSkip.pm

13 years agotests: remove useless test: misc/pwd-unreadable-parent
Jim Meyering [Thu, 28 Apr 2011 12:18:50 +0000 (14:18 +0200)]
tests: remove useless test: misc/pwd-unreadable-parent

* tests/Makefile.am (TESTS): Remove misc/pwd-unreadable-parent.
This test was misleading and useless (was always skipped).
Inspired by a report from Bruno Haible: http://debbugs.gnu.org/8570
* tests/misc/pwd-unreadable-parent: Remove file.

13 years agotests: write skip explanation from perl scripts also to outer stderr
Jim Meyering [Thu, 28 Apr 2011 09:12:01 +0000 (11:12 +0200)]
tests: write skip explanation from perl scripts also to outer stderr

* tests/CuSkip.pm (skip): New file/module/function, to help
the perl test scripts "skip" a test consistently, emitting
a diagnostic both into the log file and into the outermost
stderr stream that is more likely to be seen by a human.
* tests/check.mk (TESTS_ENVIRONMENT): Add -MCuSkip.
* tests/misc/date-next-dow: Use CuSkip::skip in place of warn+exit-77.
* tests/misc/tty-eof: Likewise.
* tests/misc/uniq: Likewise.
* tests/rm/fail-eperm: Likewise.
* tests/misc/md5sum-newline: Likewise.  Also, s/program_name/ME/.
* tests/misc/ls-misc (setuid_setup, main): Likewise.
* tests/misc/pwd-long: Likewise, and add -I"$abs_srcdir" -MCuSkip
to the $PERL invocation command.
Inspired by a request from Bruno Haible regarding misc/tty-eof:
http://debbugs.gnu.org/8570

13 years agopost-release administrivia
Jim Meyering [Tue, 26 Apr 2011 14:18:02 +0000 (16:18 +0200)]
post-release administrivia

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

13 years agoversion 8.12 v8.12
Jim Meyering [Tue, 26 Apr 2011 14:00:50 +0000 (16:00 +0200)]
version 8.12

* NEWS: Record release date.

13 years agomaint: tweak sc_tight_scope rule
Jim Meyering [Tue, 26 Apr 2011 07:27:32 +0000 (09:27 +0200)]
maint: tweak sc_tight_scope rule

* src/Makefile.am (sc_tight_scope): Remove useless quotes,
change 1>&2 to >&2, and combine a few short lines.

13 years agodd: work around compilation failure on AIX 5.1 and 5.2
Jim Meyering [Tue, 26 Apr 2011 07:09:43 +0000 (09:09 +0200)]
dd: work around compilation failure on AIX 5.1 and 5.2

* src/dd.c (O_NOCACHE): Undefine.  This symbol is defined
via AIX's <fcntl.h>, yet used as an enum name in dd.c.
Reported by Gary V. Vaughan in http://debbugs.gnu.org/8555
* NEWS (Portability): Mention this.

13 years agomaint: move two small functions, so we can remove a fwd decl
Jim Meyering [Tue, 26 Apr 2011 07:02:44 +0000 (09:02 +0200)]
maint: move two small functions, so we can remove a fwd decl

* src/dd.c (cleanup, quit): Move the definition of quit to follow the
definition of process_signals, so we can remove the declaration of
the latter.

13 years agomaint: change some leading 8-space sequences to TABs in a Makefile.am
Jim Meyering [Mon, 25 Apr 2011 12:43:22 +0000 (14:43 +0200)]
maint: change some leading 8-space sequences to TABs in a Makefile.am

src/Makefile.am (fs-magic, fs-kernel-magic): Change some leading
8-space sequences to TABs.

13 years agostat: recognize V9FS and ECRYPTFS file systems
Jim Meyering [Mon, 25 Apr 2011 12:40:45 +0000 (14:40 +0200)]
stat: recognize V9FS and ECRYPTFS file systems

* src/stat.c (human_fstype): Add magic numbers for V9FS and ECRYPTFS.

13 years agotail --follow=name no longer implies --retry
Jim Meyering [Sun, 24 Apr 2011 21:20:01 +0000 (23:20 +0200)]
tail --follow=name no longer implies --retry

* src/tail.c (tail_forever_inotify): Just as without inotify,
tail --follow=name now terminates when the last tailed-by-name file
is unlinked or moved aside.  This bug was introduced on 2009-06-15
via commit ae494d4b, "tail: use inotify if it is available".
Reported by Tim Underwood in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22286
* NEWS (Bug fixes): Mention this.
* tests/tail-2/follow-name: Test for this.
* tests/Makefile.am (TESTS): Add it.

13 years agocopy: include both src and dest names in clone failure diagnostic
Jeff Liu [Sun, 24 Apr 2011 14:25:31 +0000 (16:25 +0200)]
copy: include both src and dest names in clone failure diagnostic

* src/copy.c (copy_reg): Upon btrfs clone failure, print not just
the destination file name, but also the source file name.
That may be useful upon failure of a cross-device clone attempt.

13 years agotests: tail-2/pipe-f2: avoid false-positive failure
Jim Meyering [Sat, 23 Apr 2011 21:54:11 +0000 (23:54 +0200)]
tests: tail-2/pipe-f2: avoid false-positive failure

Otherwise, this would fail (albeit rarely) on a "make -j24 check" run.
* tests/tail-2/pipe-f2: Increase timeout from 1 second to 10,
to avoid false positive failure.

13 years agomaint: explicitly list full-read and full-write module names
Jim Meyering [Sat, 23 Apr 2011 21:47:37 +0000 (23:47 +0200)]
maint: explicitly list full-read and full-write module names

* bootstrap.conf (gnulib_modules): Include full-read and full-write
explicitly.  Before, we'd get them via safe-read, but with newer
gnulib, that is no longer enough: link failure due to undefined
references to full_write.

13 years agodoc: tail/inotify does use --sleep-interval=S, with --pid=P
Jim Meyering [Sat, 23 Apr 2011 14:08:08 +0000 (16:08 +0200)]
doc: tail/inotify does use --sleep-interval=S, with --pid=P

* doc/coreutils.texi (tail invocation): Mention it.
* src/tail.c (usage): Likewise.
(tail_forever_inotify): Clarify comment.

13 years agotests: sparse-fiemap: adjust syntax to accommodate older awk
Alan Curry [Fri, 22 Apr 2011 09:08:50 +0000 (11:08 +0200)]
tests: sparse-fiemap: adjust syntax to accommodate older awk

* tests/cp/sparse-fiemap: Parenthesize ternary expression used
as an argument to awk's printf.  Otherwise, gawk 3.0.1 and the
one from debian stable's original-awk would get a syntax error.
Reported by Dennis Clarke.

Copyright note: tiny change

13 years agotests: sparse-fiemap: with root/ext3, do not create an ext4 FS
Jim Meyering [Thu, 21 Apr 2011 19:01:13 +0000 (21:01 +0200)]
tests: sparse-fiemap: with root/ext3, do not create an ext4 FS

* tests/cp/sparse-fiemap: When this test was run as root on an ext3
file system, (ext3 had known problems), it would trickily create and
mount a loopback ext4 file system and use that instead.  However, due
to a bug in 2.6.39-rc1..rc3, this loopback test (when run in another
loopback FS) exposed a bug with 1k-blocksize ext4 whereby non-NUL
data would be read from a hole.  For details, see this:
http://thread.gmane.org/gmane.comp.file-systems.ext4/24495

13 years agotests: sparse-fiemap: report more detail upon failure; ignore an FP
Jim Meyering [Thu, 21 Apr 2011 16:08:20 +0000 (18:08 +0200)]
tests: sparse-fiemap: report more detail upon failure; ignore an FP

* tests/cp/sparse-fiemap: Fail right away with details, when cmp fails.
When extent maps are found to differ, display them and merely warn.

13 years agocopy: use FIEMAP (extent_copy) only for apparently-sparse files,
Jim Meyering [Wed, 20 Apr 2011 09:21:09 +0000 (11:21 +0200)]
copy: use FIEMAP (extent_copy) only for apparently-sparse files,

to avoid the expense of extent_copy's unconditional use of
FIEMAP_FLAG_SYNC.
* src/copy.c (copy_reg): Do not attempt extent_copy on a file
that appears to have no holes.
* NEWS (Changes in behavior): Document this.  At first I labeled this
as a bug fix, but that would be inaccurate, considering there is no
documentation of FIEMAP semantics, nor even consensus among kernel
FS developers.  Here's hoping SEEK_HOLE/SEEK_DATA support will soon
make it into the linux kernel.

13 years agocopy: factor out a tiny sparse-testing function
Jim Meyering [Wed, 20 Apr 2011 08:23:32 +0000 (10:23 +0200)]
copy: factor out a tiny sparse-testing function

* src/copy.c (HAVE_STRUCT_STAT_ST_BLOCKS): Define to 0 if undefined,
so we can use it in the return expression, here:
(is_probably_sparse): New function, factored out of...
(copy_reg): ...here.  Use the new function.

13 years agocopy: do not treat unwritten extents specially: avoid XFS/ext4 data loss
Jim Meyering [Wed, 20 Apr 2011 08:15:15 +0000 (10:15 +0200)]
copy: do not treat unwritten extents specially: avoid XFS/ext4 data loss

* src/copy.c (extent_copy): Do not treat "unwritten extents" specially.
Otherwise, with a release-candidate 2.6.39-rc3 kernel, XFS or ext4,
when using gold as your linker, and if you forget to run "make check",
you could end up installing files full of zeros instead of the expected
binaries.  For a lot of discussion, see
http://thread.gmane.org/gmane.comp.file-systems.xfs.general/37895
* tests/cp/fiemap-empty: Disable this test.

13 years agocopy: always use FIEMAP_FLAG_SYNC, for now
Jim Meyering [Wed, 20 Apr 2011 07:49:15 +0000 (09:49 +0200)]
copy: always use FIEMAP_FLAG_SYNC, for now

* src/extent-scan.c (extent_need_sync): Always return true,
to make the sole caller always use FIEMAP_FLAG_SYNC.
This will doubtless have an undesirable performance impact,
but we'll mitigate that shortly, by using extent_copy only on
files with holes.

13 years agotests: remove spurious syntax from a perl snippet
Jim Meyering [Wed, 20 Apr 2011 07:46:27 +0000 (09:46 +0200)]
tests: remove spurious syntax from a perl snippet

* tests/cp/sparse-fiemap: Remove spurious BEGIN {...} block.

13 years agodircolors: add .ear, .war, .sar, for Java jar-like archives
Ondřej Vašík [Sun, 17 Apr 2011 09:20:47 +0000 (11:20 +0200)]
dircolors: add .ear, .war, .sar, for Java jar-like archives

* src/dircolors.hin: Add .ear, .war, .sar, for Java jar-like archives
Suggested by Ville Skyttä in https://bugzilla.redhat.com/616497.

13 years agopost-release administrivia
Jim Meyering [Wed, 13 Apr 2011 19:32:49 +0000 (21:32 +0200)]
post-release administrivia

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

13 years agoversion 8.11 v8.11
Jim Meyering [Wed, 13 Apr 2011 19:13:50 +0000 (21:13 +0200)]
version 8.11

* NEWS: Record release date.

13 years agomaint: mention dd's new partial read warning in NEWS
Pádraig Brady [Wed, 13 Apr 2011 14:27:13 +0000 (15:27 +0100)]
maint: mention dd's new partial read warning in NEWS

* NEWS: Mention the new feature, from commits e1788d9e and 194c1e89

13 years agotests: fix a false positive fiemap test on some file systems
Pádraig Brady [Wed, 13 Apr 2011 06:58:02 +0000 (07:58 +0100)]
tests: fix a false positive fiemap test on some file systems

* tests/filefrag-extent-compare: Don't check the length of the
last extent, as this was seen to vary on XFS, where it leaves
trailing blocks allocated for performance reasons.
* tests/cp/fiemap-empty: Though not seen as an issue in practise,
try to avoid possible issues with the allocator in file systems,
by requesting to allocate a power of 2.

13 years agomaint: correct kernel version in test comment
Pádraig Brady [Tue, 12 Apr 2011 10:30:33 +0000 (11:30 +0100)]
maint: correct kernel version in test comment

13 years agomaint: remove unnecessary inclusion of <stdio.h>
Jim Meyering [Tue, 12 Apr 2011 10:14:26 +0000 (12:14 +0200)]
maint: remove unnecessary inclusion of <stdio.h>

* src/extent-scan.c: Don't include <stdio.h>.  It was not used.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Mon, 11 Apr 2011 12:33:23 +0000 (14:33 +0200)]
build: update gnulib submodule to latest

13 years agocfg.mk: remove useless semicolon and backslash
Jim Meyering [Mon, 11 Apr 2011 07:55:48 +0000 (09:55 +0200)]
cfg.mk: remove useless semicolon and backslash

* cfg.mk (sc_NEWS_two_empty_lines): Remove semicolon and backslash.

13 years agodoc: tweak NEWS
Jim Meyering [Mon, 11 Apr 2011 07:07:10 +0000 (09:07 +0200)]
doc: tweak NEWS

* NEWS: Slightly obfuscate a line to avoid a false-positive
doubled-word ("is-is") match.
Fix a grammar error in news for 8.2.
* cfg.mk (old_NEWS_hash): Resync.

13 years agomaint: install: remove support for --preserve_context ("_", not "-")
Jim Meyering [Sun, 10 Apr 2011 09:26:14 +0000 (11:26 +0200)]
maint: install: remove support for --preserve_context ("_", not "-")

* src/install.c: Its use has elicited a warning for two years.
Use --preserve-context instead.
* NEWS (changes in behavior): Mention this.

13 years agomaint: reorder install.c to eliminate declarations of static functions
Jim Meyering [Sun, 10 Apr 2011 09:22:59 +0000 (11:22 +0200)]
maint: reorder install.c to eliminate declarations of static functions

* src/install.c: Remove static function declarations.

13 years agomaint: rename variables for clarity...
Jim Meyering [Sun, 10 Apr 2011 08:38:50 +0000 (10:38 +0200)]
maint: rename variables for clarity...

and to avoid a false-positive "TO to" in new doubled word check.
* src/install.c (change_timestamps): Rename parameters for
readability.  Make the comment match the code.

13 years agomaint: remove doubled words in comments, e.g., s/to to/to/
Jim Meyering [Sat, 9 Apr 2011 21:23:01 +0000 (23:23 +0200)]
maint: remove doubled words in comments, e.g., s/to to/to/

* tests/ls/color-norm: s/to to/to/
* gl/lib/mbsalign.h (mbs_align_t): s/or or/or/
* src/extent-scan.c (extent_scan_read): s/the the/the/
* src/libstdbuf.c: s/the the/the/
* tests/misc/stdbuf: s/on on/on/
* ChangeLog-2005: s/for\n\tfor /for\n\t/

13 years agomaint: misc typo fixes
Pádraig Brady [Sat, 9 Apr 2011 20:53:00 +0000 (22:53 +0200)]
maint: misc typo fixes

* src/fiemap.h: s/can not/cannot/
* NEWS: s/in/is/
* doc/coreutils.texi: Remove spurious "and".
s/effect/affect/
Use matched ``...'' quotes.

13 years agomaint: correct kernel version in NEWS
Pádraig Brady [Wed, 6 Apr 2011 23:23:00 +0000 (00:23 +0100)]
maint: correct kernel version in NEWS

* NEWS: Adjust to match commit 1c3654cb, 2011-04-02,
"copy: require fiemap sync also for 2.6.38 kernels"

13 years agocopy: handle mergeable extents across fiemap scans
Pádraig Brady [Tue, 5 Apr 2011 10:04:13 +0000 (11:04 +0100)]
copy: handle mergeable extents across fiemap scans

* extent-scan.h (extent_scan_free): Init the pointer to NULL,
and reset the count to 0, so that we can realloc the buffer.
* src/extent-scan.c (extent_scan_init): Likewise.
(extent_scan_read): Loop over multiple fiemap scans, so we handle
mergeable extents that span across fiemap scan boundaries.  Once
we have enough unique extents, return so as to minimize memory use.

13 years agocopy: fix an unlikely memory leak when a fiemap copy fails
Pádraig Brady [Tue, 5 Apr 2011 18:16:40 +0000 (19:16 +0100)]
copy: fix an unlikely memory leak when a fiemap copy fails

* src/copy.c (extent_copy): Free the extents array when
sparse_copy() fails.

13 years agotests: avoid spurious parallel failure due to temporary disk full
Jim Meyering [Sun, 3 Apr 2011 19:54:10 +0000 (21:54 +0200)]
tests: avoid spurious parallel failure due to temporary disk full

Running the new fiemap-empty test uses 600MB of disk space via
fallocate, and in so doing caused failure in unrelated tests that
were running in parallel on a small file system.  Rather than
simply running fallocate (which allocates the space, inducing
disk full when it fails), skip the test if there is less than
800MB of free space, as computed via stat and awk.
* tests/init.cfg (require_file_system_bytes_free_): New function.
* tests/cp/fiemap-empty: Use it.

13 years agotests: don't ever leave a backgrounded "sleep 10m" process
Jim Meyering [Sun, 3 Apr 2011 15:30:49 +0000 (17:30 +0200)]
tests: don't ever leave a backgrounded "sleep 10m" process

* tests/misc/help-version: Sleep only ~30s, not 10m.
The latter was a problem when somehow that sleep process would
hang around and thereby prevent (for up to 10m) a normal unmount
of the temporary partition in which I'd run the tests.

13 years agotests: preserve-gid: don't chown temporary PATH dir to a nameless UID
Jim Meyering [Sun, 3 Apr 2011 14:37:45 +0000 (16:37 +0200)]
tests: preserve-gid: don't chown temporary PATH dir to a nameless UID

* tests/cp/preserve-gid: Simply chmod a+rx instead.
That is safer, in case the nameless UID actually has an account,
and might take advantage of root running a program in a directory
under its control

13 years agotests: preserve-gid: remove useless use of "env"
Jim Meyering [Sun, 3 Apr 2011 10:38:05 +0000 (12:38 +0200)]
tests: preserve-gid: remove useless use of "env"

* tests/cp/preserve-gid: Remove useless use of "env".

13 years agotests: convert common root-build test failure to a "skip"
Jim Meyering [Sun, 3 Apr 2011 09:27:21 +0000 (11:27 +0200)]
tests: convert common root-build test failure to a "skip"

* tests/mv/sticky-to-xpart: Skip rather than failing this test
when run as root and the binaries are not accessible by "nobody".

13 years agotests: minor improvement of sc_tight_scope rule
Jim Meyering [Sat, 2 Apr 2011 16:25:40 +0000 (18:25 +0200)]
tests: minor improvement of sc_tight_scope rule

* src/Makefile.am (sc_tight_scope): Adjust rule to use an eval-based
trap-setting for-loop rather than 4x hard-coded 128+N constants.
Also catch SIGQUIT (3).  Tweak comments.

13 years agodocs: mention POSIX 2008
Eric Blake [Fri, 1 Apr 2011 21:37:35 +0000 (15:37 -0600)]
docs: mention POSIX 2008

* doc/coreutils.texi (Standards conformance): Give value of
_POSIX2_VERSION matching the _POSIX_C_SOURCE of POSIX 2008.

13 years agomaint: prohibit direct use of strncmp: prefer STREQ_LEN, STRNCMP_LIT
Jim Meyering [Thu, 31 Mar 2011 15:59:16 +0000 (17:59 +0200)]
maint: prohibit direct use of strncmp: prefer STREQ_LEN, STRNCMP_LIT

* cfg.mk (sc_prohibit_strncmp): New rule, mostly from libvirt.
* src/system.h (STREQ_LEN, STRPREFIX, STRNCMP_LIT): Define.
* src/df.c (get_dev, get_point): Convert.
* src/extent-scan.c (extent_need_sync): Likewise.
* src/ls.c (is_colored, decode_switches): Likewise.
(parse_ls_color, (print_color_indicator): Likewise.
* src/md5sum.c (split_3): Likewise.
* src/split.c (main, emit_ancillary_info): Likewise.
* src/tr.c (look_up_char_class): Likewise.
* src/uname.c (main): Likewise.
* src/who.c (scan_entries): Likewise.

13 years agocopy: require fiemap sync also for 2.6.38 kernels
Jim Meyering [Sat, 2 Apr 2011 17:59:30 +0000 (19:59 +0200)]
copy: require fiemap sync also for 2.6.38 kernels

* src/extent-scan.c (extent_need_sync): Require sync also for 2.6.38.
Without this, part of the cp/fiemap-empty test would fail both on
F15-to-be (2.6.38.1-6.fc15.x86_64) and rawhide.  For details, see
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22190

13 years agocp: always detect copy-into-self: avoid infloop w/large PATH_MAX
Jim Meyering [Mon, 28 Mar 2011 07:14:31 +0000 (09:14 +0200)]
cp: always detect copy-into-self: avoid infloop w/large PATH_MAX

When running the erroneous command, cp -rl A D D, and depending on the
structure of directories A and D and the file system type (because that
changes order of dir. entry traversal), cp would sometimes fail to
detect that D was being copied into D, and would create D/D/D/D/D/...
until it hit PATH_MAX or exhausted some resource.
I noticed this via the occasional failure of the cp/into-self test
when run using a ZFS file system.  It is occasional because the bug
is dependent on the order in which directory entries are traversed,
and that is apparently indeterminate with ZFS.
Technically, with the current recursive implementation, there is no
risk of an infinite loop, due to stack limitations, but with an
eventual fts-based implementation, it might have iterated until
disk space or inodes are exhausted.
* src/copy.c (copy_dir): Avoid copy-into-self interminable loop on
systems with large PATH_MAX.  On other systems, diagnose the copy-into-
self error consistently.  Handle the parameter,
first_dir_created_per_command_line_arg, correctly when there are two
or more sub-directories.

13 years agomaint: fix a comment typo
Jim Meyering [Sat, 2 Apr 2011 12:03:53 +0000 (14:03 +0200)]
maint: fix a comment typo

* tests/cp/fiemap-empty: Correct typo in comment.  Add "FIXME".

13 years agocopy: process empty extents more efficiently
Pádraig Brady [Fri, 11 Feb 2011 08:55:22 +0000 (08:55 +0000)]
copy: process empty extents more efficiently

* src/copy.c (extent_copy): Treat an allocated but empty extent
much like a hole.  I.E. don't read data we know is going to be NUL.
Also we convert the empty extent to a hole only when SPARSE_ALWAYS
so that the source and dest have the same allocation.  This will
be improved soon, when we use fallocate() to do the allocation.
* tests/cp/fiemap-empty: A new test for efficiency and correctness
of copying empty extents.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the change in behavior.

13 years agocopy: protect against overlapping extents
Pádraig Brady [Mon, 28 Mar 2011 18:22:21 +0000 (19:22 +0100)]
copy: protect against overlapping extents

* src/extent-scan.c (extent_scan_read): Add a more stringent check
for OFF_T overflow, to ensure subsequent code is immune.
Detect overlapping extents and adjust, so as files always copied.
Detection using a single scan with fallback to a standard copy
was thought too expensive in memory or time.
* NEWS: Mention the fix

13 years agocopy: link rather than copy symlinks, when --link used
Pádraig Brady [Thu, 31 Mar 2011 10:28:58 +0000 (11:28 +0100)]
copy: link rather than copy symlinks, when --link used

This bug was introduced in commit ca9e212c, 2009-09-24,
"cp, mv: use linkat to guarantee semantics", which
inadvertently disabled the creation of hardlinks to symlinks.
However rather than implementing the intention of that commit
and relying on gnulib linkat emulation, we'll revert to the
previous emulation as that maintains ownership and timestamps.

* src/copy.c (copy_internal): Use our existing hardlink to
symlink emulation when link() might dereference the symlink.
Also ensure that we copy the timestamps of the original symlink
when we use the emulation.
* tests/cp/link-symlink: Add a test to ensure timestamps copied.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
Reported by Ruediger Meier

13 years agotests: inotify-rotate: avoid race condition with overloaded disk
Jim Meyering [Thu, 31 Mar 2011 16:56:47 +0000 (18:56 +0200)]
tests: inotify-rotate: avoid race condition with overloaded disk

* tests/tail-2/inotify-rotate: Wait 50% longer for grep to succeed.
Without this change, this test would fail consistently when using
"make -j25 check" with F15 in a virtio- and spinning-rust-backed
virtual machine.

13 years agocopy: with fiemap copy, only sync when needed
Pádraig Brady [Wed, 30 Mar 2011 21:50:05 +0000 (22:50 +0100)]
copy: with fiemap copy, only sync when needed

* src/extent-scan.h (struct extent_scan): Add the fm_flags member to
pass to the fiemap scan.
* src/extent-scan.c (extent_need_sync): A new function used to
detect Linux kernels before 2.6.38.
(extent_scan_init): Add FIEMAP_FLAG_SYNC when needed.
* tests/cp/sparse-fiemap: Adjust comment.
* NEWS: Mention the change in behavior.
Indirectly suggested by Mike Frysinger

13 years agotests: avoid unwarranted failure in mock-simulated non-SELinux env.
Mathieu Bridon [Mon, 28 Mar 2011 07:39:53 +0000 (09:39 +0200)]
tests: avoid unwarranted failure in mock-simulated non-SELinux env.

* tests/init.cfg (require_selinux_): Skip the test also when
/proc/filesystems does not list selinuxfs.
Add comments.
* cfg.mk (exclude_file_name_regexp--sc_file_system): Exempt
tests/init.cfg, with its use of /proc/filesystems.
Based on the patch by Mathieu Bridon in http://debbugs.gnu.org/8359.
More discussion in http://bugzilla.redhat.com/573111

13 years agomaint: correct formatting style in a header
Jim Meyering [Mon, 28 Mar 2011 05:57:51 +0000 (07:57 +0200)]
maint: correct formatting style in a header

* src/find-mount-point.h: Move "*" to where it belongs.
Move "const", too.
* src/find-mount-point.c: Move "const" to conform.
* src/Makefile.am (sc_tight_scope): Allow `*'s before the function name.
Use perl's -l option and drop the \n after (and quotes around) $1.

13 years agodf: fix alignment of columns
Pádraig Brady [Mon, 19 Apr 2010 07:41:50 +0000 (08:41 +0100)]
df: fix alignment of columns

* src/df.c (alloc_table_row): A new function to allocate storage
for a row of strings.
(print_table): A new function to interate over all stored strings in
the table, and apply alignment honoring the max width of each column.
(get_header): Renamed from print_header, and adjusted accordingly.
(get_dev): Renamed from show_dev.  Also we no longer wrap longer
device names over two lines, which can be an unexpected issue for
scripts parsing the output from df.
(get_disk): s/show_/get_/
(get_point): Likewise.
(get_entry): Likewise.
(get_all_entries): Likewise.
* NEWS: Mention the change.

13 years agobuild: update gnulib submodule to latest
Jim Meyering [Tue, 22 Mar 2011 05:09:06 +0000 (06:09 +0100)]
build: update gnulib submodule to latest

13 years agotests: exercise tests new "==" operator
Jim Meyering [Tue, 22 Mar 2011 05:07:35 +0000 (06:07 +0100)]
tests: exercise tests new "==" operator

* tests/misc/test: Exercise the new operator.
* NEWS (Changes in behavior): Mention it.

13 years agotest: accept "==" as a synonym for "="
David A. Wheeler [Tue, 22 Mar 2011 05:03:55 +0000 (06:03 +0100)]
test: accept "==" as a synonym for "="

Make GNU coreutils' test recognize "==" as a synonym for "=".
This is already the case in GNU coreutils' expr, bash, ksh,
busybox ash, FreeBSD-current /bin/sh and /bin/test, and
OpenBSD's /bin/sh.

Before, env test a '==' a would fail with this diagnostic:
"test: ==: binary operator expected".  Now, it succeeds.
* src/test.c: Accept "==" as a synonym for "=".
* doc/coreutils.texi (String tests): Document it.
Reported as http://debbugs.gnu.org/8263
Also see http://austingroupbugs.net/view.php?id=375

13 years agotests: fix a bug in the cp/preserve-gid test
Jim Meyering [Sun, 20 Mar 2011 07:56:06 +0000 (08:56 +0100)]
tests: fix a bug in the cp/preserve-gid test

* tests/cp/preserve-gid: Ensure that every process under test uses
the cp binary we've just built.  Before this fix, with a restrictive
umask or build-dir permissions, the UID-changing tests would end up
using whatever cp happened to be available through $PATH
Analysis by arbogast.cedric@gmail.com in http://debbugs.gnu.org/8292.

13 years agobootstrap: do not exclude m4/message.m4
Paul Eggert [Sun, 20 Mar 2011 19:24:57 +0000 (12:24 -0700)]
bootstrap: do not exclude m4/message.m4

* bootstrap.conf (excluded_files): Don't exclude m4/lcmessage.m4,
as it's needed with the latest gnulib.

13 years agomaint: remove a name from THANKS.in that is derived from git log
Jim Meyering [Sat, 19 Mar 2011 15:55:35 +0000 (16:55 +0100)]
maint: remove a name from THANKS.in that is derived from git log

The names in THANKS are generated from two sources: the hard-coded
list, THANKS.in, and the names of committers from the git log.
When a contributor on the hard-coded list commits a change,
we remove their now-redundant name from THANKS.in.
* THANKS.in: Remove a now-duplicate name.

13 years agotests: fix the sparse-fiemap test
Pádraig Brady [Sat, 19 Mar 2011 23:58:49 +0000 (23:58 +0000)]
tests: fix the sparse-fiemap test

* tests/filefrag-extent-compare: Merge adjacent extents in
each list before processing, so we correctly account for
split extents in either list.
* tests/cp/sparse-fiemap: Remove the explicit syncing,
which was only changing the way extents were arranged,
and thus working around the extent comparison issue
that was seen on ext4 loop back.

13 years agosort: avoid memory pressure of 130MB/thread when reading from pipe
Jim Meyering [Wed, 16 Mar 2011 15:09:31 +0000 (16:09 +0100)]
sort: avoid memory pressure of 130MB/thread when reading from pipe

* src/sort.c (INPUT_FILE_SIZE_GUESS): Decrease initial allocation
factor used to size buffer used when reading a non-regular file.
For motivation, see discussion here:
http://thread.gmane.org/gmane.comp.gnu.coreutils.general/878/focus=887

13 years agomaint: stop using .x-sc_* files to list syntax-check exemptions
Jim Meyering [Mon, 14 Mar 2011 13:26:38 +0000 (14:26 +0100)]
maint: stop using .x-sc_* files to list syntax-check exemptions

Instead, use the brand new mechanism with which you merely use a
variable (derived from the rule name) defined in cfg.mk to an ERE
matching the exempted file names.
* gnulib: Update to latest, to get maint.mk that implements this.
* Makefile.am (syntax_check_exceptions): Remove variable.
(EXTRA_DIST): Remove use of the variable.
* cfg.mk (sc_x_sc_dist_check): Remove rule, no longer useful.
(exclude_file_name_regexp--sc_space_tab): Define variable.
(exclude_file_name_regexp--sc_bindtextdomain): Likewise.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Likewise.
(exclude_file_name_regexp--sc_error_message_uppercase): Likewise.
(exclude_file_name_regexp--sc_trailing_blank): Likewise.
(exclude_file_name_regexp--sc_system_h_headers): Likewise.
(exclude_file_name_regexp--sc_require_config_h_first): Likewise.
(exclude_file_name_regexp--sc_require_config_h): Likewise.
(exclude_file_name_regexp--sc_po_check): Likewise.
(exclude_file_name_regexp--sc_prohibit_always-defined_macros): Likewise.
(exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF): Likewise.
(exclude_file_name_regexp--sc_program_name): Likewise.
(exclude_file_name_regexp--sc_file_system): Likewise.
(exclude_file_name_regexp--sc_prohibit_always_true_header_tests):
Likewise.
(exclude_file_name_regexp--sc_prohibit_fail_0): Likewise.
(exclude_file_name_regexp--sc_prohibit_atoi_atof): Likewise.
(exclude_file_name_regexp--sc_prohibit_tab_based_indentation): Likewise.
(exclude_file_name_regexp--sc_prohibit_stat_st_blocks): Likewise.
* configure.ac [whether localtime caches TZ]: Use return 0/1, not
exit (0/1) to avoid triggering a sc_prohibit_magic_number_exit failure.
* .x-sc_GPL_version: Remove file.
* .x-sc_bindtextdomain: Likewise.
* .x-sc_error_message_uppercase: Likewise.
* .x-sc_file_system: Likewise.
* .x-sc_obsolete_symbols: Likewise.
* .x-sc_po_check: Likewise.
* .x-sc_program_name: Likewise.
* .x-sc_prohibit_always-defined_macros: Likewise.
* .x-sc_prohibit_always_true_header_tests: Likewise.
* .x-sc_prohibit_atoi_atof: Likewise.
* .x-sc_prohibit_empty_lines_at_EOF: Likewise.
* .x-sc_prohibit_fail_0: Likewise.
* .x-sc_prohibit_magic_number_exit: Likewise.
* .x-sc_prohibit_stat_st_blocks: Likewise.
* .x-sc_prohibit_strcmp: Likewise.
* .x-sc_prohibit_tab_based_indentation: Likewise.
* .x-sc_require_config_h: Likewise.
* .x-sc_require_config_h_first: Likewise.
* .x-sc_space_tab (config): Likewise.
* .x-sc_sun_os_names: Likewise.
* .x-sc_system_h_headers: Likewise.
* .x-sc_trailing_blank: Likewise.
* .x-sc_unmarked_diagnostics: Likewise.
* .x-sc_useless_cpp_parens: Likewise.

13 years agomaint: use wcswidth from gnulib
Pádraig Brady [Sat, 12 Mar 2011 14:22:54 +0000 (14:22 +0000)]
maint: use wcswidth from gnulib

* gl/lib/mbsalign.c (rpl_wcswidth): Remove this in favor
of the equivalent wcswidth replacement in gnulib.
* bootstrap.conf: Depend on the wcswidth module.
Suggested by Bruno Haible.

13 years agotouch: update to latest gnulib to fix Solaris 10 touch segfault
Jim Meyering [Sun, 13 Mar 2011 12:20:54 +0000 (13:20 +0100)]
touch: update to latest gnulib to fix Solaris 10 touch segfault

* gnulib: Update to latest, to address http://debbugs.gnu.org/8230.
When built on Solaris 9 and run on Solaris 10, touch would segfault.
Reported by Ben Walton.
* bootstrap: Update from gnulib.
* tests/init.sh: Likewise.
* NEWS (Bug fixes): Mention this.

13 years agosort: spawn fewer threads for small inputs
Jim Meyering [Thu, 10 Feb 2011 07:48:27 +0000 (08:48 +0100)]
sort: spawn fewer threads for small inputs

* src/sort.c (SUBTHREAD_LINES_HEURISTIC): Do not spawn a new thread
for every 4 lines.  Increase this from 4 to 128K.  128K lines seems
appropriate for a 5-year-old dual-core laptop, but it is too low for
some common combinations of short lines and/or newer systems.
* NEWS (Bug fixes): Mention it.