summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix fcntl(fd, F_GETOWN) with pipes. As a regressionvisa2018-11-131-2/+2
| | | | | | | of kern_descrip.c r1.177 and sys_pipe.c r1.82, the call always returned an error. OK jca@ anton@ mpi@
* Utilize sigio with pipes. This makes fcntl(fd, F_SETOWN, arg) correctlyvisa2018-11-121-8/+8
| | | | | | | | handle arg as a process ID if the value is positive and as a process group ID if the value is negative. In addition, now the signal sending checks privileges. OK mpi@
* Reorder checks in the read/write(2) family of syscalls to prepare makingmpi2018-08-201-5/+5
| | | | | | | | | | | | file operations mp-safe. This change makes it clear that `f_offset' is only accessed in vn_read() and vn_write(), which will help taking it out of the KERNEL_LOCK(). This refactoring uncovered a race in vn_read() which is now documented and will be addressed in a later diff. ok visa@
* Grab the KERNEL_LOCK() in MP-unsafe fo_close routines. This preventsvisa2018-08-151-1/+3
| | | | | | | a scenario where MP-unsafe code gets run without the kernel lock as a consequence of an unlocked system call. OK mpi@, kettenis@
* Make it possible to run pipe(2) and pipe2(2) mostly w/o KERNEL_LOCK():mpi2018-08-131-16/+23
| | | | | | | | - Update counters atomatically - Use IPL_MPFLOOR for pipe's pool. - Grab the KERNEL_LOCK() before calling km_alloc(9) & km_free(9) Inputs from kettenis@, ok visa@
* Move socket & pipe specific logic in their ioctl handler.mpi2018-07-101-1/+7
| | | | ok visa@, tb@
* Put file descriptors on shared data structures when they are completelympi2018-06-181-5/+8
| | | | | | | | | | | | | | | | | setup, take 3. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]' or the global linked list. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu Masson, visa@, guenther@ and art@ Previous version ok bluhm@, ok visa@, sthen@
* Revert introduction of fdinsert(), a sanitify check triggers whenmpi2018-06-051-8/+5
| | | | | | closing a LARVAL file. Found the hardway by sthen@.
* Put file descriptors on shared data structures when they are completelympi2018-06-021-5/+8
| | | | | | | | | | | | | | | | | setup. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]'. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu -, visa@, guenther@ and art@ ok visa@, bluhm@
* Convert 'struct fileops' definitions to C99.mpi2018-04-101-3/+8
| | | | ok millert@, deraadt@, florian@
* Stop assuming <sys/file.h> will pull in fcntl.h when _KERNEL is defined.guenther2018-01-021-1/+2
| | | | ok millert@ sthen@
* Add a flags argument to falloc() that lets it optionally set theguenther2017-02-111-9/+6
| | | | | | | close-on-exec flag on the newly allocated fd. Make falloc()'s return arguments non-optional: assert that they're not NULL. ok mpi@ millert@
* Add ktracing of the fds returned by pipe() and socketpair()guenther2016-10-081-1/+8
| | | | ok deraadt@
* all pools have their ipl set via pool_setipl, so fold it into pool_init.dlg2016-09-151-4/+3
| | | | | | | | | | | | | | | | | | | | | | the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
* pool_setipldlg2016-08-301-1/+2
| | | | ok natano@
* Convert to uiomove(); from Martin Natanostefan2016-01-151-10/+9
| | | | ok millert@
* remove unnecessary casts where the incoming type is void *.tedu2016-01-061-12/+11
|
* remove stale lint annotationstedu2015-12-051-5/+1
|
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-4/+4
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* start retiring the nointr allocator. specify PR_WAITOK as a flag as atedu2014-12-191-3/+3
| | | | marker for which pools are not interrupt safe. ok dlg
* Replace uvm_km_alloc(9) and uvm_km_free(9) with the equivalent km_alooc(9)kettenis2014-09-281-4/+4
| | | | | | and km_free(9) calls. ok tedu@, mlarkin@
* Add additional kernel interfaces for setting close-on-exec on fdsguenther2014-08-311-5/+31
| | | | | | | when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC, SOCK_CLOEXEC. Includes SOCK_NONBLOCK support. ok matthew@
* Copy timespecs member by member in fo_stat callback functions, to avoidguenther2014-01-241-4/+7
| | | | | | | leaking values in the padding bytes on LP64. Also, vn_stat() was lacking the zero-fill to clean its padding. ok kettenis@ deraadt@ phessler@
* bzero -> memsettedu2014-01-211-3/+3
|
* take a file descriptor table lock after allocating pipe structuresmikeb2012-05-061-9/+8
| | | | and buffers; ok guenther
* Add struct proc * argument to FRELE() and FILE_SET_MATURE() inguenther2012-04-221-3/+3
| | | | | | anticipation of further changes to closef(). No binary change. ok krw@ miod@ deraadt@
* keep the fdplock around copyout in pipe. ok matthewtedu2011-07-081-5/+2
|
* Remove the sys_opipe() kernel entry point. sys_pipe() is the future.matthew2011-07-081-9/+18
| | | | | | | While here, switch compat_linux to just use sys_pipe() rather than incorrectly wrapping sys_opipe(). ok tedu@, miod@
* Fix the return values from pipe_kqfilter - kqfilters should return annicm2011-05-271-5/+6
| | | | | | errno not 0/1. ok guenther
* fix typos in comments, no code changes;schwarze2010-01-141-2/+2
| | | | | from Brad Tilley <brad at 16systems dot com>; ok oga@
* Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tnicm2009-11-091-3/+3
| | | | | | | | | | supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
* pipeclose() calls pileseltimeout() which does the KNOTE(); therefore callingderaadt2009-10-301-2/+1
| | | | | KNOTE() a second time is not needed (and perhaps bad) ok claudio millert
* Switch struct stat's timespec members to the names standardized inguenther2009-01-291-4/+4
| | | | | | | | POSIX 1003.1-2008, with compatibility macros for the names used in previous version of OpenBSD. Update all the references in the kernel to use the new, standard member names. ok'ed by miod@, otto@; ports build test by naddy@
* de-__inline a trio of functions to shave some space.blambert2008-07-111-7/+7
| | | | ok art@
* When updating the timestamps on pipes, use getnanotime() instead of moremiod2007-11-281-4/+4
| | | | | | | accurate but more expensive nanotime(), the loss of precision shouldn't matter. Inspired from the other *BSD which did a similar change. ok tedu@ millert@ henning@ deraadt@
* Correctly deal with EOF on pipe wrt kqueue. Based on a fix presentmillert2007-08-071-2/+3
| | | | in FreeBSD and NetBSD. OK art@ beck@
* missing punctuation in comments; from bret lambertjmc2006-11-171-2/+2
|
* ansi/deregister. No binary change.jsg2005-12-131-47/+16
|
* remove p arg from fdplocktedu2004-07-221-2/+2
|
* In pipe_read, when the pipelock fails (most likely because we catch aart2004-07-211-2/+2
| | | | | | | signal), don't jump to unlocked_error: and do things that we don't need to do (including messing up the internal state of the pipe). Just return. ok niklas@ miod@
* This moves access to wall and uptime variables in MI code,tholo2004-06-241-7/+7
| | | | | | | | | | | | | | encapsulating all such access into wall-defined functions that makes sure locking is done as needed. It also cleans up some uses of wall time vs. uptime some places, but there is sure to be more of these needed as well, particularily in MD code. Also, many current calls to microtime() should probably be changed to getmicrotime(), or to the {,get}microuptime() versions. ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others "Oh, that is not your problem!" from miod@
* lock filedesc before manipulating. avoids some rare races.tedu2004-01-061-1/+7
| | | | testing for quite some time by brad + otto
* Bring several fixes from FreeBSD to our current pipe implementation:miod2003-10-031-82/+106
| | | | | | | | | | | | | | | | - when allocating or growing a pipe buffer is not possible, do not panic but report the error and handle it correctly. (1.73) - "The pipe_write() code was locking the pipe without busying it first in certain cases, and a close() by another process could potentially rip the pipe out from under the (blocked) locking operation." (from Al Viro, 1.81) - "Remove test in pipe_write() which causes write(2) to return EAGAIN on a non-blocking pipe in cases where select(2) returns the file descriptor as ready for write. This in turns causes libc_r, for one, to busy wait in such cases. Note: it is a quick performance fix, a more complex fix might be required in case this turns out to have unexpected side effects." (1.141)
* Replace select backends with poll backends. selscan() and pollscan()millert2003-09-231-36/+31
| | | | | | | now call the poll backend. With this change we implement greater poll(2) functionality instead of emulating it via the select backend. Adapted from NetBSD and including some changes from FreeBSD. Tested by many, deraadt@ OK
* First round of __P removal in sysmillert2002-03-141-14/+14
|
* - Rename FILE_{,UN}USE to FREF and FRELE. USE is a bad verb and we don't haveart2002-02-081-3/+5
| | | | | | | | | | | | | | the same semantics as NetBSD anyway, so it's good to avoid name collissions. - Always fdremove before freeing the file, not the other way around. - falloc FREFs the file. - have FILE_SET_MATURE FRELE the file (It feels like a good ortogonality to falloc FREFing the file). - Use closef as much as possible instead of ffree in error paths of falloc:ing functions. closef is much more careful with the fd and can deal with the fd being forcibly closed by dup2. Also try to avoid manually calling *fo_close when closef can do that for us (this makes some error paths mroe complicated (sys_socketpair and sys_pipe), but others become simpler (sys_open)).
* Pool deals fairly well with physical memory shortage, but it doesn't dealart2002-01-231-3/+2
| | | | | | | | | | | | | | | | | | well (not at all) with shortages of the vm_map where the pages are mapped (usually kmem_map). Try to deal with it: - group all information the backend allocator for a pool in a separate struct. The pool will only have a pointer to that struct. - change the pool_init API to reflect that. - link all pools allocating from the same allocator on a linked list. - Since an allocator is responsible to wait for physical memory it will only fail (waitok) when it runs out of its backing vm_map, carefully drain pools using the same allocator so that va space is freed. (see comments in code for caveats and details). - change pool_reclaim to return if it actually succeeded to free some memory, use that information to make draining easier and more efficient. - get rid of PR_URGENT, noone uses it.
* Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.miod2001-11-061-2/+1
| | | | (Look ma, I might have broken the tree)
* - every new fd created by falloc() is marked as larval and should not be usedart2001-10-261-1/+3
| | | | | | | any anyone. Every caller of falloc matures the fd when it's usable. - Since every lookup in the fd table must now check this flag and all of them do the same thing, move all the necessary checks into a function - fd_getfile.
* merge vm/vm_kern.h into uvm/uvm_extern.h; art@ okmickey2001-09-191-3/+1
|