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

Kernel: Tidy up SysFS construction

- Use KResultOr and TRY() to propagate errors
- Check for OOM errors
- Move allocation out of constructors

There's still a lot more to do here, as SysFS is still quite brittle
in the face of memory pressure.
This commit is contained in:
Andreas Kling 2021-09-06 11:06:20 +02:00
parent 788b91a65c
commit 47bfbe343b
5 changed files with 19 additions and 19 deletions

View file

@ -32,7 +32,7 @@ public:
virtual KResultOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, FileDescription*) { return EROFS; }
virtual KResult refresh_data(FileDescription&) const { return KSuccess; }
virtual NonnullRefPtr<SysFSInode> to_inode(SysFS const&) const;
virtual KResultOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const&) const;
InodeIndex component_index() const { return m_component_index; };
@ -51,7 +51,7 @@ public:
virtual KResult traverse_as_directory(unsigned, Function<bool(FileSystem::DirectoryEntryView const&)>) const override;
virtual RefPtr<SysFSComponent> lookup(StringView name) override;
virtual NonnullRefPtr<SysFSInode> to_inode(SysFS const& sysfs_instance) const override final;
virtual KResultOr<NonnullRefPtr<SysFSInode>> to_inode(SysFS const& sysfs_instance) const override final;
protected:
explicit SysFSDirectory(StringView name);