# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1311606967 -7200 # Node ID 46a3e65e850f52a058219b24afcb25a40d92dddc # Parent 675ef249d116fa5e44d8fb4c8b744f5d71e448df added pod diff -r 675ef249d116 -r 46a3e65e850f fuse --- a/fuse Mon Jul 25 16:36:53 2011 +0200 +++ b/fuse Mon Jul 25 17:16:07 2011 +0200 @@ -6,28 +6,56 @@ use autodie qw(:all); use Getopt::Long; use Fuse; +use POSIX qw(setpgid); +use Pod::Usage; +use Hash::Util qw(lock_keys); +use File::Basename; -my $opt_debug = 0; +my %o = ( + debug => undef, + detach => 1, +); lock_keys %o; + +use constant ME => basename $0; -GetOptions("debug!" => \$opt_debug) - and @ARGV == 2 - or die "Bad Usage\n"; +MAIN: { -my $src = shift; -my $mp = shift; + GetOptions( + "d|debug!" => \$o{debug}, + "detach!" => \$o{detach}, + "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, + "m|man" => sub { pod2usage(-verbose => 2, -exit => 0, + -noperlpod => system("perldoc -V 1>/dev/null 2>&1")) }, + ) and @ARGV == 2 or pod2usage; + + my ($src, $mp) = @ARGV; -$fs::DATA = "$src/data"; -$fs::IDX = "$src/idx"; + $fs::DATA = "$src/data"; + $fs::IDX = "$src/idx"; + + die ME.": $fs::DATA: $!" if not -d $fs::DATA; + die ME.": $fs::IDX: $!" if not -d $fs::IDX; + + if (!$o{debug} and $o{detach}) { + fork() and exit; + $0 = "FUSE $src $mp"; + open(STDOUT => ">/dev/null"); + open(STDIN => "/dev/null"); -Fuse::main(mountpoint => $mp, - debug => $opt_debug, - getattr => "fs::getattr", - getdir => "fs::getdir", - open => "fs::openfile", - read => "fs::readbuffer", - write => "fs::writebuffer", - ); + setpgid($$ => $$); + } + + Fuse::main(mountpoint => $mp, + debug => $o{debug} // 0, + getattr => "fs::getattr", + getdir => "fs::getdir", + open => "fs::openfile", + read => "fs::readbuffer", + write => "fs::writebuffer", + ); + +} { package fs; use strict; @@ -179,3 +207,41 @@ } } + +__END__ + +=head1 NAME + + fuse - the fuse mount helper for imagers backups + +=head1 SYNOPSIS + + fuse [options] {src} {mount point} + +=head1 DESCRIPTION + +B mounts the src directory (containing F and F +directories) the the specified mount point. + +=head1 OPTIONS + +=over 4 + +=item B<-d>|B<--debug> + +Enables debugging output from B. When using this option, +B does not detach from the terminal. (default: off) + +=item B<-->I<[no]>B + +Detach or don't detach from the terminal. (default: detach) + +=item B<-h>|B<--help> + +=item B<-m>|B<--man> + +The common help and man options. + +=back + +=cut