vfs: new helper - vfs_ustat()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 3 Jan 2012 03:28:36 +0000 (22:28 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 4 Jan 2012 03:53:07 +0000 (22:53 -0500)
... and bury user_get_super()/statfs_by_dentry() - they are
purely internal now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/parisc/hpux/sys_hpux.c
fs/compat.c
fs/internal.h
fs/statfs.c
include/linux/fs.h

index 6ab9580..d9dc6cd 100644 (file)
@@ -136,16 +136,9 @@ struct hpux_ustat {
  */
 static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
 {
-       struct super_block *s;
        struct hpux_ustat tmp;  /* Changed to hpux_ustat */
        struct kstatfs sbuf;
-       int err = -EINVAL;
-
-       s = user_get_super(dev);
-       if (s == NULL)
-               goto out;
-       err = statfs_by_dentry(s->s_root, &sbuf);
-       drop_super(s);
+       int err = vfs_ustat(dev, &sbuf);
        if (err)
                goto out;
 
index c987875..9db5a60 100644 (file)
@@ -342,16 +342,9 @@ asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct c
  */
 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u)
 {
-       struct super_block *sb;
        struct compat_ustat tmp;
        struct kstatfs sbuf;
-       int err;
-
-       sb = user_get_super(new_decode_dev(dev));
-       if (!sb)
-               return -EINVAL;
-       err = statfs_by_dentry(sb->s_root, &sbuf);
-       drop_super(sb);
+       int err = vfs_ustat(new_decode_dev(dev), &sbuf);
        if (err)
                return err;
 
index 839d3f9..7b1cb15 100644 (file)
@@ -78,6 +78,7 @@ extern int do_remount_sb(struct super_block *, int, void *, int);
 extern bool grab_super_passive(struct super_block *sb);
 extern struct dentry *mount_fs(struct file_system_type *,
                               int, const char *, void *);
+extern struct super_block *user_get_super(dev_t);
 
 /*
  * open.c
index 9cf04a1..2aa6a22 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/statfs.h>
 #include <linux/security.h>
 #include <linux/uaccess.h>
+#include "internal.h"
 
 static int flags_by_mnt(int mnt_flags)
 {
@@ -45,7 +46,7 @@ static int calculate_f_flags(struct vfsmount *mnt)
                flags_by_sb(mnt->mnt_sb->s_flags);
 }
 
-int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
+static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
 {
        int retval;
 
@@ -205,19 +206,23 @@ SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user
        return error;
 }
 
-SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
+int vfs_ustat(dev_t dev, struct kstatfs *sbuf)
 {
-       struct super_block *s;
-       struct ustat tmp;
-       struct kstatfs sbuf;
+       struct super_block *s = user_get_super(dev);
        int err;
-
-       s = user_get_super(new_decode_dev(dev));
        if (!s)
                return -EINVAL;
 
-       err = statfs_by_dentry(s->s_root, &sbuf);
+       err = statfs_by_dentry(s->s_root, sbuf);
        drop_super(s);
+       return err;
+}
+
+SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf)
+{
+       struct ustat tmp;
+       struct kstatfs sbuf;
+       int err = vfs_ustat(new_decode_dev(dev), &sbuf);
        if (err)
                return err;
 
index ed17e54..cec429d 100644 (file)
@@ -1939,7 +1939,7 @@ extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
 extern int vfs_statfs(struct path *, struct kstatfs *);
 extern int user_statfs(const char __user *, struct kstatfs *);
 extern int fd_statfs(int, struct kstatfs *);
-extern int statfs_by_dentry(struct dentry *, struct kstatfs *);
+extern int vfs_ustat(dev_t, struct kstatfs *);
 extern int freeze_super(struct super_block *super);
 extern int thaw_super(struct super_block *super);
 extern bool our_mnt(struct vfsmount *mnt);
@@ -2531,7 +2531,6 @@ extern void put_filesystem(struct file_system_type *fs);
 extern struct file_system_type *get_fs_type(const char *name);
 extern struct super_block *get_super(struct block_device *);
 extern struct super_block *get_active_super(struct block_device *bdev);
-extern struct super_block *user_get_super(dev_t);
 extern void drop_super(struct super_block *sb);
 extern void iterate_supers(void (*)(struct super_block *, void *), void *);
 extern void iterate_supers_type(struct file_system_type *,