Before, when using shred on a device, one had to specify --exact,
authorJim Meyering <jim@meyering.net>
Sat, 8 Mar 2003 16:57:55 +0000 (16:57 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 8 Mar 2003 16:57:55 +0000 (16:57 +0000)
or be careful to choose a size that would not be rounded up and
exceed the maximum value;  that could result in a failure of
the final write.

(do_wipefd): --exact is now the default for non-regular
files.  Suggestion from Ben Elliston.
(usage): Say it.

src/shred.c

index be377b1..305023b 100644 (file)
@@ -174,7 +174,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
       fputs (_("\
   -u, --remove   truncate and remove file after overwriting\n\
   -v, --verbose  show progress\n\
-  -x, --exact    do not round file sizes up to the next full block\n\
+  -x, --exact    do not round file sizes up to the next full block;\n\
+                   this is the default for non-regular files\n\
   -z, --zero     add a final overwrite with zeros to hide shredding\n\
   -              shred standard output\n\
 "), stdout);
@@ -1223,7 +1224,8 @@ do_wipefd (int fd, char const *qname, struct isaac_state *s,
            }
        }
 
-      if (0 <= size && !(flags->exact))
+      /* Allow `rounding up' only for regular files.  */
+      if (0 <= size && !(flags->exact) && S_ISREG (st.st_mode))
        {
          size += ST_BLKSIZE (st) - 1 - (size - 1) % ST_BLKSIZE (st);