From 29c93235b9032b0f58c99563e5a30c6bd33d8dd0 Mon Sep 17 00:00:00 2001 From: Mark Glines Date: Fri, 15 Feb 2002 07:30:16 +0000 Subject: [PATCH] fixed mkdir/rmdir killed some debug messages in tested code, added some in untested stuff updated the readme --- perl/Fuse.xs | 41 ++--------------------------------------- perl/Makefile.PL | 2 +- perl/README | 33 +++++++++++++++++++++++++++++++++ perl/loopback.pl | 17 ++++------------- 4 files changed, 40 insertions(+), 53 deletions(-) diff --git a/perl/Fuse.xs b/perl/Fuse.xs index 23f87ae..b3ea053 100644 --- a/perl/Fuse.xs +++ b/perl/Fuse.xs @@ -10,26 +10,12 @@ #else #define DEBUGf(a...) #endif -static int -not_here(char *s) -{ - croak("%s not implemented on this architecture", s); - return -1; -} - -static double -constant(char *name, int len, int arg) -{ - errno = ENOENT; - return 0; -} SV *_PLfuse_callbacks[18]; int _PLfuse_getattr(const char *file, struct stat *result) { dSP; int rv, statcount; - DEBUGf("getattr begin: %i\n",sp-PL_stack_base); ENTER; SAVETMPS; PUSHMARK(SP); @@ -64,7 +50,6 @@ int _PLfuse_getattr(const char *file, struct stat *result) { FREETMPS; LEAVE; PUTBACK; - DEBUGf("getattr end: %i\n",sp-PL_stack_base); return rv; } @@ -73,7 +58,6 @@ int _PLfuse_readlink(const char *file,char *buf,size_t buflen) { char *rvstr; dSP; I32 ax; - DEBUGf("readlink begin: %i\n",sp-PL_stack_base); if(buflen < 1) return EINVAL; ENTER; @@ -87,7 +71,6 @@ int _PLfuse_readlink(const char *file,char *buf,size_t buflen) { rv = -ENOENT; else { SV *mysv = POPs; - DEBUGf("type = %i\n",SvTYPE(mysv)); if(SvTYPE(mysv) == SVt_IV || SvTYPE(mysv) == SVt_NV) rv = SvIV(mysv); else { @@ -97,17 +80,14 @@ int _PLfuse_readlink(const char *file,char *buf,size_t buflen) { } FREETMPS; LEAVE; - DEBUGf("ribbit3: %i (%s)\n",rv,buf); buf[buflen-1] = 0; PUTBACK; - DEBUGf("readlink end: %i\n",sp-PL_stack_base); return rv; } int _PLfuse_getdir(const char *file, fuse_dirh_t dirh, fuse_dirfil_t dirfil) { int prv, rv; dSP; - DEBUGf("getdir begin: %i\n",sp-PL_stack_base); ENTER; SAVETMPS; PUSHMARK(SP); @@ -126,7 +106,6 @@ int _PLfuse_getdir(const char *file, fuse_dirh_t dirh, fuse_dirfil_t dirfil) { FREETMPS; LEAVE; PUTBACK; - DEBUGf("getdir end: %i\n",sp-PL_stack_base); return rv; } @@ -135,7 +114,6 @@ int _PLfuse_mknod (const char *file, mode_t mode, dev_t dev) { SV *rvsv; char *rvstr; dSP; - DEBUGf("mknod begin: %i\n",sp-PL_stack_base); ENTER; SAVETMPS; PUSHMARK(SP); @@ -152,7 +130,6 @@ int _PLfuse_mknod (const char *file, mode_t mode, dev_t dev) { FREETMPS; LEAVE; PUTBACK; - DEBUGf("mknod end: %i\n",sp-PL_stack_base); return rv; } @@ -177,7 +154,7 @@ int _PLfuse_mkdir (const char *file, mode_t mode) { FREETMPS; LEAVE; PUTBACK; - DEBUGf("mkdir end: %i\n",sp-PL_stack_base); + DEBUGf("mkdir end: %i %i\n",sp-PL_stack_base,rv); return rv; } @@ -226,7 +203,7 @@ int _PLfuse_rmdir (const char *file) { FREETMPS; LEAVE; PUTBACK; - DEBUGf("rmdir end: %i\n",sp-PL_stack_base); + DEBUGf("rmdir end: %i %i\n",sp-PL_stack_base,rv); return rv; } @@ -557,20 +534,6 @@ getattr: _PLfuse_getattr, MODULE = Fuse PACKAGE = Fuse PROTOTYPES: DISABLE - -double -constant(sv,arg) - PREINIT: - STRLEN len; - INPUT: - SV * sv - char * s = SvPV(sv, len); - int arg - CODE: - RETVAL = constant(s,len,arg); - OUTPUT: - RETVAL - void perl_fuse_main(...) PREINIT: diff --git a/perl/Makefile.PL b/perl/Makefile.PL index d495683..17ccb51 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' => [''], # e.g., '-lm' + 'LIBS' => ['-lefence'], # 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/README b/perl/README index b22b87e..ce80884 100644 --- a/perl/README +++ b/perl/README @@ -24,3 +24,36 @@ This is contributed to the FUSE project by Mark Glines , and is therefore subject to the same license and copyright as FUSE itself. Please see the AUTHORS and COPYING files from the FUSE distribution for more information. + +BUGS + +Currently theres a huge problem with atomicity - putting an md5sum or something +in a while loop, and cd'ing into the mountpoint from a different directory +causes some interesting failures. For normal perl, every call should grab a +global lock. For thread-perl, I'm gonna have to do some research to figure out +the best solution. + +Quite a few things aren't tested. + +The tested (and seemingly working) stuff includes: +getattr +readlink +getdir +mknod +mkdir +unlink +rmdir +open +read +statfs + +which leaves: +symlink +rename +link +chmod +chown +truncate +utime +write + diff --git a/perl/loopback.pl b/perl/loopback.pl index a962993..4a531e2 100644 --- a/perl/loopback.pl +++ b/perl/loopback.pl @@ -14,35 +14,24 @@ sub fixup { return "/tmp/test" . shift } sub x_getattr { my ($file) = fixup(shift); - debug("getattr $file"); return -ENOENT() unless -e $file; - debug(lstat($file)); return (lstat($file)); } sub x_getdir { my ($dirname) = fixup(shift); - debug("getdir >$dirname<"); unless(opendir(DIRHANDLE,$dirname)) { - debug("ENOENT"); return -ENOENT(); } - debug("ok"); my (@files) = readdir(DIRHANDLE); closedir(DIRHANDLE); - debug(@files); return (@files, 0); } sub x_open { my ($file) = fixup(shift); - debug("open flags = $_[0]"); my ($fd) = POSIX::open($file,@_); - if(!defined($fd)) { - debug("POSIX::open(".join(",",$file,@_).") returned undef"); - return -ENOSYS(); - } - debug("open $file = $fd"); + return -ENOSYS() if(!defined($fd)); return $fd if $fd < 0; POSIX::close($fd); return 0; @@ -83,13 +72,15 @@ sub x_rmdir { return err(rmdir(fixup(shift)) ); } sub x_symlink { return err(symlink(fixup(shift),fixup(shift))); } sub x_rename { return err(rename(fixup(shift),fixup(shift)) ); } sub x_link { return err(link(fixup(shift),fixup(shift)) ); } -sub x_mkdir { return err(mkdir(fixup(shift),shift) ); } sub x_chmod { return err(chmod(fixup(shift),shift) ); } sub x_chown { return err(chown(fixup(shift),shift,shift) ); } sub x_chmod { return err(chmod(fixup(shift),shift) ); } sub x_truncate { return truncate(fixup(shift),shift) ? 0 : -$! ; } sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; } +sub x_mkdir { my ($name, $perm) = @_; return 0 if mkdir(fixup($name),$perm); return -$!; } +sub x_rmdir { return 0 if rmdir fixup(shift); return -$!; } + sub x_mknod { # since this is called for ALL files, not just devices, I'll do some checks # and possibly run the real mknod command. -- 2.30.2