Skip to content

Commit 8c7bba2

Browse files
jmichalski-antfkokosinski
authored andcommitted
fs: add virtiofs operations
This commit adds virtiofs functions and required fuse structures Signed-off-by: Jakub Michalski <jmichalski@antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
1 parent c5b6e6a commit 8c7bba2

File tree

8 files changed

+1728
-0
lines changed

8 files changed

+1728
-0
lines changed

subsys/fs/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ if(CONFIG_FILE_SYSTEM_LIB_LINK)
1717
endif()
1818

1919
add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_EXT2 ext2)
20+
add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_VIRTIOFS virtiofs)
2021

2122
zephyr_library_link_libraries(FS)
2223

2324
target_link_libraries_ifdef(CONFIG_FAT_FILESYSTEM_ELM FS INTERFACE ELMFAT)
2425
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS FS INTERFACE LITTLEFS)
2526
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_EXT2 FS INTERFACE EXT2)
27+
target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_VIRTIOFS FS INTERFACE VIRTIOFS)
2628
endif()
2729

2830
add_subdirectory_ifdef(CONFIG_FCB ./fcb)

subsys/fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ config FUSE_FS_ACCESS
105105
rsource "Kconfig.fatfs"
106106
rsource "Kconfig.littlefs"
107107
rsource "ext2/Kconfig"
108+
rsource "virtiofs/Kconfig"
108109

109110
endif # FILE_SYSTEM
110111

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+
fuse.c
11+
)
12+
13+
zephyr_library_link_libraries(VIRTIOFS)

subsys/fs/virtiofs/Kconfig

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
help
8+
Enable virtiofs file system support.
9+
10+
config VIRTIOFS_DEBUG
11+
bool "Print virtiofs verbose debug information"
12+
help
13+
Enables printing of virtiofs verbose debug information
14+
15+
config VIRTIOFS_MAX_FILES
16+
int "Virtiofs max open files"
17+
default 1024
18+
help
19+
Virtiofs max simultaneously open files
20+
21+
config VIRTIOFS_MAX_VQUEUE_SIZE
22+
int "Virtiofs max virtqueue size"
23+
default 1024
24+
help
25+
Maximum size of virtqueue
26+
27+
config VIRTIOFS_NO_NOTIFICATION_QUEUE_SLOT
28+
bool "Omit notification queue (idx 1) and assume that idx 1 is the first request queue"
29+
default y
30+
help
31+
According to virtio specification v1.3 section 5.11.2 queue at idx 1 is notification queue and
32+
request queues start at idx 2, however on qemu+virtiofsd thats not true and idx 1 is
33+
the first request queue
34+
35+
config VIRTIOFS_VIRTIOFSD_UNLINK_QUIRK
36+
bool "Fix unlink() with some virtiofsd versions"
37+
default y
38+
help
39+
Some virtiofsd versions (at least Debian 1:7.2+dfsg-7+deb12u7)
40+
will fail with EIO on unlink if the file wasn't looked up before
41+
42+
config VIRTIOFS_UID_VALUE
43+
int "Virtiofs user ID"
44+
default 0
45+
help
46+
Each virtiofs request contains user ID, this config allows setting
47+
that value. The result is as if user with given UID accessed the file/resource.
48+
49+
config VIRTIOFS_GID_VALUE
50+
int "Virtiofs group ID"
51+
default 0
52+
help
53+
Each virtiofs request contains group ID, this config allows setting
54+
that value. The result is as if user with given GID accessed the file/resource.
55+
56+
config VIRTIOFS_PID_VALUE
57+
int "Virtiofs process ID"
58+
default 0
59+
help
60+
Each virtiofs request contains process ID, this config allows setting
61+
that value. The result is as if process with given PID accessed the file/resource.
62+
63+
config VIRTIOFS_CREATE_MODE_VALUE
64+
int "Virtiofs mode value used during file/directory creation"
65+
default 438 #0666
66+
help
67+
During creation of file or directory we have to set mode, this config allows
68+
configuring that value. This determines access permissions for created files and directories.
69+
70+
module = VIRTIOFS
71+
module-str = virtiofs
72+
source "subsys/logging/Kconfig.template.log_config"

0 commit comments

Comments
 (0)