Cleanup pipe(2) flags, now that native handle them.
This commit is contained in:
parent
755f765c3a
commit
88a8e0469e
@ -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 struct linux_sys_pipe2_args *uap,
|
||||
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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,v 1.111 2014/05/18 09:30:00 njoly Exp $
|
||||
|
||||
#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;
|
||||
|
@ -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,v 1.65 2011/04/14 00:59:06 christos Exp
|
||||
* 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 *pfds, register_t *retval, int flags)
|
||||
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 struct linux_sys_pipe_args *uap,
|
||||
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 struct linux_sys_pipe2_args *uap,
|
||||
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);
|
||||
}
|
||||
|
@ -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_t *retval, int nfds,
|
||||
}
|
||||
|
||||
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, register_t *retval, int flags)
|
||||
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 struct linux32_sys_pipe_args *uap,
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user