# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1312708047 -7200 # Node ID 92690b23b3171799966bcdfeba56629e043570d4 # Parent 19a7554ddd6c6549f1a49442e99b915fb5783840 fixed and added man/help/debug diff -r 19a7554ddd6c -r 92690b23b317 bin/blockfuse --- a/bin/blockfuse Sun Aug 07 10:01:07 2011 +0200 +++ b/bin/blockfuse Sun Aug 07 11:07:27 2011 +0200 @@ -25,22 +25,39 @@ use POSIX; use autodie qw(:all); use Fuse; +use Getopt::Long; +use Pod::Usage; +my $opt_debug = 0; our $VERSION = "0.1"; -my $mountpoint = shift // die "$0: need mountpoint!\n"; +GetOptions( + "debug!" => \$opt_debug, + "h|help" => sub { pod2usage(-verbose => 1, -exit => 0) }, + "m|man" => sub { + pod2usage( + -verbose => 2, + -exit => 0, + -noperldoc => system("perldoc -V 1>/dev/null 2>&1") + ); + }, + ) + and @ARGV == 1 + or pod2usage(); warn "Your're probably not running a 64bit system, the devices sizes " . "will be incorrect!\n" if not `uname -m` =~ /64/; -fork() and exit 0; - -open(STDIN, " $$); +if (not $opt_debug) { + fork() and exit 0; + open(STDIN, " $$); +} Fuse::main( - mountpoint => $mountpoint, + mountpoint => $ARGV[0], + debug => $opt_debug, getattr => \&my_getattr, getdir => \&my_getdir, open => \&my_open, @@ -80,7 +97,7 @@ sub my_open { my $path = "/dev" . shift; eval { open($FD{$path} => $path) }; - return $!; + return $@ ? $! : 0; } sub my_release { @@ -97,3 +114,44 @@ return $_; } } + +__END__ + +=head1 NAME + + blockfuse - mount /dev and map block devices into files + +=head1 SYNOPSIS + + blockfuse [-d|--debug] {mountpoint} + + blockfuse [-h|--help] [-m|--man] + +=head1 DESCRIPTION + +B is a Fuse helper to mount the "/dev" structure to some +mointpoint and map all block devices into ordinary files. This makes +B happy. + +=head1 OPTIONS + +=over + +=item B<-d> | B<--debug> + +Switch on Fuse debugging. It will prevent B to fork to background +too. (default: no debugging) + +=item B<-h> | B<--help> | B<-m> | B<--man> + +The standard help options. + +=back + +=head1 AUTHOR and SOURCE + +Heiko Schlittermann + +Source: L + +=cut