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

fs: add ksys_umount() helper; remove in-kernel call to sys_umount()

Using this helper allows us to avoid the in-kernel call to the sys_umount()
syscall. The ksys_ prefix denotes that this function is meant as a drop-in
replacement for the syscall. In particular, it uses the same calling
convention as ksys_umount().

In the near future, the only fs-external caller of ksys_umount() should be
converted to call do_umount() directly. Then, ksys_umount() can be moved
within sys_umount() again.

This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>

+9 -3
+7 -2
fs/namespace.c
··· 1680 1680 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD 1681 1681 */ 1682 1682 1683 - SYSCALL_DEFINE2(umount, char __user *, name, int, flags) 1683 + int ksys_umount(char __user *name, int flags) 1684 1684 { 1685 1685 struct path path; 1686 1686 struct mount *mnt; ··· 1720 1720 return retval; 1721 1721 } 1722 1722 1723 + SYSCALL_DEFINE2(umount, char __user *, name, int, flags) 1724 + { 1725 + return ksys_umount(name, flags); 1726 + } 1727 + 1723 1728 #ifdef __ARCH_WANT_SYS_OLDUMOUNT 1724 1729 1725 1730 /* ··· 1732 1727 */ 1733 1728 SYSCALL_DEFINE1(oldumount, char __user *, name) 1734 1729 { 1735 - return sys_umount(name, 0); 1730 + return ksys_umount(name, 0); 1736 1731 } 1737 1732 1738 1733 #endif
+1
include/linux/syscalls.h
··· 948 948 949 949 int ksys_mount(char __user *dev_name, char __user *dir_name, char __user *type, 950 950 unsigned long flags, void __user *data); 951 + int ksys_umount(char __user *name, int flags); 951 952 952 953 #endif
+1 -1
init/do_mounts_initrd.c
··· 105 105 else 106 106 printk("failed\n"); 107 107 printk(KERN_NOTICE "Unmounting old root\n"); 108 - sys_umount("/old", MNT_DETACH); 108 + ksys_umount("/old", MNT_DETACH); 109 109 printk(KERN_NOTICE "Trying to free ramdisk memory ... "); 110 110 if (fd < 0) { 111 111 error = fd;