unify sys_pipe implementation
Subsystems (9)
PATCH 1/1 unify sys_pipe implementation
In preparation for adding pipe2, the variant with a flag parameter, this is a patch which unifies the implementation of the majority of the architectures. There is a difference in the way sys_pipe is implemented for some architectures. This is why so far each architecture defined its own copy in arch/*/kernel/sys*.c. Most of the time these are exact copies. To avoid this fs/pipe.c now contains this common code and the architecture's unistd.h file defines if necessary the macro __ARCH_WANT_SYS_PIPE.
A few architectures still have their own sys_pipe files. In a few cases I can imagine this not to be necessary. I leave this to the arch maintainers.
The net result is that we have 230 lines less.
arch/arm/kernel/sys_arm.c | 17 ----------------- arch/avr32/kernel/sys_avr32.c | 13 ------------- arch/blackfin/kernel/sys_bfin.c | 17 ----------------- arch/frv/kernel/sys_frv.c | 17 ----------------- arch/h8300/kernel/sys_h8300.c | 17 ----------------- arch/m68k/kernel/sys_m68k.c | 17 ----------------- arch/m68knommu/kernel/sys_m68k.c | 17 ----------------- arch/mn10300/kernel/sys_mn10300.c | 17 ----------------- arch/parisc/kernel/sys_parisc.c | 13 ------------- arch/powerpc/kernel/syscalls.c | 17 ----------------- arch/s390/kernel/sys_s390.c | 17 ----------------- arch/sh/kernel/sys_sh64.c | 17 ----------------- arch/um/kernel/syscall.c | 17 ----------------- arch/v850/kernel/syscalls.c | 17 ----------------- arch/x86/kernel/sys_i386_32.c | 17 ----------------- arch/x86/kernel/sys_x86_64.c | 17 ----------------- fs/pipe.c | 20 ++++++++++++++++++++ include/asm-arm/unistd.h | 1 + include/asm-avr32/unistd.h | 1 + include/asm-blackfin/unistd.h | 1 + include/asm-frv/unistd.h | 1 + include/asm-h8300/unistd.h | 1 + include/asm-m68k/unistd.h | 1 + include/asm-m68knommu/unistd.h | 1 + include/asm-mn10300/unistd.h | 1 + include/asm-parisc/unistd.h | 1 + include/asm-powerpc/unistd.h | 1 + include/asm-s390/unistd.h | 1 + include/asm-sh/unistd_64.h | 1 + include/asm-v850/unistd.h | 1 + include/asm-x86/unistd_32.h | 1 + include/asm-x86/unistd_64.h | 1 + 32 files changed, 35 insertions(+), 264 deletions(-)
arch/arm/kernel/sys_arm.c +0 -17
@@ -34,23 +34,6 @@ extern unsigned long do_mremap(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr); -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ inline long do_mmap2( unsigned long addr, unsigned long len,
arch/avr32/kernel/sys_avr32.c +0 -13
@@ -14,19 +14,6 @@#include <asm/mman.h> #include <asm/uaccess.h> -asmlinkage int sys_pipe(unsigned long __user *filedes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (filedes, fd,sizeof (fd))) - error = -EFAULT ; - } -return error; -} -asmlinkage long sys_mmap2 (unsigned long addr,unsigned long len,unsigned long prot,unsigned long flags,unsigned long fd,off_t offset)
arch/blackfin/kernel/sys_bfin.c +0 -17
@@ -45,23 +45,6 @@#include <asm/cacheflush.h> #include <asm/dma.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ static inline long do_mmap2(unsigned long addr, unsigned long len,
arch/frv/kernel/sys_frv.c +0 -17
@@ -28,23 +28,6 @@#include <asm/setup.h> #include <asm/uaccess.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage long sys_pipe (unsigned long __user * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -asmlinkage long sys_mmap2 (unsigned long addr,unsigned long len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long pgoff)
arch/h8300/kernel/sys_h8300.c +0 -17
@@ -27,23 +27,6 @@#include <asm/traps.h> #include <asm/unistd.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ static inline long do_mmap2( unsigned long addr, unsigned long len,
arch/m68k/kernel/sys_m68k.c +0 -17
@@ -30,23 +30,6 @@#include <asm/page.h> #include <asm/unistd.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long __user * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ static inline long do_mmap2( unsigned long addr, unsigned long len,
arch/m68knommu/kernel/sys_m68k.c +0 -17
@@ -28,23 +28,6 @@#include <asm/cacheflush.h> #include <asm/unistd.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ static inline long do_mmap2( unsigned long addr, unsigned long len,
arch/mn10300/kernel/sys_mn10300.c +0 -17
@@ -29,23 +29,6 @@#define MIN_MAP_ADDR PAGE_SIZE/* minimum fixed mmap address */ /* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way Unix traditionally does this, though. -*/ -asmlinkage long sys_pipe (unsigned long __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} - -/* * memory mapping syscall */ asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
arch/parisc/kernel/sys_parisc.c +0 -13
@@ -33,19 +33,6 @@#include <linux/utsname.h> #include <linux/personality.h> -int sys_pipe (int __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -static unsigned long get_unshared_area (unsigned long addr,unsigned long len) {struct vm_area_struct *vma;
arch/powerpc/kernel/syscalls.c +0 -17
@@ -136,23 +136,6 @@ int sys_ipc(uint call, int first, unsigned long second, long third,return ret; } -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -int sys_pipe (int __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -static inline unsigned long do_mmap2 (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long off,int shift)
arch/s390/kernel/sys_s390.c +0 -17
@@ -32,23 +32,6 @@#include <asm/uaccess.h> #include "entry.h" -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way Unix traditionally does this, though. -*/ -asmlinkage long sys_pipe (unsigned long __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -/* common code for old and new mmaps */ static inline long do_mmap2( unsigned long addr, unsigned long len,
arch/sh/kernel/sys_sh64.c +0 -17
@@ -31,23 +31,6 @@#include <asm/unistd.h> /* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way Unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} - -/* * Do a system call from kernel instead of calling sys_execve so we * end up with proper pt_regs. */
arch/um/kernel/syscall.c +0 -17
@@ -73,23 +73,6 @@ long old_mmap(unsigned long addr, unsigned long len, out:return err; } -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -long sys_pipe (unsigned long __user * fildes) -{ -int fd[2 ]; -long error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,sizeof (fd))) - error = -EFAULT ; - } -return error; -} -long sys_uname (struct old_utsname __user * name) {
arch/v850/kernel/syscalls.c +0 -17
@@ -132,23 +132,6 @@ sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)return ret; } -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way unix traditionally does this, though. -*/ -int sys_pipe (int *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} - static inline unsigned long do_mmap2 (unsigned long addr, size_t len, unsigned long prot, unsigned long flags,
arch/x86/kernel/sys_i386_32.c +0 -17
@@ -22,23 +22,6 @@#include <asm/uaccess.h> #include <asm/unistd.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way Unix traditionally does this, though. -*/ -asmlinkage int sys_pipe(unsigned long __user * fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -asmlinkage long sys_mmap2 (unsigned long addr,unsigned long len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long pgoff)
arch/x86/kernel/sys_x86_64.c +0 -17
@@ -17,23 +17,6 @@#include <asm/uaccess.h> #include <asm/ia32.h> -/* -* sys_pipe() is the normal C calling standard for creating -* a pipe. It's not the way Unix traditionally does this, though. -*/ -asmlinkage long sys_pipe (int __user *fildes) -{ -int fd[2 ]; -int error; - - error =do_pipe (fd); -if (!error) { -if (copy_to_user (fildes, fd,2 *sizeof (int ))) - error = -EFAULT ; - } -return error; -} -asmlinkage long sys_mmap (unsigned long addr,unsigned long len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long off) {
fs/pipe.c +20 -0
@@ -20,6 +20,7 @@#include <asm/uaccess.h> #include <asm/ioctls.h> +#include <asm/unistd.h> /* * We use a start+len construction, which provides full use of the
@@ -1075,6 +1076,25 @@ int do_pipe(int *fd)return error; } +#ifdef __ARCH_WANT_SYS_PIPE +/* +* sys_pipe() is the normal C calling standard for creating +* a pipe. It's not the way Unix traditionally does this, though. +*/ +asmlinkage long sys_pipe (unsigned long __user *fildes) +{ +int fd[2 ]; +int error; + + error =do_pipe (fd); +if (!error) { +if (copy_to_user (fildes, fd,sizeof (fd))) + error = -EFAULT ; + } +return error; +} +#endif +/* * pipefs should _never_ be mounted by userland - too much of security hassle, * no real gain from having the whole whorehouse mounted. So we don't need
include/asm-arm/unistd.h +1 -0
@@ -422,6 +422,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE#if !defined(CONFIG_AEABI ) || defined(CONFIG_OABI_COMPAT )#define __ARCH_WANT_SYS_TIME
include/asm-avr32/unistd.h +1 -0
@@ -331,6 +331,7 @@#define __ARCH_WANT_SYS_GETPGRP#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-blackfin/unistd.h +1 -0
@@ -418,6 +418,7 @@#define __ARCH_WANT_SYS_NICE#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-frv/unistd.h +1 -0
@@ -361,6 +361,7 @@#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-h8300/unistd.h +1 -0
@@ -352,6 +352,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-m68k/unistd.h +1 -0
@@ -352,6 +352,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE/* whitelist for checksyscalls */ #define __IGNORE_restart_syscall
include/asm-m68knommu/unistd.h +1 -0
@@ -353,6 +353,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-mn10300/unistd.h +1 -0
@@ -369,6 +369,7 @@#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-parisc/unistd.h +1 -0
@@ -974,6 +974,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE#endif /* __ASSEMBLY__ */
include/asm-powerpc/unistd.h +1 -0
@@ -371,6 +371,7 @@#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE#ifdef CONFIG_PPC32 #define __ARCH_WANT_OLD_STAT#endif
include/asm-s390/unistd.h +1 -0
@@ -383,6 +383,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE#define __ARCH_WANT_SYS_RT_SIGSUSPEND# ifndef CONFIG_64BIT # define __ARCH_WANT_STAT64
include/asm-sh/unistd_64.h +1 -0
@@ -402,6 +402,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-v850/unistd.h +1 -0
@@ -226,6 +226,7 @@#define __ARCH_WANT_SYS_SIGPENDING#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-x86/unistd_32.h +1 -0
@@ -358,6 +358,7 @@#define __ARCH_WANT_SYS_SIGPROCMASK#define __ARCH_WANT_SYS_RT_SIGACTION#define __ARCH_WANT_SYS_RT_SIGSUSPEND +#define __ARCH_WANT_SYS_PIPE/* * "Conditional" syscalls
include/asm-x86/unistd_64.h +1 -0
@@ -665,6 +665,7 @@ __SYSCALL(__NR_timerfd_gettime, sys_timerfd_gettime)#define __ARCH_WANT_SYS_TIME#define __ARCH_WANT_COMPAT_SYS_TIME#endif /* __NO_STUBS */ +#define __ARCH_WANT_SYS_PIPE#ifdef __KERNEL__/*
fs/pipe.c int do_pipe(int *fd) · line 1084
Quoted 7 lines · Ulrich Drepper
fs/pipe.c +6
-0+#ifdef __ARCH_WANT_SYS_PIPE +/* +* sys_pipe() is the normal C calling standard for creating +* a pipe. It's not the way Unix traditionally does this, though. +*/ +asmlinkage long sys_pipe (unsigned long __user *fildes)
Gaah. If you do this, at least clean it up and use "int *fildes", rather than copying the uglier old "unsigned long" ones that only exist because originally we had lots of odd int/long things that didn't matter on x86.
Yeah, yeah, the thing that matters is actually
fs/pipe.c int do_pipe(int *fd) · line 1091
Quoted 3 lines
fs/pipe.c +2
-0+int fd[2 ]; +if (copy_to_user (fildes, fd,sizeof (fd)))
so it happens to work on all architectures anyway, but..
Also, we shouldn't need __ARCH_WANT_SYS_PIPE for this. Just make it unconditional, and then any architecture that wants somethign else can do their own "myarch_sys_pipe()" or whatever.
Linus