another try to fix files larger than 2Gb: for this we pop 0.09_3
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 Mar 2008 19:40:20 +0000 (19:40 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 Mar 2008 19:40:20 +0000 (19:40 +0000)
float from stack since long is limited to 4Gb

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/fuse/perl-llin@123 6e4b0b00-1209-0410-87b2-b275959b5705

Changes
Fuse.pm
Fuse.xs
test/getattr.t

diff --git a/Changes b/Changes
index 69ad5c9..a0f8692 100644 (file)
--- a/Changes
+++ b/Changes
@@ -52,4 +52,6 @@ Revision history for Perl extension Fuse.
     - added fuse_get_context
     - works with MacFUSE http://code.google.com/p/macfuse/
     - added example filter_attr_fs.pl
-    - fix 2Gb file bug, RT #32639, RT #33903
+
+0.09_3
+    - really fix 2+ Gb file bug, RT #32639, RT #33903
diff --git a/Fuse.pm b/Fuse.pm
index b87f1fa..2132aa7 100644 (file)
--- a/Fuse.pm
+++ b/Fuse.pm
@@ -28,7 +28,7 @@ our %EXPORT_TAGS = (
 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
 
 our @EXPORT = ();
-our $VERSION = '0.09_2';
+our $VERSION = '0.09_3';
 
 sub AUTOLOAD {
     # This AUTOLOAD is used to 'autoload' constants from the constant()
diff --git a/Fuse.xs b/Fuse.xs
index 3a07821..b87d44a 100644 (file)
--- a/Fuse.xs
+++ b/Fuse.xs
@@ -64,7 +64,7 @@ int _PLfuse_getattr(const char *file, struct stat *result) {
                result->st_ctime = POPi;
                result->st_mtime = POPi;
                result->st_atime = POPi;
-               result->st_size = (size_t)POPi;
+               result->st_size = POPn; // we pop double here to support files larger than 4Gb (long limit)
                result->st_rdev = POPi;
                result->st_gid = POPi;
                result->st_uid = POPi;
index 62e3670..a945cdc 100644 (file)
@@ -2,46 +2,50 @@
 use test::helper qw($_real $_point);
 use Test::More;
 use Data::Dumper;
-plan tests => 29;
-my ($a, $b) = ("$_real/wibble","$_point/wibble");
-# create 3G file to expose 2G bug
-open(my $fh, '>', $a) || die "can't open $b: $!";
-seek($fh, 3 * 1024 * 1024 * 1024, 0);
-print $fh ' ';
-close($fh);
-diag "size $b = ",-s $b;
-is(-A "$a", -A "$b", '-A'); # 1
-is(-B "$a", -B "$b", '-B'); # 2
-is(-C "$a", -C "$b", '-C'); # 3
-is(-M "$a", -M "$b", '-M'); # 4
-is(-O "$a", -O "$b", '-O'); # 5
-is(-R "$a", -R "$b", '-R'); # 6
-is(-S "$a", -S "$b", '-S'); # 7
-is(-T "$a", -T "$b", '-T'); # 8
-is(-W "$a", -W "$b", '-W'); # 9
-is(-X "$a", -X "$b", '-X'); # 10
-is(-b "$a", -b "$b", '-b'); # 11
-is(-c "$a", -c "$b", '-c'); # 12
-is(-d "$a", -d "$b", '-d'); # 13
-is(-e "$a", -e "$b", '-e'); # 14
-is(-f "$a", -f "$b", '-f'); # 15
-is(-g "$a", -g "$b", '-g'); # 16
-is(-k "$a", -k "$b", '-k'); # 17
-is(-l "$a", -l "$b", '-l'); # 18
-is(-o "$a", -o "$b", '-o'); # 19
-is(-p "$a", -p "$b", '-p'); # 20
-is(-r "$a", -r "$b", '-r'); # 21
-is(-s "$a", -s "$b", '-s'); # 22
-is(-t "$a", -t "$b", '-t'); # 23
-is(-u "$a", -u "$b", '-u'); # 24
-is(-w "$a", -w "$b", '-w'); # 25
-is(-x "$a", -x "$b", '-x'); # 26
-is(-z "$a", -z "$b", '-z'); # 27
-my (@astat, @bstat);
-@astat = stat("$a");
-@bstat = stat("$b");
-# dev, inode and blksize can legally change
-@astat = @astat[2..10,12];
-@bstat = @bstat[2..10,12];
-is(join(" ",@astat),join(" ",@bstat),"stat()");
-ok( unlink($a), 'unlink' );
+plan tests => 203;
+sub test_file {
+       my $size = shift;
+       my ($a, $b) = ("$_real/wibble-$size","$_point/wibble-$size");
+#      diag "test $size Gb file";
+       open(my $fh, '>', $a) || die "can't open $b: $!";
+       seek($fh, $size * 1024 * 1024 * 1024, 0);
+       print $fh ' ';
+       close($fh);
+#      diag "size $b = ",-s $b, " $a = ", -s $a;
+       is(-A "$a", -A "$b", '-A'); # 1
+       is(-B "$a", -B "$b", '-B'); # 2
+       is(-C "$a", -C "$b", '-C'); # 3
+       is(-M "$a", -M "$b", '-M'); # 4
+       is(-O "$a", -O "$b", '-O'); # 5
+       is(-R "$a", -R "$b", '-R'); # 6
+       is(-S "$a", -S "$b", '-S'); # 7
+       is(-T "$a", -T "$b", '-T'); # 8
+       is(-W "$a", -W "$b", '-W'); # 9
+       is(-X "$a", -X "$b", '-X'); # 10
+       is(-b "$a", -b "$b", '-b'); # 11
+       is(-c "$a", -c "$b", '-c'); # 12
+       is(-d "$a", -d "$b", '-d'); # 13
+       is(-e "$a", -e "$b", '-e'); # 14
+       is(-f "$a", -f "$b", '-f'); # 15
+       is(-g "$a", -g "$b", '-g'); # 16
+       is(-k "$a", -k "$b", '-k'); # 17
+       is(-l "$a", -l "$b", '-l'); # 18
+       is(-o "$a", -o "$b", '-o'); # 19
+       is(-p "$a", -p "$b", '-p'); # 20
+       is(-r "$a", -r "$b", '-r'); # 21
+       is(-s "$a", -s "$b", '-s'); # 22
+       is(-t "$a", -t "$b", '-t'); # 23
+       is(-u "$a", -u "$b", '-u'); # 24
+       is(-w "$a", -w "$b", '-w'); # 25
+       is(-x "$a", -x "$b", '-x'); # 26
+       is(-z "$a", -z "$b", '-z'); # 27
+       my (@astat, @bstat);
+       @astat = stat("$a");
+       @bstat = stat("$b");
+       # dev, inode and blksize can legally change
+       @astat = @astat[2..10,12];
+       @bstat = @bstat[2..10,12];
+       is(join(" ",@astat),join(" ",@bstat),"stat()");
+       ok( unlink($a), 'unlink' );
+}
+test_file( $_ ) foreach ( 1, 2, 4, 8, 16, 32, 64 );