mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
vmmcache: initial implementation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user