|
PatchworkOS
19e446b
A non-POSIX operating system.
|
Filesystem interface. More...
Filesystem interface.
The filesystem interface represents a filesystem type, e.g. fat32, tmpfs, devfs, etc. Each filesystem is exposed in a directory within the fs sysfs directory named after the filesystem.
The directory itself can be used to mount instances of that filesystem type.
Within each filesystem directory are readable files representing each mounted instance of that filesystem type, named after the superblock ID, containing the following information:
Where the id is the superblock ID, block_size is the block size of the superblock, and max_file_size is the maximum size of a file on this superblock.
Data Structures | |
| struct | filesystem_t |
| Filesystem structure, represents a filesystem type, e.g. fat32, tmpfs, devfs, etc. More... | |
Macros | |
| #define | OPTIONS_FOR_EACH(options, key, value) |
| Helper macro for iterating over options passed to a filesystem mount operation. | |
Functions | |
| void | filesystem_expose (void) |
Exposes the sysfs fs directory. | |
| uint64_t | filesystem_register (filesystem_t *fs) |
| Registers a filesystem. | |
| void | filesystem_unregister (filesystem_t *fs) |
| Unregisters a filesystem. | |
| filesystem_t * | filesystem_get_by_name (const char *name) |
| Gets a filesystem by name. | |
| filesystem_t * | filesystem_get_by_path (const char *path, process_t *process) |
| Gets a filesystem by path. | |
| bool | options_next (const char **iter, char *buffer, size_t size, char **key, char **value) |
| Helper function for iterating over options passed to a filesystem mount operation. | |
| #define OPTIONS_FOR_EACH | ( | options, | |
| key, | |||
| value | |||
| ) |
Helper macro for iterating over options passed to a filesystem mount operation.
Each helper option is specified as key=value pairs, with multiple options separated by commas.
| options | The options string. |
| key | The key variable. |
| value | The value variable. |
Definition at line 140 of file filesystem.h.
| void filesystem_expose | ( | void | ) |
Exposes the sysfs fs directory.
s
Must be called before filesystem_get_by_path() can be used.
Definition at line 215 of file filesystem.c.
| uint64_t filesystem_register | ( | filesystem_t * | fs | ) |
Registers a filesystem.
| fs | The filesystem to register. |
0. On failure, ERR and errno is set to:EINVAL: Invalid parameters.map_insert(). Definition at line 233 of file filesystem.c.
| void filesystem_unregister | ( | filesystem_t * | fs | ) |
Unregisters a filesystem.
| fs | The filesystem to unregister, or NULL for no-op. |
Definition at line 259 of file filesystem.c.
| filesystem_t * filesystem_get_by_name | ( | const char * | name | ) |
Gets a filesystem by name.
| name | The name of the filesystem. |
NULL. Definition at line 276 of file filesystem.c.
| filesystem_t * filesystem_get_by_path | ( | const char * | path, |
| process_t * | process | ||
| ) |
Gets a filesystem by path.
The path should point to a directory in the fs sysfs directory.
| path | The path to check. |
| process | The process whose namespace to use. |
NULL and errno is set to:ENOENT: The path does not exist.ENOMEM: Out of memory.EINVAL: The path is not a directory in the fs sysfs directory. Definition at line 284 of file filesystem.c.
Helper function for iterating over options passed to a filesystem mount operation.
Each helper option is specified as key=value pairs, with multiple options separated by commas.
| iter | Pointer to the current iterator position. Updated on each call. |
| buffer | Buffer to store the current option. |
| size | Size of the buffer. |
| key | Pointer to store the key of the current option. |
| value | Pointer to store the value of the current option. |
1 if an option was found, 0 if no more options are available. Definition at line 327 of file filesystem.c.