PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
filesystem.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/dentry.h>
4#include <kernel/fs/file.h>
5#include <kernel/fs/inode.h>
6#include <kernel/fs/mount.h>
7#include <kernel/fs/path.h>
9#include <kernel/fs/sysfs.h>
10#include <kernel/proc/process.h>
11#include <kernel/sync/rwlock.h>
12#include <kernel/utils/map.h>
13
14#include <sys/io.h>
15#include <sys/list.h>
16#include <sys/math.h>
17#include <sys/proc.h>
18
19/**
20 * @brief Filesystem interface.
21 * @defgroup kernel_fs_filesystem Filesystem
22 * @ingroup kernel_fs
23 *
24 * @{
25 */
26
27/**
28 * @brief Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
29 */
30typedef struct filesystem
31{
32 map_entry_t mapEntry; ///< Used internally.
33 list_t superblocks; ///< Used internally.
34 rwlock_t lock; ///< Used internally.
35 const char* name;
36 dentry_t* (*mount)(filesystem_t* fs, const char* devName, void* private);
38
39/**
40 * @brief Registers a filesystem.
41 *
42 * @param fs The filesystem to register.
43 * @return On success, `0`. On failure, `ERR` and `errno` is set to:
44 * - `EINVAL`: Invalid parameters.
45 * - Other values from `map_insert()`.
46 */
48
49/**
50 * @brief Unregisters a filesystem.
51 *
52 * @param fs The filesystem to unregister, or `NULL` for no-op.
53 */
55
56/**
57 * @brief Gets a filesystem by name.
58 *
59 * @param name The name of the filesystem.
60 * @return On success, the filesystem. On failure, returns `NULL`.
61 */
62filesystem_t* filesystem_get(const char* name);
63
64/** @} */
filesystem_t * filesystem_get(const char *name)
Gets a filesystem by name.
Definition filesystem.c:80
uint64_t filesystem_register(filesystem_t *fs)
Registers a filesystem.
Definition filesystem.c:40
void filesystem_unregister(filesystem_t *fs)
Unregisters a filesystem.
Definition filesystem.c:64
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Directory entry structure.
Definition dentry.h:84
Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
Definition filesystem.h:31
const char * name
Definition filesystem.h:35
map_entry_t mapEntry
Used internally.
Definition filesystem.h:32
rwlock_t lock
Used internally.
Definition filesystem.h:34
list_t superblocks
Used internally.
Definition filesystem.h:33
A doubly linked list.
Definition list.h:49
Map entry structure.
Definition map.h:68
Read-Write Ticket Lock structure.
Definition rwlock.h:61