no longer link against efence
authorMark Glines <mark@glines.org>
Mon, 11 Mar 2002 12:07:47 +0000 (12:07 +0000)
committerMark Glines <mark@glines.org>
Mon, 11 Mar 2002 12:07:47 +0000 (12:07 +0000)
add documentation for Fuse::main() and the optional flags (and mountpoint)
fix the multithreading/debug flag stuff
turn off multithreading by default (makes read() stable!)

perl/Fuse.pm
perl/Fuse.xs
perl/Makefile.PL
perl/loopback.pl

index 3a20fd931f47ccf02d0220a1f6dbcecf720a8cc0..5e1848393011716c8fa6bc766cf42f8e2882923a 100644 (file)
@@ -69,7 +69,7 @@ sub main {
        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})) {
@@ -82,7 +82,9 @@ sub main {
                        $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.
@@ -129,6 +131,53 @@ None by default.
 
 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
index b3ea053d6d9746e0e5f0166f70013b7ecb11a241..f197449222218c6d749f7f17d897b802b54c7c3f 100644 (file)
@@ -538,7 +538,7 @@ void
 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;
@@ -548,27 +548,48 @@ perl_fuse_main(...)
                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)) {
index 17ccb51bbdef3270a9c72915593c418b7c02e326..d495683ccb7d26ba48afb678aca5ac70bb93f66c 100644 (file)
@@ -8,7 +8,7 @@ WriteMakefile(
     ($] >= 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'
index 4a531e258da5d04f4be6cf9bf978d0f651405a03..c055db58fd6e8f2af70135acad564d326723998e 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/debugperl 
 
 use strict;
 use Fuse;
@@ -104,7 +104,25 @@ sub x_mknod {
 
 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
 );