open: make file truncation require FILE_WRITE

This commit is contained in:
Matheus
2024-08-24 23:16:30 -03:00
parent 193f5b49b9
commit 0e0471f8ee
+1 -1
View File
@@ -77,7 +77,7 @@ syscallret_t syscall_openat(context_t *context, int dirfd, char *path, int flags
if (ret.errno)
goto cleanup;
if (vnode->type == V_TYPE_REGULAR && (flags & O_TRUNC)) {
if (vnode->type == V_TYPE_REGULAR && (flags & O_TRUNC) && (flags & FILE_WRITE)) {
MUTEX_ACQUIRE(&vnode->sizelock, false);
ret.errno = VOP_RESIZE(vnode, 0, &_cpu()->thread->proc->cred);
MUTEX_RELEASE(&vnode->sizelock);