statfs fixes
authorMiklos Szeredi <miklos@szeredi.hu>
Thu, 19 Feb 2004 14:23:27 +0000 (14:23 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Thu, 19 Feb 2004 14:23:27 +0000 (14:23 +0000)
ChangeLog
example/fusexmp.c
example/null.c
include/fuse.h
include/linux/fuse.h
kernel/inode.c
lib/fuse.c

index 98802590806987e6b859f0f7b164374ed0d42d68..54cfd16a54e527fe76e71b28c922fda085bd79ca 100644 (file)
--- 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
index 1a96ba546ddd96a7b3dfdfd1fa71a91896fe92b9..3c1b601cb4ecdb00a4237afab4abd8870747039a 100644 (file)
@@ -233,19 +233,15 @@ static int xmp_write(const char *path, const char *buf, size_t size,
     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)
index f9ead7826ab30b69d0260ad06861cdbd7ffd0de1..d897e92c050caff02bc11b5ea2cc8e139349ad94 100644 (file)
@@ -64,19 +64,12 @@ static int null_write(const char *path, const char *UNUSED(buf), size_t size,
     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[])
index c2f0be4b40847d4435fa2ffddc28a3017790bad6..7fdcc6ea9c56ef1e7cf7ac28c2cd01429f36a6e4 100644 (file)
@@ -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>
 
 /* ----------------------------------------------------------- *
 /** 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 @@ struct fuse_operations {
     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);
 };
index 909c8b055ca9ffab3501380706d00734d40fcc27..2b516a5782683079222e51edbdc73edd81085025 100644 (file)
@@ -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_attr {
 };
 
 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)
index 257b41d0f4178316f8cbda603ae0e65141cca381..9ab0dc3df3a7305e380de2e40d26abc4eb9f4bfc 100644 (file)
@@ -79,15 +79,14 @@ static void fuse_put_super(struct super_block *sb)
 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)
index 7aa1eca73a6976e856b16edccae49954b08d458b..ffb348934ac5edda819c1e8047c483d66beabfbc 100644 (file)
@@ -853,15 +853,30 @@ static void do_write(struct fuse *f, struct fuse_in_header *in,
     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));