mirror of
https://github.com/RGBCube/serenity
synced 2025-07-03 05:32:13 +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
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);
|
m_lookup_cache.remove(name);
|
||||||
|
|
||||||
auto child_inode = fs().get_inode(child_id);
|
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);
|
did_remove_child(name);
|
||||||
return KSuccess;
|
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);
|
auto temp_buffer = ByteBuffer::create_uninitialized(size_to_allocate);
|
||||||
BufferStream stream(temp_buffer);
|
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 << (u32)entry.inode.index();
|
||||||
stream << (u8)entry.file_type;
|
stream << (u8)entry.file_type;
|
||||||
stream << (u32)entry.name_length;
|
stream << (u32)entry.name_length;
|
||||||
stream << entry.name;
|
stream << entry.name;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (result.is_error())
|
||||||
|
result.error();
|
||||||
|
|
||||||
stream.snip();
|
stream.snip();
|
||||||
|
|
||||||
if (static_cast<size_t>(size) < temp_buffer.size())
|
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();
|
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;
|
InodeIdentifier resolved_inode;
|
||||||
if (auto mount = find_mount_for_host(entry.inode))
|
if (auto mount = find_mount_for_host(entry.inode))
|
||||||
resolved_inode = mount->guest().identifier();
|
resolved_inode = mount->guest().identifier();
|
||||||
|
@ -329,7 +329,9 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
|
||||||
return KResult(-EROFS);
|
return KResult(-EROFS);
|
||||||
|
|
||||||
if (should_truncate_file) {
|
if (should_truncate_file) {
|
||||||
inode.truncate(0);
|
KResult result = inode.truncate(0);
|
||||||
|
if (result.is_error())
|
||||||
|
return result;
|
||||||
inode.set_mtime(kgettimeofday().tv_sec);
|
inode.set_mtime(kgettimeofday().tv_sec);
|
||||||
}
|
}
|
||||||
auto description = FileDescription::create(custody);
|
auto description = FileDescription::create(custody);
|
||||||
|
|
|
@ -126,7 +126,7 @@ private:
|
||||||
|
|
||||||
bool is_vfs_root(InodeIdentifier) const;
|
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(Inode&);
|
||||||
Mount* find_mount_for_host(InodeIdentifier);
|
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)
|
KResultOr<size_t> TTY::read(FileDescription&, size_t, u8* buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (Process::current()->pgid() != pgid()) {
|
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);
|
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)
|
KResultOr<size_t> TTY::write(FileDescription&, size_t, const u8* buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (Process::current()->pgid() != pgid()) {
|
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);
|
return KResult(-EINTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue