Filesys-Fuse3
view release on metacpan or search on metacpan
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = (
'all' => [ qw(FUSE_BUF_IS_FD FUSE_BUF_FD_SEEK FUSE_BUF_FD_RETRY UTIME_NOW UTIME_OMIT XATTR_CREATE XATTR_REPLACE fuse_get_context fuse_version fuse_buf_copy fuse_buf_size FUSE_IOCTL_COMPAT FUSE_IOCTL_UNRESTRICTED FUSE_IOCTL_RETRY FUSE_IOCTL_MAX_...
'xattr' => [ qw(XATTR_CREATE XATTR_REPLACE) ],
'utime' => [ qw(UTIME_NOW UTIME_OMIT) ],
'zerocopy' => [ qw(FUSE_BUF_IS_FD FUSE_BUF_FD_SEEK FUSE_BUF_FD_RETRY) ],
'ioctl' => [ qw(FUSE_IOCTL_COMPAT FUSE_IOCTL_UNRESTRICTED FUSE_IOCTL_RETRY FUSE_IOCTL_MAX_IOV) ],
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = ();
our $VERSION = '0.021';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
# XS function. If a constant is not found then control is passed
# to the AUTOLOAD in AutoLoader.
my $constname;
our $AUTOLOAD;
($constname = $AUTOLOAD) =~ s/.*:://;
croak '& not defined' if $constname eq 'constant';
my $val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($!{EINVAL}) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
croak "Your vendor has not defined Fuse macro $constname";
}
}
{
no strict 'refs';
# Fixed between 5.005_53 and 5.005_61
if ($] >= 5.00561) {
*$AUTOLOAD = sub () { $val };
}
else {
*$AUTOLOAD = sub { $val };
}
}
goto &$AUTOLOAD;
}
bootstrap Filesys::Fuse3 $VERSION;
use constant FUSE_IOCTL_COMPAT => (1 << 0);
use constant FUSE_IOCTL_UNRESTRICTED => (1 << 1);
use constant FUSE_IOCTL_RETRY => (1 << 2);
use constant FUSE_IOCTL_MAX_IOV => 256;
sub main {
my ($fuse_vmajor, $fuse_vminor, $fuse_vmicro) = fuse_version();
my $fuse_version = $fuse_vmajor + ($fuse_vminor * 1.0 / 1_000) +
($fuse_vmicro * 1.0 / 1_000_000);
# â ï¸ @names must match the callback_index enum defined in Fuse.xs
my @names = qw(getattr readlink mknod mkdir unlink rmdir symlink
rename link chmod chown truncate open read write
statfs flush release fsync setxattr getxattr listxattr
removexattr opendir readdir releasedir fsyncdir init
destroy access create lock utimens
bmap ioctl poll write_buf read_buf flock fallocate);
my @subs = map {undef} @names;
my $tmp = 0;
my %mapping = map { $_ => $tmp++ } @names;
# â ï¸ @otherargs must match the arg_index enum defined in Fuse.xs
my @otherargs = qw(debug threaded mountpoint mountopts nullpath_ok
utimens_as_array);
my %otherargs = (
debug => 0,
threaded => 0,
mountpoint => '',
mountopts => '',
nullpath_ok => 0,
utimens_as_array => 0,
);
while(my $name = shift) {
my ($subref) = shift;
if(exists($otherargs{$name})) {
$otherargs{$name} = $subref;
} else {
croak 'Usage: Filesys::Fuse3::main(getattr => "main::my_getattr", ...)' unless $subref;
if (exists $mapping{$name}) {
$subs[$mapping{$name}] = $subref;
}
else {
carp "There is no function $name";
}
}
}
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_fuse3_main(@otherargs{@otherargs},@subs);
}
sub fuse_buf_size {
my ($buf) = @_;
return sum(map { $_->{size} } @$buf);
This function is called for all non-directory, non-symlink nodes,
not just devices.
=head3 mkdir
Arguments: New directory pathname, numeric modes.
Returns an errno.
Called to create a directory.
=head3 unlink
Arguments: Filename.
Returns an errno.
Called to remove a file, device, or symlink.
=head3 rmdir
Arguments: Pathname.
Returns an errno.
Called to remove a directory.
=head3 symlink
Arguments: Existing filename, symlink name.
Returns an errno.
Called to create a symbolic link.
=head3 rename
Arguments: old filename, new filename.
Returns an errno.
Called to rename a file, and/or move a file from one directory to another.
=head3 link
Arguments: Existing filename, hardlink name.
Returns an errno.
Called to create hard links.
=head3 chmod
Arguments: Pathname, numeric modes.
Returns an errno.
Called to change permissions on a file/directory/device/symlink.
=head3 chown
Arguments: Pathname, numeric uid, numeric gid.
Returns an errno.
Called to change ownership of a file/directory/device/symlink.
=head3 truncate
Arguments: Pathname, numeric offset.
Returns an errno.
Called to truncate a file, at the given offset.
=head3 utime
Arguments: Pathname, numeric actime, numeric modtime.
Returns an errno.
Called to change access/modification times for a file/directory/device/symlink.
=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), fileinfo hash reference.
Returns an errno, a file handle (optional).
The fileinfo hash reference contains information from the B<fuse> C<open()> call which may be modified by the module.
The only fileinfo fields presently supported are:
direct_io (version 2.4 onwards)
keep_cache (version 2.4 onwards)
nonseekable (version 2.8 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 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, file handle. You can use length($buffer) to
find the buffersize.
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 NULs and all sorts of other wonderful stuff.
=head3 statfs
Arguments: none
Returns any of the following:
( run in 3.710 seconds using v1.01-cache-2.11-cpan-71847e10f99 )