Skip to content

Commit 2dbf6e0

Browse files
author
Al Viro
committed
kill vfs_submount()
The last remaining user of vfs_submount() (tracefs) is easy to convert to fs_context_for_submount(); do that and bury that thing, along with SB_SUBMOUNT Reviewed-by: Jan Kara <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Tested-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 006ff74 commit 2dbf6e0

File tree

5 files changed

+17
-30
lines changed

5 files changed

+17
-30
lines changed

fs/namespace.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,21 +1329,6 @@ struct vfsmount *vfs_kern_mount(struct file_system_type *type,
13291329
}
13301330
EXPORT_SYMBOL_GPL(vfs_kern_mount);
13311331

1332-
struct vfsmount *
1333-
vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,
1334-
const char *name, void *data)
1335-
{
1336-
/* Until it is worked out how to pass the user namespace
1337-
* through from the parent mount to the submount don't support
1338-
* unprivileged mounts with submounts.
1339-
*/
1340-
if (mountpoint->d_sb->s_user_ns != &init_user_ns)
1341-
return ERR_PTR(-EPERM);
1342-
1343-
return vfs_kern_mount(type, SB_SUBMOUNT, name, data);
1344-
}
1345-
EXPORT_SYMBOL_GPL(vfs_submount);
1346-
13471332
static struct mount *clone_mnt(struct mount *old, struct dentry *root,
13481333
int flag)
13491334
{

fs/super.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,6 @@ struct super_block *sget(struct file_system_type *type,
823823
struct super_block *old;
824824
int err;
825825

826-
/* We don't yet pass the user namespace of the parent
827-
* mount through to here so always use &init_user_ns
828-
* until that changes.
829-
*/
830-
if (flags & SB_SUBMOUNT)
831-
user_ns = &init_user_ns;
832-
833826
retry:
834827
spin_lock(&sb_lock);
835828
if (test) {
@@ -849,7 +842,7 @@ struct super_block *sget(struct file_system_type *type,
849842
}
850843
if (!s) {
851844
spin_unlock(&sb_lock);
852-
s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns);
845+
s = alloc_super(type, flags, user_ns);
853846
if (!s)
854847
return ERR_PTR(-ENOMEM);
855848
goto retry;

include/linux/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,6 @@ extern int send_sigurg(struct file *file);
12401240
/* These sb flags are internal to the kernel */
12411241
#define SB_DEAD BIT(21)
12421242
#define SB_DYING BIT(24)
1243-
#define SB_SUBMOUNT BIT(26)
12441243
#define SB_FORCE BIT(27)
12451244
#define SB_NOSEC BIT(28)
12461245
#define SB_BORN BIT(29)

include/linux/mount.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ extern struct vfsmount *vfs_create_mount(struct fs_context *fc);
9898
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
9999
int flags, const char *name,
100100
void *data);
101-
extern struct vfsmount *vfs_submount(const struct dentry *mountpoint,
102-
struct file_system_type *type,
103-
const char *name, void *data);
104101

105102
extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
106103
extern void mark_mounts_for_expiry(struct list_head *mounts);

kernel/trace/trace.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <linux/workqueue.h>
5252
#include <linux/sort.h>
5353
#include <linux/io.h> /* vmap_page_range() */
54+
#include <linux/fs_context.h>
5455

5556
#include <asm/setup.h> /* COMMAND_LINE_SIZE */
5657

@@ -10075,6 +10076,8 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
1007510076
{
1007610077
struct vfsmount *mnt;
1007710078
struct file_system_type *type;
10079+
struct fs_context *fc;
10080+
int ret;
1007810081

1007910082
/*
1008010083
* To maintain backward compatibility for tools that mount
@@ -10084,10 +10087,20 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
1008410087
type = get_fs_type("tracefs");
1008510088
if (!type)
1008610089
return NULL;
10087-
mnt = vfs_submount(mntpt, type, "tracefs", NULL);
10090+
10091+
fc = fs_context_for_submount(type, mntpt);
1008810092
put_filesystem(type);
10089-
if (IS_ERR(mnt))
10090-
return NULL;
10093+
if (IS_ERR(fc))
10094+
return ERR_CAST(fc);
10095+
10096+
ret = vfs_parse_fs_string(fc, "source",
10097+
"tracefs", strlen("tracefs"));
10098+
if (!ret)
10099+
mnt = fc_mount(fc);
10100+
else
10101+
mnt = ERR_PTR(ret);
10102+
10103+
put_fs_context(fc);
1009110104
return mnt;
1009210105
}
1009310106

0 commit comments

Comments
 (0)