Mon Oct 31 21:31:29 2011 UTC ()
PR/45545 Yui NARUSE: pipe2's return value is wrong


(christos)
diff -r1.22 -r1.23 src/sys/kern/sys_descrip.c

cvs diff -r1.22 -r1.23 src/sys/kern/sys_descrip.c (expand / switch to unified diff)

--- src/sys/kern/sys_descrip.c 2011/06/26 16:42:42 1.22
+++ src/sys/kern/sys_descrip.c 2011/10/31 21:31:29 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_descrip.c,v 1.22 2011/06/26 16:42:42 christos Exp $ */ 1/* $NetBSD: sys_descrip.c,v 1.23 2011/10/31 21:31:29 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE. 60 * SUCH DAMAGE.
61 * 61 *
62 * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95 62 * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95
63 */ 63 */
64 64
65/* 65/*
66 * System calls on descriptors. 66 * System calls on descriptors.
67 */ 67 */
68 68
69#include <sys/cdefs.h> 69#include <sys/cdefs.h>
70__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.22 2011/06/26 16:42:42 christos Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.23 2011/10/31 21:31:29 christos Exp $");
71 71
72#include <sys/param.h> 72#include <sys/param.h>
73#include <sys/systm.h> 73#include <sys/systm.h>
74#include <sys/filedesc.h> 74#include <sys/filedesc.h>
75#include <sys/kernel.h> 75#include <sys/kernel.h>
76#include <sys/vnode.h> 76#include <sys/vnode.h>
77#include <sys/proc.h> 77#include <sys/proc.h>
78#include <sys/file.h> 78#include <sys/file.h>
79#include <sys/namei.h> 79#include <sys/namei.h>
80#include <sys/socket.h> 80#include <sys/socket.h>
81#include <sys/socketvar.h> 81#include <sys/socketvar.h>
82#include <sys/stat.h> 82#include <sys/stat.h>
83#include <sys/ioctl.h> 83#include <sys/ioctl.h>
@@ -749,15 +749,18 @@ sys_pipe(struct lwp *l, const void *v, r @@ -749,15 +749,18 @@ sys_pipe(struct lwp *l, const void *v, r
749int 749int
750sys_pipe2(struct lwp *l, const struct sys_pipe2_args *uap, register_t *retval) 750sys_pipe2(struct lwp *l, const struct sys_pipe2_args *uap, register_t *retval)
751{ 751{
752 /* { 752 /* {
753 syscallarg(int[2]) fildes; 753 syscallarg(int[2]) fildes;
754 syscallarg(int) flags; 754 syscallarg(int) flags;
755 } */ 755 } */
756 int fd[2], error; 756 int fd[2], error;
757 757
758 if ((error = pipe1(l, retval, SCARG(uap, flags))) != 0) 758 if ((error = pipe1(l, retval, SCARG(uap, flags))) != 0)
759 return error; 759 return error;
760 fd[0] = retval[0]; 760 fd[0] = retval[0];
761 fd[1] = retval[1]; 761 fd[1] = retval[1];
762 return copyout(fd, SCARG(uap, fildes), sizeof(fd)); 762 if ((error = copyout(fd, SCARG(uap, fildes), sizeof(fd))) != 0)
 763 return error;
 764 retval[0] = 0;
 765 return 0;
763} 766}