1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 20:25:07 +00:00

Kernel: Implement multi-watch InodeWatcher :^)

This patch modifies InodeWatcher to switch to a one watcher, multiple
watches architecture.  The following changes have been made:

- The watch_file syscall is removed, and in its place the
  create_iwatcher, iwatcher_add_watch and iwatcher_remove_watch calls
  have been added.
- InodeWatcher now holds multiple WatchDescriptions for each file that
  is being watched.
- The InodeWatcher file descriptor can be read from to receive events on
  all watched files.

Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
This commit is contained in:
sin-ack 2021-05-12 19:17:51 +00:00 committed by Andreas Kling
parent 2de11b0dc8
commit fe5ca6ca27
16 changed files with 521 additions and 262 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -1033,6 +1034,8 @@ KResultOr<ssize_t> Ext2FSInode::write_bytes(off_t offset, ssize_t count, const U
nwritten += num_bytes_to_copy;
}
did_modify_contents();
dbgln_if(EXT2_VERY_DEBUG, "Ext2FSInode[{}]::write_bytes(): After write, i_size={}, i_blocks={} ({} blocks in list)", identifier(), size(), m_raw_inode.i_blocks, m_block_list.size());
return nwritten;
}
@ -1208,7 +1211,7 @@ KResult Ext2FSInode::add_child(Inode& child, const StringView& name, mode_t mode
return result;
m_lookup_cache.set(name, child.index());
did_add_child(child.identifier());
did_add_child(child.identifier(), name);
return KSuccess;
}
@ -1245,7 +1248,7 @@ KResult Ext2FSInode::remove_child(const StringView& name)
if (result.is_error())
return result;
did_remove_child(child_id);
did_remove_child(child_id, name);
return KSuccess;
}
@ -1674,10 +1677,15 @@ KResult Ext2FSInode::decrement_link_count()
if (fs().is_readonly())
return EROFS;
VERIFY(m_raw_inode.i_links_count);
--m_raw_inode.i_links_count;
set_metadata_dirty(true);
if (m_raw_inode.i_links_count == 0)
did_delete_self();
if (ref_count() == 1 && m_raw_inode.i_links_count == 0)
fs().uncache_inode(index());
set_metadata_dirty(true);
return KSuccess;
}