summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_pipe.c
Commit message (Collapse)AuthorAgeFilesLines
...
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachdillon2001-07-041-11/+7
| | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
* Correctly hook up the write kqfilter to pipes.jlemon2001-06-151-5/+7
| | | | Submitted by: Niels Provos <provos@citi.umich.edu>
* The pipe_write() code was locking the pipe without busying it first indillon2001-06-041-5/+20
| | | | | | | certain cases, and a close() by another process could potentially rip the pipe out from under the (blocked) locking operation. Reported-by: Alexander Viro <viro@math.psu.edu>
* whitespace/stylealfred2001-05-241-1/+2
|
* aquire vm_mutex a little bit earlier to protect a pmap call.alfred2001-05-231-1/+1
|
* - Assert that the vm mutex is held in pipe_free_kmem().jhb2001-05-211-1/+6
| | | | | | | | - Don't release the vm mutex early in pipespace() but instead hold it across vm_object_deallocate() if vm_map_find() returns an error and across pipe_free_kmem() if vm_map_find() succeeds. - Add a XXX above a zfree() since zalloc already has its own locking, one would hope that zfree() wouldn't need the vm lock.
* Introduce a global lock for the vm subsystem (vm_mtx).alfred2001-05-191-1/+10
| | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
* Cleanupalfred2001-05-171-54/+50
| | | | | | | | | | | | | | | | | | | | | Remove comment about setting error for reads on EOF, read returns 0 on EOF so the code should be ok. Remove non-effective priority boost, PRIO+1 doesn't do anything (according to McKusick), if a real priority boost is needed it should have been +4. Style fixes: .) return foo -> return (foo) .) FLAG1|FlAG2 -> FLAG1 | FlAG2 .) wrap long lines .) unwrap short lines .) for(i=0;i=foo;i++) -> for (i = 0; i=foo; i++) .) remove braces for some conditionals with a single statement .) fix continuation lines. md5 couldn't verify the binary because some code had to be shuffled around to address the style issues.
* initialize pipe pointersalfred2001-05-171-0/+1
|
* pipe_create has to zero out the select record earlier to avoidalfred2001-05-171-1/+1
| | | | | | | returning a half-initialized pipe and causing pipeclose() to follow a junk pointer. Discovered by: "Nick S" <snicko@noid.org>
* Remove an 'optimization' I hope to never see again.alfred2001-05-081-89/+111
| | | | | | | | | | | | | | | | | | The pipe code could not handle running out of kva, it would panic if that happened. Instead return ENFILE to the application which is an acceptable error return from pipe(2). There was some slightly tricky things that needed to be worked on, namely that the pipe code can 'realloc' the size of the buffer if it detects that the pipe could use a bit more room. However if it failed the reallocation it could not cope and would panic. Fix this by attempting to grow the pipe while holding onto our old resources. If all goes well free the old resources and use the new ones, otherwise continue to use the smaller buffer already allocated. While I'm here add a few blank lines for style(9) and remove 'register'.
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-2/+2
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Extend kqueue down to the device layer.jlemon2001-02-151-8/+23
| | | | Backwards compatible approach suggested by: peter
* Style improvements for last fix. Should be functionally the same.dwmalone2001-01-111-19/+19
| | | | Submitted by: bde
* select() DKI is now in <sys/selinfo.h>.wollman2001-01-091-1/+1
|
* If we failed to allocate the file discriptor for the write end ofdwmalone2001-01-081-0/+8
| | | | | | | | the pipe, then we were corrupting the pipe_zone free list by calling pipeclose on rpipe twice. NULL out rpipe to avoid this. Reviewed by: dillon Reviewed by: iedowse
* This patchset fixes a large number of file descriptor race conditions.dillon2000-11-181-2/+7
| | | | | | | | | | | | Pre-rfork code assumed inherent locking of a process's file descriptor array. However, with the advent of rfork() the file descriptor table could be shared between processes. This patch closes over a dozen serious race conditions related to one thread manipulating the table (e.g. closing or dup()ing a descriptor) while another is blocked in an open(), close(), fcntl(), read(), write(), etc... PR: kern/11629 Discussed with: Alexander Viro <viro@math.psu.edu>
* Pipes are not writeable while a direct write is in progress. However,jlemon2000-09-141-1/+1
| | | | | | the kqueue filter got the sense of the test reversed, so fix it. Spotted by: Michael Elkins <me@sigpipe.org>
* Back out the previous change to the queue(3) interface.jake2000-05-261-1/+1
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-1/+1
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Include UID and GID information for stat() calls using the values filledchris2000-05-111-2/+3
| | | | | | into the file descriptor data by falloc(). Reviewed by: phk
* Introduce kqueue() and kevent(), a kernel event notification facility.jlemon2000-04-161-0/+67
|
* Fix in-kernel infinite loop in pipe_write() when the reader goes awaydillon2000-03-241-3/+15
| | | | at just the wrong time.
* Use vfs_timestamp() instead of getnanotime() to set timestamps. Thisbde1999-12-261-3/+4
| | | | | | | fixee incoherency of pipe timestamps relative to file timestamps in the usual case where getnanotime() is not used for the latter. (File and pipe timestamps are still incoherent relative to real time unless the vfs_timestamp_precision sysctl is set to 2 or 3).
* Fix two problems with pipe_write():tegge1999-12-131-23/+64
| | | | | | | | | | | | | | | | | | | | | 1. Data written beyond end of pipe buffer, causing kernel memory corruption. - Check that space is still valid after obtaining the pipe lock. - Defer the calculation of transfer size until the pipe lock has been obtained. - Update the pipe buffer pointers while holding the pipe lock. 2. Writes of size <= PIPE_BUF not always atomic. - Allow an internal write to span two contiguous segments, so writes of size <= PIPE_BUF can be kept atomic when wrapping around from the end to the start of the pipe buffer. PR: 15235 Reviewed by: Matt Dillon <dillon@FreeBSD.org>
* Update pipe code for fo_stat() entry point - pipe_stat() is now no longerpeter1999-11-081-5/+9
| | | | used outside the pipe code.
* useracc() the prequel:phk1999-10-291-1/+0
| | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument.
* Fix bug in pipe code relating to writes of mmap'd but illegal addressdillon1999-09-201-3/+2
| | | | | | | | | spaces which cross a segment boundry in the page table. pmap_kextract() is not designed for access to the user space portion of the page table and cannot handle the null-page-directory-entry case. The fix is to have vm_fault_quick() return a success or failure which is then used to avoid calling pmap_kextract().
* This is what was "fdfix2.patch," a fix for fd sharing. It's prettygreen1999-09-191-4/+6
| | | | | | | | | | | | | | | | | far-reaching in fd-land, so you'll want to consult the code for changes. The biggest change is that now, you don't use fp->f_ops->fo_foo(fp, bar) but instead fo_foo(fp, bar), which increments and decrements the fp refcount upon entry and exit. Two new calls, fhold() and fdrop(), are provided. Each does what it seems like it should, and if fdrop() brings the refcount to zero, the fd is freed as well. Thanks to peter ("to hell with it, it looks ok to me.") for his review. Thanks to msmith for keeping me from putting locks everywhere :) Reviewed by: peter
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Fix fd race conditions (during shared fd table usage.) Badfileops isgreen1999-08-041-5/+6
| | | | | | | | | | | | now used in f_ops in place of NULL, and modifications to the files are more carefully ordered. f_ops should also be set to &badfileops upon "close" of a file. This does not fix other problems mentioned in this PR than the first one. PR: 11629 Reviewed by: peter
* Restructure pipe_read in order to eliminate several race conditions.alc1999-06-051-68/+46
| | | | Submitted by: Matthew Dillon <dillon@apollo.backplane.com> and myself
* Add standard padding argument to pread and pwrite syscall. That should make themdt1999-04-041-5/+7
| | | | | | | | | NetBSD compatible. Add parameter to fo_read and fo_write. (The only flag FOF_OFFSET mean that the offset is set in the struct uio). Factor out some common code from read/pread/write/pwrite syscalls.
* Fix race in pipe read code whereby a blocked lock can allow anotherdillon1999-02-041-20/+39
| | | | | | | | | process to sneak in and write to or close the pipe. The read code enters a 'piperd' state after doing the lock operation without checking to see if the state changed, which can cause the process to wait forever. The code has also been documented more.
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-281-3/+3
| | | | kernel compile
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-271-6/+6
| | | | kernel compile
* Include <sys/select.h> -- don't depend on pollution in <sys/proc.h>.bde1999-01-271-1/+2
|
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-3/+1
| | | | and local variables, goto labels, and functions declared but not defined.
* Installed the second patch attached to kern/7899 with some changes suggestedtruckman1998-11-111-11/+15
| | | | | | | | | | | | | | | | by bde, a few other tweaks to get the patch to apply cleanly again and some improvements to the comments. This change closes some fairly minor security holes associated with F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN had on tty devices. For more details, see the description on the PR. Because this patch increases the size of the proc and pgrp structures, it is necessary to re-install the includes and recompile libkvm, the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w. PR: kern/7899 Reviewed by: bde, elvind
* Added a second argument, "activate" to the vm_page_unwire() call so thatdg1998-10-281-3/+3
| | | | the caller can select either inactive or active queue to put the page on.
* Fixed two potentially serious classes of bugs:dg1998-10-131-3/+3
| | | | | | | | | | | | | | | | 1) The vnode pager wasn't properly tracking the file size due to "size" being page rounded in some cases and not in others. This sometimes resulted in corrupted files. First noticed by Terry Lambert. Fixed by changing the "size" pager_alloc parameter to be a 64bit byte value (as opposed to a 32bit page index) and changing the pagers and their callers to deal with this properly. 2) Fixed a bogus type cast in round_page() and trunc_page() that caused some 64bit offsets and sizes to be scrambled. Removing the cast required adding casts at a few dozen callers. There may be problems with other bogus casts in close-by macros. A quick check seemed to indicate that those were okay, however.
* This commit fixes various 64bit portability problems required fordfr1998-06-071-3/+3
| | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time.
* Moved some #includes from <sys/param.h> nearer to where they are actuallybde1998-03-281-1/+2
| | | | used.
* Add two new functions, get{micro|nano}time.phk1998-03-261-7/+7
| | | | | | | | | | | | They are atomic, but return in essence what is in the "time" variable. gettime() is now a macro front for getmicrotime(). Various patches to use the two new functions instead of the various hacks used in their absence. Some puntuation and grammer patches from Bruce. A couple of XXX comments.
* Staticize.eivind1998-02-091-3/+3
|
* Back out DIAGNOSTIC changes.eivind1998-02-061-3/+1
|
* Turn DIAGNOSTIC into a new-style option.eivind1998-02-041-1/+3
|
* Remove a bunch of variables which were unused both in GENERIC and LINT.phk1997-11-071-2/+1
| | | | Found by: -Wunused
* Move the "retval" (3rd) parameter from all syscall functions and putphk1997-11-061-6/+5
| | | | | | | | | | | | it in struct proc instead. This fixes a boatload of compiler warning, and removes a lot of cruft from the sources. I have not removed the /*ARGSUSED*/, they will require some looking at. libkvm, ps and other userland struct proc frobbing programs will need recompiled.
* Ack! Fix excessive cut/paste blunder during poll mods. Who had thepeter1997-10-061-3/+3
| | | | | | | | | | | pointy hat last? :-] When one is selecting (or polling) for write, it helps if we use the write side of the pipe when requesting wakeups instead of the read side. This broke ghostview (at least) - I'm suprised it wasn't noticed for so long. Reviewed by: Greg Lehey <grog@lemis.com>
OpenPOWER on IntegriCloud