summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Devices/BXVGADevice.cpp6
-rw-r--r--Kernel/Devices/BXVGADevice.h2
-rw-r--r--Kernel/File.cpp2
-rw-r--r--Kernel/File.h2
-rw-r--r--Kernel/FileSystem/FileDescriptor.cpp2
-rw-r--r--Kernel/SharedMemory.cpp4
-rw-r--r--Kernel/SharedMemory.h2
7 files changed, 11 insertions, 9 deletions
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index bcdf4bb174..7dc3f00a6d 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -84,7 +84,7 @@ dword BXVGADevice::find_framebuffer_address()
return framebuffer_address;
}
-KResultOr<Region*> BXVGADevice::mmap(Process& process, LinearAddress preferred_laddr, size_t offset, size_t size)
+KResultOr<Region*> BXVGADevice::mmap(Process& process, LinearAddress preferred_laddr, size_t offset, size_t size, int prot)
{
ASSERT(offset == 0);
ASSERT(size == framebuffer_size_in_bytes());
@@ -95,7 +95,9 @@ KResultOr<Region*> BXVGADevice::mmap(Process& process, LinearAddress preferred_l
move(vmo),
0,
"BXVGA Framebuffer",
- true, true);
+ prot & PROT_READ,
+ prot & PROT_WRITE
+ );
kprintf("BXVGA: %s(%u) created Region{%p} with size %u for framebuffer P%x with laddr L%x\n",
process.name().characters(), process.pid(),
region, region->size(), framebuffer_address().as_ptr(), region->laddr().get());
diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h
index d797724475..517d13d4f6 100644
--- a/Kernel/Devices/BXVGADevice.h
+++ b/Kernel/Devices/BXVGADevice.h
@@ -18,7 +18,7 @@ public:
void set_y_offset(int);
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg) override;
- virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t) override;
+ virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t, int prot) override;
size_t framebuffer_size_in_bytes() const { return m_framebuffer_size.area() * sizeof(dword) * 2; }
Size framebuffer_size() const { return m_framebuffer_size; }
diff --git a/Kernel/File.cpp b/Kernel/File.cpp
index 78a1371cef..7de0f240f8 100644
--- a/Kernel/File.cpp
+++ b/Kernel/File.cpp
@@ -24,7 +24,7 @@ int File::ioctl(FileDescriptor&, unsigned, unsigned)
return -ENOTTY;
}
-KResultOr<Region*> File::mmap(Process&, LinearAddress, size_t, size_t)
+KResultOr<Region*> File::mmap(Process&, LinearAddress, size_t, size_t, int)
{
return KResult(-ENODEV);
}
diff --git a/Kernel/File.h b/Kernel/File.h
index 7655448d4b..7e8ead39c3 100644
--- a/Kernel/File.h
+++ b/Kernel/File.h
@@ -24,7 +24,7 @@ public:
virtual ssize_t read(FileDescriptor&, byte*, ssize_t) = 0;
virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) = 0;
virtual int ioctl(FileDescriptor&, unsigned request, unsigned arg);
- virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t size);
+ virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot);
virtual String absolute_path(FileDescriptor&) const = 0;
diff --git a/Kernel/FileSystem/FileDescriptor.cpp b/Kernel/FileSystem/FileDescriptor.cpp
index e199fdd298..24074afdc0 100644
--- a/Kernel/FileSystem/FileDescriptor.cpp
+++ b/Kernel/FileSystem/FileDescriptor.cpp
@@ -324,7 +324,7 @@ InodeMetadata FileDescriptor::metadata() const
KResultOr<Region*> FileDescriptor::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
{
if (m_file)
- return m_file->mmap(process, laddr, offset, size);
+ return m_file->mmap(process, laddr, offset, size, prot);
if (!is_fsfile())
return KResult(-ENODEV);
diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp
index b371566828..bf5b4a6e8d 100644
--- a/Kernel/SharedMemory.cpp
+++ b/Kernel/SharedMemory.cpp
@@ -89,9 +89,9 @@ int SharedMemory::write(FileDescriptor&, const byte* data, int data_size)
ASSERT_NOT_REACHED();
}
-KResultOr<Region*> SharedMemory::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size)
+KResultOr<Region*> SharedMemory::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot)
{
if (!vmo())
return KResult(-ENODEV);
- return process.allocate_region_with_vmo(laddr, size, *vmo(), offset, name(), true, true);
+ return process.allocate_region_with_vmo(laddr, size, *vmo(), offset, name(), prot & PROT_READ, prot & PROT_WRITE);
}
diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h
index 4c8520ce12..8fa1ac8399 100644
--- a/Kernel/SharedMemory.h
+++ b/Kernel/SharedMemory.h
@@ -31,7 +31,7 @@ private:
virtual String absolute_path(FileDescriptor&) const override;
virtual const char* class_name() const override { return "SharedMemory"; }
virtual bool is_shared_memory() const override { return true; }
- virtual KResultOr<Region*> mmap(Process&, LinearAddress, size_t offset, size_t size) override;
+ virtual KResultOr<Region*> mmap(Process&, LinearAddress, size_t offset, size_t size, int prot) override;
SharedMemory(const String& name, uid_t, gid_t, mode_t);