From: Jim Meyering Date: Sun, 18 Apr 1999 13:32:35 +0000 (+0000) Subject: (main): Open the output file with *read* access X-Git-Tag: TEXTUTILS-1_22j~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f913cc64f0afbd2e920f70fce20523c301a0135;p=thirdparty%2Fcoreutils.git (main): Open the output file with *read* access only if we might need to read to satisfy a `seek=' request. From Matthias Urlichs. --- diff --git a/src/dd.c b/src/dd.c index e4d3cc9e4e..c4a013ec16 100644 --- a/src/dd.c +++ b/src/dd.c @@ -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;