summaryrefslogtreecommitdiff
path: root/Kernel/VM/SharedInodeVMObject.cpp
blob: 91e7873fb7941998a39ff3b56cbc4eade9497103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <Kernel/FileSystem/Inode.h>
#include <Kernel/VM/SharedInodeVMObject.h>

namespace Kernel {

NonnullRefPtr<SharedInodeVMObject> SharedInodeVMObject::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(*new SharedInodeVMObject(inode, size));
    vmobject->inode().set_shared_vmobject(*vmobject);
    return vmobject;
}

RefPtr<VMObject> SharedInodeVMObject::clone()
{
    return adopt_ref(*new SharedInodeVMObject(*this));
}

SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
    : InodeVMObject(inode, size)
{
}

SharedInodeVMObject::SharedInodeVMObject(const SharedInodeVMObject& other)
    : InodeVMObject(other)
{
}

}