freebsd-dev/sys/kern
John Baldwin 5fc3031366 - Change falloc() to acquire an fd from the process table last so that
it can do it w/o needing to hold the filelist_lock sx lock.
- fdalloc() doesn't need Giant to call free() anymore.  It also doesn't
  need to drop and reacquire the filedesc lock around free() now as a
  result.
- Try to make the code that copies fd tables when extending the fd table in
  fdalloc() a bit more readable by performing assignments in separate
  statements.  This is still a bit ugly though.
- Use max() instead of an if statement so to figure out the starting point
  in the search-for-a-free-fd loop in fdalloc() so it reads better next to
  the min() in the previous line.
- Don't grow nfiles in steps up to the size needed if we dup2() to some
  really large number.  Go ahead and double 'nfiles' in a loop prior
  to doing the malloc().
- malloc() doesn't need Giant now.
- Use malloc() and free() instead of MALLOC() and FREE() in fdalloc().
- Check to see if the size we are going to grow to is too big, not if the
  current size of the fd table is too big in the loop in fdalloc().  This
  means if we are out of space or if dup2() requests too high of a fd,
  then we will return an error before we go off and try to allocate some
  huge table and copy the existing table into it.
- Move all of the logic for dup'ing a file descriptor into do_dup() instead
  of putting some of it in do_dup() and duplicating other parts in four
  different places.  This makes dup(), dup2(), and fcntl(F_DUPFD) basically
  wrappers of do_dup now.  fcntl() still has an extra check since it uses
  a different error return value in one case then the other functions.
- Add a KASSERT() for an assertion that may not always be true where the
  fdcheckstd() function assumes that falloc() returns the fd requested and
  not some other fd.  I think that the assertion is always true because we
  are always single-threaded when we get to this point, but if one was
  using rfork() and another process sharing the fd table were playing with
  the fd table, there might could be a problem.
- To handle the problem of a file descriptor we are dup()'ing being closed
  out from under us in dup() in general, do_dup() now obtains a reference
  on the file in question before calling fdalloc().  If after the call to
  fdalloc() the file for the fd we are dup'ing is a different file, then
  we drop our reference on the original file and return EBADF.  This
  race was only handled in the dup2() case before and would just retry
  the operation.  The error return allows the user to know they are being
  stupid since they have a locking bug in their app instead of dup'ing
  some other descriptor and returning it to them.

Tested on:	i386, alpha, sparc64
2002-09-03 20:16:31 +00:00
..
bus_if.m
clock_if.m
device_if.m
genassym.sh
imgact_aout.c Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to 2002-09-01 21:41:24 +00:00
imgact_elf32.c
imgact_elf64.c
imgact_elf.c Grammer cleanup 2002-09-02 17:27:30 +00:00
imgact_elfN.c
imgact_gzip.c
imgact_shell.c
inflate.c
init_main.c Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to 2002-09-01 21:41:24 +00:00
init_sysent.c Regen. 2002-08-19 20:02:29 +00:00
kern_acct.c In order to better support flexible and extensible access control, 2002-08-15 20:55:08 +00:00
kern_acl.c
kern_clock.c
kern_condvar.c fix bogus CTR3 message. 2002-09-02 07:55:06 +00:00
kern_conf.c
kern_descrip.c - Change falloc() to acquire an fd from the process table last so that 2002-09-03 20:16:31 +00:00
kern_environment.c
kern_event.c In continuation of early fileop credential changes, modify fo_ioctl() to 2002-08-17 02:36:16 +00:00
kern_exec.c Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to 2002-09-01 21:41:24 +00:00
kern_exit.c
kern_fork.c slight cleanup of single-threading code for KSE processes 2002-08-22 21:45:58 +00:00
kern_idle.c
kern_intr.c
kern_jail.c
kern_kse.c In the kernel code, we have the tsleep() call with the PCATCH argument. 2002-09-03 12:56:01 +00:00
kern_kthread.c
kern_ktr.c
kern_ktrace.c Pass active_cred and file_cred into the MAC framework explicitly 2002-08-19 19:04:53 +00:00
kern_linker.c In order to better support flexible and extensible access control, 2002-08-15 20:55:08 +00:00
kern_lock.c Include <sys/lockmgr.h> for the definitions of the locking interfaces that 2002-08-27 09:59:47 +00:00
kern_lockf.c Add a #include for <sys/mount.h> 2002-08-13 10:07:05 +00:00
kern_mac.c Close a race in process label changing opened due to dropping the 2002-08-19 20:26:32 +00:00
kern_malloc.c
kern_mib.c
kern_module.c
kern_mtxpool.c
kern_mutex.c Add some KASSERT()'s to ensure that we don't perform spin mutex ops on 2002-09-03 18:25:16 +00:00
kern_ntptime.c
kern_physio.c
kern_poll.c Increase size of ifnet.if_flags from 16 bits (short) to 32 bits (int). To avoid 2002-08-18 07:05:00 +00:00
kern_proc.c Fix typos; each file has at least one s/seperat/separat/ 2002-08-11 13:05:30 +00:00
kern_prot.c
kern_resource.c
kern_sema.c
kern_shutdown.c
kern_sig.c In the kernel code, we have the tsleep() call with the PCATCH argument. 2002-09-03 12:56:01 +00:00
kern_subr.c o Convert a vm_page_sleep_busy() into a vm_page_sleep_if_busy() 2002-08-04 06:27:37 +00:00
kern_switch.c Rejig the code to figure out estcpu and work out how long a KSEGRP has been 2002-08-30 00:25:49 +00:00
kern_sx.c
kern_synch.c Rejig the code to figure out estcpu and work out how long a KSEGRP has been 2002-08-30 00:25:49 +00:00
kern_syscalls.c
kern_sysctl.c Introduce a new sysctl flag, CTLFLAG_SKIP, which will cause 2002-08-10 19:56:45 +00:00
kern_tc.c
kern_thread.c In the kernel code, we have the tsleep() call with the PCATCH argument. 2002-09-03 12:56:01 +00:00
kern_time.c A side effect of some debugging: prototypify and deregister. 2002-08-18 21:24:22 +00:00
kern_timeout.c
kern_uuid.c Include <sys/systm.h> for the declarations of many things instead of 2002-08-22 12:47:22 +00:00
kern_xxx.c
ksched.c
link_elf_obj.c Unrot SPARSE_MAPPING code (vm_map_pageable -> vm_map_wire). 2002-08-29 01:16:14 +00:00
link_elf.c Unrot SPARSE_MAPPING code (vm_map_pageable -> vm_map_wire). 2002-08-29 01:16:14 +00:00
linker_if.m
Make.tags.inc
Makefile
makesyscalls.sh
md4c.c
md5c.c
p1003_1b.c
posix4_mib.c
subr_acl_posix1e.c
subr_autoconf.c
subr_blist.c
subr_bus.c
subr_clist.c
subr_clock.c Use the CPU_* OID constants instead of OID_AUTO for the clock-related 2002-08-07 19:43:54 +00:00
subr_devstat.c
subr_disk.c Don't use "NULL" when "0" is really meant. 2002-08-21 23:39:52 +00:00
subr_disklabel.c
subr_diskmbr.c
subr_diskslice.c
subr_eventhandler.c
subr_hints.c
subr_kobj.c
subr_log.c
subr_mbuf.c Make m_flags an int instead of a short, this is consistent with the 2002-08-15 14:09:16 +00:00
subr_mchain.c
subr_module.c
subr_param.c Change hw.physmem and hw.usermem to unsigned long like they used to be 2002-08-30 04:04:37 +00:00
subr_pcpu.c
subr_power.c
subr_prf.c Make kern.log_console_output a tuneable aswell as a sysctl. 2002-08-11 18:47:42 +00:00
subr_prof.c
subr_rman.c Add sanity check seeing if adjusted start address exceeds end address 2002-08-29 12:39:21 +00:00
subr_rtc.c Use the CPU_* OID constants instead of OID_AUTO for the clock-related 2002-08-07 19:43:54 +00:00
subr_sbuf.c
subr_scanf.c
subr_smp.c
subr_taskqueue.c
subr_trap.c Spell proprly properly: 2002-08-22 14:36:03 +00:00
subr_turnstile.c Add some KASSERT()'s to ensure that we don't perform spin mutex ops on 2002-09-03 18:25:16 +00:00
subr_witness.c Add WITNESS_FILE() and WITNESS_LINE(), which allow users of witness 2002-08-26 18:31:26 +00:00
subr_xxx.c
sys_generic.c Split out a number of mostly VFS and signal related syscalls into 2002-09-01 20:37:28 +00:00
sys_pipe.c Don't use "NULL" when "0" is really meant. 2002-08-21 23:39:52 +00:00
sys_process.c Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
sys_socket.c In continuation of early fileop credential changes, modify fo_ioctl() to 2002-08-17 02:36:16 +00:00
syscalls.c Regen. 2002-08-19 20:02:29 +00:00
syscalls.master mac_syscall is now implemented, switch to MSTD. 2002-08-19 20:01:31 +00:00
sysv_ipc.c
sysv_msg.c Make SYSVMSG mpsafe. Right now there is a global lock over the 2002-08-13 08:00:36 +00:00
sysv_sem.c Make SYSVSEM mpsafe. Each semaphore set gets its own lock, however 2002-08-13 08:47:17 +00:00
sysv_shm.c return foo -> return (foo) 2002-08-15 02:10:12 +00:00
tty_compat.c
tty_conf.c
tty_cons.c Remove new console devices with cnremove before initializing them in 2002-08-06 18:56:41 +00:00
tty_pty.c
tty_subr.c
tty_tty.c Pass active_cred and file_cred into the MAC framework explicitly 2002-08-19 19:04:53 +00:00
tty.c
uipc_accf.c
uipc_cow.c o Synchronize updates to struct vm_page::cow with the page queues lock. 2002-09-02 04:04:12 +00:00
uipc_domain.c
uipc_jumbo.c
uipc_mbuf2.c
uipc_mbuf.c
uipc_proto.c
uipc_sockbuf.c Further improved the performance of sbreserve() by moving the calculation 2002-08-16 18:41:48 +00:00
uipc_socket2.c Further improved the performance of sbreserve() by moving the calculation 2002-08-16 18:41:48 +00:00
uipc_socket.c Make similar changes to fo_stat() and fo_poll() as made earlier to 2002-08-16 12:52:03 +00:00
uipc_syscalls.c accept(2) on a socket that has been shutdown(2) normally returns 2002-08-28 20:56:01 +00:00
uipc_usrreq.c
vfs_acl.c
vfs_aio.c Replace (ab)uses of "NULL" where "0" is really meant. 2002-08-22 21:24:01 +00:00
vfs_bio.c Change hw.physmem and hw.usermem to unsigned long like they used to be 2002-08-30 04:04:37 +00:00
vfs_cache.c Split up __getcwd so that kernel callers of the internal version 2002-09-02 22:40:30 +00:00
vfs_cluster.c Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
vfs_default.c Remember to unlock the (optional) vnode in vfs_stdextattrctl(). Failing 2002-08-13 11:11:51 +00:00
vfs_export.c
vfs_extattr.c Split out a number of mostly VFS and signal related syscalls into 2002-09-01 20:37:28 +00:00
vfs_init.c
vfs_lookup.c - Replace v_flag with v_iflag and v_vflag 2002-08-04 10:29:36 +00:00
vfs_mount.c Keep a copy of the credential used to mount filesystems around so 2002-08-19 06:52:21 +00:00
vfs_subr.c Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
vfs_syscalls.c Split out a number of mostly VFS and signal related syscalls into 2002-09-01 20:37:28 +00:00
vfs_vnops.c Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
vnode_if.src - Add two new debugging macros: ASSERT_VI_LOCKED and ASSERT_VI_UNLOCKED 2002-08-21 06:19:29 +00:00