I'm pretty sure nothing in userspace needs the old sys_opipe() system
call entry point.

sys_pipe is still implemented using it, so just rename it to "opipe()"
and continue using in the kernel.  As a bonus, this made me notice
that linux_sys_pipe() was reimplementing sys_pipe() (except without
correct file descriptor table locking), so we can just get rid of that
function and have compat_linux use sys_pipe() directly.

Shrinks an i386 kernel by 190 bytes!!

ok?

Index: kern/syscalls.master
===================================================================
RCS file: /cvs/src/sys/kern/syscalls.master,v
retrieving revision 1.111
diff -u -p -r1.111 syscalls.master
--- kern/syscalls.master        7 Jul 2011 23:45:00 -0000       1.111
+++ kern/syscalls.master        8 Jul 2011 02:37:03 -0000
@@ -110,7 +110,7 @@
 39     STD             { pid_t sys_getppid(void); }
 40     OBSOL           lstat43
 41     STD             { int sys_dup(int fd); }
-42     STD             { int sys_opipe(void); }
+42     OBSOL           opipe
 43     STD             { gid_t sys_getegid(void); }
 44     STD             { int sys_profil(caddr_t samples, size_t size, \
                            u_long offset, u_int scale); }
Index: kern/sys_pipe.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.59
diff -u -p -r1.59 sys_pipe.c
--- kern/sys_pipe.c     27 May 2011 08:53:15 -0000      1.59
+++ kern/sys_pipe.c     8 Jul 2011 02:37:03 -0000
@@ -99,9 +99,8 @@ int   pipespace(struct pipe *, u_int);
  * The pipe system call for the DTYPE_PIPE type of pipes
  */
 
-/* ARGSUSED */
 int
-sys_opipe(struct proc *p, void *v, register_t *retval)
+opipe(struct proc *p, int *retval)
 {
        struct filedesc *fdp = p->p_fd;
        struct file *rf, *wf;
Index: kern/uipc_syscalls.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_syscalls.c,v
retrieving revision 1.79
diff -u -p -r1.79 uipc_syscalls.c
--- kern/uipc_syscalls.c        4 Apr 2011 12:44:10 -0000       1.79
+++ kern/uipc_syscalls.c        8 Jul 2011 02:37:03 -0000
@@ -47,6 +47,7 @@
 #include <sys/signalvar.h>
 #include <sys/unpcb.h>
 #include <sys/un.h>
+#include <sys/pipe.h>
 #ifdef KTRACE
 #include <sys/ktrace.h>
 #endif
@@ -893,14 +894,11 @@ sys_pipe(struct proc *p, void *v, regist
                syscallarg(int *) fdp;
        } */ *uap = v;
        int error, fds[2];
-       register_t rval[2];
 
-       if ((error = sys_opipe(p, v, rval)) != 0)
+       if ((error = opipe(p, fds)) != 0)
                return (error);
 
-       fds[0] = rval[0];
-       fds[1] = rval[1];
-       error = copyout(fds, SCARG(uap, fdp), 2 * sizeof (int));
+       error = copyout(fds, SCARG(uap, fdp), sizeof(fds));
        if (error) {
                fdplock(p->p_fd);
                fdrelease(p, fds[0]);
Index: sys/pipe.h
===================================================================
RCS file: /cvs/src/sys/sys/pipe.h,v
retrieving revision 1.13
diff -u -p -r1.13 pipe.h
--- sys/pipe.h  21 Nov 2005 18:16:46 -0000      1.13
+++ sys/pipe.h  8 Jul 2011 02:37:03 -0000
@@ -85,6 +85,7 @@ struct pipe {
 
 #ifdef _KERNEL
 void   pipe_init(void);
+int    opipe(struct proc *p, int *);
 #endif /* _KERNEL */
 
 #endif /* !_SYS_PIPE_H_ */
Index: compat/linux/syscalls.master
===================================================================
RCS file: /cvs/src/sys/compat/linux/syscalls.master,v
retrieving revision 1.57
diff -u -p -r1.57 syscalls.master
--- compat/linux/syscalls.master        7 Jul 2011 06:15:47 -0000       1.57
+++ compat/linux/syscalls.master        8 Jul 2011 02:37:03 -0000
@@ -97,7 +97,7 @@
 39     STD             { int linux_sys_mkdir(char *path, int mode); }
 40     STD             { int linux_sys_rmdir(char *path); }
 41     NOARGS          { int sys_dup(u_int fd); }
-42     STD             { int linux_sys_pipe(int *pfds); }
+42     NOARGS          { int sys_pipe(int *fdp); }
 43     STD             { int linux_sys_times(struct times *tms); }
 44     STD             { int linux_sys_prof(void); }
 45     STD             { int linux_sys_brk(char *nsize); }
Index: compat/linux/linux_misc.c
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.69
diff -u -p -r1.69 linux_misc.c
--- compat/linux/linux_misc.c   7 Jul 2011 01:19:39 -0000       1.69
+++ compat/linux/linux_misc.c   8 Jul 2011 02:37:03 -0000
@@ -765,52 +765,6 @@ linux_sys_times(p, v, retval)
 }
 
 /*
- * OpenBSD passes fd[0] in retval[0], and fd[1] in retval[1].
- * Linux directly passes the pointer.
- */
-int
-linux_sys_pipe(p, v, retval)
-       struct proc *p;
-       void *v;
-       register_t *retval;
-{
-       struct linux_sys_pipe_args /* {
-               syscallarg(int *) pfds;
-       } */ *uap = v;
-       int error;
-       int pfds[2];
-#ifdef __i386__
-       int reg_edx = retval[1];
-#endif /* __i386__ */
-
-       if ((error = sys_opipe(p, 0, retval))) {
-#ifdef __i386__
-               retval[1] = reg_edx;
-#endif /* __i386__ */
-               return error;
-       }
-
-       /* Assumes register_t is an int */
-
-       pfds[0] = retval[0];
-       pfds[1] = retval[1];
-       if ((error = copyout(pfds, SCARG(uap, pfds), 2 * sizeof (int)))) {
-#ifdef __i386__
-               retval[1] = reg_edx;
-#endif /* __i386__ */
-               fdrelease(p, retval[0]);
-               fdrelease(p, retval[1]);
-               return error;
-       }
-
-       retval[0] = 0;
-#ifdef __i386__
-       retval[1] = reg_edx;
-#endif /* __i386__ */
-       return 0;
-}
-
-/*
  * Alarm. This is a libc call which uses setitimer(2) in OpenBSD.
  * Fiddle with the timers to make it work.
  */

Reply via email to