summaryrefslogtreecommitdiff
path: root/src/dd.c
AgeCommit message (Collapse)Author
2009-02-02update copyright dates from recent changesJim Meyering
* src/dd.c: Add 2009 to list of copyright years. * tests/dd/seek-skip-past-file: Likewise. * tests/dd/seek-skip-past-dev: Likewise. * m4/xattr.m4: Likewise. * src/copy.h: Likewise.
2009-01-28dd: Better handle user specified offsets that are too bigPádraig Brady
Following are the before and after operations for seekable files, for the various erroneous offsets handled by this patch: skip beyond end of file before: immediately exit(0); after : immediately printf("cannot skip to specified offset"); exit(0); skip > max file size before: read whole file and exit(0); after : immediately printf("cannot skip: Invalid argument"); exit(1); seek > max file size before: immediately printf("truncate error: EFBIG"); exit(1); after : immediately printf("truncate error: EFBIG"); exit(1); skip > OFF_T_MAX before: read whole device/file and exit(0); after : immediately printf("cannot skip:"); exit(1); seek > OFF_T_MAX before: immediately printf("truncate error: offset too large"); exit(1); after : immediately printf("truncate error: offset too large"); exit(1); skip > device size before: read whole device and exit(0); after : immediately printf("cannot skip: Invalid argument"); exit(1); seek > device size before: read whole device and printf("write error: ENOSPC"); exit(1); after : immediately printf("cannot seek: Invalid argument"); exit(1); * NEWS: Summarize this change in behavior. * src/dd.c (skip): Add error checking for large seek/skip offsets on seekable files, rather than deferring to using read() to advance offset. (dd_copy): Print a warning if skip past EOF, as per FIXME comment. * test/Makefile.am: Add 2 new tests. * tests/dd/seek-skip-past-file: Add tests for first 3 cases above. * tests/dd/seek-skip-past-dev: Add root only test for last case above.
2008-12-26maint: ensure dd's computation of O_FULLBLOCK uses all O_ symbol namesJim Meyering
* src/dd.c (O_FULLBLOCK): Use a more uniform initializer, that makes it easier to extract all O_ symbol names. * maint.mk (syntax-check-rules): Also search for sc_ rules in cfg.mk. (sc_root_tests): Ensure that this rule sets $diff. * cfg.mk (sc_dd_O_FLAGS): New rule.
2008-12-26dd: add support for opening files in Concurrent I/O (CIO) modeMatt Harden
* src/dd.c (O_CIO): New flag. * src/dd.c (O_FULLBLOCK): Add O_CIO to the list of flags that O_FULLBLOCK should be greater than. * src/dd.c (flags): Give the name "cio" to the new O_CIO flag, mirroring the treatment of O_DIRECT. * src/dd.c (usage): Add a description of the new flag when it is available. * doc/coreutils.text (dd invocation): Describe the new flag. * NEWS: Mention the new feature.
2008-11-22Revert part of "dd: avoid unnecessary memory copies"Pádraig Brady
This reverts part of commit fbd87029cfc494a72bb73ade27ef46382c5bc832. Paul Eggert noticed the problem in http://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00153.html * doc/coreutils.texi (dd invocation): Clarify.
2008-11-21dd: avoid unnecessary memory copiesPádraig Brady
* src/dd.c (scanargs): When not otherwise required (e.g. for conversion), use two-buffer mode only when the input and output buffer sizes differ. Before, some of the most basic invocations of dd, e.g., dd < in > out, would unnecessarily use separate buffers and perform memory copies between them.
2008-08-26use new global, "Version", rather than macro, VERSIONJim Meyering
With this change, a version-string update no longer forces recompilation of 100+ src/*.o files. * src/version.c (Version): New global. New file. * src/version.h: Declare it. * src/Makefile.am: Put it in a library that everyone links to. (noinst_LIBRARIES, libver_a_SOURCES): Define. (LDADD): Add libver.a. (sc_tight_scope): Use perl (was sed), and a more relaxed regexp to build the global-variable-name-recognizing regexp list. * src/system.h: Include "version.h". (case_GETOPT_VERSION_CHAR): Use Version rather than VERSION. * src/basename.c (main): Use Version rather than VERSION. * src/chroot.c (main): Likewise. * src/cksum.c (main): Likewise. * src/dd.c (main): Likewise. * src/dirname.c (main): Likewise. * src/echo.c (main): Likewise. * src/hostid.c (main): Likewise. * src/hostname.c (main): Likewise. * src/link.c (main): Likewise. * src/logname.c (main): Likewise. * src/nice.c (main): Likewise. * src/nohup.c (main): Likewise. * src/printenv.c (main): Likewise. * src/printf.c (main): Likewise. * src/pwd.c (main): Likewise. * src/setuidgid.c (main): Likewise. * src/sleep.c (main): Likewise. * src/sync.c (main): Likewise. * src/test.c (main): Likewise. * src/timeout.c (main): Likewise. * src/true.c (main): Likewise. * src/tsort.c (main): Likewise. * src/unlink.c (main): Likewise. * src/uptime.c (main): Likewise. * src/users.c (main): Likewise. * src/whoami.c (main): Likewise. * src/yes.c (main): Likewise.
2008-08-11dd: clarify meaning of multiplication factors; put xM in orderBenno Schulenberg
2008-08-09dd.c: reduce duplication in new O_FULLBLOCK-defining codeJim Meyering
* src/dd.c (MULTIPLE_BITS_SET): New macro, extracted from... (multiple_bits_set): ...this function. Use a single-line, and far simpler expression (no need to list all O_* symbols again) to validate the derived O_FULLBLOCK value.
2008-07-23dd: minor fullblock changesJim Meyering
* src/dd.c (O_FULLBLOCK): Define using an enum, not #define. Derive the value, rather than hard-coding to one that might conflict. (usage): Mention iflag=fullblock in --help output. (scanargs): Reset the O_FULLBLOCK bit, so that we don't try to set an undefined attribute via fcntl (fd, F_SETFL, ... * tests/dd/misc: Signal framework_failure when necessary. Use "compare actual expected", so any diffs look "right". * NEWS (dd): Alphabetize and reword. * coreutils.texi (dd invocation): Adjust wording.
2008-07-23dd: new option: iflag=fullblock to accumulate full input blocksKamil Dudka
* src/dd.c (iread_fullblock): New function for reading full blocks. (scanargs): Check for new parameter iflag=fullblock. (skip): Use iread_fnc pointer instead of iread function. (dd_copy): Use iread_fnc pointer instead of iread function. * tests/dd/misc: Add test for dd - read full blocks. * doc/coretuils.texi: Mention new parameter iflag=fullblock. * NEWS: Mentioned the change.
2008-07-23dd: adjust --help output so help2man formats the man page properlyJim Meyering
* src/dd.c (usage): Use two spaces (not one) to separate "directory" from its description, so help2man formats the derived man page properly.
2008-06-16remove redundant const directivesJim Meyering
In 1463824d8e7f72c31f1d803d7cfe2b608ccafc5c, I added some missing "const" directives, as well as some new, redundant ones. This removes the redundant ones. Pointed out by Eric Blake. * base64.c, cat.c, chcon.c, chgrp.c, chmod.c, chown.c, comm.c: * cp.c, csplit.c, cut.c, date.c, dd.c, df.c, dircolors.c, du.c: * env.c, expand.c, fmt.c, fold.c, groups.c, head.c, id.c: * install.c, join.c, kill.c, ln.c, ls.c, md5sum.c, mkdir.c: * mkfifo.c, mknod.c, mktemp.c, mv.c, nice.c, nl.c, od.c: * paste.c, pathchk.c, pinky.c, pr.c, ptx.c, readlink.c, rm.c: * rmdir.c, runcon.c, seq.c, shred.c, shuf.c, sort.c, split.c: * stat.c, stty.c, su.c, sum.c, tac.c, tail.c, tee.c, timeout.c: * touch.c, tr.c, truncate.c, tty.c, uname.c, unexpand.c, uniq.c: * wc.c, who.c: Remove redundant const directives. * maint.mk (sc_const_long_option): Don't require redundant "const".
2008-06-14add "const" attribute, where possibleJim Meyering
* maint.mk (sc_const_long_option): New rule. Enforce global change. * src/base64.c (long_options): Use "const" where possible. * src/cat.c (main): Likewise. * src/chcon.c (long_options): Likewise. * src/chgrp.c (long_options): Likewise. * src/chmod.c (long_options): Likewise. * src/chown.c (long_options): Likewise. * src/comm.c (long_options, OUTPUT_DELIMITER_OPTION): Likewise. * src/cp.c (long_opts): Likewise. * src/csplit.c (longopts): Likewise. * src/cut.c (longopts): Likewise. * src/date.c (long_options): Likewise. * src/dd.c (conversions, flags, statuses): Likewise. * src/df.c (long_options): Likewise. * src/dircolors.c (long_options): Likewise. * src/du.c (long_options): Likewise. * src/env.c (longopts): Likewise. * src/expand.c (longopts): Likewise. * src/fmt.c (long_options): Likewise. * src/fold.c (longopts): Likewise. * src/groups.c (longopts): Likewise. * src/head.c (long_options): Likewise. * src/id.c (longopts): Likewise. * src/install.c (long_options): Likewise. * src/join.c (longopts): Likewise. * src/kill.c (long_options): Likewise. * src/ln.c (long_options): Likewise. * src/ls.c (long_time_format, long_options, sort_functions): Likewise. * src/md5sum.c (long_options): Likewise. * src/mkdir.c (longopts): Likewise. * src/mkfifo.c (longopts): Likewise. * src/mknod.c (longopts): Likewise. * src/mktemp.c (longopts): Likewise. * src/mv.c (long_options): Likewise. * src/nice.c (longopts): Likewise. * src/nl.c (longopts): Likewise. * src/od.c (charname, long_options): Likewise. * src/paste.c (longopts): Likewise. * src/pathchk.c (longopts): Likewise. * src/pinky.c (longopts): Likewise. * src/pr.c (long_options): Likewise. * src/ptx.c (long_options): Likewise. * src/readlink.c (longopts): Likewise. * src/rm.c (long_opts): Likewise. * src/rmdir.c (longopts): Likewise. * src/runcon.c (long_options): Likewise. * src/seq.c (long_options): Likewise. * src/shred.c (long_opts): Likewise. * src/shuf.c (long_opts): Likewise. * src/sort.c (monthtab, long_options): Likewise. * src/split.c (longopts): Likewise. * src/stat.c (long_options): Likewise. * src/stty.c (mode_info, control_info, longopts, set_mode) Likewise. (set_control_char, speeds): Likewise. * src/su.c (longopts): Likewise. * src/sum.c (longopts): Likewise. * src/tac.c (longopts): Likewise. * src/tail.c (long_options): Likewise. * src/tee.c (long_options): Likewise. * src/timeout.c (long_options): Likewise. * src/touch.c (longopts): Likewise. * src/tr.c (long_options): Likewise. * src/truncate.c (longopts): Likewise. * src/tty.c (longopts): Likewise. * src/uname.c (uname_long_options, arch_long_options): Likewise. * src/unexpand.c (longopts): Likewise. * src/uniq.c (longopts): Likewise. * src/wc.c (longopts): Likewise. * src/who.c (longopts): Likewise.
2008-06-03use gnulib's progname moduleJim Meyering
* bootstrap.conf (gnulib_modules): Add progname. * src/*.c (program_name): Remove declaration. * (main): Call set_program_name rather than setting program_name. * src/nice.c (main): Cast program_name to "(char *)". * src/prog-fprintf.c: Include "system.h" * src/system.h: Include "progname.h". * maint.mk (sc_program_name): Adjust rule. Suggestion from Eric Blake.
2008-06-02declare program_name consistentlyJim Meyering
* src/base64.c: Likewise. * src/basename.c: Likewise. * src/cat.c: Likewise. * src/chcon.c: Likewise. * src/chgrp.c: Likewise. * src/chmod.c: Likewise. * src/chown.c: Likewise. * src/chroot.c: Likewise. * src/cksum.c: Likewise. * src/comm.c: Likewise. * src/cp.c: Likewise. * src/csplit.c: Likewise. * src/cut.c: Likewise. * src/date.c: Likewise. * src/dd.c: Likewise. * src/df.c: Likewise. * src/dircolors.c: Likewise. * src/dirname.c: Likewise. * src/du.c: Likewise. * src/echo.c: Likewise. * src/env.c: Likewise. * src/expand.c: Likewise. * src/expr.c: Likewise. * src/factor.c: Likewise. * src/fmt.c: Likewise. * src/fold.c: Likewise. * src/groups.c: Likewise. * src/head.c: Likewise. * src/hostid.c: Likewise. * src/hostname.c: Likewise. * src/id.c: Likewise. * src/install.c: Likewise. * src/join.c: Likewise. * src/kill.c: Likewise. * src/link.c: Likewise. * src/ln.c: Likewise. * src/logname.c: Likewise. * src/ls.c: Likewise. * src/md5sum.c: Likewise. * src/mkdir.c: Likewise. * src/mkfifo.c: Likewise. * src/mknod.c: Likewise. * src/mktemp.c: Likewise. * src/mv.c: Likewise. * src/nice.c: Likewise. * src/nl.c: Likewise. * src/nohup.c: Likewise. * src/od.c: Likewise. * src/paste.c: Likewise. * src/pathchk.c: Likewise. * src/pinky.c: Likewise. * src/pr.c: Likewise. * src/printenv.c: Likewise. * src/printf.c: Likewise. * src/ptx.c: Likewise. * src/pwd.c: Likewise. * src/readlink.c: Likewise. * src/rm.c: Likewise. * src/rmdir.c: Likewise. * src/runcon.c: Likewise. * src/seq.c: Likewise. * src/setuidgid.c: Likewise. * src/shuf.c: Likewise. * src/sleep.c: Likewise. * src/sort.c: Likewise. * src/split.c: Likewise. * src/stat.c: Likewise. * src/stty.c: Likewise. * src/su.c: Likewise. * src/sum.c: Likewise. * src/sync.c: Likewise. * src/tac.c: Likewise. * src/tail.c: Likewise. * src/tee.c: Likewise. * src/test.c: Likewise. * src/timeout.c: Likewise. * src/touch.c: Likewise. * src/tr.c: Likewise. * src/true.c: Likewise. * src/tsort.c: Likewise. * src/tty.c: Likewise. * src/uname.c: Likewise. * src/unexpand.c: Likewise. * src/uniq.c: Likewise. * src/unlink.c: Likewise. * src/uptime.c: Likewise. * src/users.c: Likewise. * src/wc.c: Likewise. * src/who.c: Likewise. * src/whoami.c: Likewise. * src/yes.c: Likewise.
2008-05-26convert 3-author programs to use proper_nameJim Meyering
g grep -E -l 'define AUTHORS "[^,]+", "[^,]+", "[^,]+"$'|xargs perl -pi -e \ 's/(define AUTHORS) ("[^,]+"), ("[^,]+"), ("[^,]+")$/$1 \\\n proper_name ($2), \\\n proper_name ($3), \\\n proper_name ($4)/'
2008-03-07dd: avoid unnecessary, but harmless close_stdout call.Jim Meyering
* src/dd.c (close_stdout_required): New global. (maybe_close_stdout): New function. (main): Set the global. Reported by Ulrich Drepper in http://bugzilla.redhat.com/436368
2008-01-31Don't modify argv in dd due to ',' in arguments.Paul Eggert
* src/dd.c: Include quotearg.h. (operand_matches): New function. (parse_symbols, operand_is): Use it. (parse_symbols): 1st arg is now const pointer. Don't modify it. msgid arg is now just the message, not a format. (scanargs): Add some 'const's to check for problems like the above.
2008-01-30Don't modify argv in dd.Paul Eggert
* src/dd.c (operand_is): New function. (scanargs): Use it so that we don't need to modify argv, as a nicety. Problem reported by Adam Goode in <http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00264.html>.
2007-12-04Reflect change in gnulib: don't include getpagesize.h,Jim Meyering
now that it's provided by unistd.h. * src/cat.c: Don't include getpagesize.h. * src/copy.c: Likewise. * src/dd.c: Likewise. * src/shred.c: Likewise. * src/split.c: Likewise.
2007-07-23Update all copyright notices to use the newer form.Jim Meyering
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering
2007-03-28Help translators include translation team's web or email address.Jim Meyering
* src/system.h (emit_bug_reporting_address): New function. * src/base64.c: Use it rather than a literal printf. * src/basename.c, src/cat.c, src/chgrp.c, src/chmod.c: * src/chown.c, src/chroot.c, src/cksum.c, src/comm.c, src/cp.c: * src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: * src/head.c, src/hostid.c, src/hostname.c, src/id.c, src/install.c: * src/join.c, src/kill.c, src/link.c, src/ln.c, src/logname.c: * src/ls.c, src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c: * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/od.c: * src/paste.c, src/pathchk.c, src/pinky.c, src/pr.c, src/printenv.c: * src/printf.c, src/ptx.c, src/pwd.c, src/readlink.c, src/rm.c: * src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, src/shuf.c: * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c: * src/su.c, src/sum.c, src/sync.c, src/system.h, src/tac.c: * src/tail.c, src/tee.c, src/test.c, src/touch.c, src/tr.c: * src/true.c, src/tsort.c, src/tty.c, src/uname.c, src/unexpand.c: * src/uniq.c, src/unlink.c, src/uptime.c, src/users.c, src/wc.c: * src/who.c, src/whoami.c, src/yes.c: Likewise.
2007-02-22Honor dd's noatime flag if possible, even if not supported on build fsPaul Eggert
* doc/coreutils.texi (dd invocation): Warn that noatime might not be reliable. * src/dd.c (flags, usage): Look at O_NOATIME, not HAVE_WORKING_O_NOATIME, to decide whether to support the noatime flag, so that dd attempts O_NOATIME even if the build file system does not support it. Problem reported by Jim Meyering today in bug-coreutils. * tests/dd/misc: Generate a warning, not a failure, if noatime exists but fails.
2007-02-10Remove excess leading spaces that would make help2man misbehave.Jim Meyering
* src/printf.c (usage): Remove excess spaces on 2nd line of %b desc. * src/nl.c (usage): Remove excess spaces on 2nd line of pBRE desc. * src/dd.c (usage): Remove excess spaces on 2nd line of sync desc. * src/date.c (usage): Use two spaces after each optional flag, not one. Reported by Thomas Huriaux in <http://bugs.debian.org/410407>.
2007-01-26* src/dd.c (advance_input_after_read_error): Change diagnostic toJim Meyering
say "invalid file offset" rather than "screwy file offset".
2006-12-22* NEWS: dd bs= operands now silently override later ibs= and obs=,Paul Eggert
as POSIX requires. * src/dd.c (scanargs): Implement it. * tests/dd/misc (outbytes): Test it. * doc/coreutils.texi (dd invocation): Specify that bs=N overrides later ibs and obs, undoing part of the previous change. (The behavior was wrong.)
2006-11-27Improve the check for departures from C89, and fix the departuresPaul Eggert
I found. * Makefile.maint (my-distcheck): Also check for C89 compatibility as best we can with GCC. * src/stat.c (PRINTF_OPTION): Omit comma before } in enum declaration; C89 doesn't allow this. * src/dcgen: Don't generate string literals longer than what C89 requires support for. * src/cut.c (usage): Don't use string literals longer than what C89 requires support for. * src/date.c (usage): Likewise. * src/dd.c (usage): Likewise. * src/du.c (usage): Likewise. * src/ls.c (usage): Likewise. * src/od.c (usage): Likewise. * src/readlink.c (usage): Likewise. * src/seq.c (usage): Likewise. * src/shred.c (usage): Likewise.
2006-11-16Help valgrind see that there is no leak in dd.c.Jim Meyering
* src/dd.c (dd_copy): Declare real_buf and real_obuf to be static, so we need not free them at all. This is easier than freeing both buffers at each of the early "return"s.
2006-10-17* src/dd.c (usage): Use two spaces (not one) to separate theJim Meyering
"fdatasync" option string from its description, so help2man formats the derived man page properly. Reported by Samuel Thibault in <http://bugs.debian.org/393649>.
2006-10-05* src/dd.c (flags): noatime and nofollow now depend onPaul Eggert
HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW, too. (usage): Output info about noatime and nofollow only if they are known to work. * src/remove.c (AD_push): Inspect HAVE_WORKING_O_NOFOLLOW rather than O_NOFOLLOW, when testing whether it's possible to avoid a race condition reliably.
2006-08-16Fix bugs when printing plurals of numbers that are notPaul Eggert
unsigned long int values. * src/system.h (select_plural): New function. * src/md5sum.c (digest_check): Use select_plural to avoid bug. * src/uptime.c (print_uptime): Likewise. * src/dd.c (print_stats): Likewise. Also, don't use ngettext to print a floating point number, as reducing to 0 or 1 doesn't work for some languages. Instead, just use "s" for seconds since it doesn't need a plural form.
2006-08-15* src/dd.c (print_stats): Don't substitute "1" for number, as thisPaul Eggert
causes confusion for the Hungarian translators. Problem reported by Egmont Koblinger.
2006-08-09Warn about oflag=append without conv=notrunc.Paul Eggert
2006-07-09(apply_translations): Use toupper rather thanPaul Eggert
islower followed by toupper; it's simpler and typically faster now that we assume at least C89 semantics. Similarly for tolower.
2006-07-08* src/dd.c (skip): Remove one of two adjacent "the"s in a comment.Jim Meyering
2006-03-30(iwrite): Remove assignment without effect.Jim Meyering
Reported by Felix Rauch Valenti.
2006-03-08(set_fd_flags): Handle file-creation flags on filePaul Eggert
descriptors, rather than ignoring them.
2006-03-06(flags, usage): New flags directory, nolinks.Paul Eggert
2005-12-07(flags, usage): Add support for noatime flag.Paul Eggert
2005-10-31(skip): Fix off-by-one error reported by Theodoros V. Kalamatianos.Paul Eggert
2005-09-30(main): Don't assume size_t has the same widthPaul Eggert
as unsigned long. Problem reported by Eric Blake.
2005-09-16(main): When failing to truncate, mention both the seek block countJim Meyering
and the block size, in case the block size is very large.
2005-09-13* src/dd.c: Detect some very unlikely buffer overflows.Paul Eggert
(INPUT_BLOCK_SLOP, OUTPUT_BLOCK_SLOP): New macros. (MAX_BLOCKSIZE): Now accepts an arg. All uses changed. (page_size): New var. (scanargs, skip, main): Use more-straightforward way to detect overflow. (dd_copy): Use page_size rather than invoking getpagesize. Use INPUT_BLOCK_SLOP, OUTPUT_BLOCK_SLOP. (main): Set page_size. Avoid a call to stat in the usual case where ftruncate succeeds.
2005-07-09Don't include stdio.h; no longer needed.Paul Eggert
2005-07-03Include fd-reopen.h.Paul Eggert
(open_fd): Remove. All callers changed to use fd_reopen instead.
2005-05-28(skip): Return the number of records that were notPaul Eggert
skipped due to encountering EOF. (dd_copy): If the file wasn't seekable and EOF was encountered, write zeros past EOF until the desired offset is reached.
2005-05-14Update FSF postal mail address.Jim Meyering
2005-05-14Update FSF postal mail address.Jim Meyering