1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

Kernel: Rename Custody::create() => try_create()

The try_ prefix indicates that this may fail. :^)
This commit is contained in:
Andreas Kling 2021-05-28 11:23:00 +02:00
parent 9a827ad3da
commit 9d801d2345
5 changed files with 18 additions and 19 deletions

View file

@ -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)

View file

@ -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();

View file

@ -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;

View file

@ -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) {

View file

@ -26,11 +26,11 @@ KResultOr<int> Process::sys$chroot(Userspace<const char*> user_path, size_t path
m_root_directory_relative_to_global_root = directory;
int chroot_mount_flags = mount_flags == -1 ? directory->mount_flags() : mount_flags;
auto custody = Custody::create(nullptr, "", directory->inode(), chroot_mount_flags);
if (custody.is_error())
return custody.error();
auto custody_or_error = Custody::try_create(nullptr, "", directory->inode(), chroot_mount_flags);
if (custody_or_error.is_error())
return custody_or_error.error();
set_root_directory(custody.release_value());
set_root_directory(custody_or_error.release_value());
return 0;
}