Here's a quick-and-dirty patch for shred (fileutils-4.1) so it can verify data with the -V option, useful for checking hard disks and other media. It also fixes a compile error when compiling for i386 (and no i686 or higher). According to the man page, shred can shred stdout, but on FreeBSD 2.2.8 and GNU/Linux (red hat 6.0) I get the following error: sean@x16 [/home/sean/fileutils-4.1] src/shred - src/shred: -: invalid file type Sean
437a438 > int verify; /* -V flag: verify data */ 447a449 > {"verify", no_argument, NULL, 'V'}, 476a479 > -V, --verify read data after writing it\n\ 807c810 < #if __GNUC__ >= 2 && (__i386__ || __alpha__) --- > #if __GNUC__ >= 2 && (__i686__ || __alpha__) 834c837 < # if __i386__ --- > # if __i686__ 863c866 < #else /* !(__i386__ || __alpha__) */ --- > #else /* !(__i686__ || __alpha__) */ 868c871 < #endif /* !(__i386__ || __alpha__) */ --- > #endif /* !(__i686__ || __alpha__) */ 1061c1064,1065 < struct isaac_state *s, unsigned long k, unsigned long n) --- > struct isaac_state *s, unsigned long k, unsigned long n, > struct Options const *flags) 1070a1075 > word32 v[ISAAC_WORDS * 3]; /* Multiple of 4K and of pattern size */ 1072a1078 > word32 v[1024 * 3]; /* Multiple of 4K and of pattern size */ 1150a1157,1164 > > /* > * With the --verify option set, we want to know about bad > * media, so we bail out. > */ > > if (flags->verify) return -1; > 1164a1179,1204 > > /* > * If --verify is set, we need to read the data to see if it's > * OK. > */ > > if (flags->verify && ssize) > { > if (lseek (fd, (off_t) (offset + soff), SEEK_SET) == -1) > { > error (0, errno, "%s: lseek", qname); > return -1; > } > > if (ssize != read (fd, (char *) v, ssize) ) > { > error (0, errno, "%s: read", qname); > return -1; > } > > if (memcmp (r + soff, v, ssize) ) > { > error (0, 0, _("%s: verify failed"), qname); > return -1; > } > } 1494c1534 < if (dopass (fd, qname, &size, passarray[i], s, i + 1, n) < 0) --- > if (dopass (fd, qname, &size, passarray[i], s, i + 1, n, flags) < 0) 1506c1546 < if (dopass (fd, qname, &size, 0, s, flags->n_iterations + 1, n) < 0) --- > if (dopass (fd, qname, &size, 0, s, flags->n_iterations + 1, n, flags) < 0) 1707c1747,1751 < fd = open (name, O_WRONLY | O_NOCTTY); --- > if (flags->verify) > fd = open (name, O_RDWR | O_NOCTTY); > else > fd = open (name, O_WRONLY | O_NOCTTY); > 1780c1824 < while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, NULL)) != -1) --- > while ((c = getopt_long (argc, argv, "fn:s:uvxzV", long_opts, NULL)) != -1) 1788a1833,1836 > break; > > case 'V': > flags.verify = 1;