*** dd.c.prev Mon Oct 16 13:05:29 2000 --- dd.c Thu Oct 19 11:42:19 2000 *************** *** 1240,1250 **** if (output_file != NULL) { int omode = O_RDWR | O_CREAT; ! if (seek_record == 0 && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; output_fd = open (output_file, omode, 0666); if (output_fd < 0) error (1, errno, "%s", output_file); #if HAVE_FTRUNCATE --- 1240,1251 ---- if (output_file != NULL) { int omode = O_RDWR | O_CREAT; ! if ((seek_record == 0 && seek_bytes == 0) ! && !(conversions_mask & C_NOTRUNC)) omode |= O_TRUNC; output_fd = open (output_file, omode, 0666); if (output_fd < 0) error (1, errno, "%s", output_file); #if HAVE_FTRUNCATE *************** *** 1252,1261 **** --- 1253,1268 ---- { off_t o = seek_record * output_blocksize; if (o / output_blocksize != seek_record) error (1, 0, _("file offset out of range")); if (ftruncate (output_fd, o) < 0) + error (0, errno, "%s", output_file); + } + + if (seek_bytes != 0 && !(conversions_mask & C_NOTRUNC)) + { + if (ftruncate (output_fd, seek_bytes) < 0) error (0, errno, "%s", output_file); } #endif } else