vfs: make setattr take in which attributes to change

This commit is contained in:
Matheus
2024-05-27 23:05:57 -03:00
parent 04d8431b32
commit 0030a0b21b
11 changed files with 93 additions and 56 deletions
+1 -10
View File
@@ -3,18 +3,10 @@
#include <kernel/timekeeper.h>
syscallret_t syscall_utimensat(context_t *, int fd, char *upath, timespec_t uts[2], int flags) {
// TODO
// uts -> NULL -> current time
// upath -> NULL -> dirfd points to vnode
syscallret_t ret = {
.ret = -1
};
if (flags != 0) {
ret.errno = EINVAL;
return ret;
}
timespec_t ts[2];
if (uts == NULL)
ts[0] = ts[1] = timekeeper_time();
@@ -55,7 +47,6 @@ syscallret_t syscall_utimensat(context_t *, int fd, char *upath, timespec_t uts[
goto cleanup;
}
// XXX race condition with other system calls
vattr_t attr;
ret.errno = VOP_GETATTR(node, &attr, &_cpu()->thread->proc->cred);
if (ret.errno)
@@ -64,7 +55,7 @@ syscallret_t syscall_utimensat(context_t *, int fd, char *upath, timespec_t uts[
attr.atime = ts[0];
attr.mtime = ts[1];
ret.errno = VOP_SETATTR(node, &attr, &_cpu()->thread->proc->cred);
ret.errno = VOP_SETATTR(node, &attr, V_ATTR_ATIME | V_ATTR_MTIME, &_cpu()->thread->proc->cred);
ret.ret = ret.errno ? -1 : 0;
cleanup: