diff options
Diffstat (limited to 'perl')
-rw-r--r-- | perl/.cvsignore | 1 | ||||
-rw-r--r-- | perl/Fuse.pm | 27 | ||||
-rw-r--r-- | perl/Fuse.xs | 47 | ||||
-rwxr-xr-x | perl/example.pl | 3 |
4 files changed, 67 insertions, 11 deletions
diff --git a/perl/.cvsignore b/perl/.cvsignore new file mode 100644 index 0000000..5d5c2dc --- /dev/null +++ b/perl/.cvsignore @@ -0,0 +1 @@ +Fuse.bs Fuse.c Makefile blib pm_to_blib diff --git a/perl/Fuse.pm b/perl/Fuse.pm index 93acfb6..3a20fd9 100644 --- a/perl/Fuse.pm +++ b/perl/Fuse.pm @@ -65,8 +65,8 @@ sub AUTOLOAD { bootstrap Fuse $VERSION; sub main { - my (@subs) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); - my (@names) = qw(getattr readlink getdir mknod mkdir unlink rmdir symlink rename link chmod chown truncate utime open read write); + my (@subs) = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + 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=>""); @@ -121,6 +121,14 @@ Every constant you need (file types, open() flags, error values, etc) can be imported either from POSIX or from Fcntl, often both. See their respective documentations, for more information. +=head2 EXPORT + +None by default. + +=head2 EXPORTABLE CONSTANTS + +None. + =head2 FUNCTIONS YOUR FILESYSTEM MAY IMPLEMENT =head3 getattr @@ -278,13 +286,20 @@ Returns an errno. Called in an attempt to write (or overwrite) a portion of the file. Be prepared because $buffer could contain random binary data with NULLs and all sorts of other wonderful stuff. -=head2 EXPORT +=head3 statfs -None by default. +Arguments: none +Returns any of the following: -=head2 Exportable constants +-ENOANO() -None. +or + +$namelen, $files, $files_free, $blocks, $blocks_avail, $blocksize + +or + +-ENOANO(), $namelen, $files, $files_free, $blocks, $blocks_avail, $blocksize =head1 AUTHOR diff --git a/perl/Fuse.xs b/perl/Fuse.xs index ca0459d..6061d9f 100644 --- a/perl/Fuse.xs +++ b/perl/Fuse.xs @@ -24,7 +24,7 @@ constant(char *name, int len, int arg) return 0; } -SV *_PLfuse_callbacks[17]; +SV *_PLfuse_callbacks[18]; int _PLfuse_getattr(const char *file, struct stat *result) { dSP; @@ -472,6 +472,42 @@ int _PLfuse_write (const char *file, const char *buf, size_t buflen, off_t off) return rv; } +int _PLfuse_statfs (struct statfs *st) { + int rv; + char *rvstr; + dSP; + DEBUGf("statfs begin\n"); + ENTER; + SAVETMPS; + PUSHMARK(SP); + PUTBACK; + rv = call_sv(_PLfuse_callbacks[17],G_ARRAY); + SPAGAIN; + if(rv > 5) { + st->f_bsize = POPi; + st->f_bavail = st->f_bfree = POPi; + st->f_blocks = POPi; + st->f_ffree = POPi; + st->f_files = POPi; + st->f_namelen = POPi; + if(rv > 6) + rv = POPi; + else + rv = 0; + } else + if(rv > 1) + croak("inappropriate number of returned values from statfs"); + else + if(rv) + rv = POPi; + else + rv = -ENOSYS; + FREETMPS; + LEAVE; + DEBUGf("statfs end\n"); + return rv; +} + struct fuse_operations _available_ops = { getattr: _PLfuse_getattr, _PLfuse_readlink, @@ -489,7 +525,8 @@ getattr: _PLfuse_getattr, _PLfuse_utime, _PLfuse_open, _PLfuse_read, - _PLfuse_write + _PLfuse_write, + _PLfuse_statfs }; MODULE = Fuse PACKAGE = Fuse @@ -512,13 +549,13 @@ constant(sv,arg) 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}; + 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; char **argv; STRLEN n_a; STRLEN l; INIT: - if(items != 21) { + if(items != 22) { fprintf(stderr,"Perl<->C inconsistency or internal error\n"); XSRETURN_UNDEF; } @@ -544,7 +581,7 @@ perl_fuse_main(...) else argc--; - for(i=0;i<17;i++) { + for(i=0;i<18;i++) { SV *var = ST(i+4); if((var != &PL_sv_undef) && SvROK(var)) { if(SvTYPE(SvRV(var)) == SVt_PVCV) { diff --git a/perl/example.pl b/perl/example.pl index bc62cad..d01278c 100755 --- a/perl/example.pl +++ b/perl/example.pl @@ -70,6 +70,8 @@ sub e_read { return substr($files{$file}{cont},$off,$buf); } +sub e_statfs { return 255, 1, 1, 1, 1, 2 } + # If you run the script directly, it will run fusermount, which will in turn # re-run this script. Hence the funky semantics. my ($mountpoint) = ""; @@ -79,6 +81,7 @@ Fuse::main( getattr=>\&e_getattr, getdir=>\&e_getdir, open=>\&e_open, + statfs=>\&e_statfs, #read=>\&e_read, #debug=>1, threaded=>0 ); |