Commit cf31e70d6cf93f19fe9bf1144966ef40991ac723

Authored by Al Viro
1 parent c972b4bc83

vfs: new helper - vfs_ustat()

... and bury user_get_super()/statfs_by_dentry() - they are
purely internal now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 5 changed files with 17 additions and 26 deletions Side-by-side Diff

arch/parisc/hpux/sys_hpux.c
... ... @@ -136,16 +136,9 @@
136 136 */
137 137 static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
138 138 {
139   - struct super_block *s;
140 139 struct hpux_ustat tmp; /* Changed to hpux_ustat */
141 140 struct kstatfs sbuf;
142   - int err = -EINVAL;
143   -
144   - s = user_get_super(dev);
145   - if (s == NULL)
146   - goto out;
147   - err = statfs_by_dentry(s->s_root, &sbuf);
148   - drop_super(s);
  141 + int err = vfs_ustat(dev, &sbuf);
149 142 if (err)
150 143 goto out;
151 144  
... ... @@ -342,16 +342,9 @@
342 342 */
343 343 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
344 344 {
345   - struct super_block *sb;
346 345 struct compat_ustat tmp;
347 346 struct kstatfs sbuf;
348   - int err;
349   -
350   - sb = user_get_super(new_decode_dev(dev));
351   - if (!sb)
352   - return -EINVAL;
353   - err = statfs_by_dentry(sb->s_root, &sbuf);
354   - drop_super(sb);
  347 + int err = vfs_ustat(new_decode_dev(dev), &sbuf);
355 348 if (err)
356 349 return err;
357 350  
... ... @@ -78,6 +78,7 @@
78 78 extern bool grab_super_passive(struct super_block *sb);
79 79 extern struct dentry *mount_fs(struct file_system_type *,
80 80 int, const char *, void *);
  81 +extern struct super_block *user_get_super(dev_t);
81 82  
82 83 /*
83 84 * open.c
... ... @@ -7,6 +7,7 @@
7 7 #include <linux/statfs.h>
8 8 #include <linux/security.h>
9 9 #include <linux/uaccess.h>
  10 +#include "internal.h"
10 11  
11 12 static int flags_by_mnt(int mnt_flags)
12 13 {
... ... @@ -45,7 +46,7 @@
45 46 flags_by_sb(mnt->mnt_sb->s_flags);
46 47 }
47 48  
48   -int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
  49 +static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
49 50 {
50 51 int retval;
51 52  
52 53  
53 54  
54 55  
55 56  
... ... @@ -205,19 +206,23 @@
205 206 return error;
206 207 }
207 208  
208   -SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
  209 +int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
209 210 {
210   - struct super_block *s;
211   - struct ustat tmp;
212   - struct kstatfs sbuf;
  211 + struct super_block *s = user_get_super(dev);
213 212 int err;
214   -
215   - s = user_get_super(new_decode_dev(dev));
216 213 if (!s)
217 214 return -EINVAL;
218 215  
219   - err = statfs_by_dentry(s->s_root, &sbuf);
  216 + err = statfs_by_dentry(s->s_root, sbuf);
220 217 drop_super(s);
  218 + return err;
  219 +}
  220 +
  221 +SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
  222 +{
  223 + struct ustat tmp;
  224 + struct kstatfs sbuf;
  225 + int err = vfs_ustat(new_decode_dev(dev), &sbuf);
221 226 if (err)
222 227 return err;
223 228  
... ... @@ -1939,7 +1939,7 @@
1939 1939 extern int vfs_statfs(struct path *, struct kstatfs *);
1940 1940 extern int user_statfs(const char __user *, struct kstatfs *);
1941 1941 extern int fd_statfs(int, struct kstatfs *);
1942   -extern int statfs_by_dentry(struct dentry *, struct kstatfs *);
  1942 +extern int vfs_ustat(dev_t, struct kstatfs *);
1943 1943 extern int freeze_super(struct super_block *super);
1944 1944 extern int thaw_super(struct super_block *super);
1945 1945 extern bool our_mnt(struct vfsmount *mnt);
... ... @@ -2531,7 +2531,6 @@
2531 2531 extern struct file_system_type *get_fs_type(const char *name);
2532 2532 extern struct super_block *get_super(struct block_device *);
2533 2533 extern struct super_block *get_active_super(struct block_device *bdev);
2534   -extern struct super_block *user_get_super(dev_t);
2535 2534 extern void drop_super(struct super_block *sb);
2536 2535 extern void iterate_supers(void (*)(struct super_block *, void *), void *);
2537 2536 extern void iterate_supers_type(struct file_system_type *,