mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
Kernel: Tidy up Plan9FS construction a bit
This commit is contained in:
parent
36725228fa
commit
d34f2b643e
3 changed files with 12 additions and 25 deletions
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
NonnullRefPtr<Plan9FS> Plan9FS::create(FileDescription& file_description)
|
KResultOr<NonnullRefPtr<Plan9FS>> Plan9FS::try_create(FileDescription& file_description)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new Plan9FS(file_description));
|
return adopt_nonnull_ref_or_enomem(new (nothrow) Plan9FS(file_description));
|
||||||
}
|
}
|
||||||
|
|
||||||
Plan9FS::Plan9FS(FileDescription& file_description)
|
Plan9FS::Plan9FS(FileDescription& file_description)
|
||||||
|
@ -202,9 +202,7 @@ KResult Plan9FS::initialize()
|
||||||
Message version_message { *this, Message::Type::Tversion };
|
Message version_message { *this, Message::Type::Tversion };
|
||||||
version_message << (u32)m_max_message_size << "9P2000.L";
|
version_message << (u32)m_max_message_size << "9P2000.L";
|
||||||
|
|
||||||
auto result = post_message_and_wait_for_a_reply(version_message);
|
TRY(post_message_and_wait_for_a_reply(version_message));
|
||||||
if (result.is_error())
|
|
||||||
return result;
|
|
||||||
|
|
||||||
u32 msize;
|
u32 msize;
|
||||||
StringView remote_protocol_version;
|
StringView remote_protocol_version;
|
||||||
|
@ -224,15 +222,8 @@ KResult Plan9FS::initialize()
|
||||||
if (m_remote_protocol_version >= ProtocolVersion::v9P2000u)
|
if (m_remote_protocol_version >= ProtocolVersion::v9P2000u)
|
||||||
attach_message << (u32)-1;
|
attach_message << (u32)-1;
|
||||||
|
|
||||||
result = post_message_and_wait_for_a_reply(attach_message);
|
TRY(post_message_and_wait_for_a_reply(attach_message));
|
||||||
if (result.is_error()) {
|
m_root_inode = TRY(Plan9FSInode::try_create(*this, root_fid));
|
||||||
dbgln("Attaching failed");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_root_inode = Plan9FSInode::create(*this, root_fid);
|
|
||||||
if (!m_root_inode)
|
|
||||||
return ENOMEM;
|
|
||||||
return KSuccess;
|
return KSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,9 +676,9 @@ Plan9FSInode::Plan9FSInode(Plan9FS& fs, u32 fid)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<Plan9FSInode> Plan9FSInode::create(Plan9FS& fs, u32 fid)
|
KResultOr<NonnullRefPtr<Plan9FSInode>> Plan9FSInode::try_create(Plan9FS& fs, u32 fid)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new Plan9FSInode(fs, fid));
|
return adopt_nonnull_ref_or_enomem(new (nothrow) Plan9FSInode(fs, fid));
|
||||||
}
|
}
|
||||||
|
|
||||||
Plan9FSInode::~Plan9FSInode()
|
Plan9FSInode::~Plan9FSInode()
|
||||||
|
@ -927,12 +918,8 @@ KResultOr<NonnullRefPtr<Inode>> Plan9FSInode::lookup(StringView name)
|
||||||
u32 newfid = fs().allocate_fid();
|
u32 newfid = fs().allocate_fid();
|
||||||
Plan9FS::Message message { fs(), Plan9FS::Message::Type::Twalk };
|
Plan9FS::Message message { fs(), Plan9FS::Message::Type::Twalk };
|
||||||
message << fid() << newfid << (u16)1 << name;
|
message << fid() << newfid << (u16)1 << name;
|
||||||
auto result = fs().post_message_and_wait_for_a_reply(message);
|
TRY(fs().post_message_and_wait_for_a_reply(message));
|
||||||
|
return TRY(Plan9FSInode::try_create(fs(), newfid));
|
||||||
if (result.is_error())
|
|
||||||
return result;
|
|
||||||
|
|
||||||
return Plan9FSInode::create(fs(), newfid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<NonnullRefPtr<Inode>> Plan9FSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
KResultOr<NonnullRefPtr<Inode>> Plan9FSInode::create_child(StringView, mode_t, dev_t, UserID, GroupID)
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Plan9FS final : public FileBackedFileSystem {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Plan9FS() override;
|
virtual ~Plan9FS() override;
|
||||||
static NonnullRefPtr<Plan9FS> create(FileDescription&);
|
static KResultOr<NonnullRefPtr<Plan9FS>> try_create(FileDescription&);
|
||||||
|
|
||||||
virtual KResult initialize() override;
|
virtual KResult initialize() override;
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plan9FSInode(Plan9FS&, u32 fid);
|
Plan9FSInode(Plan9FS&, u32 fid);
|
||||||
static NonnullRefPtr<Plan9FSInode> create(Plan9FS&, u32 fid);
|
static KResultOr<NonnullRefPtr<Plan9FSInode>> try_create(Plan9FS&, u32 fid);
|
||||||
|
|
||||||
enum class GetAttrMask : u64 {
|
enum class GetAttrMask : u64 {
|
||||||
Mode = 0x1,
|
Mode = 0x1,
|
||||||
|
|
|
@ -77,7 +77,7 @@ KResultOr<FlatPtr> Process::sys$mount(Userspace<const Syscall::SC_mount_params*>
|
||||||
if (description_or_error.is_error())
|
if (description_or_error.is_error())
|
||||||
return EBADF;
|
return EBADF;
|
||||||
auto description = description_or_error.release_value();
|
auto description = description_or_error.release_value();
|
||||||
fs = Plan9FS::create(*description);
|
fs = TRY(Plan9FS::try_create(*description));
|
||||||
} else if (fs_type == "proc"sv || fs_type == "ProcFS"sv) {
|
} else if (fs_type == "proc"sv || fs_type == "ProcFS"sv) {
|
||||||
fs = TRY(ProcFS::try_create());
|
fs = TRY(ProcFS::try_create());
|
||||||
} else if (fs_type == "devpts"sv || fs_type == "DevPtsFS"sv) {
|
} else if (fs_type == "devpts"sv || fs_type == "DevPtsFS"sv) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue