2021-01-15 11:28:07 +01:00
|
|
|
/*
|
2022-08-23 18:51:18 +02:00
|
|
|
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
2021-01-15 11:28:07 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-15 11:28:07 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/FileSystem/AnonymousFile.h>
|
2021-08-06 10:45:34 +02:00
|
|
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
2021-01-15 11:28:07 +01:00
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2022-08-19 20:53:40 +02:00
|
|
|
AnonymousFile::AnonymousFile(NonnullLockRefPtr<Memory::AnonymousVMObject> vmobject)
|
2021-01-15 11:28:07 +01:00
|
|
|
: m_vmobject(move(vmobject))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-16 13:15:15 -06:00
|
|
|
AnonymousFile::~AnonymousFile() = default;
|
2021-01-15 11:28:07 +01:00
|
|
|
|
2022-08-23 18:51:18 +02:00
|
|
|
ErrorOr<NonnullLockRefPtr<Memory::VMObject>> AnonymousFile::vmobject_for_mmap(Process&, Memory::VirtualRange const&, u64& offset, bool)
|
2021-01-15 11:28:07 +01:00
|
|
|
{
|
|
|
|
if (offset != 0)
|
2021-01-20 23:11:17 +01:00
|
|
|
return EINVAL;
|
2021-01-15 11:28:07 +01:00
|
|
|
|
2022-08-23 18:51:18 +02:00
|
|
|
return m_vmobject;
|
2021-01-15 11:28:07 +01:00
|
|
|
}
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
ErrorOr<NonnullOwnPtr<KString>> AnonymousFile::pseudo_path(OpenFileDescription const&) const
|
2021-10-30 00:45:23 +02:00
|
|
|
{
|
|
|
|
return KString::try_create(":anonymous-file:"sv);
|
|
|
|
}
|
|
|
|
|
2021-01-15 11:28:07 +01:00
|
|
|
}
|