Commit 0f32ab8c authored by Dominik Brodowski's avatar Dominik Brodowski

fs: add ksys_unlink() wrapper; remove in-kernel calls to sys_unlink()

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

In the near future, all callers of ksys_unlink() should be converted to
call do_unlinkat() directly or, at least, to operate on regular kernel
pointers.

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: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 447016e9
...@@ -954,4 +954,15 @@ int ksys_chroot(const char __user *filename); ...@@ -954,4 +954,15 @@ int ksys_chroot(const char __user *filename);
ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count); ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
int ksys_chdir(const char __user *filename); int ksys_chdir(const char __user *filename);
/*
* The following kernel syscall equivalents are just wrappers to fs-internal
* functions. Therefore, provide stubs to be inlined at the callsites.
*/
extern long do_unlinkat(int dfd, struct filename *name);
static inline long ksys_unlink(const char __user *pathname)
{
return do_unlinkat(AT_FDCWD, getname(pathname));
}
#endif #endif
...@@ -16,7 +16,7 @@ extern int root_mountflags; ...@@ -16,7 +16,7 @@ extern int root_mountflags;
static inline int create_dev(char *name, dev_t dev) static inline int create_dev(char *name, dev_t dev)
{ {
sys_unlink(name); ksys_unlink(name);
return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev)); return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
} }
......
...@@ -128,11 +128,11 @@ bool __init initrd_load(void) ...@@ -128,11 +128,11 @@ bool __init initrd_load(void)
* mounted in the normal path. * mounted in the normal path.
*/ */
if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
sys_unlink("/initrd.image"); ksys_unlink("/initrd.image");
handle_initrd(); handle_initrd();
return true; return true;
} }
} }
sys_unlink("/initrd.image"); ksys_unlink("/initrd.image");
return false; return false;
} }
...@@ -288,7 +288,7 @@ int __init rd_load_image(char *from) ...@@ -288,7 +288,7 @@ int __init rd_load_image(char *from)
sys_close(out_fd); sys_close(out_fd);
out: out:
kfree(buf); kfree(buf);
sys_unlink("/dev/ram"); ksys_unlink("/dev/ram");
return res; return res;
} }
......
...@@ -319,7 +319,7 @@ static void __init clean_path(char *path, umode_t fmode) ...@@ -319,7 +319,7 @@ static void __init clean_path(char *path, umode_t fmode)
if (S_ISDIR(st.mode)) if (S_ISDIR(st.mode))
sys_rmdir(path); sys_rmdir(path);
else else
sys_unlink(path); ksys_unlink(path);
} }
} }
...@@ -591,7 +591,7 @@ static void __init clean_rootfs(void) ...@@ -591,7 +591,7 @@ static void __init clean_rootfs(void)
if (S_ISDIR(st.mode)) if (S_ISDIR(st.mode))
sys_rmdir(dirp->d_name); sys_rmdir(dirp->d_name);
else else
sys_unlink(dirp->d_name); ksys_unlink(dirp->d_name);
} }
num -= dirp->d_reclen; num -= dirp->d_reclen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment