diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-28 11:23:00 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-28 11:23:00 +0200 |
commit | 9d801d2345581f9524ae61f93e4e3785249ae0e4 (patch) | |
tree | 489129173def8cc9a9c10b69419e6bbd75b7bf6b /Kernel/FileSystem | |
parent | 9a827ad3da16aafd8ef47efefd5b18ca2fb1f07b (diff) | |
download | serenity-9d801d2345581f9524ae61f93e4e3785249ae0e4.zip |
Kernel: Rename Custody::create() => try_create()
The try_ prefix indicates that this may fail. :^)
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/Custody.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/Custody.h | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 2 | ||||
-rw-r--r-- | Kernel/FileSystem/VirtualFileSystem.cpp | 23 |
4 files changed, 14 insertions, 15 deletions
diff --git a/Kernel/FileSystem/Custody.cpp b/Kernel/FileSystem/Custody.cpp index ed621a3f1a..fca850e674 100644 --- a/Kernel/FileSystem/Custody.cpp +++ b/Kernel/FileSystem/Custody.cpp @@ -12,7 +12,7 @@ namespace Kernel { -KResultOr<NonnullRefPtr<Custody>> Custody::create(Custody* parent, StringView name, Inode& inode, int mount_flags) +KResultOr<NonnullRefPtr<Custody>> Custody::try_create(Custody* parent, StringView name, Inode& inode, int mount_flags) { auto name_kstring = KString::try_create(name); if (!name_kstring) diff --git a/Kernel/FileSystem/Custody.h b/Kernel/FileSystem/Custody.h index f324693e1b..47b7815fd0 100644 --- a/Kernel/FileSystem/Custody.h +++ b/Kernel/FileSystem/Custody.h @@ -21,7 +21,7 @@ namespace Kernel { class Custody : public RefCounted<Custody> { MAKE_SLAB_ALLOCATED(Custody) public: - static KResultOr<NonnullRefPtr<Custody>> create(Custody* parent, StringView name, Inode& inode, int mount_flags); + static KResultOr<NonnullRefPtr<Custody>> try_create(Custody* parent, StringView name, Inode&, int mount_flags); ~Custody(); diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 73bb7daf1a..2ba826b07d 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -1537,7 +1537,7 @@ KResultOr<NonnullRefPtr<Custody>> ProcFSInode::resolve_as_link(Custody& base, Re if (!description) return ENOENT; auto proxy_inode = ProcFSProxyInode::create(const_cast<ProcFS&>(fs()), *description); - return Custody::create(&base, "", proxy_inode, base.mount_flags()); + return Custody::try_create(&base, "", proxy_inode, base.mount_flags()); } Custody* res = nullptr; diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index ea3db0c577..299a34fae1 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -131,11 +131,10 @@ bool VFS::mount_root(FS& file_system) m_mounts.append(move(mount)); - auto root_custody = Custody::create(nullptr, "", *m_root_inode, root_mount_flags); - if (root_custody.is_error()) + auto custody_or_error = Custody::try_create(nullptr, "", *m_root_inode, root_mount_flags); + if (custody_or_error.is_error()) return false; - m_root_custody = root_custody.release_value(); - + m_root_custody = custody_or_error.release_value(); return true; } @@ -383,10 +382,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio if (inode_or_error.is_error()) return inode_or_error.error(); - auto new_custody = Custody::create(&parent_custody, p.basename(), inode_or_error.value(), parent_custody.mount_flags()); - if (new_custody.is_error()) - return new_custody.error(); - auto description = FileDescription::create(*new_custody.release_value()); + auto new_custody_or_error = Custody::try_create(&parent_custody, p.basename(), inode_or_error.value(), parent_custody.mount_flags()); + if (new_custody_or_error.is_error()) + return new_custody_or_error.error(); + auto description = FileDescription::create(*new_custody_or_error.release_value()); if (!description.is_error()) { description.value()->set_rw_mode(options); description.value()->set_file_flags(options); @@ -994,11 +993,11 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path_without_veil(StringView path mount_flags_for_child = mount->flags(); } - auto new_custody = Custody::create(&parent, part, *child_inode, mount_flags_for_child); - if (new_custody.is_error()) - return new_custody.error(); + auto new_custody_or_error = Custody::try_create(&parent, part, *child_inode, mount_flags_for_child); + if (new_custody_or_error.is_error()) + return new_custody_or_error.error(); - custody = new_custody.release_value(); + custody = new_custody_or_error.release_value(); if (child_inode->metadata().is_symlink()) { if (!have_more_parts) { |