Kernel: Make utimensat ignore the dirfd when given an absolute path

This commit is contained in:
implicitfield 2024-05-11 08:57:42 +04:00 committed by Tim Schumacher
commit 05cf1327ed
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00

View file

@ -69,8 +69,15 @@ ErrorOr<FlatPtr> Process::sys$utimensat(Userspace<Syscall::SC_utimensat_params c
times[1] = now;
}
auto resolve_base = [&](StringView path) -> ErrorOr<NonnullRefPtr<Custody>> {
if (!path.is_empty() && path[0] == '/')
return VirtualFileSystem::the().root_custody();
else
return custody_for_dirfd(params.dirfd);
};
auto path = TRY(get_syscall_path_argument(params.path));
auto base = TRY(custody_for_dirfd(params.dirfd));
auto base = TRY(resolve_base(path->view()));
auto& atime = times[0];
auto& mtime = times[1];
TRY(VirtualFileSystem::the().utimensat(credentials(), path->view(), *base, atime, mtime, follow_symlink));