From b2bc718c1f3239795d396a213e347e95f979ee70 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 19 Feb 2020 10:32:14 +0100 Subject: [PATCH] fs_query: report 'writeable' attribute for files --- repos/gems/recipes/pkg/test-fs_tool/runtime | 2 +- repos/gems/run/fs_query.run | 6 +++--- repos/gems/src/app/fs_query/main.cc | 13 ++++++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/repos/gems/recipes/pkg/test-fs_tool/runtime b/repos/gems/recipes/pkg/test-fs_tool/runtime index 8a96bccf9..34278e5b0 100644 --- a/repos/gems/recipes/pkg/test-fs_tool/runtime +++ b/repos/gems/recipes/pkg/test-fs_tool/runtime @@ -10,7 +10,7 @@ [init -> report_rom] report 'test -> fs_query -> listing' [init -> report_rom] <listing> [init -> report_rom] <dir path="/fs/items"> - [init -> report_rom] <file name="1">first</file> + [init -> report_rom] <file name="1" writeable="yes">first</file> [init -> report_rom] </dir> [init -> report_rom] </listing> diff --git a/repos/gems/run/fs_query.run b/repos/gems/run/fs_query.run index 8a39a7d40..f53bb68d0 100644 --- a/repos/gems/run/fs_query.run +++ b/repos/gems/run/fs_query.run @@ -190,9 +190,9 @@ regsub {.*report 'fs_query -> listing'} $output {} output compare_output_to { [init -> report_rom] [init -> report_rom] -[init -> report_rom] fourth -[init -> report_rom] first -[init -> report_rom] updated +[init -> report_rom] fourth +[init -> report_rom] first +[init -> report_rom] updated [init -> report_rom] [init -> report_rom] [init -> report_rom] diff --git a/repos/gems/src/app/fs_query/main.cc b/repos/gems/src/app/fs_query/main.cc index 9bfd19791..598e31264 100644 --- a/repos/gems/src/app/fs_query/main.cc +++ b/repos/gems/src/app/fs_query/main.cc @@ -24,6 +24,7 @@ namespace Fs_query { struct Watched_file; struct Watched_directory; struct Main; + using Node_rwx = Vfs::Node_rwx; } @@ -31,11 +32,13 @@ struct Fs_query::Watched_file { File_content::Path const _name; + Node_rwx const _rwx; + Watcher _watcher; - Watched_file(Directory const &dir, File_content::Path name, + Watched_file(Directory const &dir, File_content::Path name, Node_rwx rwx, Vfs::Watch_response_handler &handler) - : _name(name), _watcher(dir, name, handler) { } + : _name(name), _rwx(rwx), _watcher(dir, name, handler) { } virtual ~Watched_file() { } @@ -68,6 +71,9 @@ struct Fs_query::Watched_file xml.node("file", [&] () { xml.attribute("name", _name); + if (_rwx.writeable) + xml.attribute("writeable", "yes"); + if (query.attribute_value("content", false)) _gen_content(xml, alloc, dir); }); @@ -110,7 +116,8 @@ struct Fs_query::Watched_directory || (entry.type() == Dirent_type::TRANSACTIONAL_FILE); if (file) { try { - new (_alloc) Registered(_files, _dir, entry.name(), handler); + new (_alloc) Registered(_files, _dir, entry.name(), + entry.rwx(), handler); } catch (...) { } } });