mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
Userland+LibCore: Update FileWatcher + its users for InodeWatcher 2.0
With the new InodeWatcher API, the old style of creating a watcher per inode will no longer work. Therefore the FileWatcher API has been updated to support multiple watches, and its users have also been refactored to the new style. At the moment, all operations done on a (Blocking)FileWatcher return Result objects, however, this may be changed in the future if it becomes too obnoxious. :^) Co-authored-by: Gunnar Beutner <gunnar@beutner.name>
This commit is contained in:
parent
fe5ca6ca27
commit
2159f90e00
12 changed files with 403 additions and 140 deletions
|
@ -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
|
||||
*/
|
||||
|
@ -22,9 +23,22 @@ int fcntl(int fd, int cmd, ...)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int watch_file(const char* path, size_t path_length)
|
||||
int create_inode_watcher(unsigned flags)
|
||||
{
|
||||
int rc = syscall(SC_watch_file, path, path_length);
|
||||
int rc = syscall(SC_create_inode_watcher, flags);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int inode_watcher_add_watch(int fd, const char* path, size_t path_length, unsigned event_mask)
|
||||
{
|
||||
Syscall::SC_inode_watcher_add_watch_params params { fd, { path, path_length }, event_mask };
|
||||
int rc = syscall(SC_inode_watcher_add_watch, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int inode_watcher_remove_watch(int fd, int wd)
|
||||
{
|
||||
int rc = syscall(SC_inode_watcher_remove_watch, fd, wd);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue