2020-02-28 19:20:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-02-28 19:20:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Bitmap.h>
|
2021-08-06 08:45:34 +00:00
|
|
|
#include <Kernel/Memory/VMObject.h>
|
2020-02-28 19:20:35 +00:00
|
|
|
#include <Kernel/UnixTypes.h>
|
|
|
|
|
2021-08-06 11:49:36 +00:00
|
|
|
namespace Kernel::Memory {
|
2020-02-28 19:20:35 +00:00
|
|
|
|
|
|
|
class InodeVMObject : public VMObject {
|
|
|
|
public:
|
|
|
|
virtual ~InodeVMObject() override;
|
|
|
|
|
|
|
|
Inode& inode() { return *m_inode; }
|
2021-07-21 22:02:34 +00:00
|
|
|
Inode const& inode() const { return *m_inode; }
|
2020-02-28 19:20:35 +00:00
|
|
|
|
|
|
|
size_t amount_dirty() const;
|
|
|
|
size_t amount_clean() const;
|
|
|
|
|
|
|
|
int release_all_clean_pages();
|
2022-08-15 03:05:42 +00:00
|
|
|
int try_release_clean_pages(int page_amount);
|
2020-02-28 19:20:35 +00:00
|
|
|
|
|
|
|
u32 writable_mappings() const;
|
|
|
|
|
|
|
|
protected:
|
2022-08-24 13:56:26 +00:00
|
|
|
explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
|
|
|
explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
2020-02-28 19:20:35 +00:00
|
|
|
|
2021-07-21 22:02:34 +00:00
|
|
|
InodeVMObject& operator=(InodeVMObject const&) = delete;
|
2020-02-28 19:20:35 +00:00
|
|
|
InodeVMObject& operator=(InodeVMObject&&) = delete;
|
|
|
|
InodeVMObject(InodeVMObject&&) = delete;
|
|
|
|
|
|
|
|
virtual bool is_inode() const final { return true; }
|
|
|
|
|
2023-03-07 11:25:00 +00:00
|
|
|
NonnullRefPtr<Inode> m_inode;
|
2020-02-28 19:20:35 +00:00
|
|
|
Bitmap m_dirty_pages;
|
|
|
|
};
|
|
|
|
|
2020-05-08 20:10:47 +00:00
|
|
|
}
|