From: Miklos Szeredi Date: Thu, 25 Mar 2004 11:17:52 +0000 (+0000) Subject: default statfs X-Git-Tag: fuse_1_9~76 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=77f39949dc5174bc42be9ecf2dda6119e1dd506b;p=qemu-gpiodev%2Flibfuse.git default statfs --- diff --git a/ChangeLog b/ChangeLog index d0334cd..32a32ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-03-25 Miklos Szeredi + + * If filesystem doesn't define a statfs operation, then an + all-zero default statfs is returned instead of ENOSYS + 2004-03-24 Miklos Szeredi * Add FS_BINARY_MOUNTDATA filesystem flag for kernels > 2.6.4 diff --git a/lib/fuse.c b/lib/fuse.c index 27e331a..2ca30bb 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -914,6 +914,13 @@ static void do_write(struct fuse *f, struct fuse_in_header *in, send_reply(f, in, res, NULL, 0); } +static int default_statfs(struct statfs *buf) +{ + buf->f_namelen = 255; + buf->f_bsize = 512; + return 0; +} + static void convert_statfs(struct statfs *statfs, struct fuse_kstatfs *kstatfs) { kstatfs->bsize = statfs->f_bsize; @@ -931,14 +938,14 @@ static void do_statfs(struct fuse *f, struct fuse_in_header *in) struct fuse_statfs_out arg; struct statfs buf; - res = -ENOSYS; - if(f->op.statfs) { + memset(&buf, 0, sizeof(struct statfs)); + if(f->op.statfs) res = f->op.statfs("/", &buf); - if(res == 0) { - memset(&arg, 0, sizeof(struct fuse_statfs_out)); - convert_statfs(&buf, &arg.st); - } - } + else + res = default_statfs(&buf); + + if(res == 0) + convert_statfs(&buf, &arg.st); send_reply(f, in, res, &arg, sizeof(arg)); } diff --git a/lufis/lufis.c b/lufis/lufis.c index 38bc60a..f91c1e0 100644 --- a/lufis/lufis.c +++ b/lufis/lufis.c @@ -551,6 +551,13 @@ static int lu_release(const char *path, int flags) return 0; } +static int lu_default_statfs(struct statfs *buf) +{ + buf->f_namelen = 255; + buf->f_bsize = 512; + return 0; +} + #if FUSE_MAJOR_VERSION < 2 static int lu_statfs(struct fuse_statfs *stbuf) #else @@ -560,7 +567,7 @@ static int lu_statfs(const char *path, struct statfs *stbuf) struct lufs_sbattr_ sbattr; if(!lu_fops.statfs) - return -ENOSYS; + return lu_default_statfs(stbuf); memset(&sbattr, 0, sizeof(sbattr)); if(lu_fops.statfs(lu_context, &sbattr) < 0)