diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-06 10:45:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-06 14:05:58 +0200 |
commit | a1d7ebf85adca1550b5d61c8b7ab7fe95217e0e2 (patch) | |
tree | dd2e9c08a07ca98694a040ff2c4bd4c86f2741f8 /Kernel/Memory/SharedInodeVMObject.cpp | |
parent | 4e8e1b7b3a2cd25ab4b69cebea32232496f4a5d3 (diff) | |
download | serenity-a1d7ebf85adca1550b5d61c8b7ab7fe95217e0e2.zip |
Kernel: Rename Kernel/VM/ to Kernel/Memory/
This directory isn't just about virtual memory, it's about all kinds
of memory management.
Diffstat (limited to 'Kernel/Memory/SharedInodeVMObject.cpp')
-rw-r--r-- | Kernel/Memory/SharedInodeVMObject.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Kernel/Memory/SharedInodeVMObject.cpp b/Kernel/Memory/SharedInodeVMObject.cpp new file mode 100644 index 0000000000..1c8c7b2ae3 --- /dev/null +++ b/Kernel/Memory/SharedInodeVMObject.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <Kernel/FileSystem/Inode.h> +#include <Kernel/Memory/SharedInodeVMObject.h> + +namespace Kernel { + +RefPtr<SharedInodeVMObject> SharedInodeVMObject::try_create_with_inode(Inode& inode) +{ + size_t size = inode.size(); + if (auto shared_vmobject = inode.shared_vmobject()) + return shared_vmobject.release_nonnull(); + auto vmobject = adopt_ref_if_nonnull(new (nothrow) SharedInodeVMObject(inode, size)); + if (!vmobject) + return nullptr; + vmobject->inode().set_shared_vmobject(*vmobject); + return vmobject; +} + +RefPtr<VMObject> SharedInodeVMObject::try_clone() +{ + return adopt_ref_if_nonnull(new (nothrow) SharedInodeVMObject(*this)); +} + +SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size) + : InodeVMObject(inode, size) +{ +} + +SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other) + : InodeVMObject(other) +{ +} + +} |