12 |
use Carp; |
use Carp; |
13 |
use Data::Dumper; |
use Data::Dumper; |
14 |
|
|
15 |
our $VERSION = '0.07'; |
our $VERSION = '0.08'; |
16 |
|
|
17 |
# block size for this filesystem |
# block size for this filesystem |
18 |
use constant BLOCK => 1024; |
use constant BLOCK => 1024; |
249 |
my $self = shift; |
my $self = shift; |
250 |
|
|
251 |
if ($self->{'mount'} && $self->is_mounted) { |
if ($self->{'mount'} && $self->is_mounted) { |
252 |
system "( fusermount -u ".$self->{'mount'}." 2>&1 ) >/dev/null" || |
system "( fusermount -u ".$self->{'mount'}." 2>&1 ) >/dev/null"; |
253 |
|
if ($self->is_mounted) { |
254 |
system "sudo umount ".$self->{'mount'} || |
system "sudo umount ".$self->{'mount'} || |
255 |
return 0; |
return 0; |
256 |
|
} |
257 |
return 1; |
return 1; |
258 |
} |
} |
259 |
|
|
329 |
|
|
330 |
# read them in with sesible defaults |
# read them in with sesible defaults |
331 |
while (my $row = $sth->{'filenames'}->fetchrow_hashref() ) { |
while (my $row = $sth->{'filenames'}->fetchrow_hashref() ) { |
332 |
|
$row->{'filename'} ||= 'NULL-'.$row->{'id'}; |
333 |
$files{$row->{'filename'}} = { |
$files{$row->{'filename'}} = { |
334 |
size => $row->{'size'}, |
size => $row->{'size'}, |
335 |
mode => $row->{'writable'} ? 0644 : 0444, |
mode => $row->{'writable'} ? 0644 : 0444, |
336 |
id => $row->{'id'} || 99, |
id => $row->{'id'} || 99, |
337 |
}; |
}; |
338 |
|
|
339 |
|
|
340 |
my $d; |
my $d; |
341 |
foreach (split(m!/!, $row->{'filename'})) { |
foreach (split(m!/!, $row->{'filename'})) { |
342 |
# first, entry is assumed to be file |
# first, entry is assumed to be file |
375 |
$file =~ s,^/,,; |
$file =~ s,^/,,; |
376 |
$file = '.' unless length($file); |
$file = '.' unless length($file); |
377 |
return -ENOENT() unless exists($files{$file}); |
return -ENOENT() unless exists($files{$file}); |
378 |
my ($size) = $files{$file}{size} || BLOCK; |
my ($size) = $files{$file}{size} || 0; |
379 |
my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+BLOCK-1)/BLOCK),0,0,1,BLOCK); |
my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+BLOCK-1)/BLOCK),0,0,1,BLOCK); |
380 |
my ($atime, $ctime, $mtime); |
my ($atime, $ctime, $mtime); |
381 |
$atime = $ctime = $mtime = $files{$file}{ctime} || $ctime_start; |
$atime = $ctime = $mtime = $files{$file}{ctime} || $ctime_start; |
384 |
|
|
385 |
# 2 possible types of return values: |
# 2 possible types of return values: |
386 |
#return -ENOENT(); # or any other error you care to |
#return -ENOENT(); # or any other error you care to |
387 |
print "getattr($file) ",join(",",($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)),"\n"; |
#print "getattr($file) ",join(",",($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)),"\n"; |
388 |
return ($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); |
return ($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); |
389 |
} |
} |
390 |
|
|
434 |
|
|
435 |
read_content($file,$files{$file}{id}) unless exists($files{$file}{cont}); |
read_content($file,$files{$file}{id}) unless exists($files{$file}{cont}); |
436 |
|
|
437 |
|
$files{$file}{cont} ||= ''; |
438 |
print "open '$file' ",length($files{$file}{cont})," bytes\n"; |
print "open '$file' ",length($files{$file}{cont})," bytes\n"; |
439 |
return 0; |
return 0; |
440 |
} |
} |
567 |
|
|
568 |
my @ret = (255, $inodes, 1, $size, $size-1, BLOCK); |
my @ret = (255, $inodes, 1, $size, $size-1, BLOCK); |
569 |
|
|
570 |
print "statfs: ",join(",",@ret),"\n"; |
#print "statfs: ",join(",",@ret),"\n"; |
571 |
|
|
572 |
return @ret; |
return @ret; |
573 |
} |
} |