Skip to content

Commit df260e2

Browse files
author
Dominik Brodowski
committed
fs: add ksys_truncate() wrapper; remove in-kernel calls to sys_truncate()
Using the ksys_truncate() wrapper allows us to get rid of in-kernel calls to the sys_truncate() 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_truncate(). 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>
1 parent 806cbae commit df260e2

8 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎arch/mips/kernel/linux32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct rlimit32 {
8282
SYSCALL_DEFINE4(32_truncate64, const char __user *, path,
8383
unsigned long, __dummy, unsigned long, a2, unsigned long, a3)
8484
{
85-
return sys_truncate(path, merge_64(a2, a3));
85+
return ksys_truncate(path, merge_64(a2, a3));
8686
}
8787

8888
SYSCALL_DEFINE4(32_ftruncate64, unsigned long, fd, unsigned long, __dummy,

‎arch/parisc/kernel/sys_parisc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
292292
asmlinkage long parisc_truncate64(const char __user * path,
293293
unsigned int high, unsigned int low)
294294
{
295-
return sys_truncate(path, (long)high << 32 | low);
295+
return ksys_truncate(path, (long)high << 32 | low);
296296
}
297297

298298
asmlinkage long parisc_ftruncate64(unsigned int fd,
@@ -305,7 +305,7 @@ asmlinkage long parisc_ftruncate64(unsigned int fd,
305305
* are identical on LP64 */
306306
asmlinkage long sys_truncate64(const char __user * path, unsigned long length)
307307
{
308-
return sys_truncate(path, length);
308+
return ksys_truncate(path, length);
309309
}
310310
asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length)
311311
{
@@ -320,7 +320,7 @@ asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg
320320
asmlinkage long parisc_truncate64(const char __user * path,
321321
unsigned int high, unsigned int low)
322322
{
323-
return sys_truncate64(path, (loff_t)high << 32 | low);
323+
return ksys_truncate(path, (loff_t)high << 32 | low);
324324
}
325325

326326
asmlinkage long parisc_ftruncate64(unsigned int fd,

‎arch/powerpc/kernel/sys_ppc32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 co
9494
asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
9595
unsigned long high, unsigned long low)
9696
{
97-
return sys_truncate(path, (high << 32) | low);
97+
return ksys_truncate(path, (high << 32) | low);
9898
}
9999

100100
asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,

‎arch/s390/kernel/compat_linux.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ COMPAT_SYSCALL_DEFINE5(s390_ipc, uint, call, int, first, compat_ulong_t, second,
302302

303303
COMPAT_SYSCALL_DEFINE3(s390_truncate64, const char __user *, path, u32, high, u32, low)
304304
{
305-
return sys_truncate(path, (unsigned long)high << 32 | low);
305+
return ksys_truncate(path, (unsigned long)high << 32 | low);
306306
}
307307

308308
COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsigned int, fd, u32, high, u32, low)

‎arch/sparc/kernel/sys_sparc32.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, u
5757
if ((int)high < 0)
5858
return -EINVAL;
5959
else
60-
return sys_truncate(path, (high << 32) | low);
60+
return ksys_truncate(path, (high << 32) | low);
6161
}
6262

6363
asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)

‎arch/x86/ia32/sys_ia32.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename,
5656
unsigned long, offset_low, unsigned long, offset_high)
5757
{
58-
return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
58+
return ksys_truncate(filename,
59+
((loff_t) offset_high << 32) | offset_low);
5960
}
6061

6162
COMPAT_SYSCALL_DEFINE3(x86_ftruncate64, unsigned int, fd,

‎fs/open.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ long vfs_truncate(const struct path *path, loff_t length)
128128
}
129129
EXPORT_SYMBOL_GPL(vfs_truncate);
130130

131-
static long do_sys_truncate(const char __user *pathname, loff_t length)
131+
long do_sys_truncate(const char __user *pathname, loff_t length)
132132
{
133133
unsigned int lookup_flags = LOOKUP_FOLLOW;
134134
struct path path;

‎include/linux/syscalls.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,4 +1078,11 @@ static inline long ksys_open(const char __user *filename, int flags,
10781078
return do_sys_open(AT_FDCWD, filename, flags, mode);
10791079
}
10801080

1081+
extern long do_sys_truncate(const char __user *pathname, loff_t length);
1082+
1083+
static inline long ksys_truncate(const char __user *pathname, loff_t length)
1084+
{
1085+
return do_sys_truncate(pathname, length);
1086+
}
1087+
10811088
#endif

0 commit comments

Comments
 (0)