12 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
13 |
use Carp qw/confess/; |
use Carp qw/confess/; |
14 |
use IO::File; |
use IO::File; |
15 |
|
use Getopt::Long; |
16 |
|
|
17 |
|
my $debug = 0; |
18 |
|
my $fuse_debug = 0; |
19 |
|
|
20 |
|
GetOptions( |
21 |
|
'debug+' => \$debug, |
22 |
|
'fuse-debug+' => \$fuse_debug, |
23 |
|
); |
24 |
|
|
25 |
my $mount = { |
my $mount = { |
26 |
from => '/tmp/comp', |
from => '/tmp/comp', |
168 |
my $dest_path = $tmp; |
my $dest_path = $tmp; |
169 |
$dest_path =~ s!/[^/]+$!!; #!vim-fix |
$dest_path =~ s!/[^/]+$!!; #!vim-fix |
170 |
mkpath $dest_path unless -e $dest_path; |
mkpath $dest_path unless -e $dest_path; |
171 |
file_copy( '<:gzip', $path, '>', $tmp ); |
if ( -s $path ) { |
172 |
|
file_copy( '<:gzip', $path, '>', $tmp ) |
173 |
|
} else { |
174 |
|
warn "ERROR: filesystem corruption, $path is zero size\n"; |
175 |
|
} |
176 |
$path = $tmp; |
$path = $tmp; |
177 |
} |
} |
|
warn "<<< open abs path: $path [", -e $path ? -s $path : 'new' , "]\n"; |
|
|
return -$! unless sysopen($fh , $path, $mode); |
|
|
close($fh); |
|
178 |
|
|
179 |
$pending->{$file}->{path} = $path; |
if ( sysopen($fh , $path, $mode) ) { |
180 |
return 0; |
close($fh) || confess "can't close $path: $!"; |
181 |
|
warn "<<< open $path [", -e $path ? -s $path : 'new' , "]\n"; |
182 |
|
$pending->{$file}->{path} = $path; |
183 |
|
return 0; |
184 |
|
} else { |
185 |
|
warn "ERROR: can't open $path : $!"; |
186 |
|
return -$!; |
187 |
|
} |
188 |
|
|
189 |
} |
} |
190 |
|
|
191 |
sub x_read { |
sub x_read { |
256 |
my $path = $pending->{$old}->{path}; |
my $path = $pending->{$old}->{path}; |
257 |
$path =~ s/\Q$old\E/$new/; |
$path =~ s/\Q$old\E/$new/; |
258 |
$pending->{$new}->{path} = $path; |
$pending->{$new}->{path} = $path; |
259 |
|
$pending->{$old}->{path} = $path; |
260 |
|
|
261 |
delete( $pending->{$old} ); |
#delete( $pending->{$old} ); |
262 |
} |
} |
263 |
|
|
264 |
return $err; |
return $err; |
293 |
$no_gz =~ s/\.gz$//; |
$no_gz =~ s/\.gz$//; |
294 |
rename $path, $no_gz || confess "can't rename $path -> $no_gz: $!"; |
rename $path, $no_gz || confess "can't rename $path -> $no_gz: $!"; |
295 |
} |
} |
296 |
warn "## truncate( $file $size ) $path [", -s $path, "]\n"; |
warn "## truncate( $file $size ) $path [", -s $path, "] = $rv\n" if $debug; |
297 |
$pending->{$file}->{write}++; |
$pending->{$file}->{write}++; |
298 |
return $rv; |
return $rv; |
299 |
} |
} |
388 |
statfs =>"main::x_statfs", |
statfs =>"main::x_statfs", |
389 |
release =>"main::x_release", |
release =>"main::x_release", |
390 |
# threaded=>1, |
# threaded=>1, |
391 |
# debug => 1, |
debug => $fuse_debug, |
392 |
); |
); |