mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
3692af528e
There's no point in constructing an object just for the sake of keeping a state that can be touched by anything in the kernel code. Let's reduce everything to be in a C++ namespace called with the previous name "VirtualFileSystem" and keep a smaller textual-footprint struct called "VirtualFileSystemDetails". This change also cleans up old "friend class" statements that were no longer needed, and move methods from the VirtualFileSystem code to more appropriate places as well. Please note that the method of locking all filesystems during shutdown is removed, as in that place there's no meaning to actually locking all filesystems because of running in kernel mode entirely.
30 lines
902 B
C++
30 lines
902 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringView.h>
|
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
|
#include <Kernel/Tasks/Process.h>
|
|
|
|
namespace Kernel {
|
|
|
|
ErrorOr<FlatPtr> Process::sys$utime(Userspace<char const*> user_path, size_t path_length, Userspace<const struct utimbuf*> user_buf)
|
|
{
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
|
TRY(require_promise(Pledge::fattr));
|
|
auto path = TRY(get_syscall_path_argument(user_path, path_length));
|
|
utimbuf buf;
|
|
if (user_buf) {
|
|
TRY(copy_from_user(&buf, user_buf));
|
|
} else {
|
|
auto now = kgettimeofday().truncated_seconds_since_epoch();
|
|
// Not a bug!
|
|
buf = { now, now };
|
|
}
|
|
TRY(VirtualFileSystem::utime(vfs_root_context(), credentials(), path->view(), current_directory(), buf.actime, buf.modtime));
|
|
return 0;
|
|
}
|
|
|
|
}
|