mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Kernel: Pass 'prot' argument to File::mmap() and act on it.
Nothing crazy, this just means that PROT_READ allocates readable regions, and that PROT_WRITE allocates writable ones.
This commit is contained in:
parent
004a630bfe
commit
66c1a9be3b
Notes:
sideshowbarker
2024-07-19 13:50:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/66c1a9be3b0
7 changed files with 11 additions and 9 deletions
|
@ -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());
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue