From d84b39ac42882a2cc2e7f85ed5f02ada03744d9e Mon Sep 17 00:00:00 2001 From: Mark Glines Date: Mon, 7 Jan 2002 16:32:02 +0000 Subject: Added statfs support to kernel, lib, examples, and perl other minor perl fixes (still unstable) --- lib/fuse.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/fuse.c') diff --git a/lib/fuse.c b/lib/fuse.c index 98bab3f..88f3eae 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -306,6 +306,16 @@ static void convert_stat(struct stat *stbuf, struct fuse_attr *attr) attr->_dummy = 4096; } +static void convert_statfs(struct statfs *st, struct fuse_statfs *fst) +{ + 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; +} + static int fill_dir(struct fuse_dirhandle *dh, char *name, int type) { struct fuse_dirent dirent; @@ -793,6 +803,20 @@ static void do_write(struct fuse *f, struct fuse_in_header *in, send_reply(f, in, res, NULL, 0); } +static void do_statfs(struct fuse *f, struct fuse_in_header *in) +{ + int res; + struct statfs sbuf; + struct fuse_statfs_out arg; + + res = -ENOSYS; + if(f->op.statfs) + res = f->op.statfs(&sbuf); + if(!res) + convert_statfs(&sbuf,&arg.st); + send_reply(f, in, res, &arg, sizeof(arg)); +} + static void free_cmd(struct fuse_cmd *cmd) { free(cmd->buf); @@ -878,6 +902,10 @@ void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd) do_write(f, in, (struct fuse_write_in *) inarg); break; + case FUSE_STATFS: + do_statfs(f, in); + break; + default: fprintf(stderr, "Operation %i not implemented\n", in->opcode); send_reply(f, in, -ENOSYS, NULL, 0); -- cgit v1.2.3