summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2010-01-12ls: reorder includes to work around broken <sys/capability.h>Kamil Dudka
* src/ls.c: Include <sys/capability.h> later, to avoid build failure with a header from libcap-2.16-1 or earlier. See http://bugzilla.redhat.com/483548 for details.
2010-01-06pr: ensure the page header line is of the required formatEric Blake
Before this change, with too long a file name, the name would abut the date field on the left and possibly also the "Page N" field on the right, rather than leaving a one-space separator in each case. Fixes a regression introduced on Mar 6 2009, by commit a4053c5291d5797734b3e4f042f9e1adf3944fd6 * src/pr.c (print_header): Ensure that there is at least one space before and after the file name part of the header line. * NEWS: Mention it. * tests/pr/W20l24f-ll: s/xPage/ x Page/. * THANKS: Update. Reported by Denis McKeon, in https://savannah.gnu.org/bugs/?28492.
2010-01-05maint: always free a buffer, to avoid even semblance of a leakJim Meyering
* src/tac.c (main): Free the input buffer in most cases.
2010-01-04maint: use more readable operator: "||" rather than "|"Jim Meyering
* src/cp.c (make_dir_parents_private): Use "||" rather than "|", so that clang understands there is no undefined pointer dereference.
2010-01-01ls: fix color of broken symlinks colored as targetEric Blake
* src/ls.c (print_color_indicator): When using 'LINK target' in dircolors, treat broken symlink as C_ORPHAN. * tests/misc/ls-misc (sl-dangle2, sl-dangle3, sl-dangle4) (sl-dangle5): Test for it, and add more coverage. * NEWS: Document it. * THANKS: Update. Reported by Chris Jones.
2010-01-01df: use fputs in place of printf in a few more placesJim Meyering
* src/df.c (print_header): Use fputs rather than printf in more places. Suggested by Eric Blake.
2010-01-01maint: update all FSF copyright year lists to include 2010Jim Meyering
Use this command: git ls-files | grep -v COPYING \ | xargs env UPDATE_COPYRIGHT_USE_INTERVALS=1 \ build-aux/update-copyright
2010-01-01pr --help: add missing space between short and long options usage messageStéphane Raimbault
* src/pr.c (usage): Add missing space.
2010-01-01pr --help: improve a line-breakStéphane Raimbault
* src/pr.c (usage): Move the newline character a bit farther.
2010-01-01df: add comments to help translators align column headersStéphane Raimbault
* src/df.c (print_header): Add a comment telling translators to retain the message length, and another to align header translations.
2009-12-31doc: update tail's documentation to allow for new -F semanticsJim Meyering
* src/tail.c (usage): Reword tail -F description, so that it no longer mentions details specific to the non-inotify implementation. Also, join diagnostic strings (while staying under the 509-byte limit) to ease formatting of translations. The latter was prompted by a report from Stéphane Raimbault. * doc/coreutils.texi (tail invocation): Update description here, too.
2009-12-30tail -F: don't stop following the target of a renameGiuseppe Scrivano
This fixes a bug whereby tail -F would fail to track changes to a file that was a target of a rename, and when the source of the rename was another tailed file. * src/tail.c (tail_forever_inotify): Ensure the wd is not already present in the hash table before trying to add it. When a new watch descriptor is added to the `wd_to_name' hash table, check that it is not already present. If it is present then remove the previous element.
2009-12-29tail: remove `fdspec' from the hash table before changing its keyGiuseppe Scrivano
* src/tail.c (tail_forever_inotify): Avoid modifying fdspec->wd while it is in the wd_to_name hash table. Once it is removed, it can be added using the new `wd' as key for the hash table. This fixes the abort-inducing bug reported by Rob Wortman in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/19372
2009-12-29tail: rename an internal variableJim Meyering
* src/tail.c (tail_forever_inotify): s/wd_table/wd_to_name/
2009-12-29tail: avoid read-beyond-end-of-buffer errorJim Meyering
* src/tail.c (tail_forever_inotify): Do not use f[i] in a context where i may be larger than the largest valid index. In the final "if" clause in which we'd remove an inotify watch, we might have used f[n_files]. Use fspec instead, since it is guaranteed to be defined.
2009-12-26tac: supply link dependencyEric Blake
* src/Makefile.am (tac_LDADD): Add LIB_GETHRXTIME. * THANKS: Update. Reported by Robert Schwebel.
2009-12-26tail: shrink internal struct by 8 bytesJim Meyering
* tail.c (struct File_spec): Rearrange struct members to decrease size by 8 bytes to 76,96 on i686,x86_64 respectively.
2009-12-25maint: tail: avoid in-function #if directivesJim Meyering
* src/tail.c (fremote): Add a comment. Move definition "up" to precede first use, so we can remove its prototype and the #if..#endif around each use. (any_remote_file): Rename from any_remote_files.
2009-12-25tail: fix --follow to not use inotify on remote filesPádraig Brady
* src/tail.c (struct File_spec): Add a flag to record if file is remote. (recheck): If we're using inotify then check if the file has gone remote and if so, drop it with a warning. (any_remote_files): A new function to check for any open remote files. (tailable_stdin): A new function to refactor the check for whether a tailable file was specified through stdin. (fremote): A new function to check if a file descriptor refers to a remote file. (tail_forever_inotify): Add some comments. (tail_file): Record if a file is remote when initially opened. (main): Disable inotify if any remote files specified. Also document the caveat about remounted files not being noticed by inotify. * NEWS: Mention the fix.
2009-12-23wc: line-buffer the printed countsPádraig Brady
* src/wc.c (main): Set stdout to line buffered mode to ensure parallel running instances don't intersperse their output. This adds 6.5% to the run time in the worst case of many zero length files, but has neglible impact for standard sized files. * tests/misc/wc-parallel: New test for atomic output. * tests/Makefile.am: Reference it. * NEWS: Mention the fix This is similar to commit 710fe413, 20-10-2009, "md5sum, sha*sum, sum: line-buffer the printed checksums"
2009-12-22stat: Recognize k-afs, gfs, ocfs2 file system typesPádraig Brady
* src/stat.c (human_fstype): Add k-afs, gfs/gfs2 and ocfs2. * NEWS: Update the stat -f entry.
2009-12-22stat: add support for more file system typesPádraig Brady
* src/stat.c (human_fstype): Add the following FS types: fuseblk, rpc_pipefs. Also fix a typo of minux3 to minix3, and mention the fs-magic-compare make target to help update the list. * NEWS: Mention the fix.
2009-12-19doc: enhance and reference info about version comparisonPádraig Brady
* doc/coreutils.texi (sort invocation): Reference the additional info about filevercmp rather than the unused strverscmp. (Details about version sort): Add some examples that are not handled well by fileversmp. * src/ls.c: Change a comment referencing the now unused strverscmp.
2009-12-19rm: fix --one-file-system regression due to fts conversionPádraig Brady
* src/remove.c (rm_fts): Fix incorrect comparison of device and inode numbers. * tests/rm/one-file-system2: Add a separate test so that it can be run as a normal user (It doesn't need to mount). * tests/Makefile.am: Reference it. * NEWS: Mention the fix. Reported by Jan Larres.
2009-12-14base64: use *_OPTION_DESCRIPTION macros instead of hard-coded stringsThiago Farina
* src/base64 (usage): Use HELP_OPTION_DESCRIPTION and VERSION_OPTION_DESCRIPTION macros, not literal strings.
2009-12-13nohup: if fd_repoen fails (redirecting stdin), report itJim Meyering
* src/nohup.c (main): Don't ignore fd_reopen failure.
2009-12-13stat: recognize "sockfs" file system type, ...Jim Meyering
... now that its magic number appears in <linux/magic.h>. * src/stat.c (human_fstype) [S_MAGIC_SOCKFS]: Add case.
2009-12-12factor: add a missing va_endJim Meyering
* src/factor.c (debug): Add missing va_end.
2009-12-11tail: don't call fstat on an uninitialized FDJim Meyering
This bug showed up via valgrind as a "Conditional jump or move depends on uninitialized value(s)" error. * src/tail.c (ignore_fifo_and_pipe): New function. (main): Use it only when tailing forever. The code to compute n_viable and mark some F[i] as ignored would call isapipe on an uninitialized file descriptor. But n_viable and those .ignored marks are useful/used only when tailing forever. This bug was introduced via commit f0ff8c73 (7.6), "tail: make the new piped-stdin test as portable as the old one". * NEWS (Bug fixes): Mention it.
2009-12-08sort: fix failure if sort's parent has ignored SIGCHLDPádraig Brady
* src/sort.c (main): Reset the SIGCHLD handler to the default as otherwise wait() could return an error. * tests/misc/sort-compress: Set the CHLD handler in a subshell to SIG_IGN to ensure the sort command resets it to SIG_DFL. * NEWS: Mention the fix.
2009-12-08timeout: fix failure if timeout's parent has ignored SIGCHLDPádraig Brady
* src/timeout.c (main): Reset the SIGCHLD handler to the default as otherwise wait() could return -1 and set errno to ECHILD. This condition was ignored until commit 0b1dcf33, on 31-08-2009, "timeout: defensive handling of all wait() errors" but subsequently timeout would run the command correctly but then fail with an error message. * tests/misc/timeout: In a subshell set the CHLD handler to SIG_IGN to ensure the timeout command resets it to SIG_DFL. * NEWS: Mention the fix.
2009-12-04id: handle systems without getgroups supportEric Blake
If getgroups failed with ENOSYS, mgetgroups would unnecessarily fail, and that provoked id into freeing an uninitialized pointer. Meanwhile, we were not using xalloc_die properly. Both issues are better solved in gnulib, by introducing xgetgroups; this patch uses the new interface. Regression introduced by commit 6a31fd8d7. * gnulib: Update, for mgetgroups improvments. * src/id.c (print_full_info): Adjust caller to die on allocation failure, and no longer worry about ENOSYS. * src/group-list.c (print_group_list): Likewise. * src/setuidgid.c (main): Likewise. * NEWS: Mention the fix. * THANKS: Update. Reported by Scott Harrison.
2009-12-01sort: fix link failure on SolarisEric Blake
Commit f9d0bb8481 made sort depend on xnanosleep. * src/Makefile.am (sort_LDADD): Add LIB_NANOSLEEP.
2009-11-28maint: chown.c: remove a commentJim Meyering
* src/chown.c: Remove old spec-like comment.
2009-11-24build: fix link failure on cygwinEric Blake
Cygwin 1.5 has a broken sleep, and the gnulib tests dragged in rpl_sleep which then caused a link failure because it wasn't in libcoreutils.a. We could solve it by using the gnulib sleep module. However, sleep and usleep may interact poorly with SIGALRM, and they have less granularity; so it is better to adopt a policy that if we must sleep, prefer xnanosleep. * src/sort.c (pipe_fork): Use xnanosleep, to avoid the need for rpl_sleep on cygwin, and to reduce granularity. (MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Increase, to account for reduction in granularity. * src/tail.c (tail_file): Use xnanosleep in debug code. * cfg.mk (sc_prohibit_sleep): New rule.
2009-11-16true, false: perform initialization only when argc == 2Jim Meyering
* src/true.c (main): There is no reason to examine argv[0], call atexit, etc., in the usual case in which we're about to exit. This has the side effect of making it so that these programs no longer segfault when subjected to execve abuse. Before this change, these commands would make "true" segfault: printf '%s\n' '#include <unistd.h>' 'int main(int c, char**v)' \ '{ execve (v[1], 0, 0); }' > k.c && gcc k.c && ./a.out $PWD/true Now it succeeds. Reported by Tetsuo Handa and Bart Van Assche via Ondřej Vašík in http://bugzilla.redhat.com/537684.
2009-11-16tail -F can fail to track a file after it's been rotatedJim Meyering
Tailing forever and by-name (--follow=name, -F), tail would sometimes fail to follow a file that had been removed via rename. If you can't apply this patch and have tail 7.6 or newer, you can work around the bug via the undocumented --disable-inotify option. * src/tail.c (tail_forever_inotify): When tailing by name (-F), do not un-watch a file upon receipt of the IN_MOVE_SELF event. Reported by Arjan Opmeer in http://bugs.debian.org/548439. * NEWS (Bug fixes): Mention it. Also see http://marc.info/?l=coreutils-bug&m=125829031916515 * tests/Makefile.am (TESTS): Add tail-2/inotify-rotate. * tests/tail-2/inotify-rotate: New test.
2009-11-13build: update gnulib, for getgroups improvementsEric Blake
A replacement getgroups is now guaranteed to exist, but it may fail with ENOSYS. mgetgroups is moved to gnulib, and now takes gid_t instead of GETGROUPS_T (but setgroups still needs GETGROUPS_T). * gnulib: Update to latest. * gl/modules/mgetgroups: Delete, moved to gnulib. * gl/m4/mgetgroups.m4: Likewise. * gl/lib/mgetgroups.h: Likewise. * gl/lib/mgetgroups.c: Likewise. * src/group-list.c (print_group_list): Adjust callers. * src/id.c (print_full_info): Likewise.
2009-11-09ls: fix capability coloringPádraig Brady
Capability checking was incorrectly done on just the base name rather than on the whole path. Consequently there could be both false positives and negatives when coloring files with capabilities. Also capability checking was not done at all in certain cases for non executable files. Note passing absolute rather than relative names to cap_get_file() reduces the has_capability() overhead from around 33% to 30%. I.E. ls --color is now around 3% faster. * src/ls.c (struct fileinfo): Add a has_capability member. (print_color_indicator): Refactor to pass just a fileinfo pointer and a flag to say if we're dealing with a symlink target. (print_name_with_quoting): Likewise. (gobble_file): Set has_capability in the fileinfo struct. Also do a capability check even if executable coloring is disabled. Ditto for SETUID and SETUID coloring. Comment on how expensive has_capability() is. (print_long_format): Adjust to refactored print_name_with_quoting. (quote_name): Likewise. (print_file_name_and_frills): Likewise. * tests/ls/capability: Test the various false positive and negatives. * THANKS: Add reporter (Ivan Labath). * NEWS: Mention the fix.
2009-11-07build: consistently use freopen-saferEric Blake
cat, head, ptx, shuf, tac, tail, tee, tr, and uniq used freopen on stdout, and were potentially vulnerable. dircolors, du, and tsort only used it on stdin, which is unaffected by freopen_safer, but this covers all uses for consistency. * cfg.mk (sc_require_stdio_safer): New rule. * gl/modules/xfreopen (Depends-on): Add freopen-safer. * gl/lib/xfreopen.c (includes): Use stdio--.h. * src/ptx.c (includes): Likewise. * src/shuf.c (includes): Likewise. * src/uniq.c (includes): Likewise. * src/dircolors.c (includes): Likewise. * src/du.c (includes): Likewise. * src/tsort.c (includes): Likewise.
2009-11-07mktemp: fix bug with -q and closed stdoutEric Blake
If stdin or stdout is closed, then freopen(,stderr) can violate the premise that STDERR_FILENO==fileno(stderr), which in turn breaks mktemp -q. * bootstrap.conf (gnulib_modules): Add freopen-safer. * src/mktemp.c (includes): Use stdio--.h. * tests/misc/close-stdout: Enhance test to catch bug.
2009-11-07maint: make du's cycle-detection code consistentJim Meyering
* src/du.c (process_file): Revert the du.c-changing part of commit 8ba5d1a7. Use cycle_warning_required instead.
2009-11-07chcon, chgrp, chmod and chown now diagnose a directory cycleJim Meyering
* lib/xfts.c (cycle_warning_required): New function. * lib/xfts.h: Declare it. * src/chown-core.c (change_file_owner): Diagnose a cycle. * src/chmod.c (process_file): Likewise. * src/chcon.c (process_file): Likewise. * NEWS (Bug fixes): Mention this.
2009-11-06nproc: A new program to count the available processorsGiuseppe Scrivano
* AUTHORS: Add my name. * NEWS: Mention it. * README: Likewise. * bootstrap.conf (gnulib_modules): Add nproc. * doc/coreutils.texi (nproc invocation): Add nproc info. * man/Makefile.am (nproc.1): Add dependency. * man/nproc.x: New template. * man/.gitignore: Ignore generated man page. * po/POTFILES.in: Add src/nproc.c. * src/.gitignore: Exclude nproc. * src/Makefile.am (EXTRA_PROGRAMS): Add nproc. * src/nproc.c: New file. * tests/Makefile.am (TESTS): Add misc/nproc-{avail,positive}. * tests/misc/nproc-avail: New file. * tests/misc/nproc-positive: New file.
2009-11-05mktemp: use more robust means to avoid double-close of stdoutEric Blake
Reverts earlier patch - fflush() can succeed but fclose() fail for some cases of write failures, and we want to catch those. * src/mktemp.c (stdout_closed): New variable. (maybe_close_stdout): New function, borrowed from dd.c. (main): Track whether stdout has been closed.
2009-11-05mktemp: don't try to close stdout twiceJim Meyering
* src/mktemp.c (main): Rather than calling close_stream (which would make atexit-called close_stdout try to close it a second time), check for write failure via ferror and fflush.
2009-11-05mktemp: don't use suff_len in place of #-of-`X's variableJim Meyering
* src/mktemp.c (mkstemp_len, mkdtemp_len): Pass x_len as final argument, and not suff_len.
2009-11-05mktemp: add suffix handlingEric Blake
Now that mkstemps is supported, we might as well use it. * src/mktemp.c (TMPDIR_OPTION): New enum value. (longopts): Add new option. (usage): Document it. (count_trailing_X_s): Rename... (count_consecutive_X_s): ...to this, and add parameter. (mkstemp_len, mkdtemp_len): Add parameter. (main): Implement new option. (AUTHORS): Add myself. * AUTHORS (mktemp): Likewise. * tests/misc/mktemp: Test new option. * doc/coreutils.texi (mktemp invocation): Document it. * NEWS: Likewise. Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316.
2009-11-05build: reflect gnulib changes to tempnameEric Blake
In glibc 2.11 and gnulib, gen_tempname added a parameter suffixlen (unfortunately, it is typed as int rather than size_t, for historical compatibility to a poor choice by BSD). * gnulib: Import latest changes. * gl/lib/tempname.h.diff: Accommodate new suffixlen parameter. * gl/lib/tempname.c.diff (check_x_suffix): Allow for X in suffix beyond x_suffix_len. (gen_tempname_len): Add suffixlen parameter. (__gen_tempname): Update caller. * src/mktemp.c (mkstemp_len, mkdtemp_len): Update callers.
2009-11-05mktemp: rearrange --help outputEric Blake
* src/mktemp.c (usage): Align indentation and sort by long options. Describe valid templates. Suggested by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316.