statfs fixes
diff --git a/ChangeLog b/ChangeLog
index 9880259..54cfd16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-19  Miklos Szeredi <mszeredi@inf.bme.hu>
+
+	* statfs library API changed to match other methods.  Since this
+	  is not backward compatible FUSE_MAJOR_VERSION is changed to 2
+
+	* statfs kernel interface changed to 64 bits, added 'bavail' field
+	
 2004-02-18  Miklos Szeredi <mszeredi@inf.bme.hu>
 
 	* user-mount upgraded for 2.6.3 kernel
diff --git a/example/fusexmp.c b/example/fusexmp.c
index 1a96ba5..3c1b601 100644
--- a/example/fusexmp.c
+++ b/example/fusexmp.c
@@ -233,19 +233,15 @@
     return res;
 }
 
-static int xmp_statfs(struct fuse_statfs *fst)
+static int xmp_statfs(const char *path, struct statfs *stbuf)
 {
-    struct statfs st;
-    int rv = statfs("/",&st);
-    if(!rv) {
-    	fst->block_size  = st.f_bsize;
-    	fst->blocks      = st.f_blocks;
-    	fst->blocks_free = st.f_bavail;
-    	fst->files       = st.f_files;
-    	fst->files_free  = st.f_ffree;
-    	fst->namelen     = st.f_namelen;
-    }
-    return rv;
+    int res;
+
+    res = statfs(path, stbuf);
+    if(res == -1)
+        return -errno;
+
+    return 0;
 }
 
 static int xmp_release(const char *path, int flags)
diff --git a/example/null.c b/example/null.c
index f9ead78..d897e92 100644
--- a/example/null.c
+++ b/example/null.c
@@ -64,19 +64,12 @@
     return size;
 }
 
-static int null_statfs(struct fuse_statfs *st)
-{
-    return st->block_size = st->blocks = st->blocks_free = st->files =
-	st->files_free = st->namelen = 0;
-}
-
 static struct fuse_operations null_oper = {
     .getattr	= null_getattr,
     .truncate	= null_truncate,
     .open	= null_open,
     .read	= null_read,
     .write	= null_write,
-    .statfs	= null_statfs,
 };
 
 int main(int argc, char *argv[])
diff --git a/include/fuse.h b/include/fuse.h
index c2f0be4..7fdcc6e 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -12,7 +12,7 @@
 /* This file defines the library interface of FUSE */
 
 /** Major version of FUSE library interface */
-#define FUSE_MAJOR_VERSION 1
+#define FUSE_MAJOR_VERSION 2
 
 /** Minor version of FUSE library interface */
 #define FUSE_MINOR_VERSION 1
@@ -22,6 +22,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/statfs.h>
 #include <utime.h>
 
 /* ----------------------------------------------------------- *
@@ -31,16 +32,6 @@
 /** Handle for a FUSE filesystem */
 struct fuse;
 
-/* Statfs structure used by FUSE */
-struct fuse_statfs {
-    long block_size;
-    long blocks;
-    long blocks_free;
-    long files;
-    long files_free;
-    long namelen;
-};
-
 /** Handle for a getdir() operation */
 typedef struct fuse_dirhandle *fuse_dirh_t;
 
@@ -117,7 +108,7 @@
     int (*open)     (const char *, int);
     int (*read)     (const char *, char *, size_t, off_t);
     int (*write)    (const char *, const char *, size_t, off_t);
-    int (*statfs)   (struct fuse_statfs *);
+    int (*statfs)   (const char *, struct statfs *);
     int (*release)  (const char *, int);
     int (*fsync)    (const char *, int);
 };
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 909c8b0..2b516a5 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -9,10 +9,10 @@
 /* This file defines the kernel interface of FUSE */
 
 /** Version number of this interface */
-#define FUSE_KERNEL_VERSION 2
+#define FUSE_KERNEL_VERSION 3
 
 /** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 2
+#define FUSE_KERNEL_MINOR_VERSION 1
 
 /** The inode number of the root indode */
 #define FUSE_ROOT_INO 1
@@ -74,12 +74,13 @@
 };
 
 struct fuse_kstatfs {
-    long block_size;
-    long blocks;
-    long blocks_free;
-    long files;
-    long files_free;
-    long namelen;
+	unsigned int        bsize;
+	unsigned long long  blocks;
+	unsigned long long  bfree;
+	unsigned long long  bavail;
+	unsigned long long  files;
+	unsigned long long  ffree;
+	unsigned int        namelen;
 };
 
 #define FATTR_MODE	(1 << 0)
diff --git a/kernel/inode.c b/kernel/inode.c
index 257b41d..9ab0dc3 100644
--- a/kernel/inode.c
+++ b/kernel/inode.c
@@ -79,15 +79,14 @@
 static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr)
 {
 	stbuf->f_type    = FUSE_SUPER_MAGIC;
-	stbuf->f_bsize   = attr->block_size;
+	stbuf->f_bsize   = attr->bsize;
 	stbuf->f_blocks  = attr->blocks;
-	stbuf->f_bfree   = stbuf->f_bavail = attr->blocks_free;
+	stbuf->f_bfree   = attr->bfree;
+	stbuf->f_bavail  = attr->bavail;
 	stbuf->f_files   = attr->files;
-	stbuf->f_ffree   = attr->files_free;
-	/* Is this field necessary?  Most filesystems ignore it...
-	stbuf->f_fsid.val[0] = (FUSE_SUPER_MAGIC>>16)&0xffff;
-	stbuf->f_fsid.val[1] =  FUSE_SUPER_MAGIC     &0xffff; */
+	stbuf->f_ffree   = attr->ffree;
 	stbuf->f_namelen = attr->namelen;
+	/* fsid is left zero */
 }
 
 static int fuse_statfs(struct super_block *sb, struct kstatfs *buf)
diff --git a/lib/fuse.c b/lib/fuse.c
index 7aa1eca..ffb3489 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -853,15 +853,30 @@
     send_reply(f, in, res, NULL, 0);
 }
 
+static void convert_statfs(struct statfs *statfs, struct fuse_kstatfs *kstatfs)
+{
+    kstatfs->bsize	= statfs->f_bsize;
+    kstatfs->blocks	= statfs->f_blocks;
+    kstatfs->bfree	= statfs->f_bfree;
+    kstatfs->bavail	= statfs->f_bavail;
+    kstatfs->files	= statfs->f_files;
+    kstatfs->ffree	= statfs->f_ffree;
+    kstatfs->namelen	= statfs->f_namelen;
+}
+
 static void do_statfs(struct fuse *f, struct fuse_in_header *in)
 {
     int res;
     struct fuse_statfs_out arg;
+    struct statfs buf;
 
     res = -ENOSYS;
     if(f->op.statfs) {
-        memset(&arg, 0, sizeof(struct fuse_statfs_out));
-        res = f->op.statfs((struct fuse_statfs *) &arg.st);
+        res = f->op.statfs("/", &buf);
+        if(res == 0) {
+            memset(&arg, 0, sizeof(struct fuse_statfs_out));
+            convert_statfs(&buf, &arg.st);
+        }
     }
 
     send_reply(f, in, res, &arg, sizeof(arg));