Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

VFS: Add GPL_EXPORTED function vfs_kern_mount()

do_kern_mount() does not allow the kernel to use private mount interfaces
without exposing the same interfaces to userland. The problem is that the
filesystem is referenced by name, thus meaning that it and its mount
interface must be registered in the global filesystem list.

vfs_kern_mount() passes the struct file_system_type as an explicit
parameter in order to overcome this limitation.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

+20 -7
+15 -7
fs/super.c
··· 800 800 EXPORT_SYMBOL(get_sb_single); 801 801 802 802 struct vfsmount * 803 - do_kern_mount(const char *fstype, int flags, const char *name, void *data) 803 + vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) 804 804 { 805 - struct file_system_type *type = get_fs_type(fstype); 806 805 struct super_block *sb = ERR_PTR(-ENOMEM); 807 806 struct vfsmount *mnt; 808 807 int error; 809 808 char *secdata = NULL; 810 - 811 - if (!type) 812 - return ERR_PTR(-ENODEV); 813 809 814 810 mnt = alloc_vfsmnt(name); 815 811 if (!mnt) ··· 837 841 mnt->mnt_parent = mnt; 838 842 up_write(&sb->s_umount); 839 843 free_secdata(secdata); 840 - put_filesystem(type); 841 844 return mnt; 842 845 out_sb: 843 846 up_write(&sb->s_umount); ··· 847 852 out_mnt: 848 853 free_vfsmnt(mnt); 849 854 out: 850 - put_filesystem(type); 851 855 return (struct vfsmount *)sb; 856 + } 857 + 858 + EXPORT_SYMBOL_GPL(vfs_kern_mount); 859 + 860 + struct vfsmount * 861 + do_kern_mount(const char *fstype, int flags, const char *name, void *data) 862 + { 863 + struct file_system_type *type = get_fs_type(fstype); 864 + struct vfsmount *mnt; 865 + if (!type) 866 + return ERR_PTR(-ENODEV); 867 + mnt = vfs_kern_mount(type, flags, name, data); 868 + put_filesystem(type); 869 + return mnt; 852 870 } 853 871 854 872 EXPORT_SYMBOL_GPL(do_kern_mount);
+5
include/linux/mount.h
··· 73 73 extern struct vfsmount *do_kern_mount(const char *fstype, int flags, 74 74 const char *name, void *data); 75 75 76 + struct file_system_type; 77 + extern struct vfsmount *vfs_kern_mount(struct file_system_type *type, 78 + int flags, const char *name, 79 + void *data); 80 + 76 81 struct nameidata; 77 82 78 83 extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,