/[fuse_dbi]/fuse-couchdb/DBI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /fuse-couchdb/DBI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 52 by dpavlin, Sat Nov 27 15:08:10 2004 UTC revision 55 by dpavlin, Tue Apr 26 20:12:55 2005 UTC
# Line 12  use DBI; Line 12  use DBI;
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;
# Line 249  sub umount { Line 249  sub umount {
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    
# Line 327  sub read_filenames { Line 329  sub read_filenames {
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
# Line 371  sub e_getattr { Line 375  sub e_getattr {
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;
# Line 380  sub e_getattr { Line 384  sub e_getattr {
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    
# Line 430  sub e_open { Line 434  sub e_open {
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  }  }
# Line 562  sub e_statfs { Line 567  sub e_statfs {
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  }  }

Legend:
Removed from v.52  
changed lines
  Added in v.55

  ViewVC Help
Powered by ViewVC 1.1.26