summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2012-05-09stat: don't report negative file size as huge positive numberPaul Eggert
* src/stat.c (print_stat): Use out_int, not out_uint for stat.st_size. * NEWS (Bug fixes): Mention it.
2012-05-08split: avoid apparent infloop when splitting /dev/zero w/-n on the HurdJim Meyering
* src/split.c (main): Use stat.st_size only for regular files. Samuel Thibault reported in http://bugs.gnu.org/11424 that the /dev/zero-splitting tests would appear to infloop on GNU/Hurd, because /dev/zero's st_size is LONG_MAX. It was only a problem when using the --number (-n) option. * NEWS (Bug fixes): Mention it. This bug was introduced with the --number option, via commit v8.7-25-gbe10739
2012-05-08maint: new function: usable_st_sizeJim Meyering
2012-05-08maint: fix common spelling errorsKevin Lyda
These were identified using: https://github.com/lyda/misspell-check executed like: git ls-files | misspellings -f - * src/cat.c: Correct a spelling error. * src/comm.c: Likewise. * src/expr.c: Likewise. * src/pr.c: Likewise. * src/tac.c: Likewise. * src/test.c: Likewise. * src/ChangeLog-2005: Likewise. * src/ChangeLog-2007: Likewise. * src/NEWS: Likewise. * src/doc/coreutils.texi: Likewise. * src/lib/ChangeLog-2007: Likewise. * src/man/help2man: Likewise. * src/old/fileutils/ChangeLog-1997: Likewise. * src/old/fileutils/NEWS: Likewise. * src/old/sh-utils/ChangeLog.0: Likewise. * src/old/textutils/ChangeLog: Likewise. * src/tests/misc/comm: Likewise. * src/tests/misc/uniq: Likewise. * src/tests/mv/dir2dir: Likewise. * src/cfg.mk (old_NEWS_hash): update with `make update-NEWS-hash`
2012-05-07cp: handle a race condition more sensiblyJim Meyering
* src/copy.c (copy_reg): In a narrow race (stat sees dest, yet open-without-O_CREAT fails with ENOENT), retry the open with O_CREAT. * tests/cp/nfs-removal-race: New file. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it. Reported by Philipp Thomas and Neil F. Brown in http://bugs.gnu.org/11100
2012-05-04maint: rely on gnulib's new sys_resource moduleJim Meyering
* bootstrap.conf (gnulib_modules): Add sys_resource. * src/sort.c: Remove #if HAVE_SYS_RESOURCE_H guard around inclusion of <sys/resource.h> and move the inclusion "up" into the alphabetized list of its peers. This also avoids a failure of the sc_prohibit_always_true_header_tests syntax-check rule. * m4/jm-macros.m4 (gl_CHECK_ALL_HEADERS): Remove sys/resource.h.
2012-05-02cp,mv,install: provide POSIX_FADV_SEQUENTIAL hint to inputPádraig Brady
This was inadvertently omitted from v8.5-104-g47076e3, and gives the same 5% speedup when copying from an SSD. * src/copy.c (copy_internal): Apply the FADVISE_SEQUENTIAL hint.
2012-05-02maint: adjust comments to avoid FP match on binary-operator-at-EOLJim Meyering
* src/ls.c (print_long_format): Reformat comment to avoid "==" at end of line. Also, "sortkey" is not a word: s/sortkey/sort key/. * src/ioblksize.h: Likewise, for "|" from a shell snippet. * src/runcon.c: Likewise, for "|" in grammar-like usage.
2012-05-02maint: with split lines, don't leave an operator at end of lineJim Meyering
* src/copy.c (copy_reg): Split an expression before a binary operator, not after it. * src/cut.c (set_fields): Likewise. * src/id.c (main): Likewise. * src/install.c (setdefaultfilecon): Likewise. * src/join.c (ignore_case): Likewise. * src/pr.c (cols_ready_to_print, init_parameters, print_page): Likewise. * src/stty.c (set_window_size): Likewise. * src/wc.c (SUPPORT_OLD_MBRTOWC): Likewise. * src/who.c (scan_entries): Likewise. * src/test.c (binary_operator): Join a split line. * src/extent-scan.c (extent_scan_read): Move an ">" from end of line to beginning of the following. Likewise for two other expressions.
2012-04-30cat,cp,mv,install,split: Set the minimum IO block size used to 64KiBPádraig Brady
* NEWS: Mention the change in behavior. * src/ioblksize.h: Add updated test results and increase value from 32KiB to 64KiB.
2012-04-27id: -Zn/-Zr: avoid an invalid diagnosticJim Meyering
* src/id.c (main): Using -Z with -r or -n would fail with "id: cannot print only names or real IDs in default format", in spite of that "-Z", which specifies a non-default format. Now, it succeeds and ignores the -n or -r option. The error was that the test for default_format was not updated when I added the new --context (-Z) option in commit v6.9-33-g5320d0f.
2012-04-27id: don't call getcon unnecessarilyJim Meyering
* src/id.c (main): Invocations like "id" and "id -G" would call getcon to determine the current security context even though that result would not be used. Similarly, when POSIXLY_CORRECT is set. Rearrange conditionals and hoist the POSIXLY_CORRECT test so that we call getcon only when necessary.
2012-04-27maint: id: minor factorizationJim Meyering
* src/id.c (main): Factor out uses of "argc - optind". Move option-consistency checks to precede the potential getcon call.
2012-04-27id,groups: with no user name, print only real and/or effective IDs,Jim Meyering
... i.e., don't use the getpw* functions. Before this change, running groups or id with no user name argument would include a group name or ID from /etc/passwd. Thus, under unusual circumstances (default group is changed, but has not taken effect for a given session), those programs could print a name or ID that is neither real nor effective. To demonstrate, run this: echo 'for i in 1 2; do id -G; sleep 1.5; done' \ |su -s /bin/sh ftp - & sleep 1; perl -pi -e 's/^(ftp:x:\d+):(\d+)/$1:9876/' /etc/passwd Those id -G commands printed the following: 50 50 9876 With this change, they print this: 50 50 Similarly, running those programs set-GID could make them print one ID too many. * src/group-list.c (print_group_list): When username is NULL, pass egid, not getpwuid(ruid)->pw_gid), to xgetgroups, per the API requirements of xgetgroups callee, mgetgroups. When not using the password database, don't call getpwuid. * NEWS (Bug fixes): Mention it. * tests/misc/id-setgid: New file. * tests/Makefile.am (TESTS): Add it. (root_tests): It's a root-only test, so add it here, too. Originally reported by Brynnen Owen as http://bugs.gnu.org/7320. Raised again by Marc Mengel in http://bugzilla.redhat.com/816708.
2012-04-19maint: tac: use memcpy, not strcpyJim Meyering
* src/tac.c (main): Use memcpy, not strcpy, since we know the length.
2012-04-19maint: ls: use stpncpy/stpcpy, not strncpy/strcpyJim Meyering
* src/ls.c (gobble_file): Move a decl "down". (make_link_name): Do not hard-code '/'. Use IS_ABSOLUTE_FILE_NAME and dir_len instead. Use stpcpy/stpncpy in place of strncpy/strcpy.
2012-04-19maint: modernize/clean-up a small function in ls.cJim Meyering
* src/ls.c (make_link_name): Adjust comment style to refer to VARIABLE names, not 'variable'. Move each of two declarations "down" to first use. Compare pointer to NULL, not to 0. Don't reuse local, "linkbuf" for a different purpose.
2012-04-16maint: replace a use of strcpy in chmod.c with memcpyJim Meyering
* src/chmod.c (main): Use memcpy rather than strcpy, since we already have the length handy.
2012-04-12fmt: accept new --goal=WIDTH (-g) optionBruce Korb
Accept -g for BSD/Plan9 compatibility. * NEWS (New features): Mention it. * tests/fmt/goal-option: New test. * tests/fmt/long-line: Rename from tests/fmt-long-line. * tests/fmt/base: Rename from tests/misc/fmt. * doc/coreutils.texi: Document it. * src/fmt.c (main): Accept the new option (check_for_goals): new function to implement the operands Based on BSD's and Plan-9's fmt programs.
2012-04-12cp: change --attributes-only to not truncate existing filesPádraig Brady
* src/copy.c (copy_reg): Don't truncate an existing file, to support copying attributes between existing files. The original use case only considered creating new files, and it would be a very unusual use case to be relying on the truncating behavior. * doc/coreutils.texi (cp invocation): Mention the non truncating behavior. * tests/cp/attr-existing: A new test to ensure O_TRUNC skipped. * tests/Makefile.am: Reference the new test. * NEWS: Mention the change in behavior.
2012-03-28chmod: undo previous changePaul Eggert
It's not portable; see <http://bugs.gnu.org/11108#17>. * src/chmod.c, NEWS: Undo previous change.
2012-03-28chmod: fix symlink race conditionPaul Eggert
* NEWS: Document this. * src/chmod.c (process_file): Don't follow symlink if we think the file is not a symlink.
2012-03-26doc: use $(...), not `...` in documentation and commentsJim Meyering
* doc/coreutils.texi (dircolors invocation, Examples of expr): (shred invocation, seq invocation): Use $(...), not `...`. * src/mv.c (do_move): Likewise, in a comment.
2012-03-22ln: add the --relative optionHarald Hoyer
With the "--relative --symbolic" options, ln computes the relative symbolic link for the user. So, ln works just as cp, but creates relative symbolic links instead of copying the file. I miss this feature since the beginning of using ln. $ tree ./ / `-- usr |-- bin `-- lib `-- foo `-- foo 4 directories, 1 file $ ln -s -v --relative usr/lib/foo/foo usr/bin/foo ‘usr/bin/foo’ -> ‘../lib/foo/foo’ $ tree ./ / `-- usr |-- bin | `-- foo -> ../lib/foo/foo `-- lib `-- foo `-- foo 4 directories, 2 files $ ln -s -v --relative usr/bin/foo usr/lib/foo/link-to-foo ‘usr/lib/foo/link-to-foo’ -> ‘foo’ $ tree ./ / `-- usr |-- bin | `-- foo -> ../lib/foo/foo `-- lib `-- foo |-- link-to-foo -> foo `-- foo 4 directories, 3 files * src/Makefile.am: Reference the relpath module. * src/ln.c (usage): Mention the new option. (do_link): Call the relative conversion if specified. (convert_abs_rel): Perform the relative conversion using the relpath module. * tests/ln/relative: Add a new test. * tests/Makefile.am: Reference the new test. * doc/coreutils.texi: Document the new feature. * NEWS: Mention the new feature.
2012-03-22maint: refactor relpath() from `realpath` for use by `ln`Pádraig Brady
* src/relpath.c: Refactored from realpath.c and adjusted to support returning the relative path rather than just printing to stdout. * src/relpath.h: Export the relpath function. * src/Makefile.am: Reference the refactored relpath module. * po/POTFILES.in: Likewise. * src/realpath.c: Adjust to the refactored relpath module.
2012-03-22maint: ensure PATH_MAX is set correctlyPádraig Brady
This reverts part of commit v8.12-103-g54cbe6e. * src/system.h: Include gnulib's pathmax.h to honor system specific limits, and then we set PATH_MAX only if needed. Note pathmax.h no longer uses pathconf ("/", _PC_PATH_MAX). Note I didn't reinstate the comments about limits.h inclusion order, because pathmax.h includes limits.h anyway.
2012-03-21maint: use more modern fseeko, rather than fseekJim Meyering
* src/tac.c (temp_stream): Use fseeko, not fseek, on principle: use the more modern interface. In general it is better to avoid fseek due to its ABI-imposed 4GiB limit on the "offset", here its use was fine because the offset was always 0. Using fseeko also has the advantage of not triggering a GNULIB_POSIXCHECK warning. Reported by Eric Blake in http://thread.gmane.org/gmane.comp.gnu.coreutils.general/2426/focus=2489
2012-03-15realpath: optimize --relative-base usageEric Blake
There is no need to recompute for every path being visited whether the base is a prefix of the relative location. * src/realpath.c (relpath): Hoist base check... (main): ...here. Based on a suggestion by Pádraig Brady.
2012-03-15realpath: let --relative-to default to --relative-baseEric Blake
Most of the time, if someone wants to filter which paths are relative while leaving all others absolute, they also want to to the filtering based on the same --relative-to directory. Make this easier to specify. * src/realpath.c (main): Convert error to default. * doc/coreutils.texi (realpath invocation): Document this. * tests/misc/realpath: Adjust test to match. * NEWS: Document it.
2012-03-15realpath: fix problems with root handlingEric Blake
When --relative-base is /, all other paths should be treated as relative (except for // where it matters). Also, on platforms like Cygwin where / and // are distinct, realpath was incorrectly collapsing // into /. http://debbugs.gnu.org/10472. * src/realpath.c (path_prefix, path_common_prefix): Treat / and // as having no common match. (relpath): Allow for no match even without --relative-base. * NEWS: Document this.
2012-03-10dirname: support more than one argumentJérémy Compostella
* src/dirname.c (main): Handle new -z option and manage more than one argument. * doc/coreutils.texi (dirname invocation): Mention it. * NEWS (New features): Mention it. * tests/misc/dirname: Add a two arguments test.
2012-03-10split: support an arbitrary number of split files by defaultJérémy Compostella
* src/split.c (next_file_name): If `suffix_auto' is true and the first suffix character is 'z', generate a new file file name adding `z' to the prefix and increasing the suffix length by one. (set_suffix_length): Disable auto suffix width in various cases. * tests/split/suffix-auto-length: Test it. * doc/coreutils.texi (split invocation): Mention it. * NEWS (Improvements): Likewise.
2012-03-08chmod: add notations +40, 00440, etc.Paul Eggert
* NEWS: Document this. * doc/perm.texi (Operator Numeric Modes): New section. (Numeric Modes, Directory Setuid and Setgid): Document new behavior. * src/chmod.c (usage): Document new behavior. (main): Support new options -0, -1, etc. * tests/chmod/setgid: Test these new features.
2012-03-08du: fix -x: don't ignore non-directory argumentsJim Meyering
Surprise! "du -x non-DIR" would print nothing. Note that the problem arises only when processing a non-directory specified on the command line. Not surprisingly, "du -x" still works as expected for any directory argument. When performing its same-file-system check, du may skip an entry only if it is at fts_level 1 or greater. Command-line arguments are at fts_level == 0 (FTS_ROOTLEVEL). * src/du.c (process_file): Don't use the top-level FTS->fts_dev when testing for --one-file-system (-x). It happens to be valid for directories, but it is always 0 for a non-directory. * tests/du/one-file-system: Add tests for this. * NEWS (Bug fixes): Mention it. Reported by Daniel Stavrovski in http://bugs.gnu.org/10967. Introduced by commit v8.14-95-gcfe1040.
2012-03-07basename: support more than one argumentJérémy Compostella
* src/basename.c (perform_basename): New function refactored from main() that performs the basename work on a STRING, optionally removes a trailing SUFFIX and outputs the result. (main): Handle new options. * doc/coreutils.texi (basename invocation): Mention new options. * test/misc/basename: Add new options test cases. * NEWS (New features): Mention it.
2012-03-06maint: refactor copy to use is_nul()Pádraig Brady
* src/dd.c: Move is_nul() from here to ... * src/system.h: ... here * src/copy.c (sparse_copy): Adjust to use the refactored is_nul()
2012-02-29doc: timeout: document the exit status when run with "-s KILL"Rodrigo Campos
* src/timeout.c (usage): Document the exit status for this case, in --help and thus in the man page. Word so that it covers both the -s9 and -k options. * doc/coreutils.texi (timeout invocation): Document the exit status for this case.
2012-02-29dd: add support for the conv=sparse optionRoman Rybalko
Notes: Small seeks are not coalesced to larger ones, like is done in cache_round() for example. conv= is used rather then oflag= for FreeBSD compatibility. * src/dd.c (final_op_was_seek): A new global boolean to flag whether the final "write" was converted to a seek. (usage): Describe the new conf=sparse option. (iwrite): Convert a write of a NUL block to a seek if requested. (do_copy): Initialize the output buffer to have a sentinel, to allow for efficient testing for NUL output blocks. If the last block in the file was converted to a seek, then convert back to a write so the size is updated. * NEWS: Mention the new feature. * tests/dd/sparse: A new test for the feature. * tests/Makefile.am: Reference the new test.
2012-02-25sort: default to physmem/8, not physmem/16Paul Eggert
* src/sort.c (default_sort_size): Don't divide advice by 2. Just divide the hard limits by 2. This matches the comments. Reported by Rogier Wolff in http://bugs.gnu.org/10877
2012-02-24doc: clarify a comment in system.hJim Meyering
* src/system.h (STRNCMP_LIT): Clarify comment. Suggested by Bruno Haible.
2012-02-20split: add the --additional-suffix optionJérémy Compostella
Add the --additional-suffix option, to append an additional static suffix to output file names. * src/split.c (next_file_name): Append suffix to output file names. (main): Handle new --additional-suffix option. * NEWS (New features): Mention it. * doc/coreutils.texi (split invocation): Mention it. * tests/split/additional-suffix: New file. Test --additional-suffix. * tests/Makefile.am (TESTS): Add it. Requested by Peng Yu, in bug 6554
2012-02-20ls: adjust errnos indicating device non support for xattrsPádraig Brady
* src/ls.c (errno_unsupported): Remove EBUSY, as this caters for the case where ACLs can't be accessed because the _file_ is locked. http://lists.gnu.org/archive/html/bug-coreutils/2005-06/msg00191.html Also ENOENT is not safe to include as you get that if the _file_ is removed between the stat() and subsequent querying of xattrs.
2012-02-18ls: cache ACL- and CAP-querying syscall failuresJim Meyering
Like the optimization to avoid always-failing getfilecon calls, this change avoids always-failing queries for whether a file has a nontrivial ACL and for whether a file has certain "capabilities". When such a query fails for one file (indicating no support), we know it will always fail that way for the affected device. With this change, we have thus eliminated nearly all failing-unsupported getxattr syscalls. * src/ls.c (has_capability) [!HAVE_CAP]: Set errno to ENOTSUP. (errno_unsupported): Expand the list of E* errno values to match that of lib/acl-internal.h's ACL_NOT_WELL_SUPPORTED macro. (file_has_acl_cache, has_capability_cache): New functions. (gobble_file): Use them in place of non-caching ones. * NEWS (Improvements): Mention it. Suggested by Sven Breuner in http://thread.gmane.org/gmane.comp.gnu.coreutils.general/2187 While eliminating most getfilecon calls saved about 33%, eliminating these other calls can save almost all of the remaining ~67% cost, on some remote file systems.
2012-02-18ls: optimize for when getfilecon would often fail (~33% perf. gain)Jim Meyering
On systems or file systems without SELinux support, all getfilecon and lgetfilecon calls would fail due to lack of support. We can non- invasively cache such failure (on most recently accessed device) and avoid the vast majority of the failing underlying getxattr syscalls. * src/ls.c (errno_unsupported): New function. (selinux_challenged_device): New file-scoped global. (getfilecon_cache, lgetfilecon_cache): New error-caching wrapper functions. (gobble_file): Use the caching wrappers, for when many *getfilecon calls would fail with ENOTSUP or EOPNOTSUPP. Suggested by Sven Breuner in http://thread.gmane.org/gmane.comp.gnu.coreutils.general/2187 Improved-by: Pádraig Brady.
2012-02-18split: support optional start value for --numeric-suffixesJérémy Compostella
Allow changing the --numeric-suffixes start number from the default of 0. * src/split.c (next_file_name): Initialize the suffix index and the output filename according to start value. (main): Check that the suffix length is large enough for the numerical suffix start value. * doc/coreutils.texi (split invocation): Mention it. * NEWS (New features): Mention it. * tests/split/numeric: New file. Test --numeric-suffixes[=FROM]. * tests/Makefile.am (TESTS): Reference the new test.
2012-02-16doc: improve 'rm -f' descriptionBernhard Voelker
* doc/coreutils.texi (rm invocation): Mention that the -f option also silences the message for missing operands, which is useful in scripts e.g., for "rm -f $file_list" when $file_list is empty. * src/rm.c (usage): Likewise. Reported by Jérémy Magrin in http://bugs.gnu.org/10819
2012-02-13dd: fix issues in the count_bytes and seek_bytes flags changePádraig Brady
These edge cases were missed in the previous commit 140eca15c. * src/dd.c (main): Include the bytes slop when truncating without further I/O. Don't invalidate the whole file cache in the case where 0 < count < ibs. * tests/dd/bytes: Change to using the independent truncate command to generate the file for comparison. Remove a redundant test case and replace with one testing the truncation only logic.
2012-02-12dd: add count_bytes, skip_bytes and seek_bytes flagsJérémy Compostella
dd now accepts the count_bytes and skip_bytes input flag and the seek_bytes output flag, to more easily allow processing portions of a file. * src/dd.c (scanargs): Compute skip_records and skip_bytes when 'skip_bytes' iflag is used. Compute max_records and max_bytes when 'count_bytes' iflag is used. Compute seek_records and seek_bytes when 'seek_bytes' oflag is used. (skip_via_lseek): Use new 'bytes' parameter and handle potential 'records' equals to zero. Update the bytes parameter when called with 'fdesc' equal to STDOUT_FILENO. Update the header comments. (dd_copy): Skip accordingly to skip_records AND skip_bytes. Count accordingly to max_records AND max_bytes. Seek on output accordingly to seek_records AND seek_bytes. * NEWS (New features): Mention it. * doc/coreutils.texi (dd invocation): Detail new flags and behaviors. * tests/dd/bytes: New file. Tests for these new flags. * tests/Makefile.am (TESTS): Add it.
2012-02-12mv: "mv A B" would sometimes succeed, yet A would remain, ...Jim Meyering
But only when both A and B were hard links to the same symlink. * src/copy.c (same_file_ok): Handle another special case: the one in which we are moving a symlink onto a hard link to itself. In this case, we must explicitly tell the caller to unlink the source file. Otherwise, at least the linux-3.x kernel rename function would do nothing, as mandated by POSIX 2008. * tests/mv/symlink-onto-hardlink-to-self: New test. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it. Reported by Bernhard Voelker in http://bugs.gnu.org/10686
2012-02-06maint: add braces as requested by HACKING coding standardJérémy Compostella
* src/dd.c (dd_copy): Braces were missing for this do/while statement.