Fix for cnfsstat -a with largefiles

Heath Kehoe heath.kehoe at intermec.com
Sat Sep 16 08:48:40 UTC 2000


The following patch fixes a problem where cnfsstat -a fails on large
buffers whose position is beyond the first 2G.  You may still need
largefile support in perl itself for this to work.

This patch has also been committed to CVS.

-heath


*** ../src/inn-2.3.0/frontends/cnfsstat	Thu Aug 24 19:59:04 2000
--- ./cnfsstat	Sat Sep 16 03:32:05 2000
***************
*** 378,383 ****
--- 378,407 ----
          1;
  }
  
+ sub bigsysseek {
+     my($handle, $offset) = @_;
+ 
+     # $offset may be a bigint; and have a value that doesn't fit in a signed long.
+     # Even with largefiles enabled, perl will still truncate the argument to lseek64
+     # to 32 bits.  So we seek multiple times, <2G at a time.
+ 
+     if($offset > 2147483647) {
+ 	# Since perl truncates the return value of lseek64 to 32 bits, it might
+ 	# see a successful return value as negative, and return FALSE (undef).
+ 	# So we must ignore the return value of sysseek and assume that it worked.
+ 
+ 	seek($handle, 0, 0);
+ 	while($offset > 2000000000) {
+ 	    sysseek($handle, 2000000000, 1);
+ 	    $offset -= 2000000000;
+ 	}
+ 	sysseek($handle, $offset, 1);
+ 	return 1;
+     } else {
+ 	return sysseek($handle, $offset, 0);
+     }
+ }
+ 
  sub get_cycbuff_info {
      my($buffpath) = $_[0];
      
***************
*** 430,436 ****
  	my $sentinel = $cyclenum == 0 ? $free : $len;
  	my $offset = $cyclenum == 0 ? $minartoffset : $free + $pagesize;
  
! 	seek (BUFF, $offset, 0) || die "seek: $!\n";
  	sysread (BUFF, $buff, $pagesize)
  		|| die "read: $!\n";
  	do {
--- 454,460 ----
  	my $sentinel = $cyclenum == 0 ? $free : $len;
  	my $offset = $cyclenum == 0 ? $minartoffset : $free + $pagesize;
  
! 	bigsysseek (BUFF, $offset) || die "sysseek: $!\n";
  	sysread (BUFF, $buff, $pagesize)
  		|| die "read: $!\n";
  	do {




More information about the inn-workers mailing list