The memfs library contains an implementation of a trivial memory-based filesystem. It exports the standard OSKit filesystem interface, and depends on the underlying osenv interfaces. (See Chapter 9).
The header file <oskit/fs/memfs.h> must be included to use the memfs, and its derivative cousin, the bmodfs. When first instantiated, a memfs filesystem is empty, and may be populated using the standard file access mechanisms. A special function, oskit_memfs_file_set_contents is provided for convenience to replace the contents of a MEMFS filesystem. Clients who wish to strictly use the OSKit filesystem interface to guarantee portability to other filesystems should not use this function.
Initialize the MEMFS filesystem.
Returns handle to an empty MEMFS filesystem.
This function changes the indicated MEMFS file to use the memory from [data - data+size-1] as its contents. File must be a regular MEMFS file and not a directory.
Allocsize indicates the total amount of memory available for the file to use when growing and must be greater than or equal to size. If an attempt is made to grow the file to a size greater than allocsize, new memory will be allocated with smemalign and the file contents copied to the new memory.
If inhibit_resize is true, attempts to change the size of the file hereafter will fail with OSKIT_EPERM.
If can_sfree is true, sfree is called on the data buffer if the file grows beyond allocsize, is truncated to zero-length or is removed.
Returns zero on success, an error code otherwise.