/[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 51 by dpavlin, Sat Nov 27 14:02:18 2004 UTC revision 54 by dpavlin, Tue Apr 26 19:57:51 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.07';
16    
17    # block size for this filesystem
18    use constant BLOCK => 1024;
19    
20  =head1 NAME  =head1 NAME
21    
22  Fuse::DBI - mount your database as filesystem and use it  Fuse::DBI - mount your database as filesystem and use it
# Line 247  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 369  sub e_getattr { Line 373  sub e_getattr {
373          $file =~ s,^/,,;          $file =~ s,^/,,;
374          $file = '.' unless length($file);          $file = '.' unless length($file);
375          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
376          my ($size) = $files{$file}{size} || 1024;          my ($size) = $files{$file}{size} || 0;
377          my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+1023)/1024),0,0,1,1024);          my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,int(($size+BLOCK-1)/BLOCK),0,0,1,BLOCK);
378          my ($atime, $ctime, $mtime);          my ($atime, $ctime, $mtime);
379          $atime = $ctime = $mtime = $files{$file}{ctime} || $ctime_start;          $atime = $ctime = $mtime = $files{$file}{ctime} || $ctime_start;
380    
# Line 378  sub e_getattr { Line 382  sub e_getattr {
382    
383          # 2 possible types of return values:          # 2 possible types of return values:
384          #return -ENOENT(); # or any other error you care to          #return -ENOENT(); # or any other error you care to
385          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";
386          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);
387  }  }
388    
# Line 428  sub e_open { Line 432  sub e_open {
432    
433          read_content($file,$files{$file}{id}) unless exists($files{$file}{cont});          read_content($file,$files{$file}{id}) unless exists($files{$file}{cont});
434    
435            $files{$file}{cont} ||= '';
436          print "open '$file' ",length($files{$file}{cont})," bytes\n";          print "open '$file' ",length($files{$file}{cont})," bytes\n";
437          return 0;          return 0;
438  }  }
# Line 556  sub e_statfs { Line 561  sub e_statfs {
561                  print "$inodes: $f [$size]\n";                  print "$inodes: $f [$size]\n";
562          }          }
563    
564          $size = int(($size+1023)/1024);          $size = int(($size+BLOCK-1)/BLOCK);
565    
566          my @ret = (255, $inodes+1000, $inodes, $size, $size-10, 1024);          my @ret = (255, $inodes, 1, $size, $size-1, BLOCK);
567    
568          print "statfs: ",join(",",@ret),"\n";          #print "statfs: ",join(",",@ret),"\n";
569    
570          return @ret;          return @ret;
571  }  }

Legend:
Removed from v.51  
changed lines
  Added in v.54

  ViewVC Help
Powered by ViewVC 1.1.26