paul@93 | 1 | /* |
paul@93 | 2 | * An opener for a test file containing generated content. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@9 | 22 | #include "test_file_accessor.h" |
paul@9 | 23 | #include "test_file_opener.h" |
paul@9 | 24 | |
paul@9 | 25 | #include <stdlib.h> |
paul@9 | 26 | |
paul@9 | 27 | /* Support for providing access to files. */ |
paul@9 | 28 | |
paul@224 | 29 | TestFileOpener::TestFileOpener(ResourceRegistry *registry, offset_t file_size) |
paul@209 | 30 | : OpenerResource(registry), _file_size(file_size) |
paul@9 | 31 | { |
paul@9 | 32 | } |
paul@9 | 33 | |
paul@156 | 34 | TestFileOpener::~TestFileOpener() |
paul@156 | 35 | { |
paul@156 | 36 | } |
paul@156 | 37 | |
paul@156 | 38 | bool TestFileOpener::accessing_directory(const char *path, flags_t flags, fileid_t fileid) |
paul@156 | 39 | { |
paul@156 | 40 | (void) path; (void) flags; (void) fileid; |
paul@156 | 41 | return false; |
paul@156 | 42 | } |
paul@156 | 43 | |
paul@156 | 44 | bool TestFileOpener::accessing_file(const char *path, flags_t flags, fileid_t fileid) |
paul@156 | 45 | { |
paul@156 | 46 | (void) path; (void) flags; (void) fileid; |
paul@156 | 47 | return true; |
paul@156 | 48 | } |
paul@156 | 49 | |
paul@9 | 50 | /* Return a file identifier for the given 'path'. */ |
paul@9 | 51 | |
paul@146 | 52 | long TestFileOpener::get_fileid(const char *path, flags_t flags, fileid_t *fileid) |
paul@9 | 53 | { |
paul@143 | 54 | (void) flags; |
paul@143 | 55 | |
paul@9 | 56 | /* NOTE: Just convert the path to a number. */ |
paul@9 | 57 | |
paul@146 | 58 | *fileid = atol(path); |
paul@146 | 59 | return L4_EOK; |
paul@9 | 60 | } |
paul@9 | 61 | |
paul@9 | 62 | /* Return a new accessor for 'fileid'. */ |
paul@9 | 63 | |
paul@202 | 64 | long TestFileOpener::make_accessor(const char *path, flags_t flags, |
paul@202 | 65 | fileid_t fileid, Accessor **accessor) |
paul@9 | 66 | { |
paul@143 | 67 | (void) flags; (void) path; |
paul@143 | 68 | *accessor = new TestFileAccessor(fileid, _file_size); |
paul@143 | 69 | return L4_EOK; |
paul@9 | 70 | } |
paul@9 | 71 | |
paul@202 | 72 | /* Return a new directory accessor for 'fileid'. */ |
paul@202 | 73 | |
paul@202 | 74 | long TestFileOpener::make_directory_accessor(const char *path, flags_t flags, |
paul@202 | 75 | fileid_t fileid, |
paul@202 | 76 | DirectoryAccessor **accessor) |
paul@202 | 77 | { |
paul@202 | 78 | (void) flags; (void) path; (void) fileid; (void) accessor; |
paul@202 | 79 | return -L4_EIO; |
paul@202 | 80 | } |
paul@202 | 81 | |
paul@232 | 82 | /* Remove a filesystem object. */ |
paul@232 | 83 | |
paul@232 | 84 | long TestFileOpener::remove_object(const char *path, fileid_t fileid) |
paul@232 | 85 | { |
paul@232 | 86 | (void) path; (void) fileid; |
paul@232 | 87 | return L4_EOK; |
paul@232 | 88 | } |
paul@232 | 89 | |
paul@232 | 90 | /* Unlink a filesystem object. */ |
paul@232 | 91 | |
paul@232 | 92 | long TestFileOpener::unlink_object(const char *path, fileid_t fileid) |
paul@232 | 93 | { |
paul@232 | 94 | (void) path; (void) fileid; |
paul@232 | 95 | return -L4_EIO; |
paul@232 | 96 | } |
paul@232 | 97 | |
paul@9 | 98 | // vim: tabstop=4 expandtab shiftwidth=4 |