]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fs: add do_mkdirat() helper and ksys_mkdir() wrapper; remove in-kernel calls to syscall
authorDominik Brodowski <linux@dominikbrodowski.net>
Sun, 11 Mar 2018 10:34:49 +0000 (11:34 +0100)
committerDominik Brodowski <linux@dominikbrodowski.net>
Mon, 2 Apr 2018 18:15:54 +0000 (20:15 +0200)
Using the fs-internal do_mkdirat() helper allows us to get rid of
fs-internal calls to the sys_mkdirat() syscall.

Introducing the ksys_mkdir() wrapper allows us to avoid the in-kernel calls
to the sys_mkdir() 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 sys_mkdir().

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: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
fs/internal.h
fs/namei.c
include/linux/syscalls.h
init/do_mounts_initrd.c
init/initramfs.c
init/noinitramfs.c

index 0eda35fa174331d577f35a987b6850e529e3f069..53846bd4d9d7eb92bf7edfc83fdb9713756ef472 100644 (file)
@@ -55,6 +55,7 @@ extern void __init chrdev_init(void);
 extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *);
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
                           const char *, unsigned int, struct path *);
+long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
 long do_rmdir(int dfd, const char __user *pathname);
 long do_unlinkat(int dfd, struct filename *name);
 
index 8545151f74e9cc023c52259b6b593a97fbf6cbf7..dcf506227509b9dcc05e23a13df99e60c60a6086 100644 (file)
@@ -3803,7 +3803,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 }
 EXPORT_SYMBOL(vfs_mkdir);
 
-SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
+long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
 {
        struct dentry *dentry;
        struct path path;
@@ -3828,9 +3828,14 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
        return error;
 }
 
+SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
+{
+       return do_mkdirat(dfd, pathname, mode);
+}
+
 SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
 {
-       return sys_mkdirat(AT_FDCWD, pathname, mode);
+       return do_mkdirat(AT_FDCWD, pathname, mode);
 }
 
 int vfs_rmdir(struct inode *dir, struct dentry *dentry)
index 746043a05884bcae0f3ffc915747694cf66a864b..c982cb5f4e50699494f46ff99e799e954c1ae17b 100644 (file)
@@ -972,4 +972,11 @@ static inline long ksys_rmdir(const char __user *pathname)
        return do_rmdir(AT_FDCWD, pathname);
 }
 
+extern long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
+
+static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
+{
+       return do_mkdirat(AT_FDCWD, pathname, mode);
+}
+
 #endif
index e9e9e1c67d315c33f859c2929942fab2b9849a39..99922d1ebfe6ad7f558288977ea3034eab5ab31b 100644 (file)
@@ -60,7 +60,7 @@ static void __init handle_initrd(void)
        create_dev("/dev/root.old", Root_RAM0);
        /* mount initrd on rootfs' /root */
        mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
-       sys_mkdir("/old", 0700);
+       ksys_mkdir("/old", 0700);
        ksys_chdir("/old");
 
        /* try loading default modules from initrd */
index 73bbb227f8685a295906e6ad949b2c08c55cdb23..ca538a5f9fa990cfb492efc54996162f356504f6 100644 (file)
@@ -352,7 +352,7 @@ static int __init do_name(void)
                        }
                }
        } else if (S_ISDIR(mode)) {
-               sys_mkdir(collected, mode);
+               ksys_mkdir(collected, mode);
                sys_chown(collected, uid, gid);
                sys_chmod(collected, mode);
                dir_add(collected, mtime);
index 267739d851791b0a3e4526a3be5fb4944d8b507e..a08a9d937e60bcdac896143c9cbb33d03e3dd142 100644 (file)
@@ -29,7 +29,7 @@ static int __init default_rootfs(void)
 {
        int err;
 
-       err = sys_mkdir((const char __user __force *) "/dev", 0755);
+       err = ksys_mkdir((const char __user __force *) "/dev", 0755);
        if (err < 0)
                goto out;
 
@@ -39,7 +39,7 @@ static int __init default_rootfs(void)
        if (err < 0)
                goto out;
 
-       err = sys_mkdir((const char __user __force *) "/root", 0700);
+       err = ksys_mkdir((const char __user __force *) "/root", 0700);
        if (err < 0)
                goto out;