summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5234867)
- added is_mounted
- mount will now block until filesystem is mounted
(this might take up to 2 sec in intervals of 0.5 sec)
git-svn-id: svn://svn.rot13.org/fuse_dbi/trunk@47
17f4e80c-d0e0-0310-8903-
bfc3ae804c12
die "fork() failed: $!" unless defined $pid;
# child will return to caller
if ($pid) {
die "fork() failed: $!" unless defined $pid;
# child will return to caller
if ($pid) {
+ my $counter = 4;
+ while ($counter && ! $self->is_mounted) {
+ select(undef, undef, undef, 0.5);
+ $counter--;
+ }
+ if ($self->is_mounted) {
+ return $self;
+ } else {
+ return undef;
+ }
+=head2 is_mounted
+
+Check if fuse filesystem is mounted
+
+ if ($mnt->is_mounted) { ... }
+
+=cut
+
+sub is_mounted {
+ my $self = shift;
+
+ my $mounted = 0;
+ my $mount = $self->{'mount'} || confess "can't find mount point!";
+ if (open(MTAB, "/etc/mtab")) {
+ while(<MTAB>) {
+ $mounted = 1 if (/ $mount fuse /i);
+ }
+ close(MTAB);
+ } else {
+ warn "can't open /etc/mtab: $!";
+ }
+
+ return $mounted;
+}
+
+
=head2 umount
Unmount your database as filesystem.
=head2 umount
Unmount your database as filesystem.
sub umount {
my $self = shift;
sub umount {
my $self = shift;
- if ($self->{'mount'}) {
- if (open(MTAB, "/etc/mtab")) {
- my $mounted = 0;
- my $mount = $self->{'mount'};
- while(<MTAB>) {
- $mounted = 1 if (/ $mount fuse /i);
- }
- close(MTAB);
-
- if ($mounted) {
- system "fusermount -u ".$self->{'mount'}." 2>&1 >/dev/null" || return 0;
- return 1;
- }
-
- } else {
- warn "can't open /etc/mtab: $!";
- return 0;
- }
+ if ($self->{'mount'} && $self->is_mounted) {
+ system "fusermount -u ".$self->{'mount'}." 2>&1 >/dev/null" || return 0;
+ return 1;