Files
Sönke Holz 38c162aeea Kernel: Pass OpenFileDescription to vmobject_and_memory_type_for_mmap
This is more useful than passing a reference to the Process, which
can be easily obtained with Process::current(). Only KCOVDevice
previously used this argument.
We will need this new argument in the next commit.
2026-09-18 17:25:42 +02:00

37 lines
913 B
C++

/*
* Copyright (c) 2021-2022, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/FileSystem/AnonymousFile.h>
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Tasks/Process.h>
namespace Kernel {
AnonymousFile::AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
: m_vmobject(move(vmobject))
{
}
AnonymousFile::~AnonymousFile() = default;
ErrorOr<File::VMObjectAndMemoryType> AnonymousFile::vmobject_and_memory_type_for_mmap(OpenFileDescription&, Memory::VirtualRange const&, u64& offset, bool)
{
if (offset != 0)
return EINVAL;
return VMObjectAndMemoryType {
.vmobject = m_vmobject,
.memory_type = Memory::MemoryType::Normal,
};
}
ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(OpenFileDescription const&) const
{
return KString::try_create(":anonymous-file:"sv);
}
}