| Fuse-Filesys-Virtual documentation | Contained in the Fuse-Filesys-Virtual distribution. |
Fuse::Filesys::Virtual - mount Perl module written using Filesys::Virtual
Version 0.02
use Fuse::Filesys::Virtual;
my $fs = Filesys::Virtual::Foo->new();
my $fuse = Fuse::Filesys::Virtual->new($fs, { debug => 1});
$fuse->main(mountpoint => '/mnt', mountopts => "allow_other");
Nothing.
Constructor. Takes FS and ATTR_HASH_REF as a parameter.
FS - An instance of Virtual::Filesys ATTR_HASH_REF - reference to attribute hash.
Following key-value is recognized.
debug : true or false
Same as Fuse.
Always returns -EPERM. This function is not supported by Virtual::Filesys.
Same as Fuse.
Same as Fuse.
Same as Fuse.
Same as Fuse.
Same as Fuse.
Always returns -EPERM. This function is not supported by Virtual::Filesys.
Same as Fuse. But his function is implemented by Copy & Delete.
Always returns -EPERM. This function is not supported by Virtual::Filesys.
Always returns 0(success), but nothing is done. This function is not supported by Virtual::Filesys.
Always returns -EPERM. This function is not supported by Virtual::Filesys.
Always returns -EPERM. This function is not supported by Virtual::Filesys.
Same as Fuse.
Same as Fuse.
Same as Fuse.
Same as Fuse.
Always returns 0(no error). This function is not supported by Virtual::Filesys.
Same as Fuse.
Always returns 0(no error). This function is not supported by Virtual::Filesys.
Toshimitsu FUJIWARA, <tttfjw at gmail.com>
Threading is not supported.
You can find documentation for this module with the perldoc command.
perldoc Fuse::Filesys::Virtual
Copyright 2008 Toshimitsu FUJIWARA, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Fuse-Filesys-Virtual documentation | Contained in the Fuse-Filesys-Virtual distribution. |
# # Fuse::Filesys::Virtual # # bridge of Fuse and Filesys::Virtual # package Fuse::Filesys::Virtual; use warnings; use strict;
our $VERSION = '0.02';
use POSIX qw(:errno_h :fcntl_h); use base qw(Fuse::Class); use Fuse::Filesys::Virtual::FSWrapper; use Fuse::Filesys::Virtual::HandleCache;
sub _debug { my $self = shift; my (@msg) = @_; local ($@, $!); print STDERR __PACKAGE__, ": ", @msg if ($self->{debug}); }
sub new { my $class = shift; my ($filesys, $attr) = @_; my $wrapped = Fuse::Filesys::Virtual::FSWrapper->new($filesys); my $self = { _filesys => $wrapped, _cache => Fuse::Filesys::Virtual::HandleCache->new($wrapped), debug => $attr->{debug}, }; bless $self, $class; }
sub getattr { my $self = shift; my ($fname) = @_; my @ret = eval { $self->{_filesys}->stat($fname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return @ret; }
sub readlink { my $self = shift; return -EPERM(); }
sub getdir { my $self = shift; my ($dirname) = @_; my @ret = eval { $self->{_filesys}->list($dirname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } push(@ret, 0); return @ret; }
sub mknod { my $self = shift; my ($fname, $modes) = @_; eval { if ($self->{_filesys}->stat($fname)) { $! = EEXIST; die "file exists"; } else { my $fh = $self->{_filesys}->open_write($fname, 0); die "cannot create $fname: $!" unless($fh); $self->{_filesys}->close_write($fh); } }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub mkdir { my $self = shift; my ($dirname, $modes) = @_; eval { $self->{_filesys}->mkdir($dirname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub unlink { my $self = shift; my ($fname) = @_; my $busy = eval { return -EBUSY() if ($self->{_cache}->is_busy($fname)); }; return $busy if ($busy); eval { unless ($self->{_filesys}->delete($fname)) { $! = EPERM; die "failure"; } }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub rmdir { my $self = shift; my ($dirname) = @_; my $busy = eval { return -EBUSY() if ($self->{_cache}->is_busy($dirname)); }; return $busy if ($busy); eval { $self->{_filesys}->rmdir($dirname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub symlink { my $self = shift; return -EPERM(); }
sub rename { my $self = shift; my ($oldname, $newname) = @_; my $busy = eval { return -EBUSY() if ($self->{_cache}->is_busy($oldname)); }; return $busy if ($busy); $busy = eval { return -EBUSY() if (!$self->{_filesys}->test('d', $newname) && $self->{_cache}->is_busy($newname)); }; return $busy if ($busy); eval { $self->{_filesys}->rename($oldname, $newname) or die "cannot rename: $!"; }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub link { my $self = shift; return -EPERM(); }
sub chmod { my $self = shift; return 0; }
sub chown { my $self = shift; return -EPERM(); }
sub truncate { my $self = shift; my ($fname) = @_; eval { $self->{_cache}->truncate($fname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub utime { my $self = shift; my ($fname, $atime, $mtime) = @_; eval { $self->{_filesys}->utime($atime, $mtime, $fname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return 0; }
sub open { my $self = shift; my ($fname, $flags) = @_; my $ret = eval { if ($flags & O_RDONLY) { return -ENOENT() if ($self->{_filesys}->test('f', $fname)); } # parent directory found? my $dir = $fname; $dir =~ s/\/[^\/]+$//; if ($dir eq '' || $self->{_filesys}->test('d', $dir)) { return 0; } else { return -ENOENT(); } }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return $ret; }
sub read { my $self = shift; my ($fname, $size, $offset) = @_; my $ret = eval { $self->{_cache}->read($fname, $size, $offset); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } return $ret; };
sub write { my $self = shift; my ($fname, $buf, $offset) = @_; my $ret = eval { $self->{_cache}->write($fname, $buf, $offset); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return -$!; } # Fuse pod says we must return 'errno', but it does not work... # return written size here. return $ret; }
sub flush { my $self = shift; my ($fname) = @_; return 0; }
sub release { my $self = shift; my ($fname) = @_; eval { $self->{_cache}->release($fname); }; return 0; }
sub fsync { my $self = shift; my ($fname) = @_; eval { $self->flush($fname); }; if ($@) { $self->_debug($@); $! = EPERM if ($! == 0); return $!; } return 0; }
1; # End of Fuse::Filesys::Virtual