Index: programs/mythbackend/mainserver.cpp
===================================================================
--- programs/mythbackend/mainserver.cpp	(revision 10950)
+++ programs/mythbackend/mainserver.cpp	(working copy)
@@ -1616,14 +1616,20 @@
             .arg(increment / (1024.0 * 1024.0), 0, 'f', 2)
             .arg(sleep_time));
 
-    // Get the on disk file size and disk block size.
+    // Get the on disk file size and preferred I/O block size.
     struct stat buf;
     fstat(fd, &buf);
-    size_t fsize = buf.st_blksize * buf.st_blocks;
+    // Estimate the file size.  Don't use buf.st_blksize * buf.st_blocks
+    // The unit for st_blocks is undefined.  See section "RATIONALE" at
+    // http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html
+    off_t fsize = ((buf.st_size / buf.st_blksize) + 1) * buf.st_blksize;
 
     // Round truncate increment up to a blocksize, w/min of 1 block.
     increment = ((increment / buf.st_blksize) + 1) * buf.st_blksize;
 
+    // Estimated file size is probably low, so truncate to the estimate first
+    fsize += increment;
+
     while (fsize > increment)
     {
         fsize -= increment;
