2020-02-28 20:20:35 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-28 20:20:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/FileSystem/Inode.h>
|
2021-08-06 10:45:34 +02:00
|
|
|
#include <Kernel/Memory/PrivateInodeVMObject.h>
|
2020-02-28 20:20:35 +01:00
|
|
|
|
2021-08-06 13:49:36 +02:00
|
|
|
namespace Kernel::Memory {
|
2020-02-28 20:20:35 +01:00
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
ErrorOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
2020-02-28 20:20:35 +01:00
|
|
|
{
|
2022-01-12 20:25:39 +01:00
|
|
|
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(inode.size()));
|
2022-02-10 19:39:17 +02:00
|
|
|
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
|
|
|
|
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages), move(dirty_pages)));
|
2020-02-28 20:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
2020-02-28 20:20:35 +01:00
|
|
|
{
|
2022-01-12 20:25:39 +01:00
|
|
|
auto new_physical_pages = TRY(this->try_clone_physical_pages());
|
2022-02-10 19:39:17 +02:00
|
|
|
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
|
|
|
|
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages), move(dirty_pages)));
|
2020-02-28 20:20:35 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-10 19:39:17 +02:00
|
|
|
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
|
|
|
|
: InodeVMObject(inode, move(new_physical_pages), move(dirty_pages))
|
2020-02-28 20:20:35 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-10 19:39:17 +02:00
|
|
|
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
|
|
|
|
: InodeVMObject(other, move(new_physical_pages), move(dirty_pages))
|
2020-02-28 20:20:35 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrivateInodeVMObject::~PrivateInodeVMObject()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|