| #
8ad9ae0b |
| 10-Nov-2024 |
riastradh <riastradh@NetBSD.org> |
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup3 and opening cloning devices
show more ...
|
| #
c0216ccf |
| 26-Oct-2022 |
riastradh <riastradh@NetBSD.org> |
sys/filedesc.h: New home for extern cwdi0.
|
| #
723d09ce |
| 29-Jun-2021 |
dholland <dholland@NetBSD.org> |
Add containment for the cloning devices hack in vn_open.
Cloning devices (and also things like /dev/stderr) work by allocating a struct file, stuffing it in the file table (which is a layer violatio
Add containment for the cloning devices hack in vn_open.
Cloning devices (and also things like /dev/stderr) work by allocating a struct file, stuffing it in the file table (which is a layer violation), stuffing the file descriptor number for it in a magic field of struct lwp (which is gross), and then "failing" with one of two magic errnos, EDUPFD or EMOVEFD.
Before this commit, all callers of vn_open in the kernel (there are quite a few) were expected to check for these errors and handle the situation. Needless to say, none of them except for open() itself did, resulting in internal negative errnos being returned to userspace.
This hack is fairly deeply rooted and cannot be eliminated all at once. This commit adds logic to handle the magic errnos inside vn_open; now on success vn_open returns either a vnode or an integer file descriptor, along with a flag that says whether the underlying code requested EDUPFD or EMOVEFD. Callers not prepared to cope with file descriptors can pass NULL for the extra return values, in which case if a file descriptor would be produced vn_open fails with EOPNOTSUPP.
Since I'm rearranging vn_open's signature anyway, stop exposing struct nameidata. Instead, take three arguments: an optional vnode to use as the starting point (like openat()), the path, and additional namei flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei behavior, e.g. NOFOLLOW, can be requested via the open flags.)
This change requires a kernel bump. Ride the one an hour ago. (That was supposed to be coordinated; did not intend to let an hour slip by. My fault.)
show more ...
|
| #
d5c789b1 |
| 21-Apr-2020 |
ad <ad@NetBSD.org> |
- Give cwdi_lock its own cache line, for multithreaded processes. - Comments.
|
| #
e88c11f4 |
| 21-Apr-2020 |
ad <ad@NetBSD.org> |
Revert the changes made in February to make cwdinfo use mostly lockless, which relied on taking extra vnode refs.
Having benchmarked various experimental changes over the past few months it seems th
Revert the changes made in February to make cwdinfo use mostly lockless, which relied on taking extra vnode refs.
Having benchmarked various experimental changes over the past few months it seems that it's better to avoid vnode refs as much as possible. cwdi_lock as a RW lock already did that to some extent for getcwd() and will permit the same for namei() too.
show more ...
|
| #
926b25e1 |
| 23-Feb-2020 |
ad <ad@NetBSD.org> |
Merge from ad-namecache:
- Have a stab at clustering the members of vnode_t and vnode_impl_t in a more cache-conscious way. With that done, go back to adjusting v_usecount with atomics and keep
Merge from ad-namecache:
- Have a stab at clustering the members of vnode_t and vnode_impl_t in a more cache-conscious way. With that done, go back to adjusting v_usecount with atomics and keep vi_lock directly in vnode_impl_t (saves KVA).
- Allow VOP_LOCK(LK_NONE) for the benefit of VFS_VGET() and VFS_ROOT(). Make sure LK_UPGRADE always comes with LK_NOWAIT.
- Make cwdinfo use mostly lockless.
show more ...
|
| #
7189ee33 |
| 06-Oct-2019 |
mlelstv <mlelstv@NetBSD.org> |
Use multiple cache lines for fd_dfdfile elements when necessary.
|
| #
d46f49d3 |
| 26-Dec-2017 |
kamil <kamil@NetBSD.org> |
Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)
sys_pipe2() returns two integers (values), the 2nd one is a copy of the 2nd file descriptor that lands in fildes[2]. This is a side effe
Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)
sys_pipe2() returns two integers (values), the 2nd one is a copy of the 2nd file descriptor that lands in fildes[2]. This is a side effect of reusing the code for sys_pipe() (SYS_pipe) and not cleaning it up.
The first returned value is (on success) 0.
Introduced a small refactoring in pipe1() that it does not operate over retval[], but on an array int[2]. A user sets retval[] for pipe() when desired and needed.
This refactoring touches compat code: netbsd32, linux, linux32.
Before the changes on NetBSD/amd64:
$ ktruss -i ./a.out [...] 15131 1 a.out pipe2(0x7f7fff2e62b8, 0) = 0, 4 [...]
After the changes:
$ ktruss -i ./a.out [...] 782 1 a.out pipe2(0x7f7fff97e850, 0) = 0 [...]
There should not be a visible change for current users.
Sponsored by <The NetBSD Foundation>
show more ...
|
| #
f8c7c04b |
| 11-Feb-2012 |
martin <martin@NetBSD.org> |
Add a posix_spawn syscall, as discussed on tech-kern. Based on the summer of code project by Charles Zhang, heavily reworked later by me - all bugs are likely mine. Ok: core, releng.
|
| #
5418d2a7 |
| 25-Jan-2012 |
christos <christos@NetBSD.org> |
As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE on EPIPE for all file descriptor types:
- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD] - pr
As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE on EPIPE for all file descriptor types:
- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD] - provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD] - provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX] - provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]
show more ...
|
| #
e2bebf71 |
| 26-Jun-2011 |
christos <christos@NetBSD.org> |
* Arrange for interfaces that create new file descriptors to be able to set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).
- Add F_DUPFD_CLOEXEC to fcntl(2). - Add
* Arrange for interfaces that create new file descriptors to be able to set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).
- Add F_DUPFD_CLOEXEC to fcntl(2). - Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing. - Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter for socket(2) and socketpair(2). - Add new paccept(2) syscall that takes an additional sigset_t to alter the sigmask temporarily and a flags argument to set SOCK_CLOEXEC, SOCK_NONBLOCK. - Add new mode character 'e' to fopen(3) and popen(3) to open pipes and file descriptors for close on exec. - Add new kqueue1(2) syscall with a new flags argument to open the kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.
* Fix the system calls that take socklen_t arguments to actually do so.
* Don't include userland header files (signal.h) from system header files (rump_syscallargs.h).
* Bump libc version for the new syscalls.
show more ...
|
| #
a739efc5 |
| 01-Jun-2011 |
alnsn <alnsn@NetBSD.org> |
kern/42030 - tracking of file descriptors by ktrace/kdump
|
| #
a73f7b01 |
| 10-Apr-2011 |
christos <christos@NetBSD.org> |
- Add O_CLOEXEC to open(2) - Add fd_set_exclose() to encapsulate uses of FIO{,N}CLEX, O_CLOEXEC, F{G,S}ETFD - Add a pipe1() function to allow passing flags to the fd's that pipe(2) opens to ease im
- Add O_CLOEXEC to open(2) - Add fd_set_exclose() to encapsulate uses of FIO{,N}CLEX, O_CLOEXEC, F{G,S}ETFD - Add a pipe1() function to allow passing flags to the fd's that pipe(2) opens to ease implementation of linux pipe2(2) - Factor out fp handling code from open(2) and fhopen(2)
show more ...
|
| #
9b097994 |
| 15-Feb-2011 |
pooka <pooka@NetBSD.org> |
Support FD_CLOEXEC in rump kernels.
|
| #
e4be2748 |
| 27-Oct-2009 |
rmind <rmind@NetBSD.org> |
- Amend fd_hold() to take an argument and add assert (reflects two cases, fork1() and the rest, e.g. kthread_create(), when creating from lwp0).
- lwp_create(): do not touch filedesc internals, us
- Amend fd_hold() to take an argument and add assert (reflects two cases, fork1() and the rest, e.g. kthread_create(), when creating from lwp0).
- lwp_create(): do not touch filedesc internals, use fd_hold().
show more ...
|
| #
21506faf |
| 25-May-2009 |
yamt <yamt@NetBSD.org> |
remove prototypes of unexistent functions. (fd_clear, fd_remove)
|
| #
d991fcb3 |
| 24-May-2009 |
ad <ad@NetBSD.org> |
More changes to improve kern_descrip.c.
- Avoid atomics in more places. - Remove the per-descriptor mutex, and just use filedesc_t::fd_lock. It was only being used to synchronize close, and in any
More changes to improve kern_descrip.c.
- Avoid atomics in more places. - Remove the per-descriptor mutex, and just use filedesc_t::fd_lock. It was only being used to synchronize close, and in any case we needed to take fd_lock to free the descriptor slot. - Optimize certain paths for the <NDFDFILE case. - Sprinkle more comments and assertions. - Cache more stuff in filedesc_t. - Fix numerous minor bugs spotted along the way. - Restructure how the open files array is maintained, for clarity and so that we can eliminate the membar_consumer() call in fd_getfile(). This is mostly syntactic sugar; the main functional change is that fd_nfiles now lives alongside the open file array.
Some measurements with libmicro:
- simple file syscalls are like close() are between 1 to 10% faster. - some nice improvements, e.g. poll(1000) which is ~50% faster.
show more ...
|
| #
3cb7a24b |
| 23-May-2009 |
ad <ad@NetBSD.org> |
Make descriptor access and file allocation cheaper in many cases, mostly by avoiding a bunch of atomic operations.
|
| #
48d146fb |
| 18-Nov-2008 |
pooka <pooka@NetBSD.org> |
cwd is logically a vfs concept, so take it out from the bosom of kern_descrip and into vfs_cwd. No functional change.
|
| #
df158b64 |
| 02-Jul-2008 |
ad <ad@NetBSD.org> |
Add some comments.
|
| #
7408df12 |
| 02-Jul-2008 |
matt <matt@NetBSD.org> |
Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to fd_dup to bool. Switch assignments from 1/0 to true/false.
This make alpha kernels compile. Bump kern to 4.99.69 since struc
Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to fd_dup to bool. Switch assignments from 1/0 to true/false.
This make alpha kernels compile. Bump kern to 4.99.69 since structure changed.
show more ...
|
| #
2c51a150 |
| 02-Jul-2008 |
ad <ad@NetBSD.org> |
Alter layout of fdfile_t slightly to make it fit into 64 bytes on alpha.
|
| #
9993bc6d |
| 24-Jun-2008 |
ad <ad@NetBSD.org> |
Nothing uses getsock/getvnode any more.
|
| #
ce099b40 |
| 28-Apr-2008 |
martin <martin@NetBSD.org> |
Remove clause 3 and 4 from TNF licenses
|
| #
22ecce0f |
| 06-Apr-2008 |
apb <apb@NetBSD.org> |
#include <sys/queue.h> for SLIST_HEAD. This is needed by third party software such as lsof.
|