summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/File.h
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-10-30 00:45:23 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-31 12:06:28 +0100
commitc05c5a7ff43388994a85ce84121cdcfa6ee741ba (patch)
treea255c368c51cf8cab2f005d6bc9a8dcc1b33d641 /Kernel/FileSystem/File.h
parent88ca12f037ffd9aedc884331c927f08d57e047cd (diff)
downloadserenity-c05c5a7ff43388994a85ce84121cdcfa6ee741ba.zip
Kernel: Clarify ambiguous {File,Description}::absolute_path
Found due to smelly code in InodeFile::absolute_path. In particular, this replaces the following misleading methods: File::absolute_path This method *never* returns an actual path, and if called on an InodeFile (which is impossible), it would VERIFY_NOT_REACHED(). OpenFileDescription::try_serialize_absolute_path OpenFileDescription::absolute_path These methods do not guarantee to return an actual path (just like the other method), and just like Custody::absolute_path they do not guarantee accuracy. In particular, just renaming the method made a TOCTOU bug obvious. The new method signatures use KResultOr, just like try_serialize_absolute_path() already did.
Diffstat (limited to 'Kernel/FileSystem/File.h')
-rw-r--r--Kernel/FileSystem/File.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h
index 303549fdc3..c42ac1c51a 100644
--- a/Kernel/FileSystem/File.h
+++ b/Kernel/FileSystem/File.h
@@ -93,7 +93,8 @@ public:
virtual KResultOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared);
virtual KResult stat(::stat&) const { return EBADF; }
- virtual String absolute_path(const OpenFileDescription&) const = 0;
+ // Although this might be better described "name" or "description", these terms already have other meanings.
+ virtual KResultOr<NonnullOwnPtr<KString>> pseudo_path(const OpenFileDescription&) const = 0;
virtual KResult truncate(u64) { return EINVAL; }
virtual KResult sync() { return EINVAL; }