--- fuse-comp.pl 2007/07/09 22:44:20 25 +++ fuse-comp.pl 2007/07/09 23:28:58 26 @@ -166,7 +166,7 @@ $pending->{$file}->{path} = $path; return 0; } else { - warn "ERROR: can't open $path : $!"; + warn "ERROR: can't open $path -- $!"; return -$!; } @@ -194,7 +194,6 @@ sub x_write { my ($file,$buf,$off) = @_; - $pending->{$file}->{write}++; my $rv; my $path = fixup($file); @@ -202,14 +201,18 @@ return -ENOENT() unless -e $path; + $path = $pending->{$file}->{path} || confess "no path for $file in ", dump( $pending ); + confess "write into non-existant $path for $file: $!" unless -e $path; + my $fh = new IO::File; - return -ENOSYS() unless open($fh,'+<',$pending->{$file}->{path}); + return -ENOSYS() unless open($fh,'+<',$path); if($rv = seek( $fh ,$off,SEEK_SET)) { $rv = print( $fh $buf ); - warn "## write ", $pending->{$file}->{path}, " $off ",length( $buf ), "\n" if $debug; + warn "## write $path offset $off [",length( $buf ), "]\n" if $debug; + $pending->{$file}->{write}++; } $rv = -ENOSYS() unless $rv; - close($fh); + close($fh) || warn "can't close $path: $!"; return length($buf); } @@ -272,14 +275,18 @@ sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! } sub x_chown { - my ($path) = fixup(shift); + my ($file,$uid,$gid) = @_; + my $path = fixup($file); print "nonexistent $path\n" unless -e $path; - my ($uid,$gid) = @_; # perl's chown() does not chown symlinks, it chowns the symlink's # target. it fails when the link's target doesn't exist, because # the stat64() syscall fails. # this causes error messages when unpacking symlinks in tarballs. my ($err) = syscall(&SYS_lchown,$path,$uid,$gid,$path) ? -$! : 0; + + my $tmp = $mount->{tmp} . '/' . $file; + syscall(&SYS_lchown,$file,$uid,$gid,$path) if -e $tmp; + return $err; }