diff options
author | Jim Meyering <jim@meyering.net> | 1999-04-18 13:32:35 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-04-18 13:32:35 +0000 |
commit | 8f913cc64f0afbd2e920f70fce20523c301a0135 (patch) | |
tree | 9a054416b67c843f713590ee27bf57c3f1282121 /src | |
parent | 64dec9fafb31eb343c12ee0c36c0d4624c68a281 (diff) | |
download | coreutils-8f913cc64f0afbd2e920f70fce20523c301a0135.tar.xz |
(main): Open the output file with *read* access
only if we might need to read to satisfy a `seek=' request.
From Matthias Urlichs.
Diffstat (limited to 'src')
-rw-r--r-- | src/dd.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1121,7 +1121,9 @@ main (int argc, char **argv) if (output_file != NULL) { - int omode = O_RDWR | O_CREAT; + /* Open the output file with *read* access only if we might + need to read to satisfy a `seek=' request. */ + int omode = (seek_record ? O_RDWR : O_WRONLY) | O_CREAT; if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; |