Kernel: Implement MAP_PRIVATE file mappings
mmap() now supports mapping files with MAP_PRIVATE.
This commit is contained in:
30
kernel/include/kernel/Memory/FileBackedRegion.h
Normal file
30
kernel/include/kernel/Memory/FileBackedRegion.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/FS/Inode.h>
|
||||
#include <kernel/Memory/MemoryRegion.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class FileBackedRegion final : public MemoryRegion
|
||||
{
|
||||
BAN_NON_COPYABLE(FileBackedRegion);
|
||||
BAN_NON_MOVABLE(FileBackedRegion);
|
||||
|
||||
public:
|
||||
static BAN::ErrorOr<BAN::UniqPtr<FileBackedRegion>> create(BAN::RefPtr<Inode>, PageTable&, off_t offset, size_t size, AddressRange address_range, Type, PageTable::flags_t);
|
||||
~FileBackedRegion();
|
||||
|
||||
virtual BAN::ErrorOr<bool> allocate_page_containing(vaddr_t vaddr) override;
|
||||
|
||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> clone(PageTable& new_page_table) override;
|
||||
|
||||
private:
|
||||
FileBackedRegion(BAN::RefPtr<Inode>, PageTable&, off_t offset, ssize_t size, Type flags, PageTable::flags_t page_flags);
|
||||
|
||||
private:
|
||||
BAN::RefPtr<Inode> m_inode;
|
||||
const off_t m_offset;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Kernel
|
||||
BAN_NON_MOVABLE(MemoryRegion);
|
||||
|
||||
public:
|
||||
enum Type : uint8_t
|
||||
enum class Type : uint8_t
|
||||
{
|
||||
PRIVATE,
|
||||
SHARED
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Kernel
|
||||
|
||||
BAN::ErrorOr<BAN::StringView> path_of(int) const;
|
||||
BAN::ErrorOr<BAN::RefPtr<Inode>> inode_of(int);
|
||||
BAN::ErrorOr<int> flags_of(int) const;
|
||||
|
||||
private:
|
||||
struct OpenFileDescription : public BAN::RefCounted<OpenFileDescription>
|
||||
|
||||
Reference in New Issue
Block a user