From mboxrd@z Thu Jan 1 00:00:00 1970 From: Trond Myklebust Subject: Re: [PATCH] Allow kernel-only mount interfaces... Date: Thu, 10 Feb 2005 14:14:57 -0500 Message-ID: <1108062897.9757.41.camel@lade.trondhjem.org> References: <1108060883.9757.33.camel@lade.trondhjem.org> <20050210190113.GT2635@schnapps.adilger.int> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Linux Filesystem Development Received: from pat.uio.no ([129.240.130.16]:62935 "EHLO pat.uio.no") by vger.kernel.org with ESMTP id S261388AbVBJTPI (ORCPT ); Thu, 10 Feb 2005 14:15:08 -0500 To: Andreas Dilger In-Reply-To: <20050210190113.GT2635@schnapps.adilger.int> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org to den 10.02.2005 Klokka 12:01 (-0700) skreiv Andreas Dilger: > This will OOPS if fstype is bad, since you unconditionally put_filesystem() > on a possible PTR_ERR() type. You need an extra > > if (!IS_ERR(type)) > put_filesystem(type); > Agreed. That was not a final patch, but just a first untested draft in order to test the waters. I'm mainly wanting to hear whether or not anyone has major objections (Al ?) against the new function itself. Here's an update, though ;-) Cheers, Trond 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 super.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) Index: linux-2.6.11-rc3/fs/super.c =================================================================== --- linux-2.6.11-rc3.orig/fs/super.c +++ linux-2.6.11-rc3/fs/super.c @@ -794,17 +794,13 @@ struct super_block *get_sb_single(struct EXPORT_SYMBOL(get_sb_single); struct vfsmount * -do_kern_mount(const char *fstype, int flags, const char *name, void *data) +vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) { - struct file_system_type *type = get_fs_type(fstype); struct super_block *sb = ERR_PTR(-ENOMEM); struct vfsmount *mnt; int error; char *secdata = NULL; - if (!type) - return ERR_PTR(-ENODEV); - mnt = alloc_vfsmnt(name); if (!mnt) goto out; @@ -835,7 +831,6 @@ do_kern_mount(const char *fstype, int fl mnt->mnt_parent = mnt; mnt->mnt_namespace = current->namespace; up_write(&sb->s_umount); - put_filesystem(type); return mnt; out_sb: up_write(&sb->s_umount); @@ -846,10 +841,23 @@ out_free_secdata: out_mnt: free_vfsmnt(mnt); out: - put_filesystem(type); return (struct vfsmount *)sb; } +EXPORT_SYMBOL_GPL(vfs_kern_mount); + +struct vfsmount * +do_kern_mount(const char *fstype, int flags, const char *name, void *data) +{ + struct file_system_type *type = get_fs_type(fstype); + struct vfsmount *mnt; + if (!type) + return ERR_PTR(-ENODEV); + mnt = vfs_kern_mount(type, flags, name, data); + put_filesystem(type); + return mnt; +} + EXPORT_SYMBOL_GPL(do_kern_mount); struct vfsmount *kern_mount(struct file_system_type *type) -- Trond Myklebust