Skip to content

Commit e5631e9

Browse files
jmichalski-antfkokosinski
authored andcommitted
fs: add virtiofs operations
This commit adds virtiofs functions implementing fuse operations required to enable zephyr filesystem support Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
1 parent 3dcdc41 commit e5631e9

File tree

6 files changed

+889
-0
lines changed

6 files changed

+889
-0
lines changed

subsys/fs/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ if(CONFIG_FILE_SYSTEM_LIB_LINK)
1818

1919
add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_EXT2 ext2)
2020
add_subdirectory_ifdef(CONFIG_FUSE fuse)
21+
add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_VIRTIOFS virtiofs)
2122

2223
zephyr_library_link_libraries(FS)
2324

2425
target_link_libraries_ifdef(CONFIG_FAT_FILESYSTEM_ELM FS INTERFACE ELMFAT)
2526
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS FS INTERFACE LITTLEFS)
2627
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_EXT2 FS INTERFACE EXT2)
2728
target_link_libraries_ifdef(CONFIG_FUSE FS INTERFACE FUSE)
29+
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_VIRTIOFS FS INTERFACE VIRTIOFS)
2830
endif()
2931

3032
add_subdirectory_ifdef(CONFIG_FCB ./fcb)

subsys/fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ rsource "Kconfig.fatfs"
120120
rsource "Kconfig.littlefs"
121121
rsource "ext2/Kconfig"
122122
rsource "fuse/Kconfig"
123+
rsource "virtiofs/Kconfig"
123124

124125
endif # FILE_SYSTEM_LIB_LINK
125126

subsys/fs/virtiofs/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
add_library(VIRTIOFS INTERFACE)
5+
target_include_directories(VIRTIOFS INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
6+
7+
zephyr_library()
8+
zephyr_library_sources(
9+
virtiofs.c
10+
virtiofs_zfs.c
11+
)
12+
13+
zephyr_library_link_libraries(VIRTIOFS)

subsys/fs/virtiofs/Kconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) 2025 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config FILE_SYSTEM_VIRTIOFS
5+
bool "Virtiofs file system support"
6+
depends on FILE_SYSTEM
7+
select FUSE
8+
help
9+
Enable virtiofs file system support.
10+
11+
config VIRTIOFS_DEBUG
12+
bool "Print virtiofs verbose debug information"
13+
help
14+
Enables printing of virtiofs verbose debug information
15+
16+
config VIRTIOFS_MAX_FILES
17+
int "Virtiofs max open files"
18+
default 1024
19+
help
20+
Virtiofs max simultaneously open files
21+
22+
config VIRTIOFS_MAX_VQUEUE_SIZE
23+
int "Virtiofs max virtqueue size"
24+
default 1024
25+
help
26+
Maximum size of virtqueue
27+
28+
config VIRTIOFS_NO_NOTIFICATION_QUEUE_SLOT
29+
bool "Omit notification queue (idx 1) and assume that idx 1 is the first request queue"
30+
default y
31+
help
32+
According to virtio specification v1.3 section 5.11.2 queue at idx 1 is notification queue and
33+
request queues start at idx 2, however on qemu+virtiofsd thats not true and idx 1 is
34+
the first request queue
35+
36+
config VIRTIOFS_VIRTIOFSD_UNLINK_QUIRK
37+
bool "Fix unlink() with some virtiofsd versions"
38+
default y
39+
help
40+
Some virtiofsd versions (at least Debian 1:7.2+dfsg-7+deb12u7)
41+
will fail with EIO on unlink if the file wasn't looked up before
42+
43+
config VIRTIOFS_CREATE_MODE_VALUE
44+
int "Virtiofs mode value used during file/directory creation"
45+
default 438 #0666
46+
help
47+
During creation of file or directory we have to set mode, this config allows
48+
configuring that value. This determines access permissions for created files and directories.
49+
50+
module = VIRTIOFS
51+
module-str = virtiofs
52+
source "subsys/logging/Kconfig.template.log_config"

0 commit comments

Comments
 (0)