summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
Commit message (Collapse)AuthorAgeFilesLines
* Rewrite fdgrowtable() so common mortals can actually understand whatdes2012-12-201-55/+74
| | | | | it does and how, and add comments describing the data structures and explaining how they are managed.
* Remove the support for using non-mpsafe filesystem modules.kib2012-10-221-54/+7
| | | | | | | | | | | | In particular, do not lock Giant conditionally when calling into the filesystem module, remove the VFS_LOCK_GIANT() and related macros. Stop handling buffers belonging to non-mpsafe filesystems. The VFS_VERSION is bumped to indicate the interface change which does not result in the interface signatures changes. Conducted and reviewed by: attilio Tested by: pho
* Add F_DUP2FD_CLOEXEC. Apparently Solaris 11 already did this.kib2012-07-271-0/+8
| | | | | | Submitted by: Jukka A. Ukkonen <jau iki fi> PR: standards/169962 MFC after: 1 week
* (Incomplete) fixes for symbols visibility issues and style in fcntl.h.kib2012-07-211-1/+1
| | | | | | | | | | | | | | | | | Append '__' prefix to the tag of struct oflock, and put it under BSD namespace. Structure is needed both by libc and kernel, thus cannot be hidden under #ifdef _KERNEL. Move a set of non-standard F_* and O_* constants into BSD namespace. SUSv4 explicitely allows implemenation to pollute F_* and O_* names after fcntl.h is included, but it costs us nothing to adhere to the specification if exact POSIX compliance level is requested by user code. Change some spaces after #define to tabs. Noted by and discussed with: bde MFC after: 1 week
* Remove line which was accidentally kept in r238614.kib2012-07-191-1/+0
| | | | | | Submitted by: pjd Pointy hat to: kib MFC after: 1 week
* Implement F_DUPFD_CLOEXEC command for fcntl(2), specified by SUSv4.kib2012-07-191-0/+11
| | | | | | PR: standards/169962 Submitted by: Jukka A. Ukkonen <jau iki fi> MFC after: 1 week
* Follow-up commit to r238220:mjg2012-07-091-8/+24
| | | | | | | | | | | | | Pass only FEXEC (instead of FREAD|FEXEC) in fgetvp_exec. _fget has to check for !FWRITE anyway and may as well know about FREAD. Make _fget code a bit more readable by converting permission checking from if() to switch(). Assert that correct permission flags are passed. In collaboration with: kib Approved by: trasz (mentor) MFC after: 6 days X-MFC: with r238220
* Unbreak handling of descriptors opened with O_EXEC by fexecve(2).mjg2012-07-081-3/+10
| | | | | | | | | | | While here return EBADF for descriptors opened for writing (previously it was ETXTBSY). Add fgetvp_exec function which performs appropriate checks. PR: kern/169651 In collaboration with: kib Approved by: trasz (mentor) MFC after: 1 week
* Extend the KPI to lock and unlock f_offset member of struct file. Itkib2012-07-021-9/+12
| | | | | | | | | | | | | | | | | | now fully encapsulates all accesses to f_offset, and extends f_offset locking to other consumers that need it, in particular, to lseek() and variants of getdirentries(). Ensure that on 32bit architectures f_offset, which is 64bit quantity, always read and written under the mtxpool protection. This fixes apparently easy to trigger race when parallel lseek()s or lseek() and read/write could destroy file offset. The already broken ABI emulations, including iBCS and SysV, are not converted (yet). Tested by: pho No objections from: jhb MFC after: 3 weeks
* Don't check for race with close on advisory unlock (there is nothing smart wepjd2012-06-171-1/+2
| | | | | | | can do when such a race occurs). This saves lock/unlock cycle for the filedesc lock for every advisory unlock operation. MFC after: 1 month
* Extend the comment about checking for a race with close to explain whypjd2012-06-171-1/+17
| | | | | | | it is done and why we don't return an error in such case. Discussed with: kib MFC after: 1 month
* If VOP_ADVLOCK() call or earlier checks failed don't check for a race withpjd2012-06-171-0/+4
| | | | | | | close, because even if we had a race there is nothing to unlock. Discussed with: kib MFC after: 1 month
* Revert r237073. 'td' can be NULL here.pjd2012-06-161-3/+1
| | | | MFC after: 1 month
* One more attempt to make prototypes formated according to style(9), whichpjd2012-06-151-15/+16
| | | | | | | holefully recovers from the "worse than useless" state. Reported by: bde MFC after: 1 month
* Remove fdtofp() function and use fget_locked(), which works exactly the same.pjd2012-06-141-20/+8
| | | | MFC after: 1 month
* Assert that the filedesc lock is being held when the fdunwrap() functionpjd2012-06-141-0/+2
| | | | | | is called. MFC after: 1 month
* Simplify the code by making more use of the fdtofp() function.pjd2012-06-141-7/+4
| | | | MFC after: 1 month
* - Assert that the filedesc lock is being held when fdisused() is called.pjd2012-06-141-2/+4
| | | | | | - Fix white spaces. MFC after: 1 month
* Style fixes and assertions improvements.pjd2012-06-141-6/+7
| | | | MFC after: 1 month
* Assert that the filedesc lock is not held when closef() is called.pjd2012-06-141-1/+3
| | | | MFC after: 1 month
* Style fixes.pjd2012-06-141-17/+16
| | | | | Reported by: bde MFC after: 1 month
* Remove code duplication from fdclosexec(), which was the reason of the bugpjd2012-06-141-30/+19
| | | | | | fixed in r237065. MFC after: 1 month
* When we are closing capabilities during exec, we want to call mq_fdclose()pjd2012-06-141-3/+9
| | | | | | | | on the underlying object and not on the capability itself. Similar bug was fixed in r236853. MFC after: 1 month
* Style.pjd2012-06-141-19/+14
| | | | MFC after: 1 month
* When checking if file descriptor number is valid, explicitely check for 'fd'pjd2012-06-131-7/+7
| | | | | | being less than 0 instead of using cast-to-unsigned hack. Today's commit was brought to you by the letters 'B', 'D' and 'E' :)
* Allocate descriptor number in dupfdopen() itself instead of depending onpjd2012-06-131-16/+18
| | | | | | | | the caller using finstall(). This saves us the filedesc lock/unlock cycle, fhold()/fdrop() cycle and closes a race between finstall() and dupfdopen(). MFC after: 1 month
* There is only one caller of the dupfdopen() function, so we can simplifypjd2012-06-131-32/+14
| | | | | | | | | | | | | it a bit: - We can assert that only ENODEV and ENXIO errors are passed instead of handling other errors. - The caller always call finstall() for indx descriptor, so we can assume it is set. Actually the filedesc lock is dropped between finstall() and dupfdopen(), so there is a window there for another thread to close the indx descriptor, but it will be closed in next commit. Reviewed by: mjg MFC after: 1 month
* Remove 'low' argument from fd_last_used().mjg2012-06-131-10/+7
| | | | | | | | | | This function is static and the only caller always passes 0 as low. While here update note about return values in comment. Reviewed by: pjd Approved by: trasz (mentor) MFC after: 1 month
* Re-apply reverted parts of r236935 by pjd with some changes.mjg2012-06-131-15/+17
| | | | | | | | | | | | | | | | If fdalloc() decides to grow fdtable it does it once and at most doubles the size. This still may be not enough for sufficiently large fd. Use fd in calculations of new size in order to fix this. When growing the table, fd is already equal to first free descriptor >= minfd, also fdgrowtable() no longer drops the filedesc lock. As a result of this there is no need to retry allocation nor lookup. Fix description of fd_first_free to note all return values. In co-operation with: pjd Approved by: trasz (mentor) MFC after: 1 month
* Revert part of the r236935 for now, until I figure out why it doesn'tpjd2012-06-121-8/+6
| | | | | | work properly. Reported by: davidxu
* fdgrowtable() no longer drops the filedesc lock so it is enough topjd2012-06-111-9/+13
| | | | | | | retry finding free file descriptor only once after fdgrowtable(). Spotted by: pluknet MFC after: 1 month
* Use consistent way of checking if descriptor number is valid.pjd2012-06-111-3/+3
| | | | MFC after: 1 month
* Be consistent with white spaces.pjd2012-06-111-1/+1
| | | | MFC after: 1 month
* Remove code duplicated in kern_close() and do_dup() and use closefp() functionpjd2012-06-111-89/+7
| | | | | | | | | | introduced a minute ago. This code duplication was responsible for the bug fixed in r236853. Discussed with: kib Tested by: pho MFC after: 1 month
* Introduce closefp() function that we will be able to use to eliminatepjd2012-06-111-0/+55
| | | | | | | | | | | code duplication in kern_close() and do_dup(). This is committed separately from the actual removal of the duplicated code, as the combined diff was very hard to read. Discussed with: kib Tested by: pho MFC after: 1 month
* Merge two ifs into one to make the code almost identical to the code inpjd2012-06-111-16/+17
| | | | | | | | kern_close(). Discussed with: kib Tested by: pho MFC after: 1 month
* Move the code around a bit to move two parts of code duplicated frompjd2012-06-111-10/+11
| | | | | | | | kern_close() close together. Discussed with: kib Tested by: pho MFC after: 1 month
* Now that fdgrowtable() doesn't drop the filedesc lock we don't need topjd2012-06-111-13/+1
| | | | | | | | | check if descriptor changed from under us. Replace the check with an assert. Discussed with: kib Tested by: pho MFC after: 1 month
* When we are closing capability during dup2(), we want to call mq_fdclose()pjd2012-06-101-2/+7
| | | | | | | | on the underlying object and not on the capability itself. Discussed with: rwatson Sponsored by: FreeBSD Foundation MFC after: 1 month
* Merge two ifs into one. Other minor style fixes.pjd2012-06-101-12/+9
| | | | MFC after: 1 month
* Simplify fdtofp().pjd2012-06-101-4/+4
| | | | MFC after: 1 month
* There is no need to drop the FILEDESC lock around malloc(M_WAITOK) anymore, aspjd2012-06-091-17/+1
| | | | | | | we now use sx lock for filedesc structure protection. Reviewed by: kib MFC after: 1 month
* Remove now unused variable.pjd2012-06-091-1/+0
| | | | | MFC after: 1 month MFC with: r236820
* Make some of the loops more readable.pjd2012-06-091-16/+9
| | | | | Reviewed by: tegge MFC after: 1 month
* Correct panic message.pjd2012-06-091-1/+1
| | | | | MFC after: 1 month MFC with: r236731
* In fdalloc() f_ofileflags for the newly allocated descriptor has to be 0.pjd2012-06-071-3/+2
| | | | | | | Assert that instead of setting it to 0. Sponsored by: FreeBSD Foundation MFC after: 1 month
* Return EBADF instead of EMFILE from dup2 when the second argument iseadler2012-04-111-1/+1
| | | | | | | | | | outside the range of valid file descriptors PR: kern/164970 Submitted by: Peter Jeremy <peterjeremy@acm.org> Reviewed by: jilles Approved by: cperciva MFC after: 1 week
* Export some more useful info about shared memory objects to userlandjhb2012-04-011-0/+28
| | | | | | | | | | | | | | | | | | | via procstat(1) and fstat(1): - Change shm file descriptors to track the pathname they are associated with and add a shm_path() method to copy the path out to a caller-supplied buffer. - Use the fo_stat() method of shared memory objects and shm_path() to export the path, mode, and size of a shared memory object via struct kinfo_file. - Add a struct shmstat to the libprocstat(3) interface along with a procstat_get_shm_info() to export the mode and size of a shared memory object. - Change procstat to always print out the path for a given object if it is valid. - Teach fstat about shared memory objects and to display their path, mode, and size. MFC after: 2 weeks
* Free up allocated memory used by posix_fadvise(2).pho2012-03-081-0/+3
|
* Reformat comment to be more readable in standard Xterm.obrien2011-11-151-13/+18
| | | | (while I'm here, wrap other long lines)
OpenPOWER on IntegriCloud