Skip to content

Commit 454dab3

Browse files
author
Dominik Brodowski
committed
fs: add ksys_getdents64() helper; remove in-kernel calls to sys_getdents64()
Using this helper allows us to avoid the in-kernel calls to the sys_getdents64() 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_getdents64(). 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>
1 parent bae217e commit 454dab3

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎fs/readdir.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ static int filldir64(struct dir_context *ctx, const char *name, int namlen,
292292
return -EFAULT;
293293
}
294294

295-
SYSCALL_DEFINE3(getdents64, unsigned int, fd,
296-
struct linux_dirent64 __user *, dirent, unsigned int, count)
295+
int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
296+
unsigned int count)
297297
{
298298
struct fd f;
299299
struct linux_dirent64 __user * lastdirent;
@@ -326,6 +326,13 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
326326
return error;
327327
}
328328

329+
330+
SYSCALL_DEFINE3(getdents64, unsigned int, fd,
331+
struct linux_dirent64 __user *, dirent, unsigned int, count)
332+
{
333+
return ksys_getdents64(fd, dirent, count);
334+
}
335+
329336
#ifdef CONFIG_COMPAT
330337
struct compat_old_linux_dirent {
331338
compat_ulong_t d_ino;

‎include/linux/syscalls.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
955955
int ksys_chdir(const char __user *filename);
956956
int ksys_fchmod(unsigned int fd, umode_t mode);
957957
int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
958+
int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
959+
unsigned int count);
958960

959961
/*
960962
* The following kernel syscall equivalents are just wrappers to fs-internal

‎init/initramfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static void __init clean_rootfs(void)
579579
}
580580

581581
dirp = buf;
582-
num = sys_getdents64(fd, dirp, BUF_SIZE);
582+
num = ksys_getdents64(fd, dirp, BUF_SIZE);
583583
while (num > 0) {
584584
while (num > 0) {
585585
struct kstat st;
@@ -599,7 +599,7 @@ static void __init clean_rootfs(void)
599599
}
600600
dirp = buf;
601601
memset(buf, 0, BUF_SIZE);
602-
num = sys_getdents64(fd, dirp, BUF_SIZE);
602+
num = ksys_getdents64(fd, dirp, BUF_SIZE);
603603
}
604604

605605
ksys_close(fd);

0 commit comments

Comments
 (0)