]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Implement a close_range(2) syscall
authorkevans <kevans@FreeBSD.org>
Sun, 12 Apr 2020 21:23:19 +0000 (21:23 +0000)
committerkevans <kevans@FreeBSD.org>
Sun, 12 Apr 2020 21:23:19 +0000 (21:23 +0000)
commit6371039d47fcde7da8301b6243867c1bbfe0793e
tree30f4cf81fcfd1a7f955265b34c52d3265a977d9a
parentd762143006e2b632d87f6db4aaed6ac67d232c7b
Implement a close_range(2) syscall

close_range(min, max, flags) allows for a range of descriptors to be
closed. The Python folk have indicated that they would much prefer this
interface to closefrom(2), as the case may be that they/someone have special
fds dup'd to higher in the range and they can't necessarily closefrom(min)
because they don't want to hit the upper range, but relocating them to lower
isn't necessarily feasible.

sys_closefrom has been rewritten to use kern_close_range() using ~0U to
indicate closing to the end of the range. This was chosen rather than
requiring callers of kern_close_range() to hold FILEDESC_SLOCK across the
call to kern_close_range for simplicity.

The flags argument of close_range(2) is currently unused, so any flags set
is currently EINVAL. It was added to the interface in Linux so that future
flags could be added for, e.g., "halt on first error" and things of this
nature.

This patch is based on a syscall of the same design that is expected to be
merged into Linux.

Reviewed by: kib, markj, vangyzen (all slightly earlier revisions)
Differential Revision: https://reviews.freebsd.org/D21627
include/unistd.h
lib/libc/sys/Makefile.inc
lib/libc/sys/Symbol.map
lib/libc/sys/closefrom.2
sys/compat/freebsd32/syscalls.master
sys/kern/capabilities.conf
sys/kern/kern_descrip.c
sys/kern/syscalls.master
sys/sys/syscallsubr.h
tests/sys/file/closefrom_test.c