diff --git a/doc/connectivity/networking/net_config_guide.rst b/doc/connectivity/networking/net_config_guide.rst index 177ff434e8ae15f..fd4f0ff402f1818 100644 --- a/doc/connectivity/networking/net_config_guide.rst +++ b/doc/connectivity/networking/net_config_guide.rst @@ -87,7 +87,7 @@ Socket Options Maximum number of supported poll() entries. One needs to select proper value here depending on how many BSD sockets are polled in the system. -:kconfig:option:`CONFIG_POSIX_MAX_FDS` +:kconfig:option:`CONFIG_ZVFS_OPEN_MAX` Maximum number of open file descriptors, this includes files, sockets, special devices, etc. One needs to select proper value here depending on how many BSD sockets are created in the system. diff --git a/doc/services/portability/posix/kconfig/index.rst b/doc/services/portability/posix/kconfig/index.rst index 5a628537964c0a4..1159969b67be4cf 100644 --- a/doc/services/portability/posix/kconfig/index.rst +++ b/doc/services/portability/posix/kconfig/index.rst @@ -26,8 +26,8 @@ implementation of the POSIX API. * :kconfig:option:`CONFIG_NET_SOCKETS_POLL_MAX` * :kconfig:option:`CONFIG_POSIX_API` * :kconfig:option:`CONFIG_POSIX_FS` -* :kconfig:option:`CONFIG_POSIX_MAX_FDS` -* :kconfig:option:`CONFIG_POSIX_MAX_OPEN_FILES` +* :kconfig:option:`CONFIG_ZVFS_OPEN_MAX` +* :kconfig:option:`CONFIG_POSIX_OPEN_MAX` * :kconfig:option:`CONFIG_POSIX_MQUEUE` * :kconfig:option:`CONFIG_POSIX_RTSIG_MAX` * :kconfig:option:`CONFIG_POSIX_SIGNAL` diff --git a/drivers/modem/Kconfig b/drivers/modem/Kconfig index 02e3557918f6442..edf8d79069631ca 100644 --- a/drivers/modem/Kconfig +++ b/drivers/modem/Kconfig @@ -155,7 +155,7 @@ config MODEM_SOCKET modem_socket_init(). Note that the modem socket uses runtime allocated file descriptors reserved from the fdtable, for which the max count is set using the - Kconfig option POSIX_MAX_FDS. Make sure to update this value as both + Kconfig option ZVFS_OPEN_MAX. Make sure to update this value as both the modem sockets and the POSIX_API, if used, share them. config MODEM_SOCKET_PACKET_COUNT diff --git a/include/zephyr/net/socket_select.h b/include/zephyr/net/socket_select.h index d4cfef32cbcd9bb..c326fb58f162eee 100644 --- a/include/zephyr/net/socket_select.h +++ b/include/zephyr/net/socket_select.h @@ -29,7 +29,7 @@ extern "C" { /** @cond INTERNAL_HIDDEN */ typedef struct zsock_fd_set { - uint32_t bitset[(CONFIG_POSIX_MAX_FDS + 31) / 32]; + uint32_t bitset[(CONFIG_ZVFS_OPEN_MAX + 31) / 32]; } zsock_fd_set; /** @endcond */ diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h index e76970d67419cb5..fad08d299e1a9d7 100644 --- a/include/zephyr/posix/posix_features.h +++ b/include/zephyr/posix/posix_features.h @@ -209,7 +209,7 @@ #define _POSIX_MQ_PRIO_MAX (32) #define _POSIX_NAME_MAX (14) #define _POSIX_NGROUPS_MAX (8) -#define _POSIX_OPEN_MAX CONFIG_POSIX_MAX_FDS +#define _POSIX_OPEN_MAX CONFIG_POSIX_OPEN_MAX #define _POSIX_PATH_MAX (256) #define _POSIX_PIPE_BUF (512) #define _POSIX_RE_DUP_MAX (255) diff --git a/include/zephyr/posix/sys/sysconf.h b/include/zephyr/posix/sys/sysconf.h index 37f7ba2386b2f48..1732dfd0f181d80 100644 --- a/include/zephyr/posix/sys/sysconf.h +++ b/include/zephyr/posix/sys/sysconf.h @@ -268,7 +268,7 @@ enum { #define __z_posix_sysconf_SC_NGROUPS_MAX _POSIX_NGROUPS_MAX #define __z_posix_sysconf_SC_MQ_OPEN_MAX MQ_OPEN_MAX #define __z_posix_sysconf_SC_MQ_PRIO_MAX MQ_PRIO_MAX -#define __z_posix_sysconf_SC_OPEN_MAX CONFIG_POSIX_MAX_FDS +#define __z_posix_sysconf_SC_OPEN_MAX CONFIG_ZVFS_OPEN_MAX #define __z_posix_sysconf_SC_PAGE_SIZE PAGE_SIZE #define __z_posix_sysconf_SC_PAGESIZE PAGESIZE #define __z_posix_sysconf_SC_THREAD_DESTRUCTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS diff --git a/lib/libc/Kconfig b/lib/libc/Kconfig index f2835c9568f5486..062dd875cb0d692 100644 --- a/lib/libc/Kconfig +++ b/lib/libc/Kconfig @@ -102,6 +102,10 @@ config NEWLIB_LIBC depends on !NATIVE_APPLICATION depends on NEWLIB_LIBC_SUPPORTED select NEED_LIBC_MEM_PARTITION + imply POSIX_DEVICE_IO_ALIAS_CLOSE + imply POSIX_DEVICE_IO_ALIAS_OPEN + imply POSIX_DEVICE_IO_ALIAS_READ + imply POSIX_DEVICE_IO_ALIAS_WRITE imply POSIX_FD_MGMT_ALIAS_LSEEK help Build with newlib library. The newlib library is expected to be diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 14b6241b72c9359..863f5e93b3ef717 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -10,6 +10,15 @@ config FDTABLE for any I/O object implementing POSIX I/O semantics (i.e. read/write + aux operations). +config ZVFS_OPEN_MAX + int "Maximum number of open file descriptors" + default 16 if WIFI_NM_WPA_SUPPLICANT + default 16 if POSIX_API + default 4 + help + Maximum number of open file descriptors, this includes + files, sockets, special devices, etc. + config PRINTK_SYNC bool "Serialize printk() calls" default y if SMP && MP_MAX_NUM_CPUS > 1 && !(EFI_CONSOLE && LOG) diff --git a/lib/os/fdtable.c b/lib/os/fdtable.c index 826b616f9d5ecd8..1770bd008a86513 100644 --- a/lib/os/fdtable.c +++ b/lib/os/fdtable.c @@ -31,12 +31,14 @@ struct fd_entry { struct k_condvar cond; }; -#ifdef CONFIG_POSIX_API +#if defined(CONFIG_POSIX_DEVICE_IO) static const struct fd_op_vtable stdinout_fd_op_vtable; -#endif -static struct fd_entry fdtable[CONFIG_POSIX_MAX_FDS] = { -#ifdef CONFIG_POSIX_API +BUILD_ASSERT(CONFIG_ZVFS_OPEN_MAX >= 3, "CONFIG_ZVFS_OPEN_MAX >= 3 for CONFIG_POSIX_DEVICE_IO"); +#endif /* defined(CONFIG_POSIX_DEVICE_IO) */ + +static struct fd_entry fdtable[CONFIG_ZVFS_OPEN_MAX] = { +#if defined(CONFIG_POSIX_DEVICE_IO) /* * Predefine entries for stdin/stdout/stderr. */ @@ -62,9 +64,7 @@ static struct fd_entry fdtable[CONFIG_POSIX_MAX_FDS] = { .cond = Z_CONDVAR_INITIALIZER(fdtable[2].cond), }, #else - { - 0 - }, + {0}, #endif }; @@ -296,9 +296,7 @@ int z_alloc_fd(void *obj, const struct fd_op_vtable *vtable) return fd; } -#ifdef CONFIG_POSIX_API - -ssize_t read(int fd, void *buf, size_t sz) +ssize_t zvfs_read(int fd, void *buf, size_t sz) { ssize_t res; @@ -314,9 +312,8 @@ ssize_t read(int fd, void *buf, size_t sz) return res; } -FUNC_ALIAS(read, _read, ssize_t); -ssize_t write(int fd, const void *buf, size_t sz) +ssize_t zvfs_write(int fd, const void *buf, size_t sz) { ssize_t res; @@ -332,9 +329,8 @@ ssize_t write(int fd, const void *buf, size_t sz) return res; } -FUNC_ALIAS(write, _write, ssize_t); -int close(int fd) +int zvfs_close(int fd) { int res; @@ -352,7 +348,6 @@ int close(int fd) return res; } -FUNC_ALIAS(close, _close, int); #ifdef CONFIG_POSIX_FSYNC int fsync(int fd) @@ -372,8 +367,8 @@ off_t zvfs_lseek(int fd, off_t offset, int whence) return -1; } - return z_fdtable_call_ioctl(fdtable[fd].vtable, fdtable[fd].obj, ZFD_IOCTL_LSEEK, - offset, whence); + return z_fdtable_call_ioctl(fdtable[fd].vtable, fdtable[fd].obj, ZFD_IOCTL_LSEEK, offset, + whence); } int ioctl(int fd, unsigned long request, ...) @@ -406,6 +401,7 @@ int zvfs_fcntl(int fd, int cmd, va_list args) return res; } +#if defined(CONFIG_POSIX_DEVICE_IO) /* * fd operations for stdio/stdout/stderr */ @@ -420,7 +416,7 @@ static ssize_t stdinout_read_vmeth(void *obj, void *buffer, size_t count) static ssize_t stdinout_write_vmeth(void *obj, const void *buffer, size_t count) { #if defined(CONFIG_BOARD_NATIVE_POSIX) - return write(1, buffer, count); + return zvfs_write(1, buffer, count); #elif defined(CONFIG_NEWLIB_LIBC) || defined(CONFIG_ARCMWDT_LIBC) return z_impl_zephyr_write_stdout(buffer, count); #else @@ -441,4 +437,4 @@ static const struct fd_op_vtable stdinout_fd_op_vtable = { .ioctl = stdinout_ioctl_vmeth, }; -#endif /* CONFIG_POSIX_API */ +#endif /* defined(CONFIG_POSIX_DEVICE_IO) */ diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index 3ad45db28b905a5..40326acdadaf811 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -37,9 +37,13 @@ add_subdirectory_ifdef(CONFIG_GETOPT getopt) zephyr_library_sources_ifdef(CONFIG_EVENTFD eventfd.c) zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c) zephyr_library_sources_ifdef(CONFIG_GETENTROPY getentropy.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c) zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c) zephyr_library_sources_ifdef(CONFIG_POSIX_CONFSTR confstr.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_DEVICE_IO + # perror should be moved to the common libc + perror.c + device_io.c +) zephyr_library_sources_ifdef(CONFIG_POSIX_ENV env.c) zephyr_library_sources_ifdef(CONFIG_POSIX_FD_MGMT fd_mgmt.c diff --git a/lib/posix/options/Kconfig b/lib/posix/options/Kconfig index bdc9637bd3e28ba..069580f14a57cdd 100644 --- a/lib/posix/options/Kconfig +++ b/lib/posix/options/Kconfig @@ -13,6 +13,16 @@ config POSIX_API Enable mostly-standards-compliant implementations of various POSIX (IEEE 1003.1) APIs. +config POSIX_OPEN_MAX + int + default ZVFS_OPEN_MAX + help + The maximum number of files that a process can have open at one time. This option is not + directly user-configurable but can be adjusted via CONFIG_ZVFS_OPEN_MAX. + + For more information, please see + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html + config PTHREAD_IPC bool "POSIX pthread IPC API" default y if POSIX_API @@ -26,9 +36,9 @@ rsource "Kconfig.aio" rsource "Kconfig.barrier" rsource "Kconfig.cond" rsource "Kconfig.confstr" +rsource "Kconfig.device_io" rsource "Kconfig.env" rsource "Kconfig.eventfd" -rsource "Kconfig.fdtable" rsource "Kconfig.fd_mgmt" rsource "Kconfig.fnmatch" rsource "Kconfig.fs" diff --git a/lib/posix/options/Kconfig.deprecated b/lib/posix/options/Kconfig.deprecated index 6aaacd188113426..555842e78626f66 100644 --- a/lib/posix/options/Kconfig.deprecated +++ b/lib/posix/options/Kconfig.deprecated @@ -28,6 +28,26 @@ config POSIX_LIMITS_RTSIG_MAX Please use CONFIG_POSIX_RTSIG_MAX instead. +config POSIX_MAX_FDS + int "Maximum number of open file descriptors [DEPRECATED]" + default 0 + help + This option is deprecated. + + Please use CONFIG_POSIX_OPEN_MAX instead. + + See also CONFIG_ZVFS_OPEN_MAX. + +config POSIX_MAX_OPEN_FILES + int "Maximum number of open file descriptors [DEPRECATED]" + default 0 + help + This option is deprecated. + + Please use CONFIG_POSIX_OPEN_MAX instead. + + See also CONFIG_ZVFS_OPEN_MAX. + config TIMER bool "Timer support [DEPRECATED]" select DEPRECATED diff --git a/lib/posix/options/Kconfig.device_io b/lib/posix/options/Kconfig.device_io new file mode 100644 index 000000000000000..16591f7d8b85c16 --- /dev/null +++ b/lib/posix/options/Kconfig.device_io @@ -0,0 +1,42 @@ +# Copyright (c) 2024 Tenstorrent AI ULC +# +# SPDX-License-Identifier: Apache-2.0 + +menuconfig POSIX_DEVICE_IO + bool "POSIX Device IO" + default y if POSIX_API + select FDTABLE + help + Select 'y' here and Zephyr will provide an implementation of the POSIX_DEVICE_IO Option + Group such as FD_CLR(), FD_ISSET(), FD_SET(), FD_ZERO(), close(), fdopen(), fileno(), open(), + poll(), pread(), pselect(), pwrite(), read(), select(), and write(). + + For more informnation, please see + https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html + +if POSIX_DEVICE_IO + +# These options are intended to be used for compatibility with external POSIX +# implementations such as those in Newlib or Picolibc. + +config POSIX_DEVICE_IO_ALIAS_CLOSE + bool + help + Select 'y' here and Zephyr will provide an alias for close() as _close(). + +config POSIX_DEVICE_IO_ALIAS_OPEN + bool + help + Select 'y' here and Zephyr will provide an alias for open() as _open(). + +config POSIX_DEVICE_IO_ALIAS_READ + bool + help + Select 'y' here and Zephyr will provide an alias for read() as _read(). + +config POSIX_DEVICE_IO_ALIAS_WRITE + bool + help + Select 'y' here and Zephyr will provide an alias for write() as _write(). + +endif # POSIX_DEVICE_IO diff --git a/lib/posix/options/Kconfig.fdtable b/lib/posix/options/Kconfig.fdtable deleted file mode 100644 index 214e4a04ae98f03..000000000000000 --- a/lib/posix/options/Kconfig.fdtable +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2018 Linaro -# -# SPDX-License-Identifier: Apache-2.0 - -menu "File descriptor table options" - -config POSIX_MAX_FDS - int "Maximum number of open file descriptors" - default 16 if WIFI_NM_WPA_SUPPLICANT - default 16 if POSIX_API - default 4 - help - Maximum number of open file descriptors, this includes - files, sockets, special devices, etc. - -endmenu # "File descriptor table options" diff --git a/lib/posix/options/Kconfig.fs b/lib/posix/options/Kconfig.fs index bff95a906a9cfa9..35c01cf72a15065 100644 --- a/lib/posix/options/Kconfig.fs +++ b/lib/posix/options/Kconfig.fs @@ -12,13 +12,6 @@ menuconfig POSIX_FS if POSIX_FS -config POSIX_MAX_OPEN_FILES - int "Maximum number of open file descriptors" - default 16 - help - Maximum number of open files. Note that this setting - is additionally bounded by CONFIG_POSIX_MAX_FDS. - config POSIX_FSYNC bool "Support for fsync()" default y diff --git a/lib/posix/options/device_io.c b/lib/posix/options/device_io.c new file mode 100644 index 000000000000000..b9eab198a16ad2a --- /dev/null +++ b/lib/posix/options/device_io.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024, Tenstorrent AI ULC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include +#include +#include +#include + +/* prototypes for external, not-yet-public, functions in fdtable.c or fs.c */ +int zvfs_close(int fd); +int zvfs_open(const char *name, int flags); +ssize_t zvfs_read(int fd, void *buf, size_t sz); +ssize_t zvfs_write(int fd, const void *buf, size_t sz); + +int close(int fd) +{ + return zvfs_close(fd); +} +#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE +FUNC_ALIAS(close, _close, int); +#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_CLOSE */ + +int open(const char *name, int flags, ...) +{ + /* FIXME: necessarily need to check for O_CREAT and unpack ... if set */ + return zvfs_open(name, flags); +} +#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN +FUNC_ALIAS(open, _open, int); +#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_OPEN */ + +int poll(struct pollfd *fds, int nfds, int timeout) +{ + /* TODO: create zvfs_poll() and dispatch to subsystems based on file type */ + return zsock_poll(fds, nfds, timeout); +} + +ssize_t read(int fd, void *buf, size_t sz) +{ + return zvfs_read(fd, buf, sz); +} +#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_READ +FUNC_ALIAS(read, _read, ssize_t); +#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_READ */ + +int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) +{ + /* TODO: create zvfs_select() and dispatch to subsystems based on file type */ + return zsock_select(nfds, readfds, writefds, exceptfds, (struct zsock_timeval *)timeout); +} + +ssize_t write(int fd, const void *buf, size_t sz) +{ + return zvfs_write(fd, buf, sz); +} +#ifdef CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE +FUNC_ALIAS(write, _write, ssize_t); +#endif /* CONFIG_POSIX_DEVICEIO_ALIAS_WRITE */ diff --git a/lib/posix/options/fs.c b/lib/posix/options/fs.c index 70b8d75b3008cad..caec36692d61c56 100644 --- a/lib/posix/options/fs.c +++ b/lib/posix/options/fs.c @@ -26,7 +26,7 @@ struct posix_fs_desc { bool used; }; -static struct posix_fs_desc desc_array[CONFIG_POSIX_MAX_OPEN_FILES]; +static struct posix_fs_desc desc_array[CONFIG_POSIX_OPEN_MAX]; static struct fs_dirent fdirent; static struct dirent pdirent; @@ -39,7 +39,7 @@ static struct posix_fs_desc *posix_fs_alloc_obj(bool is_dir) struct posix_fs_desc *ptr = NULL; unsigned int key = irq_lock(); - for (i = 0; i < CONFIG_POSIX_MAX_OPEN_FILES; i++) { + for (i = 0; i < CONFIG_POSIX_OPEN_MAX; i++) { if (desc_array[i].used == false) { ptr = &desc_array[i]; ptr->used = true; @@ -80,12 +80,7 @@ static int posix_mode_to_zephyr(int mf) return mode; } -/** - * @brief Open a file. - * - * See IEEE 1003.1 - */ -int open(const char *name, int flags, ...) +int zvfs_open(const char *name, int flags) { int rc, fd; struct posix_fs_desc *ptr = NULL; @@ -123,10 +118,6 @@ int open(const char *name, int flags, ...) return fd; } -#if !defined(CONFIG_NEWLIB_LIBC) && !defined(CONFIG_PICOLIBC) -FUNC_ALIAS(open, _open, int); -#endif - static int fs_close_vmeth(void *obj) { struct posix_fs_desc *ptr = obj; diff --git a/lib/posix/options/net.c b/lib/posix/options/net.c index 5fcfdca464c8e15..618c630630ecd14 100644 --- a/lib/posix/options/net.c +++ b/lib/posix/options/net.c @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include /* From arpa/inet.h */ @@ -355,11 +353,6 @@ int listen(int sock, int backlog) return zsock_listen(sock, backlog); } -int poll(struct pollfd *fds, int nfds, int timeout) -{ - return zsock_poll(fds, nfds, timeout); -} - ssize_t recv(int sock, void *buf, size_t max_len, int flags) { return zsock_recv(sock, buf, max_len, flags); @@ -376,11 +369,6 @@ ssize_t recvmsg(int sock, struct msghdr *msg, int flags) return zsock_recvmsg(sock, msg, flags); } -int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) -{ - return zsock_select(nfds, readfds, writefds, exceptfds, (struct zsock_timeval *)timeout); -} - ssize_t send(int sock, const void *buf, size_t len, int flags) { return zsock_send(sock, buf, len, flags); diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig index 3cafa4668871c00..2bbba0878284d4d 100644 --- a/modules/hostap/Kconfig +++ b/modules/hostap/Kconfig @@ -41,7 +41,7 @@ config WIFI_NM_WPA_SUPPLICANT_WQ_PRIO int "Thread priority of wpa_supplicant iface workqueue" default 7 -# Currently we default POSIX_MAX_FDS to 16 in lib/posix/Kconfig +# Currently we default ZVFS_OPEN_MAX to 16 in lib/posix/Kconfig # l2_packet - 1 # ctrl_iface - 2 * socketpairs = 4(local and global) # z_wpa_event_sock - 1 socketpair = 2 diff --git a/samples/modules/thrift/hello/client/prj.conf b/samples/modules/thrift/hello/client/prj.conf index a83715ddfc792c7..0f094d14d6c2e2e 100644 --- a/samples/modules/thrift/hello/client/prj.conf +++ b/samples/modules/thrift/hello/client/prj.conf @@ -28,7 +28,7 @@ CONFIG_NET_TCP=y CONFIG_NET_IPV6=n CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_NET_CONNECTION_MANAGER=y # Kernel options @@ -61,7 +61,7 @@ CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" # Number of socket descriptors might need adjusting # if there are more than 1 handlers defined. -CONFIG_POSIX_MAX_FDS=16 +CONFIG_ZVFS_OPEN_MAX=16 # Some platforms require relatively large stack sizes. # This can be tuned per-board. diff --git a/samples/modules/thrift/hello/server/prj.conf b/samples/modules/thrift/hello/server/prj.conf index 1aacd9d14d758fc..fe78b9a2803a597 100644 --- a/samples/modules/thrift/hello/server/prj.conf +++ b/samples/modules/thrift/hello/server/prj.conf @@ -51,7 +51,7 @@ CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" # Number of socket descriptors might need adjusting # if there are more than 1 handlers defined. -CONFIG_POSIX_MAX_FDS=16 +CONFIG_ZVFS_OPEN_MAX=16 # Some platforms require relatively large stack sizes. # This can be tuned per-board. diff --git a/samples/net/mqtt_sn_publisher/prj.conf b/samples/net/mqtt_sn_publisher/prj.conf index 367ba8082f489f7..efe1a8f3e207ec3 100644 --- a/samples/net/mqtt_sn_publisher/prj.conf +++ b/samples/net/mqtt_sn_publisher/prj.conf @@ -5,7 +5,7 @@ CONFIG_NET_IPV4=y CONFIG_NET_IPV6=n CONFIG_NET_SOCKETS=y CONFIG_POSIX_API=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_NET_CONNECTION_MANAGER=y # Kernel options diff --git a/samples/net/sockets/dumb_http_server_mt/prj.conf b/samples/net/sockets/dumb_http_server_mt/prj.conf index af851a0406e3ee1..7b802e6e8b48246 100644 --- a/samples/net/sockets/dumb_http_server_mt/prj.conf +++ b/samples/net/sockets/dumb_http_server_mt/prj.conf @@ -2,7 +2,7 @@ CONFIG_TEST_RANDOM_GENERATOR=y # POSIX options -CONFIG_POSIX_MAX_FDS=20 +CONFIG_ZVFS_OPEN_MAX=20 CONFIG_POSIX_API=y # Networking config diff --git a/samples/net/sockets/echo_client/overlay-tls.conf b/samples/net/sockets/echo_client/overlay-tls.conf index 8235291cefc194c..b6183e9f14daa5b 100644 --- a/samples/net/sockets/echo_client/overlay-tls.conf +++ b/samples/net/sockets/echo_client/overlay-tls.conf @@ -12,4 +12,4 @@ CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048 CONFIG_NET_SOCKETS_SOCKOPT_TLS=y CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 CONFIG_NET_SOCKETS_ENABLE_DTLS=y -CONFIG_POSIX_MAX_FDS=8 +CONFIG_ZVFS_OPEN_MAX=8 diff --git a/samples/net/sockets/echo_server/overlay-tls.conf b/samples/net/sockets/echo_server/overlay-tls.conf index f9d650ecd029366..fa91a0f6258b572 100644 --- a/samples/net/sockets/echo_server/overlay-tls.conf +++ b/samples/net/sockets/echo_server/overlay-tls.conf @@ -13,4 +13,4 @@ CONFIG_NET_SOCKETS_SOCKOPT_TLS=y CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=6 CONFIG_NET_SOCKETS_ENABLE_DTLS=y CONFIG_NET_SOCKETS_DTLS_TIMEOUT=30000 -CONFIG_POSIX_MAX_FDS=16 +CONFIG_ZVFS_OPEN_MAX=16 diff --git a/samples/net/sockets/echo_server/prj.conf b/samples/net/sockets/echo_server/prj.conf index e88c98eda395629..c95e09b71b85fb2 100644 --- a/samples/net/sockets/echo_server/prj.conf +++ b/samples/net/sockets/echo_server/prj.conf @@ -6,7 +6,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y CONFIG_POSIX_API=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_NET_CONNECTION_MANAGER=y # Kernel options @@ -48,7 +48,7 @@ CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" # Number of socket descriptors might need adjusting # if there are more than 1 handlers defined. -CONFIG_POSIX_MAX_FDS=12 +CONFIG_ZVFS_OPEN_MAX=12 # How many client can connect to echo-server simultaneously CONFIG_NET_SAMPLE_NUM_HANDLERS=1 diff --git a/samples/net/sockets/echo_service/prj.conf b/samples/net/sockets/echo_service/prj.conf index d7ffe7383528066..b9c053c27a2b6d5 100644 --- a/samples/net/sockets/echo_service/prj.conf +++ b/samples/net/sockets/echo_service/prj.conf @@ -10,7 +10,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y CONFIG_NET_IPV4_MAPPING_TO_IPV6=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_NET_MAX_CONN=5 CONFIG_NET_SOCKETS_SERVICE=y CONFIG_NET_SOCKETS_POLL_MAX=20 diff --git a/samples/net/sockets/http_server/prj.conf b/samples/net/sockets/http_server/prj.conf index 3d13a55cbf29b4a..51d898eb15c2d1e 100644 --- a/samples/net/sockets/http_server/prj.conf +++ b/samples/net/sockets/http_server/prj.conf @@ -5,7 +5,7 @@ CONFIG_LOG=y CONFIG_ENTROPY_GENERATOR=y CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_INIT_STACKS=y -CONFIG_POSIX_MAX_FDS=32 +CONFIG_ZVFS_OPEN_MAX=32 CONFIG_POSIX_API=y CONFIG_FDTABLE=y CONFIG_NET_SOCKETS_POLL_MAX=32 diff --git a/samples/net/sockets/net_mgmt/prj.conf b/samples/net/sockets/net_mgmt/prj.conf index 243cce2173552cd..a94f5da00948d30 100644 --- a/samples/net/sockets/net_mgmt/prj.conf +++ b/samples/net/sockets/net_mgmt/prj.conf @@ -6,7 +6,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y CONFIG_POSIX_API=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_NET_SOCKETS_NET_MGMT=y CONFIG_NET_MGMT_EVENT=y diff --git a/samples/net/sockets/packet/prj.conf b/samples/net/sockets/packet/prj.conf index d01c89254e1552e..555e824bf588095 100644 --- a/samples/net/sockets/packet/prj.conf +++ b/samples/net/sockets/packet/prj.conf @@ -7,7 +7,7 @@ CONFIG_NET_IPV4=n CONFIG_NET_MAX_CONTEXTS=10 CONFIG_NET_SOCKETS=y CONFIG_POSIX_API=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_NET_CONTEXT_RCVTIMEO=y CONFIG_NET_MGMT=y CONFIG_NET_MGMT_EVENT=y diff --git a/samples/net/zperf/prj.conf b/samples/net/zperf/prj.conf index e355986210bbd65..0bf23e7a7e502d3 100644 --- a/samples/net/zperf/prj.conf +++ b/samples/net/zperf/prj.conf @@ -20,7 +20,7 @@ CONFIG_NET_MAX_CONTEXTS=5 CONFIG_NET_TC_TX_COUNT=1 CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_POLL_MAX=9 -CONFIG_POSIX_MAX_FDS=8 +CONFIG_ZVFS_OPEN_MAX=8 CONFIG_POSIX_API=y CONFIG_INIT_STACKS=y diff --git a/samples/subsys/video/tcpserversink/prj.conf b/samples/subsys/video/tcpserversink/prj.conf index 43ddea77f51d2ac..824c424b2fa8aa0 100644 --- a/samples/subsys/video/tcpserversink/prj.conf +++ b/samples/subsys/video/tcpserversink/prj.conf @@ -3,7 +3,7 @@ CONFIG_NETWORKING=y CONFIG_NET_TCP=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 CONFIG_POSIX_API=y # Kernel options diff --git a/subsys/net/lib/sockets/socket_obj_core.c b/subsys/net/lib/sockets/socket_obj_core.c index 276576e825fc64a..9c3e37f6185a2a5 100644 --- a/subsys/net/lib/sockets/socket_obj_core.c +++ b/subsys/net/lib/sockets/socket_obj_core.c @@ -20,8 +20,8 @@ static K_MUTEX_DEFINE(sock_obj_mutex); /* Allocate some extra socket objects so that we can track * closed sockets and get some historical statistics. */ -static struct sock_obj sock_objects[CONFIG_POSIX_MAX_FDS * 2] = { - [0 ... ((CONFIG_POSIX_MAX_FDS * 2) - 1)] = { +static struct sock_obj sock_objects[CONFIG_ZVFS_OPEN_MAX * 2] = { + [0 ... ((CONFIG_ZVFS_OPEN_MAX * 2) - 1)] = { .fd = -1, .init_done = false, } diff --git a/tests/modules/thrift/ThriftTest/overlay-tls.conf b/tests/modules/thrift/ThriftTest/overlay-tls.conf index b98beb610c33922..7676b38883292ca 100644 --- a/tests/modules/thrift/ThriftTest/overlay-tls.conf +++ b/tests/modules/thrift/ThriftTest/overlay-tls.conf @@ -14,7 +14,7 @@ CONFIG_THRIFT_SSL_SOCKET=y # tcp sockets (client, server): 2 # tls sockets (client, server): 2 # socketpairs for cancellation (accept, client, server): 6 -CONFIG_POSIX_MAX_FDS=15 +CONFIG_ZVFS_OPEN_MAX=15 # TLS configuration CONFIG_MBEDTLS=y diff --git a/tests/modules/thrift/ThriftTest/prj.conf b/tests/modules/thrift/ThriftTest/prj.conf index 6619fb8295d9b5c..80872a61085f04c 100755 --- a/tests/modules/thrift/ThriftTest/prj.conf +++ b/tests/modules/thrift/ThriftTest/prj.conf @@ -51,7 +51,7 @@ CONFIG_NET_PKT_RX_COUNT=20 # stdin, stdout, stderr: 3 # socketpair for channel: 2 # eventfd for cancellation: 1 -CONFIG_POSIX_MAX_FDS=6 +CONFIG_ZVFS_OPEN_MAX=6 # Network address config CONFIG_NET_IPV4=y diff --git a/tests/net/lib/dns_resolve/prj.conf b/tests/net/lib/dns_resolve/prj.conf index 4bc1b8706cec927..62ea99cf2f52cde 100644 --- a/tests/net/lib/dns_resolve/prj.conf +++ b/tests/net/lib/dns_resolve/prj.conf @@ -30,4 +30,4 @@ CONFIG_ZTEST=y CONFIG_MAIN_STACK_SIZE=1344 CONFIG_NET_SOCKETS_POLL_MAX=9 -CONFIG_POSIX_MAX_FDS=5 +CONFIG_ZVFS_OPEN_MAX=5 diff --git a/tests/net/lib/http_server/crime/prj.conf b/tests/net/lib/http_server/crime/prj.conf index 0596a54e47c77e8..a1f7ef3a8efe576 100644 --- a/tests/net/lib/http_server/crime/prj.conf +++ b/tests/net/lib/http_server/crime/prj.conf @@ -9,7 +9,7 @@ CONFIG_ENTROPY_GENERATOR=y CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_ZTEST_STACK_SIZE=1024 -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_REQUIRES_FULL_LIBC=y CONFIG_EVENTFD_MAX=10 CONFIG_NET_MAX_CONTEXTS=10 diff --git a/tests/net/lib/http_server/prototype/prj.conf b/tests/net/lib/http_server/prototype/prj.conf index 20570610ef79d45..5e9ad2b1412adce 100644 --- a/tests/net/lib/http_server/prototype/prj.conf +++ b/tests/net/lib/http_server/prototype/prj.conf @@ -7,7 +7,7 @@ CONFIG_POSIX_API=y CONFIG_ENTROPY_GENERATOR=y CONFIG_TEST_RANDOM_GENERATOR=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_REQUIRES_FULL_LIBC=y CONFIG_EVENTFD_MAX=10 CONFIG_NET_MAX_CONTEXTS=10 diff --git a/tests/net/lib/http_server/tls/prj.conf b/tests/net/lib/http_server/tls/prj.conf index 997a3b64264338f..63af22cbdf6a164 100644 --- a/tests/net/lib/http_server/tls/prj.conf +++ b/tests/net/lib/http_server/tls/prj.conf @@ -37,9 +37,9 @@ CONFIG_NET_BUF_TX_COUNT=128 CONFIG_NET_BUF_RX_COUNT=128 CONFIG_NET_PKT_TX_COUNT=16 CONFIG_NET_PKT_RX_COUNT=16 -CONFIG_POSIX_MAX_FDS=32 +CONFIG_ZVFS_OPEN_MAX=32 CONFIG_NET_SOCKETS_POLL_MAX=32 -CONFIG_POSIX_MAX_FDS=32 +CONFIG_ZVFS_OPEN_MAX=32 CONFIG_REQUIRES_FULL_LIBC=y CONFIG_EVENTFD_MAX=10 CONFIG_NET_MAX_CONTEXTS=10 diff --git a/tests/net/pm/prj.conf b/tests/net/pm/prj.conf index 600808218688950..5d478e4d0700b23 100644 --- a/tests/net/pm/prj.conf +++ b/tests/net/pm/prj.conf @@ -7,7 +7,7 @@ CONFIG_NET_L2_ETHERNET=n CONFIG_NET_UDP=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=2 +CONFIG_ZVFS_OPEN_MAX=2 CONFIG_ZTEST_STACK_SIZE=2048 CONFIG_MAIN_STACK_SIZE=2048 CONFIG_NET_LOG=y diff --git a/tests/net/socket/af_packet/prj.conf b/tests/net/socket/af_packet/prj.conf index a0fd507497d42d0..2eeb220abdb50f7 100644 --- a/tests/net/socket/af_packet/prj.conf +++ b/tests/net/socket/af_packet/prj.conf @@ -6,7 +6,7 @@ CONFIG_NET_UDP=y CONFIG_NET_TCP=n CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_PACKET=y -CONFIG_POSIX_MAX_FDS=8 +CONFIG_ZVFS_OPEN_MAX=8 CONFIG_NET_IPV6_DAD=n CONFIG_NET_IPV6_MLD=n diff --git a/tests/net/socket/af_packet_ipproto_raw/prj.conf b/tests/net/socket/af_packet_ipproto_raw/prj.conf index 9edcaa6be842e13..227851d398f2edd 100644 --- a/tests/net/socket/af_packet_ipproto_raw/prj.conf +++ b/tests/net/socket/af_packet_ipproto_raw/prj.conf @@ -6,7 +6,7 @@ CONFIG_NET_UDP=n CONFIG_NET_TCP=n CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_PACKET=y -CONFIG_POSIX_MAX_FDS=8 +CONFIG_ZVFS_OPEN_MAX=8 CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y CONFIG_NET_CORE_LOG_LEVEL_DBG=y diff --git a/tests/net/socket/poll/prj.conf b/tests/net/socket/poll/prj.conf index b708020ef4335be..4a404b96aea244e 100644 --- a/tests/net/socket/poll/prj.conf +++ b/tests/net/socket/poll/prj.conf @@ -5,7 +5,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_UDP=y CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_NET_PKT_TX_COUNT=8 CONFIG_NET_PKT_RX_COUNT=8 CONFIG_NET_MAX_CONN=5 diff --git a/tests/net/socket/reuseaddr_reuseport/prj.conf b/tests/net/socket/reuseaddr_reuseport/prj.conf index 1501ff0c1d8eadb..f151d25130eb1cd 100644 --- a/tests/net/socket/reuseaddr_reuseport/prj.conf +++ b/tests/net/socket/reuseaddr_reuseport/prj.conf @@ -28,7 +28,7 @@ CONFIG_NET_CONTEXT_REUSEPORT=y CONFIG_NET_HOSTNAME_ENABLE=y CONFIG_NET_HOSTNAME="ztest_hostname" -CONFIG_POSIX_MAX_FDS=8 +CONFIG_ZVFS_OPEN_MAX=8 CONFIG_NET_MAX_CONN=10 CONFIG_NET_MAX_CONTEXTS=10 diff --git a/tests/net/socket/select/prj.conf b/tests/net/socket/select/prj.conf index 89918315d115107..53c0c5de3bf9519 100644 --- a/tests/net/socket/select/prj.conf +++ b/tests/net/socket/select/prj.conf @@ -10,7 +10,7 @@ CONFIG_NET_IPV4=n CONFIG_NET_IPV6=y CONFIG_NET_SOCKETS=y # Defines fd_set size -CONFIG_POSIX_MAX_FDS=33 +CONFIG_ZVFS_OPEN_MAX=33 # Network driver config CONFIG_TEST_RANDOM_GENERATOR=y diff --git a/tests/net/socket/select/src/main.c b/tests/net/socket/select/src/main.c index aab52167c31b3f8..4a04bf67b04b9d1 100644 --- a/tests/net/socket/select/src/main.c +++ b/tests/net/socket/select/src/main.c @@ -34,7 +34,7 @@ ZTEST_USER(net_socket_select, test_fd_set) { zsock_fd_set set; - /* Relies on specific value of CONFIG_POSIX_MAX_FDS in prj.conf */ + /* Relies on specific value of CONFIG_ZVFS_OPEN_MAX in prj.conf */ zassert_equal(sizeof(set.bitset), sizeof(uint32_t) * 2, ""); ZSOCK_FD_ZERO(&set); diff --git a/tests/net/socket/service/prj.conf b/tests/net/socket/service/prj.conf index 5e51a0f6a53eebb..5f5c2325a335b0b 100644 --- a/tests/net/socket/service/prj.conf +++ b/tests/net/socket/service/prj.conf @@ -5,7 +5,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_UDP=y CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_NET_PKT_TX_COUNT=8 CONFIG_NET_PKT_RX_COUNT=8 CONFIG_NET_MAX_CONN=5 diff --git a/tests/net/socket/socketpair/prj.conf b/tests/net/socket/socketpair/prj.conf index fd15cb5309d88ae..314e999680620d3 100644 --- a/tests/net/socket/socketpair/prj.conf +++ b/tests/net/socket/socketpair/prj.conf @@ -7,7 +7,7 @@ CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETPAIR=y CONFIG_NET_SOCKETPAIR_BUFFER_SIZE=64 -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 # Network driver config CONFIG_TEST_RANDOM_GENERATOR=y diff --git a/tests/net/socket/tcp/prj.conf b/tests/net/socket/tcp/prj.conf index ca331d3e20c8872..71fc0e7d4b22cd0 100644 --- a/tests/net/socket/tcp/prj.conf +++ b/tests/net/socket/tcp/prj.conf @@ -11,7 +11,7 @@ CONFIG_NET_IPV6=y CONFIG_NET_IPV6_ND=n CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 # Network driver config CONFIG_NET_DRIVERS=y diff --git a/tests/net/socket/tcp/src/main.c b/tests/net/socket/tcp/src/main.c index 5ac3599ca1b20ce..643e8b5de0c2728 100644 --- a/tests/net/socket/tcp/src/main.c +++ b/tests/net/socket/tcp/src/main.c @@ -2491,7 +2491,7 @@ static void after(void *arg) { ARG_UNUSED(arg); - for (int i = 0; i < CONFIG_POSIX_MAX_FDS; ++i) { + for (int i = 0; i < CONFIG_ZVFS_OPEN_MAX; ++i) { (void)zsock_close(i); } } diff --git a/tests/net/socket/tls/prj.conf b/tests/net/socket/tls/prj.conf index 94fb56a7142d424..c2fca4e13d9a7b1 100644 --- a/tests/net/socket/tls/prj.conf +++ b/tests/net/socket/tls/prj.conf @@ -19,7 +19,7 @@ CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 CONFIG_NET_CONTEXT_RCVTIMEO=y CONFIG_NET_CONTEXT_SNDTIMEO=y CONFIG_NET_CONTEXT_RCVBUF=y -CONFIG_POSIX_MAX_FDS=20 +CONFIG_ZVFS_OPEN_MAX=20 # Keep timings short for the test CONFIG_NET_TCP_TIME_WAIT_DELAY=10 diff --git a/tests/net/socket/tls_ext/prj.conf b/tests/net/socket/tls_ext/prj.conf index c8a18c17f76a1ec..02b53191a58880c 100644 --- a/tests/net/socket/tls_ext/prj.conf +++ b/tests/net/socket/tls_ext/prj.conf @@ -29,7 +29,7 @@ CONFIG_NET_BUF_TX_COUNT=64 CONFIG_NET_PKT_TX_COUNT=64 CONFIG_NET_BUF_RX_COUNT=64 CONFIG_NET_PKT_RX_COUNT=64 -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 # Stack sizes CONFIG_MAIN_STACK_SIZE=2048 diff --git a/tests/net/socket/udp/prj.conf b/tests/net/socket/udp/prj.conf index aed6c93088205c1..f90a1807c3d7062 100644 --- a/tests/net/socket/udp/prj.conf +++ b/tests/net/socket/udp/prj.conf @@ -7,7 +7,7 @@ CONFIG_NET_IPV4=y CONFIG_NET_IPV6=y CONFIG_NET_UDP=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_MAX_FDS=10 +CONFIG_ZVFS_OPEN_MAX=10 CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 CONFIG_NET_IPV6_DAD=n CONFIG_NET_IPV6_MLD=n diff --git a/tests/net/socket/udp/src/main.c b/tests/net/socket/udp/src/main.c index 3d27e4121a5d2fc..26aa8295998bfad 100644 --- a/tests/net/socket/udp/src/main.c +++ b/tests/net/socket/udp/src/main.c @@ -2532,7 +2532,7 @@ static void after(void *arg) { ARG_UNUSED(arg); - for (int i = 0; i < CONFIG_POSIX_MAX_FDS; ++i) { + for (int i = 0; i < CONFIG_ZVFS_OPEN_MAX; ++i) { (void)zsock_close(i); } } diff --git a/tests/posix/fs/src/test_fs_file.c b/tests/posix/fs/src/test_fs_file.c index cb015a41ddf75aa..9614412a07a582f 100644 --- a/tests/posix/fs/src/test_fs_file.c +++ b/tests/posix/fs/src/test_fs_file.c @@ -290,7 +290,7 @@ ZTEST(posix_fs_file_test, test_fs_unlink) ZTEST(posix_fs_file_test, test_fs_fd_leak) { const int reps = - MAX(CONFIG_POSIX_MAX_OPEN_FILES, CONFIG_POSIX_MAX_FDS) + 5; + MAX(CONFIG_POSIX_OPEN_MAX, CONFIG_ZVFS_OPEN_MAX) + 5; for (int i = 0; i < reps; i++) { if (i > 0) {