History log of /netbsd-current/sys/compat/linux/common/linux_pipe.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.69 23-Sep-2021 ryo

add support COMPAT_LINUX for aarch64


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.68 26-Dec-2017 kamil

Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)

sys_pipe2() returns two integers (values), the 2nd one is a copy of the 2nd
file descriptor that lands in fildes[2]. This is a side effect of reusing
the code for sys_pipe() (SYS_pipe) and not cleaning it up.

The first returned value is (on success) 0.

Introduced a small refactoring in pipe1() that it does not operate over
retval[], but on an array int[2]. A user sets retval[] for pipe() when
desired and needed.

This refactoring touches compat code: netbsd32, linux, linux32.

Before the changes on NetBSD/amd64:

$ ktruss -i ./a.out
[...]
15131 1 a.out pipe2(0x7f7fff2e62b8, 0) = 0, 4
[...]

After the changes:

$ ktruss -i ./a.out
[...]
782 1 a.out pipe2(0x7f7fff97e850, 0) = 0
[...]

There should not be a visible change for current users.

Sponsored by <The NetBSD Foundation>


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.67 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.66 01-Jun-2014 njoly

branches: 1.66.2;
Cleanup pipe(2) flags, now that native handle them.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE rmind-smpnet-nbase netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.65 14-Apr-2011 christos

branches: 1.65.14; 1.65.28;
move dup3 to a more appropriate place because pipe is "special". Gotta love
linux.


# 1.64 10-Apr-2011 christos

- implement dup3 and pipe2
- eliminate amd64 ifdef


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 netbsd-5-1-RC4 matt-nb5-mips64-k15 uebayasi-xip-base2 yamt-nfs-mp-base10 netbsd-5-1-RC3 netbsd-5-1-RC2 uebayasi-xip-base1 netbsd-5-1-RC1 yamt-nfs-mp-base9 uebayasi-xip-base netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 yamt-nfs-mp-base8 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 yamt-nfs-mp-base7 netbsd-5-0-1-RELEASE jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base nick-hppapmap-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base mjf-devfs2-base
# 1.63 18-Jun-2008 tsutsui

branches: 1.63.18; 1.63.24;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.62 28-Apr-2008 martin

branches: 1.62.2; 1.62.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.61 20-Dec-2007 dsl

branches: 1.61.6; 1.61.8; 1.61.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base jmcneill-pm-base
# 1.60 08-Dec-2007 dsl

branches: 1.60.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.59 19-Oct-2007 njoly

branches: 1.59.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base ad-audiomp-base post-newlock2-merge
# 1.58 09-Feb-2007 ad

branches: 1.58.18; 1.58.20; 1.58.24;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.57 11-Dec-2005 christos

branches: 1.57.20;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 1.56 05-Nov-2005 manu

Fix a messed up patch


# 1.55 04-Nov-2005 manu

register_t is not an int on amd64


Revision tags: yamt-vop-base3
# 1.54 31-Oct-2005 manu

Fix pipe linux emulation on amd64


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE yamt-vop-base2 thorpej-vnode-attr-base netbsd-2-1-RELEASE yamt-vop-base netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.53 18-Jan-2003 thorpej

branches: 1.53.2; 1.53.18; 1.53.20;
Merge the nathanw_sa branch.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.52 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.51 29-Jun-2000 mrg

branches: 1.51.2; 1.51.4;
remove include of <vm/vm.h>


# 1.50 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base kenh-if-detach-base chs-ubc-base
# 1.49 04-Oct-1998 fvdl

branches: 1.49.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.48 03-Oct-1998 christos

Attempt to fix the mess.


# 1.47 01-Oct-1998 erh

Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.


# 1.46 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.45 08-Sep-1998 rvb

ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.


# 1.44 18-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.43 07-Jul-1998 thorpej

Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.


# 1.42 02-Jul-1998 thorpej

Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).


# 1.41 24-Mar-1998 mycroft

Fix typo in utime().


# 1.40 03-Mar-1998 fvdl

Only free cookiebuf when sure that the vop actually allocated it.


# 1.39 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.38 20-Feb-1998 mycroft

Linux's getsid(2) does in fact return a pid, not a pointer.


# 1.37 14-Feb-1998 thorpej

Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.


# 1.36 21-Oct-1997 fvdl

branches: 1.36.2;
msync -> __msync13


# 1.35 10-Oct-1997 fvdl

Fix braino in my interpretation of the eof flag to VOP_READDIR.


# 1.34 10-Oct-1997 mycroft

Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.


# 1.33 10-Oct-1997 fvdl

Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.


# 1.32 04-Aug-1997 bouyer

Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.


# 1.31 27-Jul-1997 augustss

branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.


# 1.30 07-Apr-1997 augustss

Add Linux nice() syscall.


# 1.29 10-Aug-1996 mycroft

sys/dir.h -> sys/dirent.h


# 1.28 23-Jun-1996 mycroft

Catch up with setre[ug]id() changes.


# 1.27 20-May-1996 fvdl

branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.


# 1.26 04-Apr-1996 christos

- Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()


# 1.25 03-Apr-1996 mycroft

Add explicit return types.


# 1.24 18-Dec-1995 fvdl

msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.


# 1.23 09-Dec-1995 mycroft

We don't need a private version of fork() here any more.


# 1.22 09-Oct-1995 mycroft

Use cookies for directory offset, mostly from Greg Hudson.


# 1.21 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.20 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.19 13-Sep-1995 fvdl

Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.


# 1.18 07-Sep-1995 fvdl

Fix some bugs & typing problems.


# 1.17 23-Aug-1995 fvdl

Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().


# 1.16 21-Aug-1995 fvdl

Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.


# 1.15 21-Aug-1995 mycroft

Implement the old and older uname(2) calls.


# 1.14 16-Aug-1995 mycroft

If updating the timeval would make it negative, zero it instead.


# 1.13 16-Aug-1995 mycroft

Allow bogus timevals, per Linux.


# 1.12 14-Aug-1995 mycroft

Export bsd_to_linux_sig[], and use it.


# 1.11 14-Aug-1995 mycroft

Rearrange #includes.


# 1.10 13-Aug-1995 mycroft

Linux doesn't allow select(2) to be restarted.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 10-Jun-1995 mycroft

Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.


# 1.4 22-Mar-1995 mycroft

Emulate the return value of times() better.


# 1.3 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


# 1.68 26-Dec-2017 kamil

Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)

sys_pipe2() returns two integers (values), the 2nd one is a copy of the 2nd
file descriptor that lands in fildes[2]. This is a side effect of reusing
the code for sys_pipe() (SYS_pipe) and not cleaning it up.

The first returned value is (on success) 0.

Introduced a small refactoring in pipe1() that it does not operate over
retval[], but on an array int[2]. A user sets retval[] for pipe() when
desired and needed.

This refactoring touches compat code: netbsd32, linux, linux32.

Before the changes on NetBSD/amd64:

$ ktruss -i ./a.out
[...]
15131 1 a.out pipe2(0x7f7fff2e62b8, 0) = 0, 4
[...]

After the changes:

$ ktruss -i ./a.out
[...]
782 1 a.out pipe2(0x7f7fff97e850, 0) = 0
[...]

There should not be a visible change for current users.

Sponsored by <The NetBSD Foundation>


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.67 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.66 01-Jun-2014 njoly

branches: 1.66.2;
Cleanup pipe(2) flags, now that native handle them.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE rmind-smpnet-nbase netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.65 14-Apr-2011 christos

branches: 1.65.14; 1.65.28;
move dup3 to a more appropriate place because pipe is "special". Gotta love
linux.


# 1.64 10-Apr-2011 christos

- implement dup3 and pipe2
- eliminate amd64 ifdef


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 netbsd-5-1-RC4 matt-nb5-mips64-k15 uebayasi-xip-base2 yamt-nfs-mp-base10 netbsd-5-1-RC3 netbsd-5-1-RC2 uebayasi-xip-base1 netbsd-5-1-RC1 yamt-nfs-mp-base9 uebayasi-xip-base netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 yamt-nfs-mp-base8 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 yamt-nfs-mp-base7 netbsd-5-0-1-RELEASE jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 nick-hppapmap-base2 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base nick-hppapmap-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base mjf-devfs2-base
# 1.63 18-Jun-2008 tsutsui

branches: 1.63.18; 1.63.24;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.


Revision tags: yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.62 28-Apr-2008 martin

branches: 1.62.2; 1.62.4;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base vmlocking2-base3 bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base matt-armv6-base hpcarm-cleanup-base
# 1.61 20-Dec-2007 dsl

branches: 1.61.6; 1.61.8; 1.61.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base jmcneill-pm-base
# 1.60 08-Dec-2007 dsl

branches: 1.60.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.59 19-Oct-2007 njoly

branches: 1.59.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base vmlocking-base ad-audiomp-base post-newlock2-merge
# 1.58 09-Feb-2007 ad

branches: 1.58.18; 1.58.20; 1.58.24;
Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base rpaulo-netinet-merge-pcb-base
# 1.57 11-Dec-2005 christos

branches: 1.57.20;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base ktrace-lwp-base
# 1.56 05-Nov-2005 manu

Fix a messed up patch


# 1.55 04-Nov-2005 manu

register_t is not an int on amd64


Revision tags: yamt-vop-base3
# 1.54 31-Oct-2005 manu

Fix pipe linux emulation on amd64


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE yamt-vop-base2 thorpej-vnode-attr-base netbsd-2-1-RELEASE yamt-vop-base netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.53 18-Jan-2003 thorpej

branches: 1.53.2; 1.53.18; 1.53.20;
Merge the nathanw_sa branch.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.52 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.51 29-Jun-2000 mrg

branches: 1.51.2; 1.51.4;
remove include of <vm/vm.h>


# 1.50 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base kenh-if-detach-base chs-ubc-base
# 1.49 04-Oct-1998 fvdl

branches: 1.49.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.48 03-Oct-1998 christos

Attempt to fix the mess.


# 1.47 01-Oct-1998 erh

Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.


# 1.46 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.45 08-Sep-1998 rvb

ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.


# 1.44 18-Aug-1998 thorpej

Add some braces to make egcs happy.


# 1.43 07-Jul-1998 thorpej

Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.


# 1.42 02-Jul-1998 thorpej

Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).


# 1.41 24-Mar-1998 mycroft

Fix typo in utime().


# 1.40 03-Mar-1998 fvdl

Only free cookiebuf when sure that the vop actually allocated it.


# 1.39 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.38 20-Feb-1998 mycroft

Linux's getsid(2) does in fact return a pid, not a pointer.


# 1.37 14-Feb-1998 thorpej

Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.


# 1.36 21-Oct-1997 fvdl

branches: 1.36.2;
msync -> __msync13


# 1.35 10-Oct-1997 fvdl

Fix braino in my interpretation of the eof flag to VOP_READDIR.


# 1.34 10-Oct-1997 mycroft

Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.


# 1.33 10-Oct-1997 fvdl

Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.


# 1.32 04-Aug-1997 bouyer

Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.


# 1.31 27-Jul-1997 augustss

branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.


# 1.30 07-Apr-1997 augustss

Add Linux nice() syscall.


# 1.29 10-Aug-1996 mycroft

sys/dir.h -> sys/dirent.h


# 1.28 23-Jun-1996 mycroft

Catch up with setre[ug]id() changes.


# 1.27 20-May-1996 fvdl

branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.


# 1.26 04-Apr-1996 christos

- Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()


# 1.25 03-Apr-1996 mycroft

Add explicit return types.


# 1.24 18-Dec-1995 fvdl

msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.


# 1.23 09-Dec-1995 mycroft

We don't need a private version of fork() here any more.


# 1.22 09-Oct-1995 mycroft

Use cookies for directory offset, mostly from Greg Hudson.


# 1.21 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.20 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.19 13-Sep-1995 fvdl

Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.


# 1.18 07-Sep-1995 fvdl

Fix some bugs & typing problems.


# 1.17 23-Aug-1995 fvdl

Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().


# 1.16 21-Aug-1995 fvdl

Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.


# 1.15 21-Aug-1995 mycroft

Implement the old and older uname(2) calls.


# 1.14 16-Aug-1995 mycroft

If updating the timeval would make it negative, zero it instead.


# 1.13 16-Aug-1995 mycroft

Allow bogus timevals, per Linux.


# 1.12 14-Aug-1995 mycroft

Export bsd_to_linux_sig[], and use it.


# 1.11 14-Aug-1995 mycroft

Rearrange #includes.


# 1.10 13-Aug-1995 mycroft

Linux doesn't allow select(2) to be restarted.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 10-Jun-1995 mycroft

Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.


# 1.4 22-Mar-1995 mycroft

Emulate the return value of times() better.


# 1.3 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.