mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
Kernel: Rename Custody::create() => try_create()
The try_ prefix indicates that this may fail. :^)
This commit is contained in:
parent
9a827ad3da
commit
9d801d2345
5 changed files with 18 additions and 19 deletions
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
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);
|
auto name_kstring = KString::try_create(name);
|
||||||
if (!name_kstring)
|
if (!name_kstring)
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Kernel {
|
||||||
class Custody : public RefCounted<Custody> {
|
class Custody : public RefCounted<Custody> {
|
||||||
MAKE_SLAB_ALLOCATED(Custody)
|
MAKE_SLAB_ALLOCATED(Custody)
|
||||||
public:
|
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();
|
~Custody();
|
||||||
|
|
||||||
|
|
|
@ -1537,7 +1537,7 @@ KResultOr<NonnullRefPtr<Custody>> ProcFSInode::resolve_as_link(Custody& base, Re
|
||||||
if (!description)
|
if (!description)
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
auto proxy_inode = ProcFSProxyInode::create(const_cast<ProcFS&>(fs()), *description);
|
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;
|
Custody* res = nullptr;
|
||||||
|
|
|
@ -131,11 +131,10 @@ bool VFS::mount_root(FS& file_system)
|
||||||
|
|
||||||
m_mounts.append(move(mount));
|
m_mounts.append(move(mount));
|
||||||
|
|
||||||
auto root_custody = Custody::create(nullptr, "", *m_root_inode, root_mount_flags);
|
auto custody_or_error = Custody::try_create(nullptr, "", *m_root_inode, root_mount_flags);
|
||||||
if (root_custody.is_error())
|
if (custody_or_error.is_error())
|
||||||
return false;
|
return false;
|
||||||
m_root_custody = root_custody.release_value();
|
m_root_custody = custody_or_error.release_value();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,10 +382,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
|
||||||
if (inode_or_error.is_error())
|
if (inode_or_error.is_error())
|
||||||
return inode_or_error.error();
|
return inode_or_error.error();
|
||||||
|
|
||||||
auto new_custody = Custody::create(&parent_custody, p.basename(), inode_or_error.value(), parent_custody.mount_flags());
|
auto new_custody_or_error = Custody::try_create(&parent_custody, p.basename(), inode_or_error.value(), parent_custody.mount_flags());
|
||||||
if (new_custody.is_error())
|
if (new_custody_or_error.is_error())
|
||||||
return new_custody.error();
|
return new_custody_or_error.error();
|
||||||
auto description = FileDescription::create(*new_custody.release_value());
|
auto description = FileDescription::create(*new_custody_or_error.release_value());
|
||||||
if (!description.is_error()) {
|
if (!description.is_error()) {
|
||||||
description.value()->set_rw_mode(options);
|
description.value()->set_rw_mode(options);
|
||||||
description.value()->set_file_flags(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();
|
mount_flags_for_child = mount->flags();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto new_custody = Custody::create(&parent, part, *child_inode, mount_flags_for_child);
|
auto new_custody_or_error = Custody::try_create(&parent, part, *child_inode, mount_flags_for_child);
|
||||||
if (new_custody.is_error())
|
if (new_custody_or_error.is_error())
|
||||||
return new_custody.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 (child_inode->metadata().is_symlink()) {
|
||||||
if (!have_more_parts) {
|
if (!have_more_parts) {
|
||||||
|
|
|
@ -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;
|
m_root_directory_relative_to_global_root = directory;
|
||||||
int chroot_mount_flags = mount_flags == -1 ? directory->mount_flags() : mount_flags;
|
int chroot_mount_flags = mount_flags == -1 ? directory->mount_flags() : mount_flags;
|
||||||
|
|
||||||
auto custody = Custody::create(nullptr, "", directory->inode(), chroot_mount_flags);
|
auto custody_or_error = Custody::try_create(nullptr, "", directory->inode(), chroot_mount_flags);
|
||||||
if (custody.is_error())
|
if (custody_or_error.is_error())
|
||||||
return custody.error();
|
return custody_or_error.error();
|
||||||
|
|
||||||
set_root_directory(custody.release_value());
|
set_root_directory(custody_or_error.release_value());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue