vfs: reduce ROM-update rate Rom_file_system::stat

The 'stat' method is called for all paths, not just the specific file
system node of the ROM module. The ROM update is needed only in the
latter case.

Otherwise, when always updating the ROM on stat, stat calls on the VFS
become very expensive in the presence of a mounted ROM module if the ROM
is obtained from fs_rom (which re-watches the file and all its
individual path elements whenever the 'update' RPC function is called).
This commit is contained in:
Norman Feske 2018-04-19 11:54:00 +02:00
parent 0a72b37363
commit 6a12a6b4ba

View File

@ -146,10 +146,17 @@ 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);
Stat_result const result = Single_file_system::stat(path, out);
_rom.update();
out.size = _rom.valid() ? _rom.size() : 0;
/*
* If the stat call refers to our node ('Single_file_system::stat'
* found a file), obtain the size of the most current ROM module
* version.
*/
if (out.mode == STAT_MODE_FILE) {
_rom.update();
out.size = _rom.valid() ? _rom.size() : 0;
}
return result;
}