2020-02-28 22:20:35 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-28 22:20:35 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/FileSystem/Inode.h>
|
2021-08-06 11:45:34 +03:00
|
|
|
#include <Kernel/Memory/PrivateInodeVMObject.h>
|
2020-02-28 22:20:35 +03:00
|
|
|
|
2021-08-06 14:49:36 +03:00
|
|
|
namespace Kernel::Memory {
|
2020-02-28 22:20:35 +03:00
|
|
|
|
2021-11-08 02:51:39 +03:00
|
|
|
ErrorOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
2020-02-28 22:20:35 +03:00
|
|
|
{
|
2022-01-12 22:25:39 +03:00
|
|
|
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(inode.size()));
|
2022-02-10 20:39:17 +03: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 22:20:35 +03:00
|
|
|
}
|
|
|
|
|
2021-11-08 02:51:39 +03:00
|
|
|
ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
2020-02-28 22:20:35 +03:00
|
|
|
{
|
2022-01-12 22:25:39 +03:00
|
|
|
auto new_physical_pages = TRY(this->try_clone_physical_pages());
|
2022-02-10 20:39:17 +03: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 22:20:35 +03:00
|
|
|
}
|
|
|
|
|
2022-02-10 20:39:17 +03: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 22:20:35 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-02-10 20:39:17 +03: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 22:20:35 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivateInodeVMObject::~PrivateInodeVMObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|