# Copyright (c) 2016 Intel Corporation
# Copyright (c) 2020 Nordic Semiconductor (ASA)
# SPDX-License-Identifier: Apache-2.0

menu "File Systems"

config FILE_SYSTEM_LIB_LINK
	bool "Link file system libraries into build"
	help
	  Link in the underlying file system libraries. This can be
	  enabled without CONFIG_FILE_SYSTEM to enable applications
	  to work directly with the underlying file system libraries.
	  This can be useful to avoid linking in the entire filesystem
	  implementation via `struct fs_file_system_t` if only a subset
	  is used.

config FILE_SYSTEM
	bool "File system support"
	select FILE_SYSTEM_LIB_LINK
	help
	  Enables support for file system.

if FILE_SYSTEM

config FILE_SYSTEM_MAX_TYPES
	int "Maximum number of distinct file system types allowed"
	default 2
	help
	  Zephyr provides several file system types including FatFS and
	  LittleFS, but it is possible to define additional ones and
	  register them.  A slot is required for each type.

config FILE_SYSTEM_MAX_FILE_NAME
	int "Optional override for maximum file name length"
	default -1
	help
	  Specify the maximum file name allowed across all enabled file
	  system types.  Zero or a negative value selects the maximum
	  file name length for enabled in-tree file systems.  This
	  default may be inappropriate when registering an out-of-tree
	  file system.  Selecting a value less than the actual length
	  supported by a file system may result in memory access
	  violations.

config FILE_SYSTEM_INIT_PRIORITY
	int "File system initialization priority"
	default 99
	help
	  Specify the initialization priority for file systems. In case
	  automount is enabled, the initialization should be done after
	  the underlying storage device is initialized.

config FILE_SYSTEM_SHELL
	bool "File system shell"
	depends on SHELL
	help
	  This shell provides basic browsing of the contents of the
	  file system.

if FILE_SYSTEM_SHELL

config FILE_SYSTEM_SHELL_MOUNT_COMMAND
	bool "File system shell mount command"
	depends on FAT_FILESYSTEM_ELM || FILE_SYSTEM_LITTLEFS
	depends on HEAP_MEM_POOL_SIZE > 0
	default y
	help
	  Enable file system shell command for mounting file systems. This
	  requires the heap to be present.

config FILE_SYSTEM_SHELL_TEST_COMMANDS
	bool "File system shell read/write/erase test commands"
	select CBPRINTF_FP_SUPPORT
	help
	  Enable additional file system shell commands for performing
	  read/write/erase tests with speed output.

config FILE_SYSTEM_SHELL_BUFFER_SIZE
	hex "File system shell buffer size"
	depends on FILE_SYSTEM_SHELL_TEST_COMMANDS
	default 0x100
	range 0x20 0x1000000
	help
	  Size of the buffer used for file system commands, will determine the
	  maximum size that can be used with a read/write test. Note that this
	  is used on the stack.

config FILE_SYSTEM_SHELL_LS_SIZE
	bool "File system shell ls command to also list size"
	default y
	help
	  While listing files in the file system shell, also list the size of
	  each file.

endif # FILE_SYSTEM_SHELL

config FILE_SYSTEM_MKFS
	bool "Allow to format file system"
	help
	  Enables function fs_mkfs that can be used to format a storage device.

config FILE_SYSTEM_GC
	bool "Allow explicit garbage collector call"
	help
	  Enables function fs_gc that can be used to proactively run garbage collector.

config FUSE_FS_ACCESS
	bool "FUSE based access to file system partitions"
	depends on ARCH_POSIX
	select NATIVE_USE_NSI_ERRNO
	help
	  Expose file system partitions to the host system through FUSE.

choice FUSE_LIBRARY_VERSION
	prompt "Host FUSE library version"
	depends on FUSE_FS_ACCESS
	default FUSE_LIBRARY_V2

config FUSE_LIBRARY_V2
	bool "Use libfuse(2)"
	help
	  Use v2 of the host FUSE library.

config FUSE_LIBRARY_V3
	bool "Use libfuse3"
	help
	  Use the host fuse3 library. This may not be available in older distributions.

endchoice

endif # FILE_SYSTEM

if FILE_SYSTEM_LIB_LINK

config APP_LINK_WITH_FS
	bool "Link 'app' with FS"
	default y
	help
	  Add FS header files to the 'app' include path. It may be
	  disabled if the include paths for FS are causing aliasing
	  issues for 'app'.

# Logging defined here as modules/fs/littlefs/lfs.c expects CONFIG_FS_LOG_LEVEL
module = FS
module-str = fs
source "subsys/logging/Kconfig.template.log_config"

rsource "Kconfig.fatfs"
rsource "Kconfig.littlefs"
rsource "ext2/Kconfig"
rsource "fuse_client/Kconfig"
rsource "virtiofs/Kconfig"

endif # FILE_SYSTEM_LIB_LINK

rsource "fcb/Kconfig"
rsource "nvs/Kconfig"
rsource "zms/Kconfig"

endmenu
