mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 11:27:29 +00:00
vfs: LOG file system
This commit is contained in:
parent
c3c6a82d13
commit
83a03df6a4
68
os/include/vfs/log_file_system.h
Normal file
68
os/include/vfs/log_file_system.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* \brief LOG file system
|
||||
* \author Norman Feske
|
||||
* \date 2014-04-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__VFS__LOG_FILE_SYSTEM_H_
|
||||
#define _INCLUDE__VFS__LOG_FILE_SYSTEM_H_
|
||||
|
||||
#include <log_session/connection.h>
|
||||
#include <vfs/single_file_system.h>
|
||||
|
||||
namespace Vfs { class Log_file_system; }
|
||||
|
||||
|
||||
class Vfs::Log_file_system : public Single_file_system
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Log_connection _log;
|
||||
|
||||
public:
|
||||
|
||||
Log_file_system(Xml_node config)
|
||||
:
|
||||
Single_file_system(NODE_TYPE_CHAR_DEVICE, name(), config)
|
||||
{ }
|
||||
|
||||
static const char *name() { return "log"; }
|
||||
|
||||
|
||||
/********************************
|
||||
** File I/O service interface **
|
||||
********************************/
|
||||
|
||||
Write_result write(Vfs_handle *, char const *src, size_t count, size_t &out_count) override
|
||||
{
|
||||
out_count = count;
|
||||
|
||||
/* count does not include the trailing '\0' */
|
||||
while (count > 0) {
|
||||
char tmp[128];
|
||||
int const curr_count = min(count, sizeof(tmp) - 1);
|
||||
strncpy(tmp, src, curr_count);
|
||||
tmp[curr_count > 0 ? curr_count : 0] = 0;
|
||||
_log.write(tmp);
|
||||
count -= curr_count;
|
||||
src += curr_count;
|
||||
}
|
||||
|
||||
return WRITE_OK;
|
||||
}
|
||||
|
||||
Read_result read(Vfs_handle *, char *dst, size_t count, size_t &out_count) override
|
||||
{
|
||||
out_count = 0;
|
||||
return READ_OK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__VFS__LOG_FILE_SYSTEM_H_ */
|
Loading…
x
Reference in New Issue
Block a user