vmmcache: initial implementation

This commit is contained in:
Matheus
2024-05-24 18:03:24 -03:00
parent 7673a365e8
commit 48b7fb4324
21 changed files with 772 additions and 134 deletions
+7
View File
@@ -57,11 +57,18 @@ syscallret_t syscall_mmap(context_t *context, void *hint, size_t len, int prot,
vmmfiledesc_t vfd;
file_t *file = NULL;
if (isfile) {
// make sure offset is page aligned
if (offset % PAGE_SIZE) {
ret.errno = EINVAL;
return ret;
}
file = fd_get(fd);
if (file == NULL) {
ret.errno = EBADF;
return ret;
}
vfd.node = file->vnode;
vfd.offset = offset;
}
+2
View File
@@ -61,7 +61,9 @@ syscallret_t syscall_openat(context_t *context, int dirfd, const char *path, int
goto cleanup;
if (vnode->type == V_TYPE_REGULAR && (flags & O_TRUNC)) {
MUTEX_ACQUIRE(&vnode->sizelock, false);
ret.errno = VOP_RESIZE(vnode, 0, &_cpu()->thread->proc->cred);
MUTEX_RELEASE(&vnode->sizelock);
if (ret.errno)
goto cleanup;
}
+3
View File
@@ -1,4 +1,5 @@
#include <kernel/syscalls.h>
#include <mutex.h>
syscallret_t syscall_ftruncate(int fd, size_t size) {
syscallret_t ret = {
@@ -16,7 +17,9 @@ syscallret_t syscall_ftruncate(int fd, size_t size) {
goto cleanup;
}
MUTEX_ACQUIRE(&file->vnode->sizelock, false);
ret.errno = VOP_RESIZE(file->vnode, size, &_cpu()->thread->proc->cred);
MUTEX_RELEASE(&file->vnode->sizelock);
ret.ret = ret.errno ? -1 : 0;
cleanup: