mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +00:00
This forces anyone who wants to look into and/or manipulate an address space to lock it. And this replaces the previous, more flimsy, manual spinlock use. Note that pointers *into* the address space are not safe to use after you unlock the space. We've got many issues like this, and we'll have to track those down as wlel.
33 lines
906 B
C++
33 lines
906 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(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
|
: m_vmobject(move(vmobject))
|
|
{
|
|
}
|
|
|
|
AnonymousFile::~AnonymousFile() = default;
|
|
|
|
ErrorOr<Memory::Region*> AnonymousFile::mmap(Process&, Memory::AddressSpace& address_space, OpenFileDescription&, Memory::VirtualRange const& range, u64 offset, int prot, bool shared)
|
|
{
|
|
if (offset != 0)
|
|
return EINVAL;
|
|
|
|
return address_space.allocate_region_with_vmobject(range, m_vmobject, offset, {}, prot, shared);
|
|
}
|
|
|
|
ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(OpenFileDescription const&) const
|
|
{
|
|
return KString::try_create(":anonymous-file:"sv);
|
|
}
|
|
|
|
}
|