Skip to content

Commit 09267de

Browse files
author
Christoph Hellwig
committed
init: add an init_umount helper
Like ksys_umount, but takes a kernel pointer for the destination path. Switch over the umount in the init code, which just happen to work due to the implicit set_fs(KERNEL_DS) during early init right now. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent c60166f commit 09267de

File tree

6 files changed

+19
-4
lines changed

6 files changed

+19
-4
lines changed

fs/init.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,17 @@ int __init init_mount(const char *dev_name, const char *dir_name,
2323
path_put(&path);
2424
return ret;
2525
}
26+
27+
int __init init_umount(const char *name, int flags)
28+
{
29+
int lookup_flags = LOOKUP_MOUNTPOINT;
30+
struct path path;
31+
int ret;
32+
33+
if (!(flags & UMOUNT_NOFOLLOW))
34+
lookup_flags |= LOOKUP_FOLLOW;
35+
ret = kern_path(name, lookup_flags, &path);
36+
if (ret)
37+
return ret;
38+
return path_umount(&path, flags);
39+
}

fs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ extern void dissolve_on_fput(struct vfsmount *);
9292

9393
int path_mount(const char *dev_name, struct path *path,
9494
const char *type_page, unsigned long flags, void *data_page);
95+
int path_umount(struct path *path, int flags);
9596

9697
/*
9798
* fs_struct.c

fs/namespace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ static inline bool may_mandlock(void)
17061706
}
17071707
#endif
17081708

1709-
static int path_umount(struct path *path, int flags)
1709+
int path_umount(struct path *path, int flags)
17101710
{
17111711
struct mount *mnt;
17121712
int retval;
@@ -1736,7 +1736,7 @@ static int path_umount(struct path *path, int flags)
17361736
return retval;
17371737
}
17381738

1739-
int ksys_umount(char __user *name, int flags)
1739+
static int ksys_umount(char __user *name, int flags)
17401740
{
17411741
int lookup_flags = LOOKUP_MOUNTPOINT;
17421742
struct path path;

include/linux/init_syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
int __init init_mount(const char *dev_name, const char *dir_name,
44
const char *type_page, unsigned long flags, void *data_page);
5+
int __init init_umount(const char *name, int flags);

include/linux/syscalls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,6 @@ asmlinkage long sys_ni_syscall(void);
12361236
* the ksys_xyzyyz() functions prototyped below.
12371237
*/
12381238

1239-
int ksys_umount(char __user *name, int flags);
12401239
int ksys_chroot(const char __user *filename);
12411240
ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
12421241
int ksys_chdir(const char __user *filename);

init/do_mounts_initrd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static void __init handle_initrd(void)
122122
else
123123
printk("failed\n");
124124
printk(KERN_NOTICE "Unmounting old root\n");
125-
ksys_umount("/old", MNT_DETACH);
125+
init_umount("/old", MNT_DETACH);
126126
}
127127
}
128128

0 commit comments

Comments
 (0)