summaryrefslogtreecommitdiff
path: root/sys/kern/sys_generic.c
Commit message (Collapse)AuthorAgeFilesLines
* Grab the process lock while calling psignal and before calling psignal.John Baldwin2001-03-071-2/+8
| | | | Notes: svn path=/head/; revision=73929
* Correctly declare variables as u_int rather than doing typecasts.Jonathan Lemon2001-02-271-7/+7
| | | | | | | | | Kill some register declarations while I'm here. Submitted by: bde (1) Notes: svn path=/head/; revision=73159
* Cast nfds to u_int before range checking it in order to catch negativeJonathan Lemon2001-02-271-1/+2
| | | | | | | | | values. PR: 25393 Notes: svn path=/head/; revision=73116
* poll(2) array limits (take 2) - after some input from bde.Peter Wemm2001-02-091-8/+7
| | | | Notes: svn path=/head/; revision=72203
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* The code I picked up from NetBSD in '97 had a nasty bug. It limitedPeter Wemm2001-02-071-7/+15
| | | | | | | | | | the index of the pollfd array to the number of fd's currently open, not the maximum number of fd's. ie: if you had 0,1,2 open, you could not use pollfd slots higher than 20. The specs say we only have to support OPEN_MAX [64] entries but we allow way more than that. Notes: svn path=/head/; revision=72146
* - Catch up to proc flag changes.John Baldwin2001-01-241-14/+35
| | | | | | | - Add proc locking for selwakeup() and selrecord(). Notes: svn path=/head/; revision=71566
* select() DKI is now in <sys/selinfo.h>.Garrett Wollman2001-01-091-0/+1
| | | | Notes: svn path=/head/; revision=70834
* Only call bwillwrite() for vnodes. Do not penalize devices or pipes.Matthew Dillon2000-12-071-1/+2
| | | | Notes: svn path=/head/; revision=69733
* Add necessary bwillwrite() in writev() entry point.Matthew Dillon2000-12-061-0/+1
| | | | | | | | | Deal with excessive dirty buffers when msync() syncs non-contiguous dirty buffers by checking for the case in UFS *before* checking for clusterability. Notes: svn path=/head/; revision=69686
* only call bwillwrite() to stall on IO when dealing with VNODEs otherwiseAlfred Perlstein2000-11-301-1/+2
| | | | | | | we will stall on non-disk IO for things like fifos and sockets Notes: svn path=/head/; revision=69407
* Protect p_wchan with sched_lock in selwakeup().Jonathan Lemon2000-11-211-0/+2
| | | | Notes: svn path=/head/; revision=69008
* This patchset fixes a large number of file descriptor race conditions.Matthew Dillon2000-11-181-26/+60
| | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=68883
* Fix a warning that has been annoying me for some time:Peter Wemm2000-07-281-1/+1
| | | | | | | | | | "kern/sys_generic.c:358: warning: cast discards qualifiers from pointer target type" The idea for using the uintptr_t intermediate cast for de-constifying a pointer was hinted at by bde some time ago. Notes: svn path=/head/; revision=63974
* Distinguish between whether ktraceing was enabled before an IOBrian Feldman2000-07-271-2/+6
| | | | | | | | | operation or after it. If the ktrace operation was enabled while the process was blocked doing IO, the race would allow it to pass down invalid (uninitialized) data and panic later down the call stack. Notes: svn path=/head/; revision=63905
* For infinite timeouts, set both the tv_sec and tv_usec fields to zero inJohn Baldwin2000-07-131-2/+6
| | | | | | | | | poll() and select(). Noticed by: Wesley Morgan <morganw@chemicals.tacorp.com> Notes: svn path=/head/; revision=63057
* Fix a very obscure bug in select() and poll() where the timeout wouldJohn Baldwin2000-07-121-2/+2
| | | | | | | | | never expire if poll() or select() was called before the system had been in multiuser for 1 second. This was caused by only checking to see if tv_sec was zero rather than checking both tv_sec and tv_usec. Notes: svn path=/head/; revision=63049
* Remove two micro-pessimizations I made. Bruce is teaching me well :)Brian Feldman2000-07-071-2/+2
| | | | | | | | KTRPOINT(p, KTR_GENIO) is more uncommon than error == 0, so it should be first in the && statement. Notes: svn path=/head/; revision=62792
* Modify ktrace's general I/O tracing, ktrgenio(), to use a struct uio *Brian Feldman2000-07-021-15/+36
| | | | | | | | | | | | | | | | instead of a struct iovec * array and int len. Get rid of stupidly trying to allocate all of the memory and copyin()ing the entire iovec[], and instead just do the proper VOP_WRITE() in ktrwrite() using a copy of the struct uio that the syscall originally used. This solves the DoS which could easily be performed; to work around the DoS, one could also remove "options KTRACE" from the kernel. This is a very strong MFC candidate for 4.1. Found by: art@OpenBSD.org Notes: svn path=/head/; revision=62378
* unstatic getfp() so that other subsystems can use it.Alfred Perlstein2000-06-121-2/+1
| | | | | | | | | make sendfile() use it. Approved by: dg Notes: svn path=/head/; revision=61591
* Some ioctl routines assume that the ioctl buffer is aligned, but aMatthew Dillon2000-05-091-3/+6
| | | | | | | | char[] declaration makes no such guarentee. A union is used to force alignment of the char buffer. Notes: svn path=/head/; revision=60269
* Fix select(2) for the Alpha. (!!) It was never returning true forPeter Wemm2000-02-201-6/+8
| | | | | | | | | | | | | | | | fd's in the range of 32-63, 96-127 etc. The first problem was the FD_*() macros were shifting a 32 bit integer "1" left by more than 32 bits. The same problem happened in selscan(). ffs() also takes an int argument and causes failure. For cases where int == long (ie: the usual case for x86, but not always as gcc can have long being a 64 bit quantity) ffs() could be used. Reported by: Marian Stagarescu <marian@bile.skycache.com> Reviewed by: dfr, gallatin (sys/types.h only) Approved by: jkh Notes: svn path=/head/; revision=57357
* Add aio_waitcomplete(). Make aio work correctly for socket descriptors.Jason Evans2000-01-141-0/+2
| | | | | | | | | | | Make gratuitous style(9) fixes (me, not the submitter) to make the aio code more readable. PR: kern/12053 Submitted by: Chris Sedore <cmsedore@maxwell.syr.edu> Notes: svn path=/head/; revision=55943
* Export the nselcoll counter via the kern.nselcoll sysctl so we can seePeter Wemm2000-01-051-1/+3
| | | | | | | | | just how bad it gets in various situations. Reminded by: adrian Notes: svn path=/head/; revision=55478
* Missed the second argument of fdrop().Brian Feldman1999-10-141-1/+1
| | | | | | | Submitted by: jhay Notes: svn path=/head/; revision=52234
* Fix a race condition with shared fd tables and writev(). It'sBrian Feldman1999-10-141-2/+7
| | | | | | | | still not safe to consider file table sharing secure. Submitted by: Ville-Pertti Keinonen <will@iki.fi> Notes: svn path=/head/; revision=52227
* Trim unused options (or #ifdef for undoc options).Peter Wemm1999-10-111-1/+0
| | | | | | | Submitted by: phk Notes: svn path=/head/; revision=52128
* This is what was "fdfix2.patch," a fix for fd sharing. It's prettyBrian Feldman1999-09-191-11/+10
| | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=51418
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Add standard padding argument to pread and pwrite syscall. That should make themDmitrij Tejblum1999-04-041-129/+89
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=45311
* Added pread and pwrite. These functions are defined by the X/OpenAlan Cox1999-03-271-1/+132
| | | | | | | | | Threads Extension. (Note: We use the same syscall numbers as NetBSD.) Submitted by: John Plevyak <jplevyak@inktomi.com> Notes: svn path=/head/; revision=45065
* Removed a bogus cast to c_caddr_t. This is part of terminatingBruce Evans1999-01-291-2/+2
| | | | | | | | | | | | | | | | | | | c_caddr_t with extreme prejudice. Here the point of the original cast to caddr_t was to break the warning about the const mismatch between write(2)'s `const void *buf' and `struct uio's `char *iov_base' (previous bitrot gave a gratuitous dependency on caddr_t being char *). Compiling with -Wcast-qual made the cast a full no-op. This change has no effect on the warning for discarding `const' on assignment to iov_base. The warning should not be fixed by splitting `struct iovec' into a non-const version for read() and a const version for write(), since correct const poisoning would affect all pointers to i/o addresses. Const'ness should probably be forgotten by not declaring it in syscalls.master. Notes: svn path=/head/; revision=43384
* Fix warnings in preparation for adding -Wall -Wcast-qual to theMatthew Dillon1999-01-271-2/+2
| | | | | | | kernel compile Notes: svn path=/head/; revision=43301
* poll(2) sets POLLNVAL for descriptors passed in that are less thanJordan K. Hubbard1998-12-101-2/+4
| | | | | | | | | | | 0. This makes it difficult to do efficient manipulation of the struct pollfd since you can't leave a slot empty. PR: 8599 Submitted-by: Marc Slemko <marcs@znep.com> Notes: svn path=/head/; revision=41632
* Installed the second patch attached to kern/7899 with some changes suggestedDon Lewis1998-11-111-32/+1
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=41086
* Fixed bogotification of pseudocode for syscall args by rev.1.53 ofBruce Evans1998-09-051-5/+5
| | | | | | | syscalls.master. Notes: svn path=/head/; revision=38864
* Change various syscalls to use size_t arguments instead of u_int.Doug Rabson1998-08-241-10/+12
| | | | | | | | | | | | | Add some overflow checks to read/write (from bde). Change all modifications to vm_page::flags, vm_page::busy, vm_object::flags and vm_object::paging_in_progress to use operations which are not interruptable. Reviewed by: Bruce Evans <bde@zeta.org.au> Notes: svn path=/head/; revision=38517
* 64bit fixes: use u_long not int for ioctl command.Doug Rabson1998-06-101-2/+3
| | | | Notes: svn path=/head/; revision=36846
* s/nanoruntime/nanouptime/gPoul-Henning Kamp1998-05-171-5/+5
| | | | | | | | | s/microruntime/microuptime/g Reviewed by: bde Notes: svn path=/head/; revision=36119
* Remove unused atv.tv_usec = 0; from select/poll codeAndrey A. Chernov1998-04-051-7/+3
| | | | Notes: svn path=/head/; revision=35041
* Time changes mark 2:Poul-Henning Kamp1998-04-041-21/+37
| | | | | | | | | | | | | | | | | | | | * Figure out UTC relative to boottime. Four new functions provide time relative to boottime. * move "runtime" into struct proc. This helps fix the calcru() problem in SMP. * kill mono_time. * add timespec{add|sub|cmp} macros to time.h. (XXX: These may change!) * nanosleep, select & poll takes long sleeps one day at a time Reviewed by: bde Tested by: ache and others Notes: svn path=/head/; revision=35029
* Try to fix poll & select after I broke them.Poul-Henning Kamp1998-04-021-11/+9
| | | | Notes: svn path=/head/; revision=34999
* Eradicate the variable "time" from the kernel, using various measures.Poul-Henning Kamp1998-03-301-16/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "time" wasn't a atomic variable, so splfoo() protection were needed around any access to it, unless you just wanted the seconds part. Most uses of time.tv_sec now uses the new variable time_second instead. gettime() changed to getmicrotime(0. Remove a couple of unneeded splfoo() protections, the new getmicrotime() is atomic, (until Bruce sets a breakpoint in it). A couple of places needed random data, so use read_random() instead of mucking about with time which isn't random. Add a new nfs_curusec() function. Mark a couple of bogosities involving the now disappeard time variable. Update ffs_update() to avoid the weird "== &time" checks, by fixing the one remaining call that passwd &time as args. Change profiling in ncr.c to use ticks instead of time. Resolution is the same. Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call hzto() which subtracts time" sequences. Reviewed by: bde Notes: svn path=/head/; revision=34961
* Fixed some style bugs in the poll() code.Bruce Evans1997-11-231-18/+8
| | | | | | | | Removed dead code to "Avoid inadvertently sleeping forever". hzto() never returns 0. Notes: svn path=/head/; revision=31364
* Move the "retval" (3rd) parameter from all syscall functions and putPoul-Henning Kamp1997-11-061-34/+25
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=30994
* Last major round (Unless Bruce thinks of somthing :-) of malloc changes.Poul-Henning Kamp1997-10-121-3/+4
| | | | | | | | | | | Distribute all but the most fundamental malloc types. This time I also remembered the trick to making things static: Put "static" in front of them. A couple of finer points by: bde Notes: svn path=/head/; revision=30354
* Distribute and statizice a lot of the malloc M_* types.Poul-Henning Kamp1997-10-111-1/+4
| | | | | | | Substantial input from: bde Notes: svn path=/head/; revision=30309
* Implement poll(2). This is mostly taken from the NetBSD implementationPeter Wemm1997-09-141-6/+158
| | | | | | | | | (from some time ago) but with a few tweaks along the way. Obtained from: NetBSD Notes: svn path=/head/; revision=29351
* Removed unused #includes.Bruce Evans1997-09-021-5/+1
| | | | Notes: svn path=/head/; revision=29041
* Modifications to existing files to support the initial AIO/LIO andJohn Dyson1997-06-161-1/+5
| | | | | | | kernel based threading support. Notes: svn path=/head/; revision=26671