# Copyright (c) 2020 Tobias Svehagen
# Copyright (c) 2023 Meta
#
# SPDX-License-Identifier: Apache-2.0

menuconfig ZVFS
	bool "Zephyr virtual filesystem (ZVFS) support [EXPERIMENTAL]"
	select EXPERIMENTAL
	help
	  ZVFS is a central, Zephyr-native library that provides a common interoperable API for all
	  types of file descriptors such as those from the non-virtual FS, sockets, eventfds, FILE *'s
	  and more. It is designed to be used by all Zephyr subsystems that need to work with files.

if ZVFS

config ZVFS_FDTABLE
	bool "ZVFS file descriptor table"
	default y
	help
	  This file provides generic file descriptor table implementation, suitable
	  for any I/O object implementing POSIX I/O semantics (i.e. read/write +
	  aux operations).

if ZVFS_FDTABLE

config ZVFS_DEFAULT_FILE_VMETHODS
	bool "ZVFS default virtual methods for files"
	help
	  Provide typical file operations, which can be referenced in a struct fd_op_vtable
	  and subsequently called by ZVFS functions.

endif

config ZVFS_EVENTFD
	bool "ZVFS event file descriptor support"
	imply ZVFS_POLL
	select ZVFS_FDTABLE
	help
	  Enable support for ZVFS event file descriptors. An eventfd can
	  be used as an event wait/notify mechanism together with POSIX calls
	  like read, write and poll.

if ZVFS_EVENTFD

config ZVFS_EVENTFD_MAX
	int "Maximum number of ZVFS eventfd's"
	default 1
	range 1 4096
	help
	  Maximum number of supported event file descriptors. If subsystems
	  specify ZVFS_EVENTFD_ADD_SIZE_* options, these will be added together
	  and the sum will be compared to the ZVFS_EVENTFD_MAX value.
	  If the sum is greater than the ZVFS_EVENTFD_MAX option, then the actual
	  eventfd count will be rounded up to the sum of the individual
	  requirements (unless the ZVFS_EVENTFD_IGNORE_MIN option is enabled).

config ZVFS_EVENTFD_IGNORE_MIN
	bool "Ignore the minimum eventfd count requirement"
	help
	  This option can be set to force setting a smaller eventfd count than
	  what's specified by enabled subsystems via ZVFS_EVENTFD_ADD_SIZE_*
	  options. This can be useful when optimizing memory usage and a more
	  precise minimum eventfd count is known for a given application. When
	  enabled, the ZVFS_EVENTFD_MAX value is used as-is.

endif # ZVFS_EVENTFD

config ZVFS_POLL
	bool "ZVFS poll"
	select POLL
	select ZVFS_FDTABLE
	help
	  Enable support for zvfs_poll().

if ZVFS_POLL

config ZVFS_POLL_MAX
	int "Max number of supported zvfs_poll() entries"
	default 8 if NRF70_ENABLE_DUAL_VIF
	default 6 if WIFI_NM_WPA_SUPPLICANT
	default 4 if SHELL_BACKEND_TELNET
	default 3
	help
	  Maximum number of entries supported for poll() call.

config ZVFS_SELECT
	bool "ZVFS select"
	help
	  Enable support for zvfs_select().

endif # ZVFS_POLL

endif # ZVFS
