aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-08-18 18:43:50 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2006-08-18 18:43:50 +0000
commit3ded1a3176bb803e016e79d0e6db5e1f3ea30473 (patch)
treed67302d0f48290b6f865fff4a8f4d162e808439a /lib/fuse.c
parent63d3c40e1fa56176a61df9ea6d430de4362aa77b (diff)
downloadlibfuse-3ded1a3176bb803e016e79d0e6db5e1f3ea30473.tar.gz
statfs improvement
Diffstat (limited to 'lib/fuse.c')
-rw-r--r--lib/fuse.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/fuse.c b/lib/fuse.c
index 00f34fb..4895192 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -108,7 +108,7 @@ static struct fuse_context *(*fuse_getcontext)(void) = NULL;
static int fuse_do_open(struct fuse *, char *, struct fuse_file_info *);
static void fuse_do_release(struct fuse *, char *, struct fuse_file_info *);
static int fuse_do_opendir(struct fuse *, char *, struct fuse_file_info *);
-static int fuse_do_statfs(struct fuse *, char *, struct statvfs *);
+static int fuse_do_statfs(struct fuse *, struct statvfs *);
#ifndef USE_UCLIBC
#define mutex_init(mut) pthread_mutex_init(mut, NULL)
@@ -1669,7 +1669,7 @@ static int default_statfs(struct statvfs *buf)
return 0;
}
-static void fuse_statfs(fuse_req_t req)
+static void fuse_statfs(fuse_req_t req, fuse_ino_t ino)
{
struct fuse *f = req_fuse_prepare(req);
struct statvfs buf;
@@ -1677,7 +1677,18 @@ static void fuse_statfs(fuse_req_t req)
memset(&buf, 0, sizeof(buf));
if (f->op.statfs) {
- err = fuse_do_statfs(f, "/", &buf);
+ if (ino && (!f->compat || f->compat >= 26)) {
+ char *path;
+ pthread_rwlock_rdlock(&f->tree_lock);
+ err = -ENOENT;
+ path = get_path(f, ino);
+ if (path) {
+ err = f->op.statfs(path, &buf);
+ free(path);
+ }
+ pthread_rwlock_unlock(&f->tree_lock);
+ } else
+ err = fuse_do_statfs(f, &buf);
} else
err = default_statfs(&buf);
@@ -2294,12 +2305,12 @@ static void convert_statfs_old(struct statfs *oldbuf, struct statvfs *stbuf)
stbuf->f_namemax = oldbuf->f_namelen;
}
-static int fuse_do_statfs(struct fuse *f, char *path, struct statvfs *buf)
+static int fuse_do_statfs(struct fuse *f, struct statvfs *buf)
{
int err;
if (!f->compat || f->compat >= 25) {
- err = f->op.statfs(path, buf);
+ err = f->op.statfs("/", buf);
} else if (f->compat > 11) {
struct statfs oldbuf;
err = ((struct fuse_operations_compat22 *) &f->op)->statfs("/", &oldbuf);
@@ -2386,9 +2397,9 @@ static int fuse_do_opendir(struct fuse *f, char *path,
return f->op.opendir(path, fi);
}
-static int fuse_do_statfs(struct fuse *f, char *path, struct statvfs *buf)
+static int fuse_do_statfs(struct fuse *f, struct statvfs *buf)
{
- return f->op.statfs(path, buf);
+ return f->op.statfs("/", buf);
}
#endif /* __FreeBSD__ */