]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
unified (weak) sys_pipe implementation
authorUlrich Drepper <drepper@redhat.com>
Sat, 3 May 2008 19:10:37 +0000 (15:10 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 3 May 2008 20:50:33 +0000 (13:50 -0700)
This replaces the duplicated arch-specific versions of "sys_pipe()" with
one unified implementation.  This removes almost 250 lines of duplicated
code.

It's marked __weak, so that *if* an architecture wants to override the
default implementation it can do so by simply having its own replacement
version, since many architectures use alternate calling conventions for
the 'pipe()' system call for legacy reasons (ie traditional UNIX
implementations often return the two file descriptors in registers)

I still haven't changed the cris version even though Linus says the BKL
isn't needed.  The arch maintainer can easily do it if there are really
no obstacles.

Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
18 files changed:
arch/arm/kernel/sys_arm.c
arch/avr32/kernel/sys_avr32.c
arch/blackfin/kernel/sys_bfin.c
arch/frv/kernel/sys_frv.c
arch/h8300/kernel/sys_h8300.c
arch/m68k/kernel/sys_m68k.c
arch/m68knommu/kernel/sys_m68k.c
arch/mn10300/kernel/sys_mn10300.c
arch/parisc/kernel/sys_parisc.c
arch/powerpc/kernel/syscalls.c
arch/s390/kernel/sys_s390.c
arch/sh/kernel/sys_sh64.c
arch/um/kernel/syscall.c
arch/v850/kernel/syscalls.c
arch/x86/kernel/sys_i386_32.c
arch/x86/kernel/sys_x86_64.c
fs/pipe.c
include/asm-powerpc/syscalls.h

index 9bd1870d980ec74b5c77936828a1f7e6f481047b..0128687ba0f71ac8c65598a108bc6278f6e60c68 100644 (file)
@@ -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,
index 8deb6003ee626afb44c14f785c25eea3b239c9f2..8e8911e55c8f27a9a55acfa7025b1d6322aba6b1 100644 (file)
 #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)
index efb7b25a2633be0c0c79971ec89ab3c9101153ed..fce49d7cf0017f0014304f8e715477cb29fa8f6b 100644 (file)
 #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,
index 04c6b1677ccf7eb49d5eea003979c6c223e6d00d..49b2cf2c38f3d313e9136dfdeaf84ef675b7b53f 100644 (file)
 #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)
index 00608be6d56772cb0ece55d72b7ff5dab9440352..2745656dcc52c8ac6ad7f3c804e81c4fb3dd91ce 100644 (file)
 #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,
index e892f17ba3fac4984a84bbdd7d5e501cab80fe90..7f54efaf60bb12a0b980a0e05c3ae908f322e6d0 100644 (file)
 #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,
index 65f7a95f056e9726281521b792e5d12a9a9b6282..70028163862981e5ce0f7082a737b97f73f88163 100644 (file)
 #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,
index 5f17a1ebc8253e658e49b173e11c8efaeedcd3ac..bca5a84dc72cced1e6c597a02ec725181a651cfb 100644 (file)
 
 #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
  */
index 4f589216b39e2a47864ea83ca897a859e2a8f3cb..71b31957c8f13805c5a8da1c93c6061bf562f2a7 100644 (file)
 #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;
index e722a4eeb5d0fc4a0a8150900b378fe38969e2bb..4fe69ca244818e78fb86c37c2091a023b4e77b0b 100644 (file)
@@ -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)
index 988d0d64c2c898f154278b8accfa5d935efe0ad8..5fdb799062b7abfa1471488fd2582660cd56b08a 100644 (file)
 #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,
index 578004d71e02dbe68d1c74b769803fa8aa45e9dd..91fb8445a5a094ac8c5f2191b9bca308b5e1b8e4 100644 (file)
 #include <asm/ptrace.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;
-}
-
 /*
  * Do a system call from kernel instead of calling sys_execve so we
  * end up with proper pt_regs.
index 9cffc628a37e0f9505f6da9a8283eaf0ee368e2f..128ee85bc8d96b78522fb7f1043a913ec0e9d269 100644 (file)
@@ -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)
 {
index 003db9c8c44aa4fc9934c7cff03169af05a96e25..1a83daf8e24f069fb6873d963a0b4d6ac6d62352 100644 (file)
@@ -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,
index a86d26f036e1ddcefee7f293964b917d1296b713..d2ab52cc1d6b17fa5ff72ef4e5b6111acc6903f5 100644 (file)
 #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)
index bd802a5e1aa344680971c51d65444c019ed9fc87..3b360ef33817c9b618e661f452e682a43dfe91bc 100644 (file)
 #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)
 {
index f73492b6817ea37d356b63f8bdfd81a960156ca7..3499f9ff6316ba7189475ec11021bab74dcf083a 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1075,6 +1075,23 @@ int do_pipe(int *fd)
        return error;
 }
 
+/*
+ * sys_pipe() is the normal C calling standard for creating
+ * a pipe. It's not the way Unix traditionally does this, though.
+ */
+asmlinkage long __weak sys_pipe(int __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;
+}
+
 /*
  * 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
index b3ca41fc8bb149c78667f132a855f2a1a28ad029..2b8a458f990a8b73e72ac2da42322812f9094bba 100644 (file)
@@ -30,7 +30,7 @@ asmlinkage int sys_fork(unsigned long p1, unsigned long p2,
 asmlinkage int sys_vfork(unsigned long p1, unsigned long p2,
                unsigned long p3, unsigned long p4, unsigned long p5,
                unsigned long p6, struct pt_regs *regs);
-asmlinkage int sys_pipe(int __user *fildes);
+asmlinkage long sys_pipe(int __user *fildes);
 asmlinkage long sys_rt_sigaction(int sig,
                const struct sigaction __user *act,
                struct sigaction __user *oact, size_t sigsetsize);