summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2013-11-08shred: fix direct I/O failures for last write to filePádraig Brady
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.
2013-11-07cp: fix --link regarding the dereferencing of symbolic linksGian Piero Carrubba
* 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>
2013-11-06shred: write larger chunks when possiblePádraig Brady
* src/shred.c (dopass): When not needing to write periodic patterns, use a 64KiB block size to reduce the number of write system calls.
2013-11-05shred: enable direct I/O when possiblePádraig Brady
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.
2013-11-01md5sum, sha*sum: improve help for --check related optionsPádraig Brady
* 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
2013-11-01maint: simplify printing of md5sum file namesPádraig Brady
* 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.
2013-10-15dircolors: add putty-256color terminal typeMike Frysinger
* 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
2013-10-11cp: correct error message for invalid arguments of '--no-preserve'Ondřej Vašík
* 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
2013-10-07mktemp: fix incorrect exit status from previous commitPádraig Brady
* 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
2013-10-06mktemp: with --quiet, only suppress I/O errorsPádraig Brady
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.
2013-10-06mktemp: synchronize the -p option with docsPádraig Brady
* 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
2013-09-26rm: with -I, prompt before deleting a write protected fileSergio Durigan Junior
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
2013-09-22maint: remove unused parameters to parse_user_spec()Pádraig Brady
* 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.
2013-09-22id: support specifying the user by user IDPádraig Brady
* 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
2013-09-21id: add -z, --zero optionBernhard Voelker
* 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
2013-09-05ls: fix possible incorrect exit status when recursing directoriesFUJIWARA Katsunori
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
2013-09-01maint: update out of date confusing commentsPádraig Brady
* 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.
2013-08-29df: fix "blocks" translation in headerPádraig Brady
* 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
2013-08-10doc: clarify when seq endsBernhard Voelker
* 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
2013-08-05doc: more semicolons instead of periods in option descriptionsBenno Schulenberg
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.
2013-08-03doc: clarify that uniq -d outputs a single entry per groupPádraig Brady
* src/uniq.c (usage): Clarify the -d option. Fixes http://bugs.gnu.org/14996
2013-08-02maint: update copyright year number ranges of numfmt sourcesBernhard Voelker
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.
2013-08-01doc: use semicolon instead of period in option descriptionsBenno Schulenberg
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
2013-07-28maint: avoid clang static analysis issues in csplitPádraig Brady
* 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.
2013-07-27du: add --inodes optionBernhard Voelker
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.
2013-07-25mv: replace empty directories in cross file system moveKen Booth
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
2013-07-22maint: use new gnulib function to free mount entries in duBernhard Voelker
* src/du.c (fill_mount_table): Use free_mount_entry() instead of freeing struct members manually.
2013-07-19rm: output number of arguments at the interactive promptRasmus Villemoes
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.
2013-07-19dd: make status=none suppress all diagnosticsPádraig Brady
* 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
2013-07-12head: avoid redundant allocations when reading empty filesPádraig Brady
* 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.
2013-07-12maint: avoid a valgrind memory leak warning from pinkyPádraig Brady
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.
2013-07-11df: reduce memory usage when filtering mount entriesAnton Ovchinnikov
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.
2013-07-11build: fix a build warning on 32 bit systems in shuf.cPádraig Brady
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.
2013-07-11shuf: add --repetition to support repetition in outputAssaf Gordon
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.
2013-07-11maint: adjust indentation in df.cPádraig Brady
* src/df.c: Adjust indentation and spacing with has gotten quite out of line in a couple of places.
2013-07-09df: fix mount list processing with unstatable mount dirsPádraig Brady
* 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.
2013-07-07maint: avoid a valgrind memory leak warning from uptimeAnton Ovchinnikov
* src/uptime.c (uptime): Free utmp_buf returned from read_utmp, to avoid a "definitely lost" warning from valgrind.
2013-07-02stat: ensure --context emits an "unrecognized option" diagnosticPádraig Brady
* src/stat.c (long_options): Remove the "context" option as it's no longer referenced since commit v8.5-65-g13f3237
2013-07-02mkdir,mkfifo,mknod: give scontext-related variable a better scopeBernhard Voelker
* src/mkdir.c (main): Move the variable ret and issuing the error message into the body of the scontext-related if-block. * src/mkfifo.c (main): Likewise. * src/mknod.c (main): Likewise.
2013-07-02maint: refactor SMACK interface to a separate modulePádraig Brady
Consolidate all smack routines and checks in a module. We replace and wrap the most commonly used smack routines, which allows removing ifdefs throughout the code. * gl/lib/smack.h: A new header containing the implementation of the wrapped and replacement routines. Note the is_smack_enabled() routine should be optimized out at compile time when compiled on a system without libsmack. * gl/modules/smack: Describe the new module and move the configure time code here from ... * m4/jm-macros.m4: ... here. * bootstrap.conf: Reference the new module. * src/id.c: Use the routines without ifdefs where possible. * src/ls.c: Likewise. * src/mkdir.c: Likewise. * src/mkfifo.c: Likewise. * src/mknod.c: Likewise.
2013-07-02id: don't show SMACK errors unless -Z is specifiedPádraig Brady
* src/id.c (main): Be consistent with the SELinux case, and only show errors in getting the security context when -Z is specified.
2013-07-01mkdir,mkfifo,mknod: with -Z, create SMACK security contextJarkko Sakkinen
Enable creation of SMACK security context with -Z command-line switch if SMACK is enabled. * mkdir.c (main): Set process security context to given SMACK label. * mkfifo.c (main): Likewise. * mknod.c (main): Likewise. * src/local.mk: link mk{dir, fifo, nod} with libsmack. * NEWS: Mention the new feature.
2013-06-24ls: with -Z, show SMACK security contextJarkko Sakkinen
Enable showing of file SMACK security with '-Z' command-line switch if SMACK is enabled. Showing SMACK context of a file does not strictly require SMACK to be enabled but this required to make choice whether to show SELinux or SMACK security context. * src/ls.c (getfilecon_cache): Retrieve SMACK context if available. (gobble_file): Handle SMACK context similarly to SELinux context. * src/local.mk: Link lsl with libsmack. * NEWS: Mention the new feature. * .mailmap: Merge the Author's 2 email addresses.
2013-06-22stdbuf: make it mandatory to specify a buffering optionPádraig Brady
This is consistent with the documented interface and avoids any ambiguity in a user thinking that stdbuf without options might reset to a "standard" buffering setup. * src/stdbuf.c (set_libstdbuf_options): Indicate with the return value whether any env variables were actually set. (main): Fail unless some env variables were set. * tests/misc/stdbuf.sh: Ensure this constraint is enforced. * NEWS: Mention the small change in behavior.
2013-06-22doc: clarify that truncate --size represents bytes by defaultPádraig Brady
* src/truncate.c (usage): Mention that --size is in bytes which is by far the most common usage. * doc/coreutils.texi (truncate invocation): Likewise. Also cross reference the --io-blocks option. Reported in http://bugs.gnu.org/14686
2013-06-20id: adjust/restrict smack support to newer versions of libsmackJarkko Sakkinen
There was slight change to libsmack such that positive values are reserved for returning length of the label for smack_new_label_from_* functions. * m4/jm-macros.m4: Set HAVE_SMACK when both smack_new_label_from_self() and recently added smack_new_label_from_path() are present. The latter's presence indicates the newer API of the former. * src/id.c (main): Check that smack_new_label_from_self() < 0, and not just non-zero.
2013-06-18tests: use appropriate precision when printing float limitsPádraig Brady
* src/getlimits.c (print_float): Adjust to use the ftoastr module, which uses the appropriate precision so that no info is lost. * cfg.mk (sc_prohibit_continued_string_alpha_in_column_1): Exclude od.c fixes http://bugs.gnu.org/14650
2013-06-12doc: clarify the description of du --separate-dirsPádraig Brady
* src/du.c (usage): Clarify that --separate-dirs doesn't exclude all directories. * doc/coreutils.texi (du invocation): Avoid implying that -S excludes the size of any non directory entries for a directory. Also don't mention st_size as it's dependent on --apparent-size. Reported by C de-Avillez in <https://launchpad.net/bugs/1187044>
2013-06-03doc: mention 'UTC' in date --utc helpAndreas Mohr
src/date.c (usage): Make -u apparent in searches for UTC.
2013-06-02od: -wN, N>64K, avoid misbehavior on systems with 32-bit size_tJim Meyering
* src/od.c (PRINT_FIELDS): Declare "i" to be of type uintmax_t, so that the numerator in the expression for "next_pad" does not overflow. (print_named_ascii): Likewise. (print_ascii): Likewise. Bug introduced via commit v6.12-42-g20c0b87. * tests/misc/od.pl: Exercise each of the three affected code paths. * NEWS (Bug fixes): Mention it. Reported by Rich Burridge.