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

This commit is contained in:
Andreas Kling 2021-08-28 21:25:18 +02:00
parent 31bc9565f8
commit 59335bd8ea
Notes: sideshowbarker 2024-07-18 05:07:15 +09:00
11 changed files with 16 additions and 16 deletions

View File

@ -26,7 +26,7 @@ RefPtr<FIFO> FIFO::try_create(uid_t uid)
KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction(FIFO::Direction direction)
{
auto description = FileDescription::create(*this);
auto description = FileDescription::try_create(*this);
if (!description.is_error()) {
attach(direction);
description.value()->set_fifo_direction({}, direction);

View File

@ -30,7 +30,7 @@ bool File::unref() const
KResultOr<NonnullRefPtr<FileDescription>> File::open(int options)
{
auto description = FileDescription::create(*this);
auto description = FileDescription::try_create(*this);
if (!description.is_error()) {
description.value()->set_rw_mode(options);
description.value()->set_file_flags(options);

View File

@ -24,7 +24,7 @@
namespace Kernel {
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custody)
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::try_create(Custody& custody)
{
auto inode_file = InodeFile::create(custody.inode());
if (inode_file.is_error())
@ -43,7 +43,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(Custody& custo
return description.release_nonnull();
}
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::create(File& file)
KResultOr<NonnullRefPtr<FileDescription>> FileDescription::try_create(File& file)
{
auto description = adopt_ref_if_nonnull(new (nothrow) FileDescription(file));
if (!description)

View File

@ -26,8 +26,8 @@ public:
class FileDescription : public RefCounted<FileDescription> {
MAKE_SLAB_ALLOCATED(FileDescription)
public:
static KResultOr<NonnullRefPtr<FileDescription>> create(Custody&);
static KResultOr<NonnullRefPtr<FileDescription>> create(File&);
static KResultOr<NonnullRefPtr<FileDescription>> try_create(Custody&);
static KResultOr<NonnullRefPtr<FileDescription>> try_create(File&);
~FileDescription();
Thread::FileBlocker::BlockFlags should_unblock(Thread::FileBlocker::BlockFlags) const;

View File

@ -312,7 +312,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VirtualFileSystem::open(StringView pat
if (auto result = inode.set_mtime(kgettimeofday().to_truncated_seconds()); result.is_error())
return result;
}
auto description = FileDescription::create(custody);
auto description = FileDescription::try_create(custody);
if (!description.is_error()) {
description.value()->set_rw_mode(options);
description.value()->set_file_flags(options);
@ -379,7 +379,7 @@ KResultOr<NonnullRefPtr<FileDescription>> VirtualFileSystem::create(StringView p
auto new_custody_or_error = Custody::try_create(&parent_custody, 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());
auto description = FileDescription::try_create(*new_custody_or_error.release_value());
if (!description.is_error()) {
description.value()->set_rw_mode(options);
description.value()->set_file_flags(options);

View File

@ -55,7 +55,7 @@ KResultOr<SocketPair> LocalSocket::create_connected_pair(int type)
return socket_or_error.error();
auto socket = static_ptr_cast<LocalSocket>(socket_or_error.release_value());
auto description1_result = FileDescription::create(*socket);
auto description1_result = FileDescription::try_create(*socket);
if (description1_result.is_error())
return description1_result.error();
@ -69,7 +69,7 @@ KResultOr<SocketPair> LocalSocket::create_connected_pair(int type)
socket->set_connect_side_role(Role::Connected);
socket->m_role = Role::Accepted;
auto description2_result = FileDescription::create(*socket);
auto description2_result = FileDescription::try_create(*socket);
if (description2_result.is_error())
return description2_result.error();

View File

@ -182,7 +182,7 @@ NonnullRefPtr<FileSystem> StorageManagement::root_filesystem() const
if (!boot_device_description) {
PANIC("StorageManagement: Couldn't find a suitable device to boot from");
}
auto e2fs = Ext2FS::create(FileDescription::create(boot_device_description.release_nonnull()).value());
auto e2fs = Ext2FS::create(FileDescription::try_create(boot_device_description.release_nonnull()).value());
if (auto result = e2fs->initialize(); result.is_error()) {
PANIC("StorageManagement: Couldn't open root filesystem: {}", result);
}

View File

@ -36,7 +36,7 @@ KResultOr<FlatPtr> Process::sys$anon_create(size_t size, int options)
auto anon_file = AnonymousFile::create(maybe_vmobject.release_value());
if (!anon_file)
return ENOMEM;
auto description_or_error = FileDescription::create(*anon_file);
auto description_or_error = FileDescription::try_create(*anon_file);
if (description_or_error.is_error())
return description_or_error.error();

View File

@ -27,7 +27,7 @@ KResultOr<FlatPtr> Process::sys$create_inode_watcher(u32 flags)
if (watcher_or_error.is_error())
return watcher_or_error.error();
auto description_or_error = FileDescription::create(*watcher_or_error.value());
auto description_or_error = FileDescription::try_create(*watcher_or_error.value());
if (description_or_error.is_error())
return description_or_error.error();

View File

@ -45,7 +45,7 @@ KResultOr<FlatPtr> Process::sys$socket(int domain, int type, int protocol)
auto result = Socket::create(domain, type, protocol);
if (result.is_error())
return result.error();
auto description_result = FileDescription::create(*result.value());
auto description_result = FileDescription::try_create(*result.value());
if (description_result.is_error())
return description_result.error();
setup_socket_fd(socket_fd.fd, description_result.value(), type);
@ -133,7 +133,7 @@ KResultOr<FlatPtr> Process::sys$accept4(Userspace<const Syscall::SC_accept4_para
return EFAULT;
}
auto accepted_socket_description_result = FileDescription::create(*accepted_socket);
auto accepted_socket_description_result = FileDescription::try_create(*accepted_socket);
if (accepted_socket_description_result.is_error())
return accepted_socket_description_result.error();

View File

@ -46,7 +46,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
if (!master)
return ENOMEM;
dbgln_if(PTMX_DEBUG, "PTYMultiplexer::open: Vending master {}", master->index());
auto description = FileDescription::create(*master);
auto description = FileDescription::try_create(*master);
if (!description.is_error()) {
description.value()->set_rw_mode(options);
description.value()->set_file_flags(options);