/[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 31 by dpavlin, Sun Oct 10 19:33:23 2004 UTC revision 40 by dpavlin, Fri Nov 19 21:56:12 2004 UTC
# Line 13  use Carp; Line 13  use Carp;
13  use Data::Dumper;  use Data::Dumper;
14    
15    
16  our $VERSION = '0.04';  our $VERSION = '0.06';
17    
18  =head1 NAME  =head1 NAME
19    
# Line 29  See C<run> below for examples how to set Line 29  See C<run> below for examples how to set
29  =head1 DESCRIPTION  =head1 DESCRIPTION
30    
31  This module will use C<Fuse> module, part of C<FUSE (Filesystem in USErspace)>  This module will use C<Fuse> module, part of C<FUSE (Filesystem in USErspace)>
32  available at L<http://sourceforge.net/projects/avf> to mount  available at L<http://fuse.sourceforge.net/> to mount
33  your database as file system.  your database as file system.
34    
35  That will give you possibility to use normal file-system tools (cat, grep, vi)  That will give you possibility to use normal file-system tools (cat, grep, vi)
# Line 169  sub mount { Line 169  sub mount {
169          $self->{'read_filenames'} = sub { $self->read_filenames };          $self->{'read_filenames'} = sub { $self->read_filenames };
170          $self->read_filenames;          $self->read_filenames;
171    
         $self->{'mounted'} = 1;  
   
172          $fuse_self = \$self;          $fuse_self = \$self;
173    
174          Fuse::main(          Fuse::main(
# Line 188  sub mount { Line 186  sub mount {
186                  debug=>0,                  debug=>0,
187          );          );
188                    
         $self->{'mounted'} = 0;  
   
189          exit(0) if ($arg->{'fork'});          exit(0) if ($arg->{'fork'});
190    
191          return 1;          return 1;
# Line 210  database to filesystem. Line 206  database to filesystem.
206  sub umount {  sub umount {
207          my $self = shift;          my $self = shift;
208    
209          if ($self->{'mounted'}) {          if ($self->{'mount'}) {
210                  system "fusermount -u ".$self->{'mount'} || croak "umount error: $!";                  if (open(MTAB, "/etc/mtab")) {
211          }                          my $mounted = 0;
212                            my $mount = $self->{'mount'};
213                            while(<MTAB>) {
214                                    $mounted = 1 if (/ $mount fuse /i);
215                            }
216                            close(MTAB);
217                    
218                            if ($mounted) {
219                                    system "fusermount -u ".$self->{'mount'}." 2>&1 >/dev/null" || return 0;
220                                    return 1;
221                            }
222    
223          return 1;                  } else {
224                            warn "can't open /etc/mtab: $!";
225                            return 0;
226                    }
227            }
228  }  }
229    
230  $SIG{'INT'} = sub {  $SIG{'INT'} = sub {
231          print STDERR "umount called by SIG INT\n";          if ($fuse_self && $$fuse_self->umount) {
232          umount;                  print STDERR "umount called by SIG INT\n";
233            }
234    };
235    
236    $SIG{'QUIT'} = sub {
237            if ($fuse_self && $$fuse_self->umount) {
238                    print STDERR "umount called by SIG QUIT\n";
239            }
240  };  };
241    
242  sub DESTROY {  sub DESTROY {
243          my $self = shift;          my $self = shift;
244          return if (! $self->{'mounted'});          if ($self->umount) {
245          print STDERR "umount called by DESTROY\n";                  print STDERR "umount called by DESTROY\n";
246          $self->umount;          }
247  }  }
248    
249  =head2 fuse_module_loaded  =head2 fuse_module_loaded
# Line 264  sub read_filenames { Line 281  sub read_filenames {
281                          type => 0040,                          type => 0040,
282                          mode => 0755,                          mode => 0755,
283                  },                  },
284                    '..' => {
285                            type => 0040,
286                            mode => 0755,
287                    },
288          #       a => {          #       a => {
289          #               cont => "File 'a'.\n",          #               cont => "File 'a'.\n",
290          #               type => 0100,          #               type => 0100,
# Line 342  sub e_getdir { Line 363  sub e_getdir {
363          my %out;          my %out;
364          foreach my $f (sort keys %files) {          foreach my $f (sort keys %files) {
365                  if ($dirname) {                  if ($dirname) {
366                          if ($f =~ s/^\E$dirname\Q\///) {                          if ($f =~ s/^\Q$dirname\E\///) {
367                                  $out{$f}++ if ($f =~ /^[^\/]+$/);                                  $out{$f}++ if ($f =~ /^[^\/]+$/);
368                          }                          }
369                  } else {                  } else {
# Line 520  __END__ Line 541  __END__
541    
542  Nothing.  Nothing.
543    
544    =head1 BUGS
545    
546    Size information (C<ls -s>) is wrong. It's a problem in upstream Fuse module
547    (for which I'm to blame lately), so when it gets fixes, C<Fuse::DBI> will
548    automagically pick it up.
549    
550  =head1 SEE ALSO  =head1 SEE ALSO
551    
552  C<FUSE (Filesystem in USErspace)> website  C<FUSE (Filesystem in USErspace)> website
553  L<http://sourceforge.net/projects/avf>  L<http://fuse.sourceforge.net/>
554    
555  Example for WebGUI which comes with this distribution in  Example for WebGUI which comes with this distribution in
556  directory C<examples/webgui.pl>. It also contains a lot of documentation  directory C<examples/webgui.pl>. It also contains a lot of documentation

Legend:
Removed from v.31  
changed lines
  Added in v.40

  ViewVC Help
Powered by ViewVC 1.1.26