diff options
-rw-r--r-- | Kernel/Devices/BXVGADevice.cpp | 2 | ||||
-rw-r--r-- | Kernel/Devices/BXVGADevice.h | 2 | ||||
-rw-r--r-- | Kernel/File.cpp | 2 | ||||
-rw-r--r-- | Kernel/File.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/FileDescriptor.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/InodeFile.cpp | 11 | ||||
-rw-r--r-- | Kernel/FileSystem/InodeFile.h | 2 | ||||
-rw-r--r-- | Kernel/SharedMemory.cpp | 2 | ||||
-rw-r--r-- | Kernel/SharedMemory.h | 2 |
9 files changed, 10 insertions, 17 deletions
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp index 673f1b4c00..e4b2d4c356 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, int prot) +KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) { ASSERT(offset == 0); ASSERT(size == framebuffer_size_in_bytes()); diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h index 517d13d4f6..2270a41a9f 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, int prot) override; + virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, 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 7de0f240f8..ffc64bec9d 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, int) +KResultOr<Region*> File::mmap(Process&, FileDescriptor&, LinearAddress, size_t, size_t, int) { return KResult(-ENODEV); } diff --git a/Kernel/File.h b/Kernel/File.h index c0ad044482..8a74b3cde1 100644 --- a/Kernel/File.h +++ b/Kernel/File.h @@ -52,7 +52,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, int prot); + virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot); virtual String absolute_path(const FileDescriptor&) const = 0; diff --git a/Kernel/FileSystem/FileDescriptor.cpp b/Kernel/FileSystem/FileDescriptor.cpp index 0fb1f71b9f..1f2f0dec31 100644 --- a/Kernel/FileSystem/FileDescriptor.cpp +++ b/Kernel/FileSystem/FileDescriptor.cpp @@ -260,7 +260,7 @@ InodeMetadata FileDescriptor::metadata() const KResultOr<Region*> FileDescriptor::mmap(Process& process, LinearAddress laddr, size_t offset, size_t size, int prot) { - return m_file->mmap(process, laddr, offset, size, prot); + return m_file->mmap(process, *this, laddr, offset, size, prot); } KResult FileDescriptor::truncate(off_t length) diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index 81ddf69205..f30fb655f1 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -23,19 +23,12 @@ ssize_t InodeFile::write(FileDescriptor& descriptor, const byte* data, ssize_t c return m_inode->write_bytes(descriptor.offset(), count, data, &descriptor); } -KResultOr<Region*> InodeFile::mmap(Process& process, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) +KResultOr<Region*> InodeFile::mmap(Process& process, FileDescriptor& descriptor, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) { ASSERT(offset == 0); // FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec. - String region_name; -#if 0 - // FIXME: I would like to do this, but it would instantiate all the damn inodes. - region_name = absolute_path(); -#else - region_name = "Memory-mapped file"; -#endif InterruptDisabler disabler; - auto* region = process.allocate_file_backed_region(preferred_laddr, size, inode(), move(region_name), prot); + auto* region = process.allocate_file_backed_region(preferred_laddr, size, inode(), descriptor.absolute_path(), prot); if (!region) return KResult(-ENOMEM); return region; diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h index 6cad93211d..5522822d1e 100644 --- a/Kernel/FileSystem/InodeFile.h +++ b/Kernel/FileSystem/InodeFile.h @@ -21,7 +21,7 @@ public: virtual ssize_t read(FileDescriptor&, byte*, ssize_t) override; virtual ssize_t write(FileDescriptor&, const byte*, ssize_t) override; - virtual KResultOr<Region*> mmap(Process&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override; + virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override; virtual String absolute_path(const FileDescriptor&) const override; diff --git a/Kernel/SharedMemory.cpp b/Kernel/SharedMemory.cpp index cfe42ac5d2..830c8ffee9 100644 --- a/Kernel/SharedMemory.cpp +++ b/Kernel/SharedMemory.cpp @@ -89,7 +89,7 @@ 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, int prot) +KResultOr<Region*> SharedMemory::mmap(Process& process, FileDescriptor&, LinearAddress laddr, size_t offset, size_t size, int prot) { if (!vmo()) return KResult(-ENODEV); diff --git a/Kernel/SharedMemory.h b/Kernel/SharedMemory.h index 07bf2efa53..b0de2e5009 100644 --- a/Kernel/SharedMemory.h +++ b/Kernel/SharedMemory.h @@ -31,7 +31,7 @@ private: virtual String absolute_path(const 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, int prot) override; + virtual KResultOr<Region*> mmap(Process&, FileDescriptor&, LinearAddress, size_t offset, size_t size, int prot) override; SharedMemory(const String& name, uid_t, gid_t, mode_t); |