1.1 --- a/libfsserver/lib/files/host_file_opener.cc Tue Jul 13 00:26:11 2021 +0200
1.2 +++ b/libfsserver/lib/files/host_file_opener.cc Tue Jul 13 23:18:37 2021 +0200
1.3 @@ -19,8 +19,6 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 -#include <sys/stat.h>
1.8 -
1.9 #include "host_file_accessor.h"
1.10 #include "host_file_opener.h"
1.11
1.12 @@ -28,14 +26,25 @@
1.13
1.14 fileid_t HostFileOpener::get_fileid(const char *path)
1.15 {
1.16 - struct stat statbuf;
1.17 + std::lock_guard<std::mutex> guard(_lock);
1.18 +
1.19 + /* The inode number would be a good choice, but the L4Re read-only file
1.20 + implementation just provides the value of a counter!
1.21 +
1.22 + See: pkg/l4re-core/l4re_vfs/include/impl/ro_file_impl.h */
1.23 +
1.24 + std::string s(path);
1.25
1.26 - /* Obtain the inode number.
1.27 - NOTE: This does not handle errors! */
1.28 + HostFileIdentifiers::iterator it = _fileids.find(s);
1.29 +
1.30 + if (it != _fileids.end())
1.31 + return it->second;
1.32
1.33 - stat(path, &statbuf);
1.34 + fileid_t fileid = _fileids.size();
1.35
1.36 - return statbuf.st_ino;
1.37 + _fileids[s] = fileid;
1.38 +
1.39 + return fileid;
1.40 }
1.41
1.42 /* Return a new accessor for 'fileid'. */