libc: add VFS watch handle accessor

Issue #3450
This commit is contained in:
Josef Söntgen 2019-08-12 18:10:14 +02:00 committed by Christian Helmuth
parent 18e586daed
commit 316f9e4df3
2 changed files with 28 additions and 0 deletions

View File

@ -767,6 +767,17 @@ struct Libc::Kernel final : Vfs::Io_response_handler,
}
}
/**
* Alloc new watch handler for given path
*/
Vfs::Vfs_watch_handle *alloc_watch_handle(char const *path)
{
Vfs::Vfs_watch_handle *watch_handle { nullptr };
typedef Vfs::Directory_service::Watch_result Result;
return _libc_env.vfs().watch(path, &watch_handle, _heap) == Result::WATCH_OK
? watch_handle : nullptr;
}
/****************************************
** Vfs::Io_response_handler interface **
@ -857,6 +868,12 @@ void Libc::dispatch_pending_io_signals()
}
Vfs::Vfs_watch_handle *Libc::watch(char const *path)
{
return kernel->alloc_watch_handle(path);
}
Genode::Duration Libc::current_time()
{
return kernel->current_time();

View File

@ -23,6 +23,7 @@
#include <base/duration.h>
#include <util/xml_node.h>
#include <vfs/vfs_handle.h>
namespace Libc {
@ -51,6 +52,16 @@ namespace Libc {
void dispatch_pending_io_signals();
/**
* Get watch handle for given path
*
* \param path path that should be be watched
*
* \return point to the watch handle object or a nullptr
* when the watch operation failed
*/
Vfs::Vfs_watch_handle *watch(char const *path);
/**
* Get time since startup in ms
*/