[syslinux] [PATCH 03/05] utils/mkdiskimage.in: Replaced the partly linux-specific file size determination by a sysseek() experiment

Thomas Schmitt scdbackup at gmx.net
Thu Jan 30 13:00:50 PST 2014


 utils/mkdiskimage.in: Replaced the partly linux-specific file size determination by a sysseek() experiment.

--- utils/mkdiskimage_patched_02.in	2014-01-30 20:49:46.000000000 +0100
+++ utils/mkdiskimage.in	2014-01-30 20:50:59.000000000 +0100
@@ -19,6 +19,7 @@
 use bytes;
 use integer;
 use Fcntl;
+use Fcntl qw(:seek);
 use Errno;
 use Cwd;
 use IO::Handle;			# For flush()
@@ -116,15 +117,8 @@ if ( $c == 0 && $file ne '' ) {
     $len = 0;
     if ( sysopen(OUTPUT, $file, O_RDWR, 0666) ) {
 	$is_open = 1;
-
-	if ( (@filestat = stat(OUTPUT)) && S_ISREG($filestat[2]) ) {
-	    $len = $filestat[7] >> 9;
-	} elsif ( $is_linux && S_ISBLK($filestat[2]) ) {
-	    $blksize = pack("L!", 0);
-	    if ( ioctl(OUTPUT, $BLKGETSIZE, $blksize) == 0 ) {
-		$len = unpack("L!", $blksize); # In 512-byte sectors!
-	    }
-	}
+	$len = sysseek(OUTPUT, 0, SEEK_END) >> 9;
+	sysseek(OUTPUT, 0, SEEK_SET);
     }
 
     if ( !$len ) {


More information about the Syslinux mailing list