/[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 36 by dpavlin, Tue Nov 16 15:34:25 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.05';  our $VERSION = '0.06';
17    
18  =head1 NAME  =head1 NAME
19    
# Line 148  sub mount { Line 148  sub mount {
148    
149          my $pid;          my $pid;
150          if ($arg->{'fork'}) {          if ($arg->{'fork'}) {
                 $self->{'mounted'} = 1;  
151                  $pid = fork();                  $pid = fork();
152                  die "fork() failed: $!" unless defined $pid;                  die "fork() failed: $!" unless defined $pid;
153                  # child will return to caller                  # child will return to caller
# Line 170  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 unless ($arg->{'fork'});  
   
172          $fuse_self = \$self;          $fuse_self = \$self;
173    
174          Fuse::main(          Fuse::main(
# Line 189  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 211  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'} || warn "umount error: $!" && return 0;                  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 265  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 521  __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

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

  ViewVC Help
Powered by ViewVC 1.1.26