From: Mark Glines Date: Mon, 11 Mar 2002 12:07:47 +0000 (+0000) Subject: no longer link against efence X-Git-Tag: debian_version_0_95-1~8 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3e3d081d28ff60331d791ae9bc4e1f8d98701d86;p=qemu-gpiodev%2Flibfuse.git no longer link against efence 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!) --- diff --git a/perl/Fuse.pm b/perl/Fuse.pm index 3a20fd9..5e18483 100644 --- a/perl/Fuse.pm +++ b/perl/Fuse.pm @@ -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 diff --git a/perl/Fuse.xs b/perl/Fuse.xs index b3ea053..f197449 100644 --- a/perl/Fuse.xs +++ b/perl/Fuse.xs @@ -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)) { diff --git a/perl/Makefile.PL b/perl/Makefile.PL index 17ccb51..d495683 100644 --- a/perl/Makefile.PL +++ b/perl/Makefile.PL @@ -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 ') : ()), - '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' diff --git a/perl/loopback.pl b/perl/loopback.pl index 4a531e2..c055db5 100644 --- a/perl/loopback.pl +++ b/perl/loopback.pl @@ -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 );