mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 13:48:21 +00:00
vfs: make setattr take in which attributes to change
This commit is contained in:
@@ -13,7 +13,7 @@ static int dochmod(vnode_t *node, mode_t mode) {
|
||||
|
||||
attr.mode = UMASK(mode);
|
||||
|
||||
return VOP_SETATTR(node, &attr, cred);
|
||||
return VOP_SETATTR(node, &attr, V_ATTR_MODE, cred);
|
||||
}
|
||||
|
||||
syscallret_t syscall_fchmodat(context_t *, int dirfd, const char *upath, mode_t mode, int flags) {
|
||||
|
||||
@@ -42,7 +42,6 @@ syscallret_t syscall_fchownat(context_t *, int fd, const char *upath, uid_t owne
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// XXX race condition with chmod
|
||||
vattr_t attr;
|
||||
ret.errno = VOP_GETATTR(node, &attr, &_cpu()->thread->proc->cred);
|
||||
if (ret.errno)
|
||||
@@ -51,7 +50,7 @@ syscallret_t syscall_fchownat(context_t *, int fd, const char *upath, uid_t owne
|
||||
attr.uid = owner;
|
||||
attr.gid = group;
|
||||
|
||||
ret.errno = VOP_SETATTR(node, &attr, &_cpu()->thread->proc->cred);
|
||||
ret.errno = VOP_SETATTR(node, &attr, V_ATTR_UID | V_ATTR_GID, &_cpu()->thread->proc->cred);
|
||||
ret.ret = ret.errno ? -1 : 0;
|
||||
|
||||
cleanup:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user