summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-02 10:14:28 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-02 10:14:28 +0200
commit5e1c7cb32c98dfb568dcd7d935a222bda9c42fda (patch)
treebdccd1ffe952457d03572cff1b30ebde1d2835c9 /Kernel/FileSystem
parent4320c5fd58a3c313bc3551b266de725b51a9732b (diff)
downloadserenity-5e1c7cb32c98dfb568dcd7d935a222bda9c42fda.zip
Kernel: Memory-mapped files now have the absolute path as their name.
It's generated when the mapping is first created, so it won't update if the file moves. Maybe that's something we should support, too.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/FileDescriptor.cpp2
-rw-r--r--Kernel/FileSystem/InodeFile.cpp11
-rw-r--r--Kernel/FileSystem/InodeFile.h2
3 files changed, 4 insertions, 11 deletions
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;