mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 22:08:59 +00:00
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
33 lines
790 B
C++
33 lines
790 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, FileDescription&, 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);
|
|
}
|
|
|
|
}
|