diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2009-04-06 22:01:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-07 11:31:09 -0400 |
commit | 909e6d94795654040ed416ac69858d5d2ce66dd3 (patch) | |
tree | c0d873c341e3419c3bb54cffd964bbe850bbb4ab | |
parent | 7ce5ba3c7ef26284f60babbe4465259d1f9968f3 (diff) |
namespaces: move proc_net_get_sb to a generic fs/super.c helper
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>
-rw-r--r-- | fs/super.c | 40 | ||||
-rw-r--r-- | include/linux/fs.h | 3 |
2 files changed, 43 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c index 77cb4ec919b9..786fe7d72790 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -771,6 +771,46 @@ void kill_litter_super(struct super_block *sb) | |||
771 | 771 | ||
772 | EXPORT_SYMBOL(kill_litter_super); | 772 | EXPORT_SYMBOL(kill_litter_super); |
773 | 773 | ||
774 | static int ns_test_super(struct super_block *sb, void *data) | ||
775 | { | ||
776 | return sb->s_fs_info == data; | ||
777 | } | ||
778 | |||
779 | static int ns_set_super(struct super_block *sb, void *data) | ||
780 | { | ||
781 | sb->s_fs_info = data; | ||
782 | return set_anon_super(sb, NULL); | ||
783 | } | ||
784 | |||
785 | int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, | ||
786 | int (*fill_super)(struct super_block *, void *, int), | ||
787 | struct vfsmount *mnt) | ||
788 | { | ||
789 | struct super_block *sb; | ||
790 | |||
791 | sb = sget(fs_type, ns_test_super, ns_set_super, data); | ||
792 | if (IS_ERR(sb)) | ||
793 | return PTR_ERR(sb); | ||
794 | |||
795 | if (!sb->s_root) { | ||
796 | int err; | ||
797 | sb->s_flags = flags; | ||
798 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); | ||
799 | if (err) { | ||
800 | up_write(&sb->s_umount); | ||
801 | deactivate_super(sb); | ||
802 | return err; | ||
803 | } | ||
804 | |||
805 | sb->s_flags |= MS_ACTIVE; | ||
806 | } | ||
807 | |||
808 | simple_set_mnt(mnt, sb); | ||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | EXPORT_SYMBOL(get_sb_ns); | ||
813 | |||
774 | #ifdef CONFIG_BLOCK | 814 | #ifdef CONFIG_BLOCK |
775 | static int set_bdev_super(struct super_block *s, void *data) | 815 | static int set_bdev_super(struct super_block *s, void *data) |
776 | { | 816 | { |
diff --git a/include/linux/fs.h b/include/linux/fs.h index bce40a2207ee..562d2855cf30 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1699,6 +1699,9 @@ struct file_system_type { | |||
1699 | struct lock_class_key i_alloc_sem_key; | 1699 | struct lock_class_key i_alloc_sem_key; |
1700 | }; | 1700 | }; |
1701 | 1701 | ||
1702 | extern int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, | ||
1703 | int (*fill_super)(struct super_block *, void *, int), | ||
1704 | struct vfsmount *mnt); | ||
1702 | extern int get_sb_bdev(struct file_system_type *fs_type, | 1705 | extern int get_sb_bdev(struct file_system_type *fs_type, |
1703 | int flags, const char *dev_name, void *data, | 1706 | int flags, const char *dev_name, void *data, |
1704 | int (*fill_super)(struct super_block *, void *, int), | 1707 | int (*fill_super)(struct super_block *, void *, int), |