Skip to content

Commit

Permalink
vfs: Add dummy ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwinci committed Oct 22, 2023
1 parent 29fefa6 commit 722a11c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/fs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "vfs.h"
#include "sched/mutex.h"
#include "mem/allocator.h"
#include "crescent/sys.h"

Vfs* VFS_LIST = NULL;
static Vfs* VFS_LIST_END = NULL;
Expand Down Expand Up @@ -29,6 +30,32 @@ void vfs_add(Vfs* vfs) {
static VNode* VNODE_LIST = NULL;
static Mutex VNODE_LIST_MUTEX = {};

static int dummy_read_dir(VNode* self, usize* offset, DirEntry* entry) {
return ERR_OPERATION_NOT_SUPPORTED;
}
static int dummy_lookup(VNode* self, Str component, VNode** ret) {
return ERR_OPERATION_NOT_SUPPORTED;
}
static int dummy_read(VNode* self, void* data, usize off, usize size) {
return ERR_OPERATION_NOT_SUPPORTED;
}
static int dummy_stat(VNode* self, Stat* stat) {
return ERR_OPERATION_NOT_SUPPORTED;
}
static int dummy_write(VNode* self, const void* data, usize off, usize size) {
return ERR_OPERATION_NOT_SUPPORTED;
}
static void dummy_release(VNode* self) {}

static const VNodeOps DUMMY_OPS = {
.read_dir = dummy_read_dir,
.lookup = dummy_lookup,
.read = dummy_read,
.stat = dummy_stat,
.write = dummy_write,
.release = dummy_release
};

VNode* vnode_alloc() {
mutex_lock(&VNODE_LIST_MUTEX);

Expand All @@ -47,6 +74,8 @@ VNode* vnode_alloc() {
return NULL;
}
memset(node, 0, sizeof(VNode));
node->ops = DUMMY_OPS;

return node;
}

Expand Down

0 comments on commit 722a11c

Please sign in to comment.