I've just noticed a couple of edge case issues.

The first hunk is for when not doing I/O,
ftruncate() should be on the full size.

The second, will not invalidate cache for the whole file,
if 0 < count < ibs

cheers,
Pádraig.

--- a/src/dd.c
+++ b/src/dd.c
@@ -2170,7 +2170,7 @@ main (int argc, char **argv)

       if (seek_records != 0 && !(conversions_mask & C_NOTRUNC))
         {
-          uintmax_t size = seek_records * output_blocksize;
+          uintmax_t size = seek_records * output_blocksize + seek_bytes;
           unsigned long int obs = output_blocksize;

           if (OFF_T_MAX / output_blocksize < seek_records)
@@ -2207,7 +2207,7 @@ main (int argc, char **argv)

   exit_status = dd_copy ();

-  if (max_records == 0)
+  if (max_records == 0 && max_bytes == 0)
     {
       /* Special case to invalidate cache to end of file.  */
       if (i_nocache && !invalidate_cache (STDIN_FILENO, 0))


Reply via email to