mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
4a9c18afb9
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
33 lines
794 B
C++
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);
|
|
}
|
|
|
|
}
|