166 |
$pending->{$file}->{path} = $path; |
$pending->{$file}->{path} = $path; |
167 |
return 0; |
return 0; |
168 |
} else { |
} else { |
169 |
warn "ERROR: can't open $path : $!"; |
warn "ERROR: can't open $path -- $!"; |
170 |
return -$!; |
return -$!; |
171 |
} |
} |
172 |
|
|
194 |
sub x_write { |
sub x_write { |
195 |
my ($file,$buf,$off) = @_; |
my ($file,$buf,$off) = @_; |
196 |
|
|
|
$pending->{$file}->{write}++; |
|
197 |
my $rv; |
my $rv; |
198 |
my $path = fixup($file); |
my $path = fixup($file); |
199 |
|
|
201 |
|
|
202 |
return -ENOENT() unless -e $path; |
return -ENOENT() unless -e $path; |
203 |
|
|
204 |
|
$path = $pending->{$file}->{path} || confess "no path for $file in ", dump( $pending ); |
205 |
|
confess "write into non-existant $path for $file: $!" unless -e $path; |
206 |
|
|
207 |
my $fh = new IO::File; |
my $fh = new IO::File; |
208 |
return -ENOSYS() unless open($fh,'+<',$pending->{$file}->{path}); |
return -ENOSYS() unless open($fh,'+<',$path); |
209 |
if($rv = seek( $fh ,$off,SEEK_SET)) { |
if($rv = seek( $fh ,$off,SEEK_SET)) { |
210 |
$rv = print( $fh $buf ); |
$rv = print( $fh $buf ); |
211 |
warn "## write ", $pending->{$file}->{path}, " $off ",length( $buf ), "\n" if $debug; |
warn "## write $path offset $off [",length( $buf ), "]\n" if $debug; |
212 |
|
$pending->{$file}->{write}++; |
213 |
} |
} |
214 |
$rv = -ENOSYS() unless $rv; |
$rv = -ENOSYS() unless $rv; |
215 |
close($fh); |
close($fh) || warn "can't close $path: $!"; |
216 |
return length($buf); |
return length($buf); |
217 |
} |
} |
218 |
|
|
275 |
sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! } |
sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! } |
276 |
|
|
277 |
sub x_chown { |
sub x_chown { |
278 |
my ($path) = fixup(shift); |
my ($file,$uid,$gid) = @_; |
279 |
|
my $path = fixup($file); |
280 |
print "nonexistent $path\n" unless -e $path; |
print "nonexistent $path\n" unless -e $path; |
|
my ($uid,$gid) = @_; |
|
281 |
# perl's chown() does not chown symlinks, it chowns the symlink's |
# perl's chown() does not chown symlinks, it chowns the symlink's |
282 |
# target. it fails when the link's target doesn't exist, because |
# target. it fails when the link's target doesn't exist, because |
283 |
# the stat64() syscall fails. |
# the stat64() syscall fails. |
284 |
# this causes error messages when unpacking symlinks in tarballs. |
# this causes error messages when unpacking symlinks in tarballs. |
285 |
my ($err) = syscall(&SYS_lchown,$path,$uid,$gid,$path) ? -$! : 0; |
my ($err) = syscall(&SYS_lchown,$path,$uid,$gid,$path) ? -$! : 0; |
286 |
|
|
287 |
|
my $tmp = $mount->{tmp} . '/' . $file; |
288 |
|
syscall(&SYS_lchown,$file,$uid,$gid,$path) if -e $tmp; |
289 |
|
|
290 |
return $err; |
return $err; |
291 |
} |
} |
292 |
|
|