Module Name: src Committed By: njoly Date: Sun Jun 1 13:42:12 UTC 2014
Modified Files: src/sys/compat/linux/arch/alpha: linux_pipe.c src/sys/compat/linux/common: linux_fcntl.h linux_file.c linux_pipe.c src/sys/compat/linux32/common: linux32_unistd.c Log Message: Cleanup pipe(2) flags, now that native handle them. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux/arch/alpha/linux_pipe.c cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux/common/linux_fcntl.h cvs rdiff -u -r1.111 -r1.112 src/sys/compat/linux/common/linux_file.c cvs rdiff -u -r1.65 -r1.66 src/sys/compat/linux/common/linux_pipe.c cvs rdiff -u -r1.38 -r1.39 src/sys/compat/linux32/common/linux32_unistd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/linux/arch/alpha/linux_pipe.c diff -u src/sys/compat/linux/arch/alpha/linux_pipe.c:1.15 src/sys/compat/linux/arch/alpha/linux_pipe.c:1.16 --- src/sys/compat/linux/arch/alpha/linux_pipe.c:1.15 Thu Apr 14 11:17:47 2011 +++ src/sys/compat/linux/arch/alpha/linux_pipe.c Sun Jun 1 13:42:12 2014 @@ -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 @@ linux_sys_pipe2(struct lwp *l, const str 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; } Index: src/sys/compat/linux/common/linux_fcntl.h diff -u src/sys/compat/linux/common/linux_fcntl.h:1.15 src/sys/compat/linux/common/linux_fcntl.h:1.16 --- src/sys/compat/linux/common/linux_fcntl.h:1.15 Tue Sep 24 13:27:50 2013 +++ src/sys/compat/linux/common/linux_fcntl.h Sun Jun 1 13:42:12 2014 @@ -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 { Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.111 src/sys/compat/linux/common/linux_file.c:1.112 --- src/sys/compat/linux/common/linux_file.c:1.111 Sun May 18 09:30:00 2014 +++ src/sys/compat/linux/common/linux_file.c Sun Jun 1 13:42:12 2014 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: linux_file.c #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 @@ conv_linux_flock(linux, flock) * 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; Index: src/sys/compat/linux/common/linux_pipe.c diff -u src/sys/compat/linux/common/linux_pipe.c:1.65 src/sys/compat/linux/common/linux_pipe.c:1.66 --- src/sys/compat/linux/common/linux_pipe.c:1.65 Thu Apr 14 00:59:06 2011 +++ src/sys/compat/linux/common/linux_pipe.c Sun Jun 1 13:42:12 2014 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: linux_pipe.c * 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 @@ linux_pipe_return(struct lwp *l, int *pf 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 @@ linux_sys_pipe(struct lwp *l, const stru 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 @@ linux_sys_pipe2(struct lwp *l, const str 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); } Index: src/sys/compat/linux32/common/linux32_unistd.c diff -u src/sys/compat/linux32/common/linux32_unistd.c:1.38 src/sys/compat/linux32/common/linux32_unistd.c:1.39 --- src/sys/compat/linux32/common/linux32_unistd.c:1.38 Sun May 18 09:30:00 2014 +++ src/sys/compat/linux32/common/linux32_unistd.c Sun Jun 1 13:42:12 2014 @@ -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 @@ linux32_select1(struct lwp *l, register_ } 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 @@ linux32_pipe(struct lwp *l, int *fd, reg 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 @@ linux32_sys_pipe(struct lwp *l, const st 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