paul@202 | 1 | /* |
paul@202 | 2 | * An object providing access to directory functionality. |
paul@202 | 3 | * |
paul@202 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@202 | 5 | * |
paul@202 | 6 | * This program is free software; you can redistribute it and/or |
paul@202 | 7 | * modify it under the terms of the GNU General Public License as |
paul@202 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@202 | 9 | * the License, or (at your option) any later version. |
paul@202 | 10 | * |
paul@202 | 11 | * This program is distributed in the hope that it will be useful, |
paul@202 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@202 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@202 | 14 | * GNU General Public License for more details. |
paul@202 | 15 | * |
paul@202 | 16 | * You should have received a copy of the GNU General Public License |
paul@202 | 17 | * along with this program; if not, write to the Free Software |
paul@202 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@202 | 19 | * Boston, MA 02110-1301, USA |
paul@202 | 20 | */ |
paul@202 | 21 | |
paul@202 | 22 | #include "directory_provider.h" |
paul@221 | 23 | #include "directory_resource.h" |
paul@202 | 24 | |
paul@202 | 25 | |
paul@202 | 26 | |
paul@202 | 27 | /* Initialise the provider. */ |
paul@202 | 28 | |
paul@221 | 29 | DirectoryProvider::DirectoryProvider(fileid_t fileid, FileRegistry *registry, |
paul@221 | 30 | DirectoryAccessor *accessor) |
paul@221 | 31 | : Provider(fileid, registry), _accessor(accessor) |
paul@202 | 32 | { |
paul@202 | 33 | } |
paul@202 | 34 | |
paul@202 | 35 | /* Deallocate the provider's resources. */ |
paul@202 | 36 | |
paul@202 | 37 | DirectoryProvider::~DirectoryProvider() |
paul@202 | 38 | { |
paul@202 | 39 | } |
paul@202 | 40 | |
paul@202 | 41 | /* Return the accessor. */ |
paul@202 | 42 | |
paul@202 | 43 | DirectoryAccessor *DirectoryProvider::accessor() |
paul@202 | 44 | { |
paul@202 | 45 | return _accessor; |
paul@202 | 46 | } |
paul@202 | 47 | |
paul@221 | 48 | /* Return a directory resource initialised with this provider. */ |
paul@221 | 49 | |
paul@221 | 50 | long DirectoryProvider::make_resource(offset_t *size, |
paul@221 | 51 | object_flags_t *object_flags, |
paul@221 | 52 | Resource **resource) |
paul@221 | 53 | { |
paul@221 | 54 | /* Provide non-file values for certain outputs. */ |
paul@221 | 55 | |
paul@221 | 56 | *size = 0; |
paul@221 | 57 | *object_flags = 0; |
paul@221 | 58 | |
paul@221 | 59 | /* Initialise the resource with the provider and a reference to the registry |
paul@221 | 60 | for detaching from the provider. */ |
paul@221 | 61 | |
paul@221 | 62 | this->attach(); |
paul@221 | 63 | *resource = new DirectoryResource(_fileid, this, _registry); |
paul@221 | 64 | return L4_EOK; |
paul@221 | 65 | } |
paul@221 | 66 | |
paul@202 | 67 | // vim: tabstop=4 expandtab shiftwidth=4 |