Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
filesystem.c
Go to the documentation of this file.
1#include "vfs/enum.h"
2#include <str.h>
3#include <vfs/filesystem.h>
4
6
7int create_filesystem(char name[16], struct fs_data* fs_data) {
8 if (!fs_data->ops) {
9 return VFS_ERR;
10 }
11 auto fs = (struct filesystem*)kalloc(sizeof(struct filesystem));
12 memset(fs, 0, sizeof(struct filesystem));
13 strncpy(fs->name, name, 16);
14
15 memcopy(&fs->data, fs_data, sizeof(struct fs_data));
16
17
18 auto curr = &registered_filesystems;
19 while (*curr)
20 curr = &(*curr)->next;
21 *curr = fs;
22
23 return VFS_OK;
24}
25
28 while (curr != 0) {
29 if (strncmp(curr->name, name, strlen(name)) == 0)
30 return curr;
31 curr = curr->next;
32 }
33 return 0;
34}
kstring name
Definition dentry.h:5
@ VFS_ERR
Definition enum.h:8
@ VFS_OK
Definition enum.h:5
int create_filesystem(char name[16], struct fs_data *fs_data)
Definition filesystem.c:7
static filesystem_t * registered_filesystems
Definition filesystem.c:5
filesystem_ptr_t retrieve_filesystem(const char name[16])
struct filesystem filesystem_t
Definition filesystem.h:14
void * kalloc(size_t size)
int strncmp(const char *s1, const char *s2, size_t n)
char * strncpy(char *dest, const char *src, size_t n)
size_t strlen(const char *s)
Definition str.c:105
void memset(void *ptr, int value, size_t num)
void memcopy(void *dest, void *src, size_t size)
char name[16]
Definition filesystem.h:32
struct filesystem * next
Definition filesystem.h:34
fs_operations_t * ops
Definition filesystem.h:28
#define KERNEL_API
Definition type.h:93