X-Git-Url: http://git.rot13.org/?p=Fuse-DBI;a=blobdiff_plain;f=DBI.pm;h=89889bd60b1e67430b0eaef2f0f7be4a5e58654e;hp=24d9d8c9317a99198c2e06a8e76a8f1cc2de26e2;hb=73d0b06304c5f122f550b153f47a9f573e57fde8;hpb=a3047ac017adb4077b648fa22e30fe7ec4e742a3 diff --git a/DBI.pm b/DBI.pm index 24d9d8c..89889bd 100755 --- a/DBI.pm +++ b/DBI.pm @@ -12,8 +12,10 @@ use DBI; use Carp; use Data::Dumper; +our $VERSION = '0.08'; -our $VERSION = '0.07'; +# block size for this filesystem +use constant BLOCK => 1024; =head1 NAME @@ -247,9 +249,11 @@ sub umount { my $self = shift; if ($self->{'mount'} && $self->is_mounted) { - system "fusermount -u ".$self->{'mount'}." 2>&1 >/dev/null" || + system "( fusermount -u ".$self->{'mount'}." 2>&1 ) >/dev/null"; + if ($self->is_mounted) { system "sudo umount ".$self->{'mount'} || return 0; + } return 1; } @@ -325,12 +329,14 @@ sub read_filenames { # read them in with sesible defaults while (my $row = $sth->{'filenames'}->fetchrow_hashref() ) { + $row->{'filename'} ||= 'NULL-'.$row->{'id'}; $files{$row->{'filename'}} = { size => $row->{'size'}, mode => $row->{'writable'} ? 0644 : 0444, id => $row->{'id'} || 99, }; + my $d; foreach (split(m!/!, $row->{'filename'})) { # first, entry is assumed to be file @@ -369,8 +375,8 @@ sub e_getattr { $file =~ s,^/,,; $file = '.' unless length($file); return -ENOENT() unless exists($files{$file}); - my ($size) = $files{$file}{size} || 1024; - my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+1023)/1024),0,0,1,1024); + my ($size) = $files{$file}{size} || 0; + my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+BLOCK-1)/BLOCK),0,0,1,BLOCK); my ($atime, $ctime, $mtime); $atime = $ctime = $mtime = $files{$file}{ctime} || $ctime_start; @@ -378,7 +384,7 @@ sub e_getattr { # 2 possible types of return values: #return -ENOENT(); # or any other error you care to - 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"; return ($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); } @@ -428,6 +434,7 @@ sub e_open { read_content($file,$files{$file}{id}) unless exists($files{$file}{cont}); + $files{$file}{cont} ||= ''; print "open '$file' ",length($files{$file}{cont})," bytes\n"; return 0; } @@ -556,11 +563,11 @@ sub e_statfs { print "$inodes: $f [$size]\n"; } - $size = int(($size+1023)/1024); + $size = int(($size+BLOCK-1)/BLOCK); - my @ret = (255, $inodes+1000, $inodes, $size, $size-10, 1024); + my @ret = (255, $inodes, 1, $size, $size-1, BLOCK); - print "statfs: ",join(",",@ret),"\n"; + #print "statfs: ",join(",",@ret),"\n"; return @ret; }