--- perl/trunk/Fuse.pm 2005/12/27 14:49:31 20 +++ perl-llin/Fuse.pm 2008/01/21 16:36:57 118 @@ -21,14 +21,14 @@ # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( - 'all' => [ qw(XATTR_CREATE XATTR_REPLACE) ], + 'all' => [ qw(XATTR_CREATE XATTR_REPLACE fuse_get_context) ], 'xattr' => [ qw(XATTR_CREATE XATTR_REPLACE) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = (); -our $VERSION = '0.07_1'; +our $VERSION = '0.09'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() @@ -75,17 +75,16 @@ bootstrap Fuse $VERSION; sub main { - my (@subs) = (undef,undef,undef,undef,undef,undef,undef,undef,undef,undef, - undef,undef,undef,undef,undef,undef,undef,undef,undef,undef, - undef,undef,undef,undef,undef); - my (@names) = qw(getattr readlink getdir mknod mkdir unlink rmdir symlink - rename link chmod chown truncate utime open read write statfs - flush release fsync setxattr getxattr listxattr removexattr); - my (@validOpts) = qw(allow_other); - my ($tmp) = 0; - my (%mapping) = map { $_ => $tmp++ } (@names); - my (%optmap) = map { $_ => 1 } (@validOpts); - my (%otherargs) = (debug=>0, threaded=>0, mountpoint=>"", mountopts=>""); + my @names = qw(getattr readlink getdir mknod mkdir unlink rmdir symlink + rename link chmod chown truncate utime open read write statfs + flush release fsync setxattr getxattr listxattr removexattr); + my @subs = map {undef} @names; + my @validOpts = qw(ro allow_other default_permissions fsname use_ino nonempty); + my $tmp = 0; + my %mapping = map { $_ => $tmp++ } @names; + my %optmap = map { $_ => 1 } @validOpts; + my @otherargs = qw(debug threaded mountpoint mountopts); + my %otherargs = (debug=>0, threaded=>0, mountpoint=>"", mountopts=>""); while(my $name = shift) { my ($subref) = shift; if(exists($otherargs{$name})) { @@ -96,10 +95,9 @@ $subs[$mapping{$name}] = $subref; } } - foreach my $opt ( split(/,/,$otherargs{mountopts}) ) { - if ( ! exists($optmap{$opt}) ) { - croak "Use of an invalid mountopt argument"; - } + foreach my $opt ( map {m/^([^=]*)/; $1} split(/,/,$otherargs{mountopts}) ) { + next if exists($optmap{$opt}); + croak "Fuse::main: invalid '$opt' argument in mountopts"; } if($otherargs{threaded}) { # make sure threads are both available, and loaded. @@ -120,7 +118,7 @@ $otherargs{threaded} = 0; } } - perl_fuse_main($otherargs{debug},$otherargs{threaded},$otherargs{mountpoint},$otherargs{mountopts},@subs); + perl_fuse_main(@otherargs{@otherargs},@subs); } # Autoload methods go after =cut, and are processed by the autosplit program. @@ -236,6 +234,15 @@ =back +=head3 Fuse::fuse_get_context + + use Fuse "fuse_get_context"; + my $caller_uid = fuse_get_context()->{"uid"}; + my $caller_gid = fuse_get_context()->{"gid"}; + my $caller_pid = fuse_get_context()->{"pid"}; + +Access context information about the current Fuse operation. + =head2 FUNCTIONS YOUR FILESYSTEM MAY IMPLEMENT =head3 getattr