]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: fix the buffer size used when writing zeros
authorPádraig Brady <P@draigBrady.com>
Mon, 31 Jan 2011 22:04:35 +0000 (22:04 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 31 Jan 2011 23:21:04 +0000 (23:21 +0000)
* src/copy.c (write_zeros): This bug caused 4 or 8 bytes to
be written at a time which is very inefficient.  One could
trigger the issue with `cp --sparse=never sparse non-sparse`
on a file system that supports fiemap.

src/copy.c

index 04c678d16408bdd28e46e759b44b13cf5eb2c272..f429c006e2b96dbeb40b6d4e362e6ddd2be39344 100644 (file)
@@ -291,7 +291,7 @@ write_zeros (int fd, uint64_t n_bytes)
 
   while (n_bytes)
     {
-      uint64_t n = MIN (sizeof nz, n_bytes);
+      uint64_t n = MIN (nz, n_bytes);
       if ((full_write (fd, zeros, n)) != n)
         return false;
       n_bytes -= n;