linux_pipe.c revision 1.48
11.48Schristos/* $NetBSD: linux_pipe.c,v 1.48 1998/10/03 20:17:43 christos Exp $ */ 21.47Serh 31.47Serh/*- 41.47Serh * Copyright (c) 1998 The NetBSD Foundation, Inc. 51.47Serh * All rights reserved. 61.47Serh * 71.47Serh * This code is derived from software contributed to The NetBSD Foundation 81.47Serh * by Eric Haszlakiewicz. 91.47Serh * 101.47Serh * Redistribution and use in source and binary forms, with or without 111.47Serh * modification, are permitted provided that the following conditions 121.47Serh * are met: 131.47Serh * 1. Redistributions of source code must retain the above copyright 141.47Serh * notice, this list of conditions and the following disclaimer. 151.47Serh * 2. Redistributions in binary form must reproduce the above copyright 161.47Serh * notice, this list of conditions and the following disclaimer in the 171.47Serh * documentation and/or other materials provided with the distribution. 181.47Serh * 3. All advertising materials mentioning features or use of this software 191.47Serh * must display the following acknowledgement: 201.47Serh * This product includes software developed by the NetBSD 211.47Serh * Foundation, Inc. and its contributors. 221.47Serh * 4. Neither the name of The NetBSD Foundation nor the names of its 231.47Serh * contributors may be used to endorse or promote products derived 241.47Serh * from this software without specific prior written permission. 251.47Serh * 261.47Serh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.47Serh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.47Serh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.47Serh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.47Serh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.47Serh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.47Serh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.47Serh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.47Serh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.47Serh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.47Serh * POSSIBILITY OF SUCH DAMAGE. 371.47Serh */ 381.1Sfvdl 391.1Sfvdl/* 401.1Sfvdl * Copyright (c) 1995 Frank van der Linden 411.1Sfvdl * All rights reserved. 421.1Sfvdl * 431.1Sfvdl * Redistribution and use in source and binary forms, with or without 441.1Sfvdl * modification, are permitted provided that the following conditions 451.1Sfvdl * are met: 461.1Sfvdl * 1. Redistributions of source code must retain the above copyright 471.1Sfvdl * notice, this list of conditions and the following disclaimer. 481.1Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 491.1Sfvdl * notice, this list of conditions and the following disclaimer in the 501.1Sfvdl * documentation and/or other materials provided with the distribution. 511.1Sfvdl * 3. All advertising materials mentioning features or use of this software 521.1Sfvdl * must display the following acknowledgement: 531.1Sfvdl * This product includes software developed for the NetBSD Project 541.1Sfvdl * by Frank van der Linden 551.1Sfvdl * 4. The name of the author may not be used to endorse or promote products 561.1Sfvdl * derived from this software without specific prior written permission 571.1Sfvdl * 581.1Sfvdl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 591.1Sfvdl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 601.1Sfvdl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 611.1Sfvdl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 621.1Sfvdl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 631.1Sfvdl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 641.1Sfvdl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 651.1Sfvdl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 661.1Sfvdl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 671.1Sfvdl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 681.1Sfvdl */ 691.1Sfvdl 701.1Sfvdl#include <sys/param.h> 711.1Sfvdl#include <sys/systm.h> 721.1Sfvdl#include <sys/kernel.h> 731.1Sfvdl#include <sys/malloc.h> 741.1Sfvdl#include <sys/mbuf.h> 751.1Sfvdl#include <sys/mman.h> 761.1Sfvdl#include <sys/mount.h> 771.1Sfvdl 781.1Sfvdl#include <sys/syscallargs.h> 791.1Sfvdl 801.1Sfvdl#include <vm/vm.h> 811.1Sfvdl#include <vm/vm_param.h> 821.1Sfvdl 831.48Schristos#include <compat/linux/common/linux_types.h> 841.48Schristos#include <compat/linux/common/linux_mmap.h> 851.48Schristos#include <compat/linux/common/linux_signal.h> 861.48Schristos 871.1Sfvdl#include <compat/linux/linux_syscallargs.h> 881.1Sfvdl 891.47Serh/* Used on: arm, i386, m68k, ppc */ 901.47Serh/* Not used on: alpha, mips, sparc, sparc64 */ 911.47Serh/* Alpha, mips, sparc and sparc64 pass one of the fds in a register */ 921.1Sfvdl 931.1Sfvdl/* 941.1Sfvdl * NetBSD passes fd[0] in retval[0], and fd[1] in retval[1]. 951.1Sfvdl * Linux directly passes the pointer. 961.1Sfvdl */ 971.1Sfvdlint 981.21Smycroftlinux_sys_pipe(p, v, retval) 991.1Sfvdl struct proc *p; 1001.20Sthorpej void *v; 1011.20Sthorpej register_t *retval; 1021.20Sthorpej{ 1031.21Smycroft struct linux_sys_pipe_args /* { 1041.1Sfvdl syscallarg(int *) pfds; 1051.20Sthorpej } */ *uap = v; 1061.1Sfvdl int error; 1071.1Sfvdl 1081.21Smycroft if ((error = sys_pipe(p, 0, retval))) 1091.1Sfvdl return error; 1101.1Sfvdl 1111.1Sfvdl /* Assumes register_t is an int */ 1121.1Sfvdl if ((error = copyout(retval, SCARG(uap, pfds), 2 * sizeof (int)))) 1131.1Sfvdl return error; 1141.1Sfvdl 1151.1Sfvdl retval[0] = 0; 1161.1Sfvdl return 0; 1171.1Sfvdl} 118