summaryrefslogtreecommitdiff
path: root/sys/kern/kern_descrip.c
AgeCommit message (Collapse)Author
2008-11-25Punctuate comment for clarity, and keep tense consistent throughoutBret Lambert
ok and improvements jmc@
2008-09-19Fix a bunch of problems and races with posix file locking.Artur Grabowski
- file descriptor table becomes the owner of the lock instead of the proc. - When grabbing the lock, we check if the fd hasn't changed under our feet, this is more or less impossible to solve without a hack like this. I've banged my head against the wall, I figured out a solution, but implementing it correctly would cost me 12 gray hairs. Screw it, this is ugly, but it works. - Wait until usecount drains before releasing the posix lock in closef. - Add missing FREF/FRELE to sys_flock - keep the pid in the flock struct instead of abusing the fact that we used to use the proc as the lock owner. Pointed out by and discussed with Al Viro, big thanks. miod@ ok
2008-06-12use PR_ZERO instead of a bzero() right after the pool_get();Thordur I. Bjornsson
ok blambert@
2008-05-06Add a PR_ZERO flag for pools, to compliment the M_ZEROThordur I. Bjornsson
malloc flag, does the same thing. use it in a few places. OK tedu@, "then go ahead. and don't forget the manpage (-:" miod@
2007-10-29MALLOC/FREE -> malloc/freeCharles Longeau
replace an hard coded value with M_WAITOK ok krw@
2007-03-15Since p_flag is often manipulated in interrupts and without biglockArtur Grabowski
it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
2006-11-14grammar, spelling, and style fixes from bret lambert;Jason McIntyre
kern_descrip.c change ok deraadt
2006-05-07add a name to rwlock so that we can tell where procs are getting stuckTed Unangst
without breaking into ddb. doubles the size of rwlock [1], but moving forward this really helps. ok/tested pedro fgsch millert krw [1 - next person to add a field to this struct gets whipped with a wet noodle]
2006-01-06typo fix from ray lai;Jason McIntyre
ok deraadt
2005-12-07do not allow setugid processes to use /dev/fd/#, unless they are aTheo de Raadt
setuid-script and are attempting to dup is the specific setuid-script fd via such a pathname; ok tedu pedro millert
2005-11-28ansi/deregister.Jonathan Gray
'go for it' deraadt@
2005-07-03change VOP_PATHCONF to take a locked vnode, as itsJared Yanovich
comment entry describes. requires that sys_fpathconf() lock its vnode. lots of testing by jolan and myself, ok pedro
2004-07-22remove p arg from fdplockTed Unangst
2004-01-12new syscall closefrom(int fd) closes all fds equal and greater than fd.Ted Unangst
ok deraadt@ millert@
2004-01-06lock filedesc before manipulating. avoids some rare races.Ted Unangst
testing for quite some time by brad + otto
2003-12-02Check array index before using it; from Tim Robbins via Niels.Todd C. Miller
2003-08-15change arguments to suser. suser now takes the process, and a flagsTed Unangst
argument. old cred only calls user suser_ucred. this will allow future work to more flexibly implement the idea of a root process. looks like something i saw in freebsd, but a little different. use of suser_ucred vs suser in file system code should be looked at again, for the moment semantics remain unchanged. review and input from art@ testing and further review miod@
2003-08-06Remove unreachable return statement after break; Patrick LatifiTodd C. Miller
2003-06-02Remove the advertising clause in the UCB license which BerkeleyTodd C. Miller
rescinded 22 July 1999. Proofed by myself and Theo.
2002-11-22Allow fdinit to be called with p == NULL so that we can useArtur Grabowski
it to properly init filedescs for proc0.
2002-11-08finishdup: Avoid reference count leak in error case by reordering some code.Artur Grabowski
2002-10-15Match reality by changing (u_int) -> (int) in comments.Thomas Nordin
2002-08-23Add missing FRELE() in finishdup() error case; ok artPeter Valchev
2002-06-03compatiblity -> compatibilityTheo de Raadt
decriptor -> descriptor authentciated -> authenticated transmition -> transmission
2002-05-23Fix a comment I missed when renaming FILE_UNUSE to FRELE.Artur Grabowski
2002-03-14First round of __P removal in sysTodd C. Miller
2002-02-19Missing FRELE in error case. ok provos@Thomas Nordin
2002-02-18fix issue on LP64 BE arch's w/ fcntl's F_GETOWNEric Jackson
pointed out by der Mouse <mouse@Rodents.Montreal.QC.CA>
2002-02-13More FREF/FRELE on relevant places. Now, only sys_mmap and a bunch of ioctl ↵Artur Grabowski
functions in sys/compat are left.
2002-02-09Protect the whole sys_fnctl with one big FREF/FRELE pair.Artur Grabowski
2002-02-08Add a comment about an obscure behavior in dup2(2).Artur Grabowski
2002-02-08Add a slightly redundant arg to finishdup that's the struct file *Artur Grabowski
present on the 'old' descriptor. It's not really necessary because we can easily find it with 'fp = p->p_fd->fd_ofiles[old];', but this allows us to require that the fp is FREFed without violating all rules of good taste and all callers have to do fd_getfile on it anyway (to detect larval and closing files. FREF the fp in all callers.
2002-02-08No more need for ffree. Since it's hard to use it safely, remove it.Artur Grabowski
2002-02-08- Rename FILE_{,UN}USE to FREF and FRELE. USE is a bad verb and we don't haveArtur Grabowski
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)).
2002-02-05Add counting of temporary references to a struct file (as opposed to referencesArtur Grabowski
from fd tables and other long-lived objects). This is to avoid races between using a file descriptor and having another process (with shared fd table) close it. We use a separate refence count so that error values from close(2) will be correctly returned to the caller of close(2). The macros for those reference counts are FILE_USE(fp) and FILE_UNUSE(fp). Make sure that the cases where closef can be called "incorrectly" (most notably dup2(2)) are handled. Right now only callers of closef (and {,p}read) use FILE_{,UN}USE correctly, more fixes incoming soon.
2002-02-04Add some comments documenting why we use fd_ofiles insteadArtur Grabowski
of fd_getfile in some places. Also, get rid of the check for old == new in dupfdopen and document why the semantics of fd_getfile make it unnecessary.
2002-02-02Reorganize sys_fcntl to make future changes easier.Artur Grabowski
2002-01-23Pool deals fairly well with physical memory shortage, but it doesn't dealArtur Grabowski
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.
2001-11-15Initialize listNiklas Hallqvist
2001-11-06Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.Miod Vallat
(Look ma, I might have broken the tree)
2001-11-05let finishdup take the proc as arguemnt instead of the filedesc.Artur Grabowski
2001-10-26 - every new fd created by falloc() is marked as larval and should not be usedArtur Grabowski
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.
2001-10-26 - split fdalloc into two functions. fdalloc now returns ENOSPC if itArtur Grabowski
would have to grow the table and fdexpand that grows the table. Since fdexpand can sleep we have to restart all operations if we have to call it. - dup2 changed so that finishdup frees the destination descriptor. - unp_externalize is a completly rewritten version from NetBSD. Changes mostly inspired by NetBSD.
2001-10-07Clean up fdrelease.Artur Grabowski
2001-10-07gc UF_MAPPED.Artur Grabowski
2001-10-01Avoid panic when unconfiguring raid device which was autoconfigured andGrigoriy Orlov
so has fdp->fd_cdir = NULL. From Tertou <TDeval@PrimeOBJ.COM>
2001-09-29Avoid panic at time of raid autoconfiguration. Raid kernel thread startsGrigoriy Orlov
when root filesystem isn't configured yet and some kernel variables can't be initialized. From Thierry Deval <TDeval@PrimeOBJ.COM>
2001-07-28Allow negative lock length in case of lockf(3). This makes lockf(3)Grigoriy Orlov
compliant to specification. costa@ ok.
2001-07-25Random cleanups that generate noise in my cvs updates.Artur Grabowski
2001-06-27remove old vmArtur Grabowski