/[fuse_dbi]/trunk/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 /trunk/DBI.pm

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

revision 17 by dpavlin, Sun Aug 29 20:12:37 2004 UTC revision 18 by dpavlin, Sun Sep 5 16:59:41 2004 UTC
# Line 14  use Proc::Simple; Line 14  use Proc::Simple;
14  use Data::Dumper;  use Data::Dumper;
15    
16    
17  our $VERSION = '0.01';  our $VERSION = '0.02';
18    
19  =head1 NAME  =head1 NAME
20    
# Line 86  sub mount { Line 86  sub mount {
86          $dbh = DBI->connect($arg->{'dsn'},$arg->{'user'},$arg->{'password'}, { AutoCommit => 0 }) || die $DBI::errstr;          $dbh = DBI->connect($arg->{'dsn'},$arg->{'user'},$arg->{'password'}, { AutoCommit => 0 }) || die $DBI::errstr;
87    
88          print "start transaction\n";          print "start transaction\n";
89          #$dbh->begin_work || die $dbh->errstr;          $dbh->begin_work || die $dbh->errstr;
90    
91          $sth->{filenames} = $dbh->prepare($arg->{'filenames'}) || die $dbh->errstr();          $sth->{filenames} = $dbh->prepare($arg->{'filenames'}) || die $dbh->errstr();
92    
# Line 324  sub update_db { Line 324  sub update_db {
324    
325  sub e_write {  sub e_write {
326          my $file = filename_fixup(shift);          my $file = filename_fixup(shift);
327          my ($buf_len,$off) = @_;          my ($buffer,$off) = @_;
328    
329          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
330    
331          my $len = length($files{$file}{cont});          my $cont = $files{$file}{cont};
332            my $len = length($cont);
333    
334          print "write '$file' [$len bytes] offset $off length\n";          print "write '$file' [$len bytes] offset $off length ",length($buffer),"\n";
335    
336          $files{$file}{cont} =          $files{$file}{cont} = "";
337                  substr($files{$file}{cont},0,$off) .  
338                  $buf_len .          $files{$file}{cont} .= substr($cont,0,$off) if ($off > 0);
339                  substr($files{$file}{cont},$off+length($buf_len));          $files{$file}{cont} .= $buffer;
340            $files{$file}{cont} .= substr($cont,-($off+length($buffer))) if ($off+length($buffer) > $len);
341    
342            $files{$file}{size} = length($files{$file}{cont});
343    
344          if (! update_db($file)) {          if (! update_db($file)) {
345                  return -ENOSYS();                  return -ENOSYS();
346          } else {          } else {
347                  return length($buf_len);                  return length($buffer);
348          }          }
349  }  }
350    
# Line 348  sub e_truncate { Line 352  sub e_truncate {
352          my $file = filename_fixup(shift);          my $file = filename_fixup(shift);
353          my $size = shift;          my $size = shift;
354    
355            print "truncate to $size\n";
356    
357          $files{$file}{cont} = substr($files{$file}{cont},0,$size);          $files{$file}{cont} = substr($files{$file}{cont},0,$size);
358            $files{$file}{size} = $size;
359          return 0          return 0
360  };  };
361    

Legend:
Removed from v.17  
changed lines
  Added in v.18

  ViewVC Help
Powered by ViewVC 1.1.26