3.2 Virtual File System
[Libraries module]

The Virtual File System module is described through the following subsections:

Virtual File System design [link] 

Virtual File System (VFS) abstract low-level file system in an uniform manner. It also caches open files and directories for faster access.

VFS represents any file or directory as a node. This is the struct vfs_node_s type.

All nodes are reference-counted. All functions returning a node give a reference to caller. No function except vfs_node_refdrop steals a reference. This is caller's responsibility to vfs_node_refdrop nodes when not needed any more.

VFS is made of two separate layers. One is operating on a path-string level, closer to the user's habits (@vfs/helpers.h); the other is operating on a node level, closer to the VFS internal structure (@vfs/ops.h). The former is using null-terminated strings, the latter is using explicit-length strings. This avoids most of the copies of user-passed read-only string.

VFS also implement root directory and current-working-directory through vfs_get_cwd and vfs_get_root (@vfs/globals.h). Configuration can make them system-wise or thread-local (#CONFIG_VFS_GLOBAL_CWD and #CONFIG_VFS_GLOBAL_ROOT).

File handles are also reference-counted. On most filesystems, nodes may be opened more than once at the same time, each instance of an open file is a struct vfs_file_s.

Valid XHTML 1.0 StrictGenerated by diaxen on Thu Aug 4 15:44:05 2022 using MkDoc