Kernel: Implement MAP_SHARED for regular files

Every inode holds a weak pointer to shared file data. This contains
physical addresses of pages for inode file data. Physical addresses
are allocated and read on demand.

When last shared mapping is unmapped. The inodes shared data is freed
and written to the inode.
This commit is contained in:
2023-09-29 18:46:44 +03:00
parent 9fc75fe445
commit f953f3d3ff
4 changed files with 139 additions and 41 deletions

View File

@@ -3,6 +3,7 @@
#include <BAN/RefPtr.h>
#include <BAN/String.h>
#include <BAN/StringView.h>
#include <BAN/WeakPtr.h>
#include <BAN/Vector.h>
#include <kernel/API/DirectoryEntry.h>
@@ -17,6 +18,9 @@ namespace Kernel
using namespace API;
class FileBackedRegion;
class SharedFileData;
class Inode : public BAN::RefCounted<Inode>
{
public:
@@ -112,6 +116,9 @@ namespace Kernel
private:
mutable RecursiveSpinLock m_lock;
BAN::WeakPtr<SharedFileData> m_shared_region;
friend class FileBackedRegion;
};
}