History

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.

Christoph Hellwig committed 6 years ago

Commit 09267de1 parent c60166f6 files · +19 −4Browse files

Unified · Split

6 files
  1. fs/init.c +14 −0
  2. fs/internal.h +1 −0
  3. fs/namespace.c +2 −2
  4. include/linux/init_syscalls.h +1 −0
  5. include/linux/syscalls.h +0 −1
  6. init/do_mounts_initrd.c +1 −1
fs/init.c+14−0
@@ -23,3 +23,17 @@ int __init init_mount(const char *dev_name, const char *dir_name, · 22 unmodified lines
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+1−0
@@ -92,6 +92,7 @@ extern void dissolve_on_fput(struct vfsmount *); · 91 unmodified lines
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+2−2
@@ -1706,7 +1706,7 @@ static inline bool may_mandlock(void) · 1705 unmodified lines
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 @@ dput_and_out: · 23 unmodified lines
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+1−0
@@ -2,3 +2,4 @@ · 1 unmodified line
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+0−1
@@ -1236,7 +1236,6 @@ asmlinkage long sys_ni_syscall(void); · 1235 unmodified lines
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+1−1
@@ -122,7 +122,7 @@ static void __init handle_initrd(void) · 121 unmodified lines
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