ladybird/Kernel/FileSystem/AnonymousFile.cpp
Andreas Kling 4a9c18afb9 Kernel: Rename FileDescription => OpenFileDescription
Dr. POSIX really calls these "open file description", not just
"file description", so let's call them exactly that. :^)
2021-09-07 13:53:14 +02:00

33 lines
794 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/FileSystem/AnonymousFile.h>
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Process.h>
namespace Kernel {
AnonymousFile::AnonymousFile(NonnullRefPtr<Memory::AnonymousVMObject> vmobject)
: m_vmobject(move(vmobject))
{
}
AnonymousFile::~AnonymousFile()
{
}
KResultOr<Memory::Region*> AnonymousFile::mmap(Process& process, OpenFileDescription&, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
{
if (offset != 0)
return EINVAL;
if (range.size() != m_vmobject->size())
return EINVAL;
return process.address_space().allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared);
}
}