Skip to content

Commit

Permalink
namespaces: move proc_net_get_sb to a generic fs/super.c helper
Browse files Browse the repository at this point in the history
The mqueuefs filesystem will use this helper as well.  Proc's main get_sb
could also be made to use it, but that will require a bit more rework.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Apr 7, 2009
1 parent 7ce5ba3 commit 909e6d9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,46 @@ void kill_litter_super(struct super_block *sb)

EXPORT_SYMBOL(kill_litter_super);

static int ns_test_super(struct super_block *sb, void *data)
{
return sb->s_fs_info == data;
}

static int ns_set_super(struct super_block *sb, void *data)
{
sb->s_fs_info = data;
return set_anon_super(sb, NULL);
}

int get_sb_ns(struct file_system_type *fs_type, int flags, void *data,
int (*fill_super)(struct super_block *, void *, int),
struct vfsmount *mnt)
{
struct super_block *sb;

sb = sget(fs_type, ns_test_super, ns_set_super, data);
if (IS_ERR(sb))
return PTR_ERR(sb);

if (!sb->s_root) {
int err;
sb->s_flags = flags;
err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
if (err) {
up_write(&sb->s_umount);
deactivate_super(sb);
return err;
}

sb->s_flags |= MS_ACTIVE;
}

simple_set_mnt(mnt, sb);
return 0;
}

EXPORT_SYMBOL(get_sb_ns);

#ifdef CONFIG_BLOCK
static int set_bdev_super(struct super_block *s, void *data)
{
Expand Down
3 changes: 3 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,9 @@ struct file_system_type {
struct lock_class_key i_alloc_sem_key;
};

extern int get_sb_ns(struct file_system_type *fs_type, int flags, void *data,
int (*fill_super)(struct super_block *, void *, int),
struct vfsmount *mnt);
extern int get_sb_bdev(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data,
int (*fill_super)(struct super_block *, void *, int),
Expand Down

0 comments on commit 909e6d9

Please sign in to comment.