diff options
author | Christoph Hellwig <hch@lst.de> | 2010-07-07 12:53:11 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:48:42 -0400 |
commit | ebabe9a9001af0af56c0c2780ca1576246e7a74b (patch) | |
tree | b263299f575c650b6e9d95c7c4bdeef958af2fc9 /fs | |
parent | 336fb3b97b78edc65bae0b223b83bf676cfe29e2 (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')
-rw-r--r-- | fs/cachefiles/bind.c | 2 | ||||
-rw-r--r-- | fs/cachefiles/daemon.c | 6 | ||||
-rw-r--r-- | fs/compat.c | 10 | ||||
-rw-r--r-- | fs/ecryptfs/super.c | 6 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 6 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 10 | ||||
-rw-r--r-- | fs/statfs.c | 50 |
7 files changed, 55 insertions, 35 deletions
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 2906077ac798..a2603e7c0bb5 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c | |||
@@ -146,7 +146,7 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | |||
146 | goto error_unsupported; | 146 | goto error_unsupported; |
147 | 147 | ||
148 | /* get the cache size and blocksize */ | 148 | /* get the cache size and blocksize */ |
149 | ret = vfs_statfs(root, &stats); | 149 | ret = vfs_statfs(&path, &stats); |
150 | if (ret < 0) | 150 | if (ret < 0) |
151 | goto error_unsupported; | 151 | goto error_unsupported; |
152 | 152 | ||
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index c2413561ea75..24eb0d37241a 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c | |||
@@ -683,6 +683,10 @@ int cachefiles_has_space(struct cachefiles_cache *cache, | |||
683 | unsigned fnr, unsigned bnr) | 683 | unsigned fnr, unsigned bnr) |
684 | { | 684 | { |
685 | struct kstatfs stats; | 685 | struct kstatfs stats; |
686 | struct path path = { | ||
687 | .mnt = cache->mnt, | ||
688 | .dentry = cache->mnt->mnt_root, | ||
689 | }; | ||
686 | int ret; | 690 | int ret; |
687 | 691 | ||
688 | //_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u", | 692 | //_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u", |
@@ -697,7 +701,7 @@ int cachefiles_has_space(struct cachefiles_cache *cache, | |||
697 | /* find out how many pages of blockdev are available */ | 701 | /* find out how many pages of blockdev are available */ |
698 | memset(&stats, 0, sizeof(stats)); | 702 | memset(&stats, 0, sizeof(stats)); |
699 | 703 | ||
700 | ret = vfs_statfs(cache->mnt->mnt_root, &stats); | 704 | ret = vfs_statfs(&path, &stats); |
701 | if (ret < 0) { | 705 | if (ret < 0) { |
702 | if (ret == -EIO) | 706 | if (ret == -EIO) |
703 | cachefiles_io_error(cache, "statfs failed"); | 707 | cachefiles_io_error(cache, "statfs failed"); |
diff --git a/fs/compat.c b/fs/compat.c index 6490d2134ff3..fc6c2adf2f6b 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -266,7 +266,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta | |||
266 | error = user_path(pathname, &path); | 266 | error = user_path(pathname, &path); |
267 | if (!error) { | 267 | if (!error) { |
268 | struct kstatfs tmp; | 268 | struct kstatfs tmp; |
269 | error = vfs_statfs(path.dentry, &tmp); | 269 | error = vfs_statfs(&path, &tmp); |
270 | if (!error) | 270 | if (!error) |
271 | error = put_compat_statfs(buf, &tmp); | 271 | error = put_compat_statfs(buf, &tmp); |
272 | path_put(&path); | 272 | path_put(&path); |
@@ -284,7 +284,7 @@ asmlinkage long compat_sys_fstatfs(unsigned int fd, struct compat_statfs __user | |||
284 | file = fget(fd); | 284 | file = fget(fd); |
285 | if (!file) | 285 | if (!file) |
286 | goto out; | 286 | goto out; |
287 | error = vfs_statfs(file->f_path.dentry, &tmp); | 287 | error = vfs_statfs(&file->f_path, &tmp); |
288 | if (!error) | 288 | if (!error) |
289 | error = put_compat_statfs(buf, &tmp); | 289 | error = put_compat_statfs(buf, &tmp); |
290 | fput(file); | 290 | fput(file); |
@@ -334,7 +334,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s | |||
334 | error = user_path(pathname, &path); | 334 | error = user_path(pathname, &path); |
335 | if (!error) { | 335 | if (!error) { |
336 | struct kstatfs tmp; | 336 | struct kstatfs tmp; |
337 | error = vfs_statfs(path.dentry, &tmp); | 337 | error = vfs_statfs(&path, &tmp); |
338 | if (!error) | 338 | if (!error) |
339 | error = put_compat_statfs64(buf, &tmp); | 339 | error = put_compat_statfs64(buf, &tmp); |
340 | path_put(&path); | 340 | path_put(&path); |
@@ -355,7 +355,7 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c | |||
355 | file = fget(fd); | 355 | file = fget(fd); |
356 | if (!file) | 356 | if (!file) |
357 | goto out; | 357 | goto out; |
358 | error = vfs_statfs(file->f_path.dentry, &tmp); | 358 | error = vfs_statfs(&file->f_path, &tmp); |
359 | if (!error) | 359 | if (!error) |
360 | error = put_compat_statfs64(buf, &tmp); | 360 | error = put_compat_statfs64(buf, &tmp); |
361 | fput(file); | 361 | fput(file); |
@@ -378,7 +378,7 @@ asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u) | |||
378 | sb = user_get_super(new_decode_dev(dev)); | 378 | sb = user_get_super(new_decode_dev(dev)); |
379 | if (!sb) | 379 | if (!sb) |
380 | return -EINVAL; | 380 | return -EINVAL; |
381 | err = vfs_statfs(sb->s_root, &sbuf); | 381 | err = statfs_by_dentry(sb->s_root, &sbuf); |
382 | drop_super(sb); | 382 | drop_super(sb); |
383 | if (err) | 383 | if (err) |
384 | return err; | 384 | return err; |
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index 4b5de6c6e0fa..f7fc286a3aa9 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c | |||
@@ -118,7 +118,11 @@ void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode) | |||
118 | */ | 118 | */ |
119 | static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 119 | static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
120 | { | 120 | { |
121 | return vfs_statfs(ecryptfs_dentry_to_lower(dentry), buf); | 121 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
122 | |||
123 | if (!lower_dentry->d_sb->s_op->statfs) | ||
124 | return -ENOSYS; | ||
125 | return lower_dentry->d_sb->s_op->statfs(lower_dentry, buf); | ||
122 | } | 126 | } |
123 | 127 | ||
124 | /** | 128 | /** |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ac17a7080239..4d6154f66e04 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1756,6 +1756,10 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | |||
1756 | struct nfs4_acl *acl = NULL; | 1756 | struct nfs4_acl *acl = NULL; |
1757 | struct nfsd4_compoundres *resp = rqstp->rq_resp; | 1757 | struct nfsd4_compoundres *resp = rqstp->rq_resp; |
1758 | u32 minorversion = resp->cstate.minorversion; | 1758 | u32 minorversion = resp->cstate.minorversion; |
1759 | struct path path = { | ||
1760 | .mnt = exp->ex_path.mnt, | ||
1761 | .dentry = dentry, | ||
1762 | }; | ||
1759 | 1763 | ||
1760 | BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); | 1764 | BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); |
1761 | BUG_ON(bmval0 & ~nfsd_suppattrs0(minorversion)); | 1765 | BUG_ON(bmval0 & ~nfsd_suppattrs0(minorversion)); |
@@ -1776,7 +1780,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | |||
1776 | FATTR4_WORD0_MAXNAME)) || | 1780 | FATTR4_WORD0_MAXNAME)) || |
1777 | (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | | 1781 | (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | |
1778 | FATTR4_WORD1_SPACE_TOTAL))) { | 1782 | FATTR4_WORD1_SPACE_TOTAL))) { |
1779 | err = vfs_statfs(dentry, &statfs); | 1783 | err = vfs_statfs(&path, &statfs); |
1780 | if (err) | 1784 | if (err) |
1781 | goto out_nfserr; | 1785 | goto out_nfserr; |
1782 | } | 1786 | } |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 3c111120b619..f6f1a718642f 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -2019,8 +2019,14 @@ out: | |||
2019 | __be32 | 2019 | __be32 |
2020 | nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat, int access) | 2020 | nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat, int access) |
2021 | { | 2021 | { |
2022 | __be32 err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP | access); | 2022 | struct path path = { |
2023 | if (!err && vfs_statfs(fhp->fh_dentry,stat)) | 2023 | .mnt = fhp->fh_export->ex_path.mnt, |
2024 | .dentry = fhp->fh_dentry, | ||
2025 | }; | ||
2026 | __be32 err; | ||
2027 | |||
2028 | err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP | access); | ||
2029 | if (!err && vfs_statfs(&path, stat)) | ||
2024 | err = nfserr_io; | 2030 | err = nfserr_io; |
2025 | return err; | 2031 | return err; |
2026 | } | 2032 | } |
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 | ||
10 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 10 | int 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 | ||
27 | int vfs_statfs(struct path *path, struct kstatfs *buf) | ||
28 | { | ||
29 | return statfs_by_dentry(path->dentry, buf); | ||
30 | } | ||
29 | EXPORT_SYMBOL(vfs_statfs); | 31 | EXPORT_SYMBOL(vfs_statfs); |
30 | 32 | ||
31 | static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf) | 33 | static 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 | ||
75 | static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) | 77 | static 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; |