my (@names) = qw(getattr readlink getdir mknod mkdir unlink rmdir symlink rename link chmod chown truncate utime open read write statfs);
my ($tmp) = 0;
my (%mapping) = map { $_ => $tmp++ } (@names);
- my (%otherargs) = (debug=>0, threaded=>1, mountpoint=>"");
+ my (%otherargs) = (debug=>0, unthreaded=>1, mountpoint=>"");
while(my $name = shift) {
my ($subref) = shift;
if(exists($otherargs{$name})) {
$subs[$mapping{$name}] = $subref;
}
}
- perl_fuse_main($0,$otherargs{threaded},$otherargs{debug},$otherargs{mountpoint},@subs);
+ print "flag: debug\n" if $otherargs{debug};
+ print "flag: unthreaded\n" if $otherargs{unthreaded};
+ perl_fuse_main($0,$otherargs{unthreaded},$otherargs{debug},$otherargs{mountpoint},@subs);
}
# Autoload methods go after =cut, and are processed by the autosplit program.
None.
+=head2 FUNCTIONS
+
+=head3 Fuse::main
+
+Takes arguments in the form of hash key=>value pairs. There are
+many valid keys. Most of them correspond with names of callback
+functions, as described in section 'FUNCTIONS YOUR FILESYSTEM MAY IMPLEMENT'.
+A few special keys also exist:
+
+
+debug => boolean
+
+=over 1
+
+This turns FUSE call tracing on and off. Default is 0 (which means off).
+
+=back
+
+mountpoint => string
+
+=over 1
+
+The point at which to mount this filesystem. There is no default, you must
+specify this. An example would be '/mnt'.
+
+=back
+
+unthreaded => boolean
+
+=over 1
+
+This turns FUSE multithreading off and on. NOTE: This perlmodule does not
+currently work properly in multithreaded mode! The author is unfortunately
+not familiar enough with perl-threads internals, and according to the
+documentation available at time of writing (2002-03-08), those internals are
+subject to changing anyway. Note that singlethreaded mode also means that
+you will not have to worry about reentrancy, though you will have to worry
+about recursive lookups (since the kernel holds a global lock on your
+filesystem and blocks waiting for one callback to complete before calling
+another).
+
+I hope to add full multithreading functionality later, but for now, I
+recommend you leave this option at the default, 1 (which means
+unthreaded, no threads will be used and no reentrancy is needed).
+
+=back
+
=head2 FUNCTIONS YOUR FILESYSTEM MAY IMPLEMENT
=head3 getattr
perl_fuse_main(...)
PREINIT:
struct fuse_operations fops = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
- int i, varnum = 0, threads, debug, argc;
+ int i, varnum = 0, nothreads, debug, argc, have_mnt;
char **argv;
STRLEN n_a;
STRLEN l;
XSRETURN_UNDEF;
}
CODE:
- threads = !SvIV(ST(1));
- debug = SvIV(ST(2));
- if(threads && debug) {
- argc = 4;
- argv = ((char*[]){NULL,NULL,"-s","-d"});
- } else if(threads) {
- argc = 3;
- argv = ((char*[]){NULL,NULL,"-s"});
- } else if(debug) {
- argc = 3;
- argv = ((char*[]){NULL,NULL,"-d"});
- } else {
- argc = 2;
- argv = ((char*[]){"str","mnt"});
+ /* how annoying. */
+ nothreads = SvIV(ST(1)) ? 1 : 0;
+ debug = SvIV(ST(2)) ? 1 : 0;
+ have_mnt = strlen(SvPV(ST(3),n_a)) ? 1 : 0;
+ switch(have_mnt<<2 | debug<<1 | nothreads) {
+ case 0: /* !nothreads !debug !mnt */
+ argv = ((char*[]){NULL});
+ argc = 1;
+ break;
+ case 1: /* nothreads !debug !mnt */
+ argv = ((char*[]){NULL,"-s"});
+ argc = 2;
+ break;
+ case 2: /* !nothreads debug !mnt */
+ argv = ((char*[]){NULL,"-d"});
+ argc = 2;
+ break;
+ case 3: /* nothreads debug !mnt */
+ argv = ((char*[]){NULL,"-s","-d"});
+ argc = 3;
+ break;
+ case 4: /* !nothreads !debug mnt */
+ argv = ((char*[]){NULL,NULL});
+ argc = 2;
+ break;
+ case 5: /* nothreads !debug mnt */
+ argv = ((char*[]){NULL,NULL,"-s"});
+ argc = 3;
+ break;
+ case 6: /* !nothreads debug mnt */
+ argv = ((char*[]){NULL,NULL,"-d"});
+ argc = 3;
+ break;
+ case 7: /* nothreads debug mnt */
+ argv = ((char*[]){NULL,NULL,"-s","-d"});
+ argc = 4;
+ break;
}
argv[0] = SvPV(ST(0),n_a);
- if(strlen(SvPV(ST(3),n_a)))
+ if(have_mnt)
argv[1] = SvPV(ST(3),n_a);
- else
- argc--;
-
+ printf("%i %i %i\n",nothreads,debug,have_mnt);
for(i=0;i<18;i++) {
SV *var = ST(i+4);
if((var != &PL_sv_undef) && SvROK(var)) {
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'Fuse.pm', # retrieve abstract from module
AUTHOR => 'Mark Glines <mark@glines.org>') : ()),
- 'LIBS' => ['-lefence'], # e.g., '-lm'
+ 'LIBS' => [''], # e.g., '-lm'
'DEFINE' => '-g -ggdb', # e.g., '-DHAVE_SOMETHING'
# Insert -I. if you add *.h files later:
'INC' => '-I../include', # e.g., '-I/usr/include/other'
-#!/usr/bin/perl
+#!/usr/bin/debugperl
use strict;
use Fuse;
my ($mountpoint) = "";
$mountpoint = shift(@ARGV) if @ARGV;
-Fuse::main(mountpoint=>$mountpoint, getattr=>\&x_getattr, readlink=>\&x_readlink, getdir=>\&x_getdir, mknod=>\&x_mknod,
- mkdir=>\&x_mkdir, unlink=>\&x_unlink, rmdir=>\&x_rmdir, symlink=>\&x_symlink, rename=>\&x_rename, link=>\&x_link,
- chmod=>\&x_chmod, chown=>\&x_chown, truncate=>\&x_truncate, utime=>\&x_utime, open=>\&x_open, read=>\&x_read, write=>\&x_write
+Fuse::main(
+ unthreaded=>1,
+ debug=>1,
+ mountpoint=>$mountpoint,
+ getattr=>\&x_getattr,
+ readlink=>\&x_readlink,
+ getdir=>\&x_getdir,
+ mknod=>\&x_mknod,
+ mkdir=>\&x_mkdir,
+ unlink=>\&x_unlink,
+ rmdir=>\&x_rmdir,
+ symlink=>\&x_symlink,
+ rename=>\&x_rename,
+ link=>\&x_link,
+ chmod=>\&x_chmod,
+ chown=>\&x_chown,
+ truncate=>\&x_truncate,
+ utime=>\&x_utime,
+ open=>\&x_open,
+ read=>\&x_read,
+ write=>\&x_write
);