aboutsummaryrefslogtreecommitdiffstats
path: root/fs/statfs.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-07-07 12:53:11 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-08-09 16:48:42 -0400
commitebabe9a9001af0af56c0c2780ca1576246e7a74b (patch)
treeb263299f575c650b6e9d95c7c4bdeef958af2fc9 /fs/statfs.c
parent336fb3b97b78edc65bae0b223b83bf676cfe29e2 (diff)
pass a struct path to vfs_statfs
We'll need the path to implement the flags field for statvfs support. We do have it available in all callers except: - ecryptfs_statfs. This one doesn't actually need vfs_statfs but just needs to do a caller to the lower filesystem statfs method. - sys_ustat. Add a non-exported statfs_by_dentry helper for it which doesn't won't be able to fill out the flags field later on. In addition rename the helpers for statfs vs fstatfs to do_*statfs instead of the misleading vfs prefix. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/statfs.c')
-rw-r--r--fs/statfs.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/fs/statfs.c b/fs/statfs.c
index 4ef021f3b612..6a305709a4da 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -7,33 +7,35 @@
7#include <linux/security.h> 7#include <linux/security.h>
8#include <linux/uaccess.h> 8#include <linux/uaccess.h>
9 9
10int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 10int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
11{ 11{
12 int retval = -ENODEV; 12 int retval;
13 13
14 if (dentry) { 14 if (!dentry->d_sb->s_op->statfs)
15 retval = -ENOSYS; 15 return -ENOSYS;
16 if (dentry->d_sb->s_op->statfs) { 16
17 memset(buf, 0, sizeof(*buf)); 17 memset(buf, 0, sizeof(*buf));
18 retval = security_sb_statfs(dentry); 18 retval = security_sb_statfs(dentry);
19 if (retval) 19 if (retval)
20 return retval; 20 return retval;
21 retval = dentry->d_sb->s_op->statfs(dentry, buf); 21 retval = dentry->d_sb->s_op->statfs(dentry, buf);
22 if (retval == 0 && buf->f_frsize == 0) 22 if (retval == 0 && buf->f_frsize == 0)
23 buf->f_frsize = buf->f_bsize; 23 buf->f_frsize = buf->f_bsize;
24 }
25 }
26 return retval; 24 return retval;
27} 25}
28 26
27int vfs_statfs(struct path *path, struct kstatfs *buf)
28{
29 return statfs_by_dentry(path->dentry, buf);
30}
29EXPORT_SYMBOL(vfs_statfs); 31EXPORT_SYMBOL(vfs_statfs);
30 32
31static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf) 33static int do_statfs_native(struct path *path, struct statfs *buf)
32{ 34{
33 struct kstatfs st; 35 struct kstatfs st;
34 int retval; 36 int retval;
35 37
36 retval = vfs_statfs(dentry, &st); 38 retval = vfs_statfs(path, &st);
37 if (retval) 39 if (retval)
38 return retval; 40 return retval;
39 41
@@ -72,12 +74,12 @@ static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
72 return 0; 74 return 0;
73} 75}
74 76
75static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) 77static int do_statfs64(struct path *path, struct statfs64 *buf)
76{ 78{
77 struct kstatfs st; 79 struct kstatfs st;
78 int retval; 80 int retval;
79 81
80 retval = vfs_statfs(dentry, &st); 82 retval = vfs_statfs(path, &st);
81 if (retval) 83 if (retval)
82 return retval; 84 return retval;
83 85
@@ -107,7 +109,7 @@ SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, b
107 error = user_path(pathname, &path); 109 error = user_path(pathname, &path);
108 if (!error) { 110 if (!error) {
109 struct statfs tmp; 111 struct statfs tmp;
110 error = vfs_statfs_native(path.dentry, &tmp); 112 error = do_statfs_native(&path, &tmp);
111 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 113 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
112 error = -EFAULT; 114 error = -EFAULT;
113 path_put(&path); 115 path_put(&path);
@@ -125,7 +127,7 @@ SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct stat
125 error = user_path(pathname, &path); 127 error = user_path(pathname, &path);
126 if (!error) { 128 if (!error) {
127 struct statfs64 tmp; 129 struct statfs64 tmp;
128 error = vfs_statfs64(path.dentry, &tmp); 130 error = do_statfs64(&path, &tmp);
129 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 131 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
130 error = -EFAULT; 132 error = -EFAULT;
131 path_put(&path); 133 path_put(&path);
@@ -143,7 +145,7 @@ SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf)
143 file = fget(fd); 145 file = fget(fd);
144 if (!file) 146 if (!file)
145 goto out; 147 goto out;
146 error = vfs_statfs_native(file->f_path.dentry, &tmp); 148 error = do_statfs_native(&file->f_path, &tmp);
147 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 149 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
148 error = -EFAULT; 150 error = -EFAULT;
149 fput(file); 151 fput(file);
@@ -164,7 +166,7 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user
164 file = fget(fd); 166 file = fget(fd);
165 if (!file) 167 if (!file)
166 goto out; 168 goto out;
167 error = vfs_statfs64(file->f_path.dentry, &tmp); 169 error = do_statfs64(&file->f_path, &tmp);
168 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 170 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
169 error = -EFAULT; 171 error = -EFAULT;
170 fput(file); 172 fput(file);
@@ -183,7 +185,7 @@ SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
183 if (!s) 185 if (!s)
184 return -EINVAL; 186 return -EINVAL;
185 187
186 err = vfs_statfs(s->s_root, &sbuf); 188 err = statfs_by_dentry(s->s_root, &sbuf);
187 drop_super(s); 189 drop_super(s);
188 if (err) 190 if (err)
189 return err; 191 return err;