[syslinux] [PATCH] Proposal for a pacifier option with mkdiskimage

Thomas Schmitt scdbackup at gmx.net
Thu Jan 23 08:47:47 PST 2014


Hi,

i too played with mkdiskimage in order to get more Linux examples.

When i applied it to a real 2 GB stick with write speed 4 MB/s
i had enough time to add some pacifier code to the big zeroizer
loop. (-s does not prevent zeroizing on block device. Probably
because truncate() fails.)

My pacifier is combined with what Perl advised me when i tried
"fsync(OUTPUT);". Of course this slows down operation on
regular files substantially.
But otherwise there is on USB sticks a super fast pacifier at
the start and a long time of no visible progress at the end.

So the pacifier is disabled unless option -S is given.
Other than regular files, USB sticks get really synced at
the end of the program in exit(0). At least on my Linux 2.6.
So syncing them intermediately does not impose an overall
time penalty. (And they don't rattle like synced hard disks.)

Would this patch have a chance to be accepted ?
It is based on
  http://git.kernel.org/cgit/boot/syslinux/syslinux.git/tree/utils/mkdiskimage.in?id=syslinux-6.03-pre1

-------------------------------------------------------------------
--- mkdiskimage.in    2014-01-23 12:23:34.000000000 +0100
+++ mkdiskimage_ts.in 2014-01-23 17:00:59.000000000 +0100
@@ -145,6 +145,7 @@ if ( $file eq '' || $c < 1 || $h < 1 || 
     print STDERR "    -4    use partition entry 4 (standard for zipdisks)\n";
     print STDERR "    -i    specify the MBR ID\n";
     print STDERR "    -s    output a sparse file (don't allocate all blocks)\n";
+    print STDERR "    -S    sync after each zeroized cylinder and show count\n";
     exit 1;
 }
 
@@ -221,12 +222,23 @@ $tracks    = $c*$h;
 unless ($opt{'s'} && truncate(OUTPUT, $totalsize)) {
     $track = "\0" x (512*$s);
 
+    $show_pacifier = $opt{'S'};
+
     # Print fractional track
     print OUTPUT "\0" x (512 * ($s-1));
 
     for ( $i = 1 ; $i < $tracks ; $i++ ) {
+	if ( $show_pacifier && ( $i - 1 ) % $h == 0) {
+	    $cyl_to_write = ( $i - 1 ) / $h + 1;
+	    IO::Handle::sync(OUTPUT);
+	    print STDERR " zeroizing cylinder $cyl_to_write of $c\r";
+	}
 	print OUTPUT $track;
     }
+    if ( $show_pacifier ) {
+	IO::Handle::sync(OUTPUT);
+	print STDERR " $totalsize blocks zeroized.              \n";
+    }
 }
 
 # Print mtools temp file
--------------------------------------------------------------------

Disclaimer: I am not really a Perl programmer.

Double disclaimer: I have never prepared a git-ish patch but i would
                   obey instructions.


Have a nice day :)

Thomas



More information about the Syslinux mailing list