mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
open: make file truncation require FILE_WRITE
This commit is contained in:
@@ -77,7 +77,7 @@ syscallret_t syscall_openat(context_t *context, int dirfd, char *path, int flags
|
|||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto cleanup;
|
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);
|
MUTEX_ACQUIRE(&vnode->sizelock, false);
|
||||||
ret.errno = VOP_RESIZE(vnode, 0, &_cpu()->thread->proc->cred);
|
ret.errno = VOP_RESIZE(vnode, 0, &_cpu()->thread->proc->cred);
|
||||||
MUTEX_RELEASE(&vnode->sizelock);
|
MUTEX_RELEASE(&vnode->sizelock);
|
||||||
|
|||||||
Reference in New Issue
Block a user