r72@llin (orig r72): dpavlin | 2006-01-03 16:43:12 +0100
[perl-fuse.git] / Fuse.xs
diff --git a/Fuse.xs b/Fuse.xs
index cbbc80c..ff761dc 100644 (file)
--- a/Fuse.xs
+++ b/Fuse.xs
@@ -541,7 +541,14 @@ int _PLfuse_write (const char *file, const char *buf, size_t buflen, off_t off)
        return rv;
 }
 
-int _PLfuse_statfs (const char *file, struct statfs *st) {
+/* FIXME check for old fuse API (< 21?) and use statfs here */
+#ifdef __FreeBSD__
+ #define _fuse_statvfs statfs
+#else
+ #define _fuse_statvfs statvfs
+#endif
+int _PLfuse_statfs (const char *file, struct _fuse_statvfs *st) {
+
        int rv;
        char *rvstr;
        FUSE_CONTEXT_PRE;
@@ -553,14 +560,24 @@ int _PLfuse_statfs (const char *file, struct statfs *st) {
        PUTBACK;
        rv = call_sv(_PLfuse_callbacks[17],G_ARRAY);
        SPAGAIN;
-       if(rv > 5) {
-               st->f_bsize    = POPi;
-               st->f_bfree    = POPi;
-               st->f_blocks   = POPi;
-               st->f_ffree    = POPi;
-               st->f_files    = POPi;
-               st->f_namelen  = POPi;
-               if(rv > 6)
+       DEBUGf("statfs got %i params\n",rv);
+       if(rv == 6 || rv == 7) {
+               st->f_bsize     = POPi;
+               st->f_bfree     = POPi;
+               st->f_blocks    = POPi;
+               st->f_ffree     = POPi;
+               st->f_files     = POPi;
+               st->f_namemax   = POPi;
+#ifndef __FreeBSD__
+               /* zero and fill-in other */
+               st->f_fsid = 0;
+               st->f_frsize = 4096;
+               st->f_flag = 0;
+               st->f_bavail = st->f_bfree;
+               st->f_favail = st->f_ffree;
+#endif
+
+               if(rv == 7)
                        rv = POPi;
                else
                        rv = 0;