1 /* 2 * A registry of filesystem object resources. 3 * 4 * Copyright (C) 2021, 2022 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 <fsserver/directory_provider.h> 25 #include <fsserver/file_opening.h> 26 #include <fsserver/file_provider.h> 27 #include <fsserver/pager.h> 28 #include <fsserver/pages.h> 29 #include <fsserver/provider_registry.h> 30 31 32 33 /* A registry of filesystem object resources. */ 34 35 class ResourceRegistry : public ProviderRegistry 36 { 37 protected: 38 Pages *_pages; 39 40 map_flags_t get_flags(flags_t flags); 41 42 /* Provider initialisation methods. */ 43 44 long make_directory_provider(FileOpening *opening, flags_t flags, 45 fileid_t fileid, Provider **provider); 46 47 long make_file_provider(FileOpening *opening, flags_t flags, 48 fileid_t fileid, Provider **provider); 49 50 long make_provider(FileOpening *opening, flags_t flags, 51 fileid_t fileid, Provider **provider); 52 53 /* Provider manipulation methods. */ 54 55 long _remove_provider(FileOpening *opening, const char *path, fileid_t fileid); 56 57 public: 58 explicit ResourceRegistry(Pages *pages); 59 60 /* Provider discovery methods. 61 NOTE: To be protected, potentially. */ 62 63 long find_provider(fileid_t fileid, Provider **provider); 64 65 /* Resource initialisation methods. */ 66 67 long get_resource(FileOpening *opening, const char *path, flags_t flags, 68 offset_t *size, object_flags_t *object_flags, 69 Resource **resource); 70 71 /* Provider manipulation methods. */ 72 73 long remove_provider(FileOpening *opening, const char *path); 74 75 long rename_provider(FileOpening *opening, const char *source, const char *target); 76 }; 77 78 // vim: tabstop=4 expandtab shiftwidth=4