fixed mkdir/rmdir
authorMark Glines <mark@glines.org>
Fri, 15 Feb 2002 07:30:16 +0000 (07:30 +0000)
committerMark Glines <mark@glines.org>
Fri, 15 Feb 2002 07:30:16 +0000 (07:30 +0000)
killed some debug messages in tested code, added some in untested stuff
updated the readme

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

index 23f87ae33b9761996f117375b91f40850b2e1343..b3ea053d6d9746e0e5f0166f70013b7ecb11a241 100644 (file)
 #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:
index d495683ccb7d26ba48afb678aca5ac70bb93f66c..17ccb51bbdef3270a9c72915593c418b7c02e326 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'             => [''], # 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'
index b22b87eedaf5ab02d3309e279f75e51d3e06fa3a..ce808844636f38468570ec0ca4b272c159ebab5b 100644 (file)
@@ -24,3 +24,36 @@ This is contributed to the FUSE project by Mark Glines <mark@glines.org>,
 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
+
index a962993d7915372f37de8d7f7fef950a00e2ff2d..4a531e258da5d04f4be6cf9bf978d0f651405a03 100644 (file)
@@ -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.