7 |
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
8 |
@ISA = "Exporter"; |
@ISA = "Exporter"; |
9 |
@EXPORT_OK = qw($_loop $_point $_pidfile $_real); |
@EXPORT_OK = qw($_loop $_point $_pidfile $_real); |
10 |
our($_loop, $_point, $_pidfile, $_real) = ("","/tmp/fusemnt-".$ENV{LOGNAME},"test/s/mounted.pid","/tmp/fusetest-".$ENV{LOGNAME}); |
my $tmp = -d '/private' ? '/private/tmp' : '/tmp'; |
11 |
$_loop = $Config{useithreads} ? "examples/loopback_t.pl" : "examples/loopback.pl"; |
our($_loop, $_point, $_pidfile, $_real) = ("","$tmp/fusemnt-".$ENV{LOGNAME},"test/s/mounted.pid","$tmp/fusetest-".$ENV{LOGNAME}); |
12 |
|
$_loop = $^O ne 'darwin' && $Config{useithreads} ? "examples/loopback_t.pl" : "examples/loopback.pl"; |
13 |
if($0 !~ qr|s/u?mount\.t$|) { |
if($0 !~ qr|s/u?mount\.t$|) { |
14 |
my ($reject) = 1; |
my ($reject) = 1; |
15 |
if(-f $_pidfile) { |
if(open my $fh, '<', $_pidfile) { |
16 |
unless(POSIX::WEXITSTATUS(system("ps `cat $_pidfile` | grep \"$_loop $_point\" >/dev/null"))) { |
my $pid = do {local $/ = undef; <$fh>}; |
17 |
if(`mount | grep "on $_point"`) { |
close $fh; |
18 |
|
if(kill 0, $pid) { |
19 |
|
if(`mount` =~ m{on (?:/private)?$_point }) { |
20 |
$reject = 0; |
$reject = 0; |
21 |
} else { |
} else { |
22 |
system("kill `cat $_pidfile`"); |
kill 1, $pid; |
23 |
} |
} |
24 |
} |
} |
25 |
} |
} |