/[fuse.before_github]/perl-llin/Fuse.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /perl-llin/Fuse.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 17 by dpavlin, Wed Jun 22 16:15:17 2005 UTC revision 18 by dpavlin, Wed Dec 21 15:33:37 2005 UTC
# Line 85  sub main { Line 85  sub main {
85          my ($tmp) = 0;          my ($tmp) = 0;
86          my (%mapping) = map { $_ => $tmp++ } (@names);          my (%mapping) = map { $_ => $tmp++ } (@names);
87          my (%optmap) = map { $_ => 1 } (@validOpts);          my (%optmap) = map { $_ => 1 } (@validOpts);
88          my (%otherargs) = (debug=>0, mountpoint=>"", mountopts=>"");          my (%otherargs) = (debug=>0, threaded=>0, mountpoint=>"", mountopts=>"");
89          while(my $name = shift) {          while(my $name = shift) {
90                  my ($subref) = shift;                  my ($subref) = shift;
91                  if(exists($otherargs{$name})) {                  if(exists($otherargs{$name})) {
92                          $otherargs{$name} = $subref;                          $otherargs{$name} = $subref;
93                  } else {                  } else {
94                          croak "There is no function $name" unless exists($mapping{$name});                          croak "There is no function $name" unless exists($mapping{$name});
95                          croak "Usage: Fuse::main(getattr => &my_getattr, ...)" unless $subref;                          croak "Usage: Fuse::main(getattr => \"main::my_getattr\", ...)" unless $subref;
                         croak "Usage: Fuse::main(getattr => &my_getattr, ...)" unless ref($subref);  
                         croak "Usage: Fuse::main(getattr => &my_getattr, ...)" unless ref($subref) eq "CODE";  
96                          $subs[$mapping{$name}] = $subref;                          $subs[$mapping{$name}] = $subref;
97                  }                  }
98          }          }
# Line 103  sub main { Line 101  sub main {
101              croak "Use of an invalid mountopt argument";              croak "Use of an invalid mountopt argument";
102            }            }
103          }          }
104          perl_fuse_main($otherargs{debug},$otherargs{mountpoint},$otherargs{mountopts},@subs);          perl_fuse_main($otherargs{debug},$otherargs{threaded},$otherargs{mountpoint},$otherargs{mountopts},@subs);
105  }  }
106    
107  # Autoload methods go after =cut, and are processed by the autosplit program.  # Autoload methods go after =cut, and are processed by the autosplit program.
# Line 120  Fuse - write filesystems in Perl using F Line 118  Fuse - write filesystems in Perl using F
118    use Fuse;    use Fuse;
119    my ($mountpoint) = "";    my ($mountpoint) = "";
120    $mountpoint = shift(@ARGV) if @ARGV;    $mountpoint = shift(@ARGV) if @ARGV;
121    Fuse::main(mountpoint=>$mountpoint, getattr=>\&my_getattr, getdir=>\&my_getdir, ...);    Fuse::main(mountpoint=>$mountpoint, getattr=>"main::my_getattr", getdir=>"main::my_getdir", ...);
122    
123  =head1 DESCRIPTION  =head1 DESCRIPTION
124    
# Line 129  This lets you implement filesystems in p Line 127  This lets you implement filesystems in p
127    
128  FUSE expects you to implement callbacks for the various functions.  FUSE expects you to implement callbacks for the various functions.
129    
 NOTE:  I have only tested the things implemented in example.pl!  
 It should work, but some things may not.  
   
130  In the following definitions, "errno" can be 0 (for a success),  In the following definitions, "errno" can be 0 (for a success),
131  -EINVAL, -ENOENT, -EONFIRE, any integer less than 1 really.  -EINVAL, -ENOENT, -EONFIRE, any integer less than 1 really.
132    
# Line 197  need 'user_allow_other' in /etc/fuse.con Line 192  need 'user_allow_other' in /etc/fuse.con
192    
193  =back  =back
194    
195  unthreaded => boolean  threaded => boolean
196    
197  =over 1  =over 1
198    
199  This turns FUSE multithreading off and on.  NOTE: This perlmodule does not  This turns FUSE multithreading on and off.  The default is 0, meaning your FUSE
200  currently work properly in multithreaded mode!  The author is unfortunately  script will run in single-threaded mode.  Note that single-threaded mode also
201  not familiar enough with perl-threads internals, and according to the  means that you will not have to worry about reentrancy, though you will have to
202  documentation available at time of writing (2002-03-08), those internals are  worry about recursive lookups.  In single-threaded mode, FUSE holds a global
203  subject to changing anyway.  Note that singlethreaded mode also means that  lock on your filesystem, and will wait for one callback to return before
204  you will not have to worry about reentrancy, though you will have to worry  calling another.  This can lead to deadlocks, if your script makes any attempt
205  about recursive lookups (since the kernel holds a global lock on your  to access files or directories in the filesystem it is providing.  (This
206  filesystem and blocks waiting for one callback to complete before calling  includes calling stat() on the mount-point, statfs() calls from the 'df'
207  another).  command, and so on and so forth.)  It is worth paying a little attention and
208    being careful about this.
209  I hope to add full multithreading functionality later, but for now, I  
210  recommend you leave this option at the default, 1 (which means  Enabling multithreading will cause FUSE to make multiple simultaneous calls
211  unthreaded, no threads will be used and no reentrancy is needed).  into the various callback functions of your perl script.  If you enable
212    threaded mode, you can enjoy all the parallel execution and interactive
213    response benefits of threads, and you get to enjoy all the benefits of race
214    conditions and locking bugs, too.  Please also ensure any other perl modules
215    you're using are also thread-safe.
216    
217    (If enabled, this option will cause a warning if your perl interpreter was not
218    built with USE_ITHREADS.)
219    
220  =back  =back
221    

Legend:
Removed from v.17  
changed lines
  Added in v.18

  ViewVC Help
Powered by ViewVC 1.1.26