vfs: let rom fs update ROM when opening file

This commit is contained in:
Norman Feske 2015-06-01 19:45:01 +02:00 committed by Christian Helmuth
parent ffaf65efa0
commit f917728ecb

View File

@ -58,6 +58,26 @@ class Vfs::Rom_file_system : public Single_file_system
static char const *name() { return "rom"; }
/*********************************
** Directory-service interface **
********************************/
/*
* Overwrite the default open function to update the ROM dataspace
* each time when opening the corresponding file.
*/
Open_result open(char const *path, unsigned,
Vfs_handle **out_handle) override
{
Open_result const result =
Single_file_system::open(path, 0, out_handle);
_rom.update();
return result;
}
/********************************
** File I/O service interface **
********************************/
@ -65,7 +85,10 @@ class Vfs::Rom_file_system : public Single_file_system
Stat_result stat(char const *path, Stat &out) override
{
Stat_result result = Single_file_system::stat(path, out);
out.size = _rom.size();
_rom.update();
out.size = _rom.is_valid() ? _rom.size() : 0;
return result;
}