POE-Component-Fuse
view release on metacpan or search on metacpan
examples/fuse.pl view on Meta::CPAN
# we simply don't support this operation because it would be too complicated for this "basic" script, ha!
$postback->( -ENOSYS() );
return;
}
sub fuse_rename : State {
my( $postback, $context, $path, $newpath ) = @_[ ARG0 .. ARG3 ];
#print "RENAME: '$path' - '$newpath'\n";
if ( exists $files{ $path } ) {
if ( ! exists $files{ $newpath } ) {
# should we add validation to make sure all parents already exist
# seems like mv() and friends check themselves, so we don't have to do it...
# proceed with the rename!
$files{ $newpath } = delete $files{ $path };
$postback->( 0 );
} else {
# destination already exists!
$postback->( -EEXIST() );
}
} else {
# path does not exist
$postback->( -ENOENT() );
}
return;
}
sub fuse_link : State {
my( $postback, $context, $path, $hardlink ) = @_[ ARG0 .. ARG3 ];
#print "LINK: '$path' - '$hardlink'\n";
# we simply don't support this operation because it would be too complicated for this "basic" script, ha!
$postback->( -ENOSYS() );
return;
}
sub fuse_chmod : State {
my( $postback, $context, $path, $modes ) = @_[ ARG0 .. ARG3 ];
print "CHMOD: '$path' - '" . sprintf( "%04o", $modes ) . " - " . mode_to_string( $modes ) . "'\n";
if ( exists $files{ $path } ) {
# okay, update the mode!
$files{ $path }{'mode'} = $modes;
# successful update of mode!
$postback->( 0 );
} else {
# path does not exist
$postback->( -ENOENT() );
}
return;
}
sub fuse_chown : State {
my( $postback, $context, $path, $uid, $gid ) = @_[ ARG0 .. ARG4 ];
#print "CHOWN: '$path' - '$uid' - '$gid'\n";
if ( exists $files{ $path } ) {
# okay, update the ownerships!!
$files{ $path }{'uid'} = $uid;
$files{ $path }{'gid'} = $gid;
# successful update of ownership!
$postback->( 0 );
} else {
# path does not exist
$postback->( -ENOENT() );
}
return;
}
sub fuse_utime : State {
my( $postback, $context, $path, $atime, $mtime ) = @_[ ARG0 .. ARG4 ];
#print "UTIME: '$path' - '$atime' - '$mtime'\n";
if ( exists $files{ $path } ) {
# okay, update the time
$files{ $path }{'atime'} = $atime;
$files{ $path }{'mtime'} = $mtime;
# successful update of time!
$postback->( 0 );
} else {
# path does not exist
$postback->( -ENOENT() );
}
return;
}
sub fuse_statfs : State {
my( $postback, $context ) = @_[ ARG0, ARG1 ];
#print "STATFS\n";
# This is a fake filesystem, so return fake data ;)
# $namelen, $files, $files_free, $blocks, $blocks_avail, $blocksize
$postback->( 255, 1, 1, 1, 1, 2 );
return;
}
sub fuse_fsync : State {
my( $postback, $context, $path, $fsync_mode ) = @_[ ARG0 .. ARG3 ];
#print "FSYNC: '$path' - '$fsync_mode'\n";
# we don't do anything that requires us to do this, so success!
$postback->( 0 );
return;
}
# copied from Fuse::Simple, thanks!
sub dump_open_flags {
( run in 0.396 second using v1.01-cache-2.11-cpan-71847e10f99 )