fs: add ksys_fchmod() and do_fchmodat() helpers and ksys_chmod() wrapper; remove in-kernel calls to syscall
Using the fs-internal do_fchmodat() helper allows us to get rid of fs-internal calls to the sys_fchmodat() syscall. Introducing the ksys_fchmod() helper and the ksys_chmod() wrapper allows us to avoid the in-kernel calls to the sys_fchmod() and sys_chmod() syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_fchmod() and sys_chmod(). 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>
This commit is contained in:
17
fs/open.c
17
fs/open.c
@@ -551,7 +551,7 @@ out_unlock:
|
||||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
|
||||
int ksys_fchmod(unsigned int fd, umode_t mode)
|
||||
{
|
||||
struct fd f = fdget(fd);
|
||||
int err = -EBADF;
|
||||
@@ -564,7 +564,12 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
|
||||
return err;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode)
|
||||
SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
|
||||
{
|
||||
return ksys_fchmod(fd, mode);
|
||||
}
|
||||
|
||||
int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
|
||||
{
|
||||
struct path path;
|
||||
int error;
|
||||
@@ -582,9 +587,15 @@ retry:
|
||||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename,
|
||||
umode_t, mode)
|
||||
{
|
||||
return do_fchmodat(dfd, filename, mode);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
|
||||
{
|
||||
return sys_fchmodat(AT_FDCWD, filename, mode);
|
||||
return do_fchmodat(AT_FDCWD, filename, mode);
|
||||
}
|
||||
|
||||
static int chown_common(const struct path *path, uid_t user, gid_t group)
|
||||
|
Reference in New Issue
Block a user