mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Propagate a few KResults properly in FileSystem subsystems
Propagating un-obsevered KResults up the stack.
This commit is contained in:
parent
c4c6d9367d
commit
d67069d922
Notes:
sideshowbarker
2024-07-19 04:16:58 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/d67069d9224 Pull-request: https://github.com/SerenityOS/serenity/pull/3001 Reviewed-by: https://github.com/awesomekling
5 changed files with 20 additions and 8 deletions
|
@ -1023,7 +1023,9 @@ KResult Ext2FSInode::remove_child(const StringView& name)
|
|||
m_lookup_cache.remove(name);
|
||||
|
||||
auto child_inode = fs().get_inode(child_id);
|
||||
child_inode->decrement_link_count();
|
||||
result = child_inode->decrement_link_count();
|
||||
if (result.is_error())
|
||||
return result;
|
||||
|
||||
did_remove_child(name);
|
||||
return KSuccess;
|
||||
|
|
|
@ -187,13 +187,17 @@ ssize_t FileDescription::get_dir_entries(u8* buffer, ssize_t size)
|
|||
|
||||
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
|
||||
BufferStream stream(temp_buffer);
|
||||
VFS::the().traverse_directory_inode(*m_inode, [&stream](auto& entry) {
|
||||
KResult result = VFS::the().traverse_directory_inode(*m_inode, [&stream](auto& entry) {
|
||||
stream << (u32)entry.inode.index();
|
||||
stream << (u8)entry.file_type;
|
||||
stream << (u32)entry.name_length;
|
||||
stream << entry.name;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (result.is_error())
|
||||
result.error();
|
||||
|
||||
stream.snip();
|
||||
|
||||
if (static_cast<size_t>(size) < temp_buffer.size())
|
||||
|
|
|
@ -191,9 +191,9 @@ bool VFS::is_vfs_root(InodeIdentifier inode) const
|
|||
return inode == root_inode_id();
|
||||
}
|
||||
|
||||
void VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
KResult VFS::traverse_directory_inode(Inode& dir_inode, Function<bool(const FS::DirectoryEntry&)> callback)
|
||||
{
|
||||
dir_inode.traverse_as_directory([&](const FS::DirectoryEntry& entry) {
|
||||
return dir_inode.traverse_as_directory([&](const FS::DirectoryEntry& entry) {
|
||||
InodeIdentifier resolved_inode;
|
||||
if (auto mount = find_mount_for_host(entry.inode))
|
||||
resolved_inode = mount->guest().identifier();
|
||||
|
@ -329,7 +329,9 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
|
|||
return KResult(-EROFS);
|
||||
|
||||
if (should_truncate_file) {
|
||||
inode.truncate(0);
|
||||
KResult result = inode.truncate(0);
|
||||
if (result.is_error())
|
||||
return result;
|
||||
inode.set_mtime(kgettimeofday().tv_sec);
|
||||
}
|
||||
auto description = FileDescription::create(custody);
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
|
||||
bool is_vfs_root(InodeIdentifier) const;
|
||||
|
||||
void traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntry&)>);
|
||||
KResult traverse_directory_inode(Inode&, Function<bool(const FS::DirectoryEntry&)>);
|
||||
|
||||
Mount* find_mount_for_host(Inode&);
|
||||
Mount* find_mount_for_host(InodeIdentifier);
|
||||
|
|
|
@ -55,7 +55,9 @@ void TTY::set_default_termios()
|
|||
KResultOr<size_t> TTY::read(FileDescription&, size_t, u8* buffer, size_t size)
|
||||
{
|
||||
if (Process::current()->pgid() != pgid()) {
|
||||
Process::current()->send_signal(SIGTTIN, nullptr);
|
||||
KResult result = Process::current()->send_signal(SIGTTIN, nullptr);
|
||||
if (result.is_error())
|
||||
return result;
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
|
||||
|
@ -91,7 +93,9 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, u8* buffer, size_t size)
|
|||
KResultOr<size_t> TTY::write(FileDescription&, size_t, const u8* buffer, size_t size)
|
||||
{
|
||||
if (Process::current()->pgid() != pgid()) {
|
||||
Process::current()->send_signal(SIGTTOU, nullptr);
|
||||
KResult result = Process::current()->send_signal(SIGTTOU, nullptr);
|
||||
if (result.is_error())
|
||||
return result;
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue