mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
dd: support iseek= and oseek=
Alias iseek=N to skip=N, oseek=N to seek=N (Bug#45648). * src/dd.c (scanargs): Parse iseek= and oseek=. * tests/dd/skip-seek.pl (sk-seek5): New test case.
This commit is contained in:
3
NEWS
3
NEWS
@@ -57,6 +57,9 @@ GNU coreutils NEWS -*- outline -*-
|
||||
dd conv=fsync now synchronizes output even after a write error,
|
||||
and similarly for dd conv=fdatasync.
|
||||
|
||||
dd now supports the aliases iseek=N for skip=N, and oseek=N for seek=N,
|
||||
like FreeBSD and other operating systems.
|
||||
|
||||
timeout --foreground --kill-after=... will now exit with status 137
|
||||
if the kill signal was sent, which is consistent with the behavior
|
||||
when the --foreground option is not specified. This allows users to
|
||||
|
||||
@@ -9189,8 +9189,7 @@ Read from @var{file} instead of standard input.
|
||||
@item of=@var{file}
|
||||
@opindex of
|
||||
Write to @var{file} instead of standard output. Unless
|
||||
@samp{conv=notrunc} is given, @command{dd} truncates @var{file} to zero
|
||||
bytes (or the size specified with @samp{seek=}).
|
||||
@samp{conv=notrunc} is given, truncate @var{file} before writing it.
|
||||
|
||||
@item ibs=@var{bytes}
|
||||
@opindex ibs
|
||||
@@ -9230,15 +9229,20 @@ When converting variable-length records to fixed-length ones
|
||||
use @var{bytes} as the fixed record length.
|
||||
|
||||
@item skip=@var{n}
|
||||
@itemx iseek=@var{n}
|
||||
@opindex skip
|
||||
@opindex iseek
|
||||
Skip @var{n} @samp{ibs}-byte blocks in the input file before copying.
|
||||
If @samp{iflag=skip_bytes} is specified, @var{n} is interpreted
|
||||
as a byte count rather than a block count.
|
||||
|
||||
@item seek=@var{n}
|
||||
@itemx oseek=@var{n}
|
||||
@opindex seek
|
||||
Skip @var{n} @samp{obs}-byte blocks in the output file before copying.
|
||||
if @samp{oflag=seek_bytes} is specified, @var{n} is interpreted
|
||||
@opindex oseek
|
||||
Skip @var{n} @samp{obs}-byte blocks in the output file before
|
||||
truncating or copying.
|
||||
If @samp{oflag=seek_bytes} is specified, @var{n} is interpreted
|
||||
as a byte count rather than a block count.
|
||||
|
||||
@item count=@var{n}
|
||||
@@ -9588,14 +9592,14 @@ This flag can be used only with @code{iflag}.
|
||||
|
||||
@item skip_bytes
|
||||
@opindex skip_bytes
|
||||
Interpret the @samp{skip=} operand as a byte count,
|
||||
Interpret the @samp{skip=} or @samp{iseek=} operand as a byte count,
|
||||
rather than a block count, which allows specifying
|
||||
an offset that is not a multiple of the I/O block size.
|
||||
This flag can be used only with @code{iflag}.
|
||||
|
||||
@item seek_bytes
|
||||
@opindex seek_bytes
|
||||
Interpret the @samp{seek=} operand as a byte count,
|
||||
Interpret the @samp{seek=} or @samp{oseek=} operand as a byte count,
|
||||
rather than a block count, which allows specifying
|
||||
an offset that is not a multiple of the I/O block size.
|
||||
This flag can be used only with @code{oflag}.
|
||||
|
||||
8
src/dd.c
8
src/dd.c
@@ -562,8 +562,8 @@ Copy a file, converting and formatting according to the operands.\n\
|
||||
obs=BYTES write BYTES bytes at a time (default: 512)\n\
|
||||
of=FILE write to FILE instead of stdout\n\
|
||||
oflag=FLAGS write as per the comma separated symbol list\n\
|
||||
seek=N skip N obs-sized blocks at start of output\n\
|
||||
skip=N skip N ibs-sized blocks at start of input\n\
|
||||
seek=N (or oseek=N) skip N obs-sized output blocks\n\
|
||||
skip=N (or iseek=N) skip N ibs-sized input blocks\n\
|
||||
status=LEVEL The LEVEL of information to print to stderr;\n\
|
||||
'none' suppresses everything but error messages,\n\
|
||||
'noxfer' suppresses the final transfer statistics,\n\
|
||||
@@ -1564,9 +1564,9 @@ scanargs (int argc, char *const *argv)
|
||||
n_max = MIN (SIZE_MAX, IDX_MAX);
|
||||
converted_idx = &conversion_blocksize;
|
||||
}
|
||||
else if (operand_is (name, "skip"))
|
||||
else if (operand_is (name, "skip") || operand_is (name, "iseek"))
|
||||
skip = n;
|
||||
else if (operand_is (name, "seek"))
|
||||
else if (operand_is (name + (*name == 'o'), "seek"))
|
||||
seek = n;
|
||||
else if (operand_is (name, "count"))
|
||||
count = n;
|
||||
|
||||
@@ -68,6 +68,16 @@ my @Tests =
|
||||
{OUT=> "bc\n"},
|
||||
{ERR=> "3+0 records in\n3+0 records out\n"},
|
||||
],
|
||||
[
|
||||
# Check that iseek and oseek aliases work too.
|
||||
'sk-seek5',
|
||||
qw (bs=1 iseek=1 oseek=2 conv=notrunc count=3 status=noxfer of=@AUX@ < ),
|
||||
{IN=> '0123456789abcdef'},
|
||||
{AUX=> 'zyxwvutsrqponmlkji'},
|
||||
{OUT=> ''},
|
||||
{ERR=> "3+0 records in\n3+0 records out\n"},
|
||||
{CMP=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
|
||||
],
|
||||
);
|
||||
|
||||
my $save_temps = $ENV{DEBUG};
|
||||
|
||||
Reference in New Issue
Block a user