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 public: 57 explicit ResourceRegistry(Pages *pages); 58 59 /* Resource discovery methods. */ 60 61 long find_provider(fileid_t fileid, Provider **provider); 62 63 /* Resource initialisation methods. */ 64 65 long get_resource(FileOpening *opening, const char *path, flags_t flags, 66 offset_t *size, object_flags_t *object_flags, 67 Resource **resource); 68 }; 69 70 // vim: tabstop=4 expandtab shiftwidth=4