L4Re/departure

libfsserver/include/fsserver/file_registry.h

202:85396ddb3260
2021-09-20 Paul Boddie Introduced directory resource, provider and accessor objects. The opendir operation has been moved from the opener to the directory resource, and the opener resource and file paging coordinator now support the creation of directory-related objects.
     1 /*     2  * A registry of filesystem objects.     3  *     4  * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software; you can redistribute it and/or     7  * modify it under the terms of the GNU General Public License as     8  * published by the Free Software Foundation; either version 2 of     9  * the License, or (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21     22 #pragma once    23     24 #include <map>    25 #include <mutex>    26     27 #include <mem/types.h>    28 #include <fsserver/accountable.h>    29     30     31     32 /* Mapping type from file identifiers to page mappers. */    33     34 typedef std::map<fileid_t, Accountable *> FileMapping;    35 typedef std::pair<fileid_t, Accountable *> FileMappingEntry;    36     37     38     39 /* A registry of filesystem objects. */    40     41 class FileRegistry    42 {    43 protected:    44     FileMapping _providers;    45     std::mutex _lock;    46     47     /* Filesystem object access. */    48     49     Accountable *get(fileid_t fileid);    50     51     void remove(fileid_t fileid, Accountable *obj);    52     53     void set(fileid_t fileid, Accountable *obj);    54     55 public:    56     /* Methods for resources. */    57     58     void detach(fileid_t fileid, Accountable *mapper);    59 };    60     61 // vim: tabstop=4 expandtab shiftwidth=4