Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat Cleanup pipe(2) flags, now that native handle them.



details:   https://anonhg.NetBSD.org/src/rev/5c9dcb20ac9e
branches:  trunk
changeset: 329647:5c9dcb20ac9e
user:      njoly <njoly%NetBSD.org@localhost>
date:      Sun Jun 01 13:42:12 2014 +0000

description:
Cleanup pipe(2) flags, now that native handle them.

diffstat:

 sys/compat/linux/arch/alpha/linux_pipe.c   |  24 +++++-----------------
 sys/compat/linux/common/linux_fcntl.h      |   3 +-
 sys/compat/linux/common/linux_file.c       |   7 ++---
 sys/compat/linux/common/linux_pipe.c       |  31 ++++++++---------------------
 sys/compat/linux32/common/linux32_unistd.c |  30 ++++++++--------------------
 5 files changed, 29 insertions(+), 66 deletions(-)

diffs (255 lines):

diff -r 666628a6937e -r 5c9dcb20ac9e sys/compat/linux/arch/alpha/linux_pipe.c
--- a/sys/compat/linux/arch/alpha/linux_pipe.c  Sun Jun 01 11:01:18 2014 +0000
+++ b/sys/compat/linux/arch/alpha/linux_pipe.c  Sun Jun 01 13:42:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_pipe.c,v 1.15 2011/04/14 11:17:47 he Exp $       */
+/*     $NetBSD: linux_pipe.c,v 1.16 2014/06/01 13:42:12 njoly Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_pipe.c,v 1.15 2011/04/14 11:17:47 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pipe.c,v 1.16 2014/06/01 13:42:12 njoly Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -80,28 +80,16 @@
                syscallarg(int *) pfds;
                syscallarg(int) flags;
        } */
-       int error;
-       int flag = 0;
+       int error, flags;
 
-       switch (SCARG(uap, flags)) {
-       case LINUX_O_CLOEXEC:
-               break;
-       case LINUX_O_NONBLOCK:
-       case LINUX_O_NONBLOCK|LINUX_O_CLOEXEC:
-               flag = O_NONBLOCK;
-               break;
-       default:
+       flags = linux_to_bsd_ioflags(SCARG(uap, flags));
+       if ((flags & ~(O_CLOEXEC|O_NONBLOCK)) != 0)
                return EINVAL;
-       }
 
-       if ((error = pipe1(l, retval, flag)))
+       if ((error = pipe1(l, retval, flags)))
                return error;
 
        (l->l_md.md_tf)->tf_regs[FRAME_A4] = retval[1];
 
-       if (SCARG(uap, flags) & LINUX_O_CLOEXEC) {
-               fd_set_exclose(l, retval[0], true);
-               fd_set_exclose(l, retval[1], true);
-       }       
        return 0;
 }
diff -r 666628a6937e -r 5c9dcb20ac9e sys/compat/linux/common/linux_fcntl.h
--- a/sys/compat/linux/common/linux_fcntl.h     Sun Jun 01 11:01:18 2014 +0000
+++ b/sys/compat/linux/common/linux_fcntl.h     Sun Jun 01 13:42:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_fcntl.h,v 1.15 2013/09/24 13:27:50 njoly Exp $   */
+/*     $NetBSD: linux_fcntl.h,v 1.16 2014/06/01 13:42:12 njoly Exp $   */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
 #define LINUX_AT_NO_AUTOMOUNT          0x0800
 #define LINUX_AT_EMPTY_PATH            0x1000
 
+int linux_to_bsd_ioflags(int);
 int linux_to_bsd_atflags(int);
 
 struct linux_flock {
diff -r 666628a6937e -r 5c9dcb20ac9e sys/compat/linux/common/linux_file.c
--- a/sys/compat/linux/common/linux_file.c      Sun Jun 01 11:01:18 2014 +0000
+++ b/sys/compat/linux/common/linux_file.c      Sun Jun 01 13:42:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_file.c,v 1.111 2014/05/18 09:30:00 njoly Exp $   */
+/*     $NetBSD: linux_file.c,v 1.112 2014/06/01 13:42:12 njoly Exp $   */
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.111 2014/05/18 09:30:00 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.112 2014/06/01 13:42:12 njoly Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -69,7 +69,6 @@
 
 #include <compat/linux/linux_syscallargs.h>
 
-static int linux_to_bsd_ioflags(int);
 static int bsd_to_linux_ioflags(int);
 #ifndef __amd64__
 static void bsd_to_linux_stat(struct stat *, struct linux_stat *);
@@ -86,7 +85,7 @@
  * The next two functions convert between the Linux and NetBSD values
  * of the flags used in open(2) and fcntl(2).
  */
-static int
+int
 linux_to_bsd_ioflags(int lflags)
 {
        int res = 0;
diff -r 666628a6937e -r 5c9dcb20ac9e sys/compat/linux/common/linux_pipe.c
--- a/sys/compat/linux/common/linux_pipe.c      Sun Jun 01 11:01:18 2014 +0000
+++ b/sys/compat/linux/common/linux_pipe.c      Sun Jun 01 13:42:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_pipe.c,v 1.65 2011/04/14 00:59:06 christos Exp $ */
+/*     $NetBSD: linux_pipe.c,v 1.66 2014/06/01 13:42:12 njoly Exp $    */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_pipe.c,v 1.65 2011/04/14 00:59:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_pipe.c,v 1.66 2014/06/01 13:42:12 njoly Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,7 +63,7 @@
  * Linux directly passes the pointer.
  */
 static int
-linux_pipe_return(struct lwp *l, int *pfds, register_t *retval, int flags)
+linux_pipe_return(struct lwp *l, int *pfds, register_t *retval)
 {
        int error;
 
@@ -79,10 +79,6 @@
                if ((error = copyout(retval, pfds, 2 * sizeof(*pfds))))
                        return error;
        }
-       if (flags & LINUX_O_CLOEXEC) {
-               fd_set_exclose(l, retval[0], true);
-               fd_set_exclose(l, retval[1], true);
-       }
        retval[0] = 0;
        return 0;
 }
@@ -99,7 +95,7 @@
        if ((error = pipe1(l, retval, 0)))
                return error;
 
-       return linux_pipe_return(l, SCARG(uap, pfds), retval, 0);
+       return linux_pipe_return(l, SCARG(uap, pfds), retval);
 }
 
 int
@@ -110,23 +106,14 @@
                syscallarg(int *) pfds;
                syscallarg(int) flags;
        } */
-       int error;
-       int flag = 0;
+       int error, flags;
 
-       switch (SCARG(uap, flags)) {
-       case LINUX_O_CLOEXEC:
-               break;
-       case LINUX_O_NONBLOCK:
-       case LINUX_O_NONBLOCK|LINUX_O_CLOEXEC:
-               flag = O_NONBLOCK;
-               break;
-       default:
+       flags = linux_to_bsd_ioflags(SCARG(uap, flags));
+       if ((flags & ~(O_CLOEXEC|O_NONBLOCK)) != 0)
                return EINVAL;
-       }
 
-       if ((error = pipe1(l, retval, flag)))
+       if ((error = pipe1(l, retval, flags)))
                return error;
 
-       return linux_pipe_return(l, SCARG(uap, pfds), retval,
-           SCARG(uap, flags));
+       return linux_pipe_return(l, SCARG(uap, pfds), retval);
 }
diff -r 666628a6937e -r 5c9dcb20ac9e sys/compat/linux32/common/linux32_unistd.c
--- a/sys/compat/linux32/common/linux32_unistd.c        Sun Jun 01 11:01:18 2014 +0000
+++ b/sys/compat/linux32/common/linux32_unistd.c        Sun Jun 01 13:42:12 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux32_unistd.c,v 1.38 2014/05/18 09:30:00 njoly Exp $ */
+/*     $NetBSD: linux32_unistd.c,v 1.39 2014/06/01 13:42:12 njoly Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.38 2014/05/18 09:30:00 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.39 2014/06/01 13:42:12 njoly Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -226,7 +226,7 @@
 }
 
 static int
-linux32_pipe(struct lwp *l, int *fd, register_t *retval, int flags)
+linux32_pipe(struct lwp *l, int *fd, register_t *retval)
 {
        /* {
                syscallarg(netbsd32_intp) fd;
@@ -240,10 +240,6 @@
        if ((error = copyout(pfds, fd, 2 * sizeof(*fd))) != 0)
                return error;
 
-       if (flags & LINUX_O_CLOEXEC) {
-               fd_set_exclose(l, retval[0], true);
-               fd_set_exclose(l, retval[1], true);
-       }
        retval[0] = 0;
        retval[1] = 0;
 
@@ -257,31 +253,23 @@
        int error;
        if ((error = pipe1(l, retval, 0)))
                return error;
-       return linux32_pipe(l, SCARG_P32(uap, fd), retval, 0);
+       return linux32_pipe(l, SCARG_P32(uap, fd), retval);
 }
 
 int
 linux32_sys_pipe2(struct lwp *l, const struct linux32_sys_pipe2_args *uap,
     register_t *retval)
 {
-       int flag = 0;
-       int error;
+       int flags, error;
 
-       switch (SCARG(uap, flags)) {
-       case LINUX_O_CLOEXEC:
-               break;
-       case LINUX_O_NONBLOCK:
-       case LINUX_O_NONBLOCK|LINUX_O_CLOEXEC:
-               flag = O_NONBLOCK;
-               break;
-       default:
+       flags = linux_to_bsd_ioflags(SCARG(uap, flags));
+       if ((flags & ~(O_CLOEXEC|O_NONBLOCK)) != 0)
                return EINVAL;
-       }
 
-       if ((error = pipe1(l, retval, flag)))
+       if ((error = pipe1(l, retval, flags)))
                return error;
 
-       return linux32_pipe(l, SCARG_P32(uap, fd), retval, SCARG(uap, flags));
+       return linux32_pipe(l, SCARG_P32(uap, fd), retval);
 }
 
 int



Home | Main Index | Thread Index | Old Index