vfs/log: allow output redirection via '> /dev/log'

Issue #3578
This commit is contained in:
Norman Feske 2019-12-04 11:22:57 +01:00 committed by Christian Helmuth
parent cd92b32622
commit 9f7b8c1a17

View File

@ -142,7 +142,7 @@ class Vfs::Log_file_system : public Single_file_system
Genode::Xml_node config) Genode::Xml_node config)
: :
Single_file_system(Node_type::CONTINUOUS_FILE, name(), Single_file_system(Node_type::CONTINUOUS_FILE, name(),
Node_rwx::ro(), config), Node_rwx::wo(), config),
_label(config.attribute_value("label", Label())), _label(config.attribute_value("label", Label())),
_log(_log_session(env.env())) _log(_log_session(env.env()))
{ } { }
@ -150,6 +150,7 @@ class Vfs::Log_file_system : public Single_file_system
static const char *name() { return "log"; } static const char *name() { return "log"; }
char const *type() override { return "log"; } char const *type() override { return "log"; }
/********************************* /*********************************
** Directory service interface ** ** Directory service interface **
*********************************/ *********************************/
@ -169,6 +170,20 @@ class Vfs::Log_file_system : public Single_file_system
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; } catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; } catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; }
} }
/*******************************
** File_io_service interface **
*******************************/
Ftruncate_result ftruncate(Vfs_handle *, file_size) override
{
/*
* Return success to allow for output redirection via '> /dev/log'.
* The shell call ftruncate after opening the destination file.
*/
return FTRUNCATE_OK;
}
}; };
#endif /* _INCLUDE__VFS__LOG_FILE_SYSTEM_H_ */ #endif /* _INCLUDE__VFS__LOG_FILE_SYSTEM_H_ */