use warnings;
use Errno;
use Carp;
+use Config;
require Exporter;
require DynaLoader;
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = (
- 'all' => [ qw(FUSE_DEBUG XATTR_CREATE XATTR_REPLACE) ],
- 'debug' => [ qw(FUSE_DEBUG) ],
+ 'all' => [ qw(XATTR_CREATE XATTR_REPLACE fuse_get_context) ],
'xattr' => [ qw(XATTR_CREATE XATTR_REPLACE) ]
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-our @EXPORT = qw(
- FUSE_DEBUG
-);
-our $VERSION = '0.06';
+our @EXPORT = ();
+our $VERSION = '0.11';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
bootstrap Fuse $VERSION;
sub main {
- my (@subs) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
- 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 $tmp = 0;
+ my %mapping = map { $_ => $tmp++ } @names;
+ 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})) {
$subs[$mapping{$name}] = $subref;
}
}
- foreach my $opt ( split(/,/,$otherargs{mountopts}) ) {
- if ( ! exists($optmap{$opt}) ) {
- croak "Use of an invalid mountopt argument";
- }
- }
- perl_fuse_main($otherargs{debug},$otherargs{threaded},$otherargs{mountpoint},$otherargs{mountopts},@subs);
+ if($otherargs{threaded}) {
+ # make sure threads are both available, and loaded.
+ if($Config{useithreads}) {
+ if(exists($threads::{VERSION})) {
+ if(exists($threads::shared::{VERSION})) {
+ # threads will work.
+ } else {
+ carp("Thread support requires you to use threads::shared.\nThreads are disabled.\n");
+ $otherargs{threaded} = 0;
+ }
+ } else {
+ carp("Thread support requires you to use threads and threads::shared.\nThreads are disabled.\n");
+ $otherargs{threaded} = 0;
+ }
+ } else {
+ carp("Thread support was not compiled into this build of perl.\nThreads are disabled.\n");
+ $otherargs{threaded} = 0;
+ }
+ }
+ perl_fuse_main(@otherargs{@otherargs},@subs);
}
# Autoload methods go after =cut, and are processed by the autosplit program.
=head2 EXPORTED SYMBOLS
-FUSE_DEBUG by default.
+None by default.
You can request all exportable symbols by using the tag ":all".
-You can request all debug symbols by using the tag ":debug".
-This will export FUSE_DEBUG.
-
You can request the extended attribute symbols by using the tag ":xattr".
This will export XATTR_CREATE and XATTR_REPLACE.
you're using are also thread-safe.
(If enabled, this option will cause a warning if your perl interpreter was not
-built with USE_ITHREADS.)
+built with USE_ITHREADS, or if you have failed to use threads or
+threads::shared.)
=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
Arguments: Containing directory name.
Returns a list: 0 or more text strings (the filenames), followed by a numeric errno (usually 0).
-This is used to obtain directory listings. Its opendir(), readdir(), filldir() and closedir() all in one call.
+This is used to obtain directory listings. It's opendir(), readdir(), filldir() and closedir() all in one call.
example rv: return ('.', 'a', 'b', 0);
=head3 open
Arguments: Pathname, numeric flags (which is an OR-ing of stuff like O_RDONLY
-and O_SYNC, constants you can import from POSIX).
-Returns an errno.
+and O_SYNC, constants you can import from POSIX), fileinfo hash reference.
+Returns an errno, a file handle (optional).
No creation, or trunctation flags (O_CREAT, O_EXCL, O_TRUNC) will be passed to open().
+The fileinfo hash reference contains flags from the Fuse open call which may be modified by the module. The only fields presently supported are:
+ direct_io (version 2.4 onwards)
+ keep_cache (version 2.4 onwards)
+ nonseekable (version 2.9 onwards)
Your open() method needs only check if the operation is permitted for the given flags, and return 0 for success.
+Optionally a file handle may be returned, which will be passed to subsequent read, write, flush, fsync and release calls.
=head3 read
-Arguments: Pathname, numeric requestedsize, numeric offset.
+Arguments: Pathname, numeric requested size, numeric offset, file handle
Returns a numeric errno, or a string scalar with up to $requestedsize bytes of data.
Called in an attempt to fetch a portion of the file.
=head3 write
-Arguments: Pathname, scalar buffer, numeric offset. You can use length($buffer) to
+Arguments: Pathname, scalar buffer, numeric offset, file handle. You can use length($buffer) to
find the buffersize.
-Returns an errno.
+Returns length($buffer) if successful (number of bytes written).
-Called in an attempt to write (or overwrite) a portion of the file. Be prepared because $buffer could contain random binary data with NULLs and all sorts of other wonderful stuff.
+Called in an attempt to write (or overwrite) a portion of the file. Be prepared because $buffer could contain random binary data with NULs and all sorts of other wonderful stuff.
=head3 statfs
=head3 flush
-Arguments: Pathname
+Arguments: Pathname, file handle
Returns an errno or 0 on success.
Called to synchronise any cached data. This is called before the file
=head3 release
-Arguments: Pathname, numeric flags passed to open
+Arguments: Pathname, numeric flags passed to open, file handle
Returns an errno or 0 on success.
Called to indicate that there are no more references to the file. Called once