# HG changeset patch # User Paul Boddie # Date 1626211117 -7200 # Node ID 404caa4bc10de0dba561e22da34d8cd2fdc8ed42 # Parent ac4025f8f4e03e5a49556f3a0fe36eed270c2508 Replaced unhelpful L4Re-provided inode numbers as file identifiers in the host- based file implementations. diff -r ac4025f8f4e0 -r 404caa4bc10d libfsserver/include/fsserver/host_file_opener.h --- a/libfsserver/include/fsserver/host_file_opener.h Tue Jul 13 00:26:11 2021 +0200 +++ b/libfsserver/include/fsserver/host_file_opener.h Tue Jul 13 23:18:37 2021 +0200 @@ -22,16 +22,29 @@ #pragma once #include +#include +#include #include +/* Collection data types. */ + +typedef std::map HostFileIdentifiers; + + + /* Support for providing access to files. */ class HostFileOpener : public OpenerResource { protected: + std::mutex _lock; + + /* File identifier register. */ + + HostFileIdentifiers _fileids; /* Configurable methods. */ diff -r ac4025f8f4e0 -r 404caa4bc10d libfsserver/lib/files/host_file_opener.cc --- a/libfsserver/lib/files/host_file_opener.cc Tue Jul 13 00:26:11 2021 +0200 +++ b/libfsserver/lib/files/host_file_opener.cc Tue Jul 13 23:18:37 2021 +0200 @@ -19,8 +19,6 @@ * Boston, MA 02110-1301, USA */ -#include - #include "host_file_accessor.h" #include "host_file_opener.h" @@ -28,14 +26,25 @@ fileid_t HostFileOpener::get_fileid(const char *path) { - struct stat statbuf; + std::lock_guard guard(_lock); + + /* The inode number would be a good choice, but the L4Re read-only file + implementation just provides the value of a counter! + + See: pkg/l4re-core/l4re_vfs/include/impl/ro_file_impl.h */ + + std::string s(path); - /* Obtain the inode number. - NOTE: This does not handle errors! */ + HostFileIdentifiers::iterator it = _fileids.find(s); + + if (it != _fileids.end()) + return it->second; - stat(path, &statbuf); + fileid_t fileid = _fileids.size(); - return statbuf.st_ino; + _fileids[s] = fileid; + + return fileid; } /* Return a new accessor for 'fileid'. */