1 /* 2 * A registry of filesystem object resources. 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 <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, const char *path, 45 flags_t flags, fileid_t fileid, 46 Provider **provider); 47 48 long make_file_provider(FileOpening *opening, const char *path, 49 flags_t flags, fileid_t fileid, 50 Provider **provider); 51 52 long make_provider(FileOpening *opening, const char *path, 53 flags_t flags, fileid_t fileid, 54 Provider **provider); 55 56 /* Provider manipulation methods. */ 57 58 long _remove_provider(FileOpening *opening, const char *path, 59 fileid_t fileid); 60 61 public: 62 explicit ResourceRegistry(Pages *pages); 63 64 /* Provider discovery methods. 65 NOTE: To be protected, potentially. */ 66 67 long find_provider(fileid_t fileid, Provider **provider); 68 69 /* Resource initialisation methods. */ 70 71 long get_resource(FileOpening *opening, const char *path, flags_t flags, 72 offset_t *size, object_flags_t *object_flags, 73 Resource **resource); 74 75 /* Provider manipulation methods. */ 76 77 long remove_provider(FileOpening *opening, const char *path); 78 79 long rename_provider(FileOpening *opening, const char *source, const char *target); 80 }; 81 82 // vim: tabstop=4 expandtab shiftwidth=4