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 <fsserver/directory_provider.h> 25 #include <fsserver/file_opening.h> 26 #include <fsserver/file_provider.h> 27 #include <fsserver/file_registry.h> 28 #include <fsserver/pager.h> 29 #include <fsserver/pages.h> 30 31 32 33 /* A registry of filesystem objects. */ 34 35 class FileObjectRegistry : public FileRegistry 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 /* Resource initialisation methods. */ 57 58 long make_directory_resource(fileid_t fileid, offset_t *size, 59 object_flags_t *object_flags, 60 DirectoryProvider *provider, 61 Resource **resource); 62 63 long make_file_resource(flags_t flags, fileid_t fileid, offset_t *size, 64 object_flags_t *object_flags, 65 FileProvider *provider, Resource **resource); 66 67 long make_resource(flags_t flags, fileid_t fileid, offset_t *size, 68 object_flags_t *object_flags, 69 Provider *provider, Resource **resource); 70 71 public: 72 explicit FileObjectRegistry(Pages *pages); 73 74 /* Resource discovery methods. */ 75 76 long find_provider(fileid_t fileid, Provider **provider); 77 78 /* Resource initialisation methods. */ 79 80 long get_resource(FileOpening *opening, const char *path, flags_t flags, 81 offset_t *size, object_flags_t *object_flags, 82 Resource **resource); 83 }; 84 85 // vim: tabstop=4 expandtab shiftwidth=4