Filesys-Fuse3
view release on metacpan or search on metacpan
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
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.
SPAGAIN;
rv = (rv ? POPi : 0);
FREETMPS;
LEAVE;
PUTBACK;
DEBUGf("chmod end: %i\n",rv);
FUSE_CONTEXT_POST;
return rv;
}
int _PLfuse_chown (const char *file, uid_t uid, gid_t gid, struct fuse_file_info *fi) {
int rv;
FUSE_CONTEXT_PRE;
DEBUGf("chown begin\n");
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVpv(file,0)));
XPUSHs(sv_2mortal(newSViv(uid)));
XPUSHs(sv_2mortal(newSViv(gid)));
PUTBACK;
rv = call_sv(MY_CXT.callback[CB_IDX_CHOWN],G_SCALAR);
SPAGAIN;
rv = (rv ? POPi : 0);
FREETMPS;
LEAVE;
PUTBACK;
DEBUGf("chown end: %i\n",rv);
FUSE_CONTEXT_POST;
return rv;
}
int _PLfuse_truncate (const char *file, off_t off, struct fuse_file_info *fi) {
int rv;
#ifndef PERL_HAS_64BITINT
char *temp;
#endif
FUSE_CONTEXT_PRE;
case CB_IDX_GETATTR : fops.getattr = _PLfuse_getattr; break;
case CB_IDX_READLINK : fops.readlink = _PLfuse_readlink; break;
case CB_IDX_MKNOD : fops.mknod = _PLfuse_mknod; break;
case CB_IDX_MKDIR : fops.mkdir = _PLfuse_mkdir; break;
case CB_IDX_UNLINK : fops.unlink = _PLfuse_unlink; break;
case CB_IDX_RMDIR : fops.rmdir = _PLfuse_rmdir; break;
case CB_IDX_SYMLINK : fops.symlink = _PLfuse_symlink; break;
case CB_IDX_RENAME : fops.rename = _PLfuse_rename; break;
case CB_IDX_LINK : fops.link = _PLfuse_link; break;
case CB_IDX_CHMOD : fops.chmod = _PLfuse_chmod; break;
case CB_IDX_CHOWN : fops.chown = _PLfuse_chown; break;
case CB_IDX_TRUNCATE : fops.truncate = _PLfuse_truncate; break;
case CB_IDX_OPEN : fops.open = _PLfuse_open; break;
case CB_IDX_READ : fops.read = _PLfuse_read; break;
case CB_IDX_WRITE : fops.write = _PLfuse_write; break;
case CB_IDX_STATFS : fops.statfs = _PLfuse_statfs; break;
case CB_IDX_FLUSH : fops.flush = _PLfuse_flush; break;
case CB_IDX_RELEASE : fops.release = _PLfuse_release; break;
case CB_IDX_FSYNC : fops.fsync = _PLfuse_fsync; break;
case CB_IDX_SETXATTR : fops.setxattr = _PLfuse_setxattr; break;
case CB_IDX_GETXATTR : fops.getxattr = _PLfuse_getxattr; break;
Makefile.PL
MANIFEST
README.md
test.pl
META.yml Module meta-data (added by MakeMaker)
test/helper.pm
test/s/umount.t
test/s/mount.t
test/test-template
test/chmod.t
test/chown.t
test/getattr.t
test/getdir.t
test/link.t
test/mkdir.t
test/mknod.t
test/open.t
test/readlink.t
test/read.t
test/rename.t
test/rmdir.t
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Filesys::Statvfs" : "0",
"Lchown" : "0",
"Unix::Mknod" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "http://github.com/dod38fr/perl-filesys-fuse3/issues"
},
"license" : [
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Filesys-Fuse3
no_index:
directory:
- t
- inc
requires:
Filesys::Statvfs: '0'
Lchown: '0'
Unix::Mknod: '0'
resources:
bugtracker: http://github.com/dod38fr/perl-filesys-fuse3/issues
license: http://www.gnu.org/licenses/lgpl-2.1.html
repository: http://github.com/dod38fr/perl-filesys-fuse3
version: '0.021'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
$micro = 0;
}
$def .= ' -DFUSE_FOUND_MAJOR_VER=' . $major;
$def .= ' -DFUSE_FOUND_MINOR_VER=' . $minor;
$def .= ' -DFUSE_FOUND_MICRO_VER=' . $micro;
WriteMakefile(
'NAME' => 'Filesys::Fuse3',
'VERSION_FROM' => 'Fuse3.pm', # finds $VERSION
'PREREQ_PM' => { # e.g., Module::Name => 1.1
'Lchown' => 0,
'Filesys::Statvfs' => 0,
'Unix::Mknod' => 0,
},
ABSTRACT_FROM => 'Fuse3.pm', # retrieve abstract from module
AUTHOR => 'Dominique Dumont <domi.dumont@free.fr>',
'LICENSE' => 'LGPL_2_1',
META_MERGE => {
resources => {
license => 'http://www.gnu.org/licenses/lgpl-2.1.html',
bugtracker => 'http://github.com/dod38fr/perl-filesys-fuse3/issues',
require it), the Perl build in OpenBSD 5.6 base does *not* support threads.
Assuming you're not an OpenBSD ninja (or completely insane), I don't
recommend trying to build your own and install it over the system Perl,
because that can have bad repercussions. Use something like
[perlbrew](http://perlbrew.pl) if you want a threaded Perl:
perlbrew install perl-<version> -Dusethreads \
--as perl-<version>_WITH_THREADS
For the tests, I recommend installing devel/p5-Lchown,
devel/p5-Filesys-Statvfs, devel/p5-Unix-Mknod and devel/p5-Test-Pod from
OpenBSD ports. (Or use the 'cpan' command from your Perlbrew-installed
version to install those modules, if you want thread support like I was
talking about above.)
Now, in your perl-fuse distribution, run:
perl Makefile.PL
make
* There is a bug if a file is created in the fuse filesystem and goes
away, then you create another file of the same name via FUSE and
try to do utime(). Not sure if it's just utime() or if other things
trip it too, but I discovered that via playing around. I *THINK*
it's a vnode caching problem.
* There is also a known issue with access() if all parent directories
of a path haven't been explicitly accessed first.
* There is a known issue with readdir() when supplying numbered dirents
to support progressive readdir().
* You should probably implement all of chown(), chmod(), truncate(), and
utime() and/or utimens(). The kernel driver will mask out future
setattr() requests if it gets ENOSYS from ANY of these. Oops.
#### COPYRIGHT AND LICENCE ####
This is contributed to the FUSE project by Mark Glines <mark@glines.org>,
and is therefore subject to the same license and copyright as FUSE itself.
It is released under LGPL 2.1. Please see the AUTHORS and COPYING files
from the FUSE distribution for more information.
examples/loopback.pl view on Meta::CPAN
my $has_Filesys__Statvfs = 0;
eval {
require Filesys::Statvfs;
1;
} and do {
$has_Filesys__Statvfs = 1;
Filesys::Statvfs->import();
};
my $use_lchown = 0;
eval {
require Lchown;
1;
} and do {
$use_lchown = 1;
Lchown->import();
};
my $has_mknod = 0;
eval {
require Unix::Mknod;
1;
} and do {
$has_mknod = 1;
Unix::Mknod->import();
};
examples/loopback.pl view on Meta::CPAN
sub x_symlink { print "symlink\n"; return symlink(shift,fixup(shift)) ? 0 : -$!; }
sub x_rename {
my ($old) = fixup(shift);
my ($new) = fixup(shift);
my ($err) = rename($old,$new) ? 0 : -ENOENT();
return $err;
}
sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! }
sub x_chown {
my ($fn) = fixup(shift);
local $!;
print "nonexistent $fn\n" unless -e $fn;
my ($uid,$gid) = @_;
if( $use_lchown ){
lchown($uid, $gid, $fn);
}else{
chown($uid, $gid, $fn);
}
return -$!;
}
sub x_chmod {
my ($fn) = fixup(shift);
my ($mode) = shift;
my ($err) = chmod($mode,$fn) ? 0 : -$!;
return $err;
}
sub x_truncate { return truncate(fixup(shift),shift) ? 0 : -$! ; }
examples/loopback.pl view on Meta::CPAN
'readdir' => 'main::x_readdir',
'create' => 'main::x_create',
'mknod' => 'main::x_mknod',
'mkdir' => 'main::x_mkdir',
'unlink' => 'main::x_unlink',
'rmdir' => 'main::x_rmdir',
'symlink' => 'main::x_symlink',
'rename' => 'main::x_rename',
'link' => 'main::x_link',
'chmod' => 'main::x_chmod',
'chown' => 'main::x_chown',
'truncate' => 'main::x_truncate',
'utimens' => 'main::x_utimens',
'open' => 'main::x_open',
'release' => 'main::x_release',
'read' => 'main::x_read',
'read_buf' => 'main::x_read_buf',
'write' => 'main::x_write',
'write_buf' => 'main::x_write_buf',
'statfs' => 'main::x_statfs',
%extraopts,
examples/rmount.pl view on Meta::CPAN
}
}
`umount $mount` unless -d $mount;
die "mountpoint $mount isn't a directory!\n" unless -d $mount;
my (%args) = (mountpoint => $mount);
map { my ($str) = $_; $args{$str} = sub { netlink($str,@_) } }
qw(getattr getdir open read write readlink unlink rmdir
symlink rename link chown chmod truncate utime mkdir
rmdir mknod statfs);
sub connect_remote {
push(@Net::SSH::ssh_options, "-p $port") if $port;
sshopen2($host, *READER, *WRITER, "./rmount_remote.pl $dir")
or die "ssh: $!\n";
select WRITER;
$| = 1;
select STDOUT;
}
examples/rmount_remote.pl view on Meta::CPAN
#!/usr/bin/perl
use strict;
use IO::File;
use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT);
use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET);
use Data::Dumper;
require 'syscall.ph'; # for SYS_mknod and SYS_lchown
my ($rootdir) = @ARGV;
# strip leading and trailing slashes
$rootdir = $1 if($rootdir =~ /^\/?(.*)\/?$/);
sub fixup { return "/$rootdir" . shift }
sub x_getattr {
my ($file) = fixup(shift);
examples/rmount_remote.pl view on Meta::CPAN
sub x_symlink { print "symlink\n"; return symlink(shift,fixup(shift)) ? 0 : -$!; }
sub x_rename {
my ($old) = fixup(shift);
my ($new) = fixup(shift);
my ($err) = rename($old,$new) ? 0 : -ENOENT();
return $err;
}
sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! }
sub x_chown {
my ($fn) = fixup(shift);
print "nonexistent $fn\n" unless -e $fn;
my ($uid,$gid) = @_;
# perl's chown() does not chown symlinks, it chowns the symlink's
# target. it fails when the link's target doesn't exist, because
# the stat64() syscall fails.
# this causes error messages when unpacking symlinks in tarballs.
my ($err) = syscall(&SYS_lchown,$fn,$uid,$gid,$fn) ? -$! : 0;
return $err;
}
sub x_chmod {
my ($fn) = fixup(shift);
my ($mode) = shift;
my ($err) = chmod($mode,$fn) ? 0 : -$!;
return $err;
}
sub x_truncate { return truncate(fixup(shift),shift) ? 0 : -$! ; }
sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; }
test/chown.t view on Meta::CPAN
my (@stat);
chdir($_point);
open($file, '>', 'file');
print $file "frog\n";
close($file);
SKIP: {
skip('Need root to give away ownership', 4) unless ($UID == 0);
ok(chown(0,0,"file"),"set 0,0");
@stat = stat("file");
ok($stat[4] == 0 && $stat[5] == 0,"0,0");
ok(chown(1,1,"file"),"set 1,1");
@stat = stat("file");
ok($stat[4] == 1 && $stat[5] == 1,"1,1");
}
unlink("file");
( run in 1.046 second using v1.01-cache-2.11-cpan-71847e10f99 )