1 /* 2 * An opener for a test file containing generated content. 3 * 4 * Copyright (C) 2021, 2022 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 #include "test_file_accessor.h" 23 #include "test_file_opener.h" 24 25 #include <stdlib.h> 26 27 /* Support for providing access to files. */ 28 29 TestFileOpener::TestFileOpener(ResourceRegistry *registry, offset_t file_size) 30 : OpenerResource(registry), _file_size(file_size) 31 { 32 } 33 34 TestFileOpener::~TestFileOpener() 35 { 36 } 37 38 bool TestFileOpener::accessing_directory(flags_t flags, fileid_t fileid) 39 { 40 (void) flags; (void) fileid; 41 return false; 42 } 43 44 bool TestFileOpener::accessing_file(flags_t flags, fileid_t fileid) 45 { 46 (void) flags; (void) fileid; 47 return true; 48 } 49 50 /* Test if a directory is empty. */ 51 52 bool TestFileOpener::directory_is_empty(fileid_t fileid) 53 { 54 (void) fileid; 55 return false; 56 } 57 58 /* Return a file identifier for the given 'path'. */ 59 60 long TestFileOpener::get_fileid(const char *path, flags_t flags, fileid_t *fileid) 61 { 62 (void) flags; 63 64 /* NOTE: Just convert the path to a number. */ 65 66 *fileid = atol(path); 67 return L4_EOK; 68 } 69 70 /* Return a new accessor for 'fileid'. */ 71 72 long TestFileOpener::make_accessor(flags_t flags, fileid_t fileid, 73 Accessor **accessor) 74 { 75 (void) flags; 76 *accessor = new TestFileAccessor(fileid, _file_size); 77 return L4_EOK; 78 } 79 80 /* Return a new directory accessor for 'fileid'. */ 81 82 long TestFileOpener::make_directory_accessor(flags_t flags, fileid_t fileid, 83 DirectoryAccessor **accessor) 84 { 85 (void) flags; (void) fileid; (void) accessor; 86 return -L4_EIO; 87 } 88 89 90 91 /* Make a new directory. */ 92 93 long TestFileOpener::make_directory_object(const char *path, sys_mode_t mode) 94 { 95 (void) path; (void) mode; 96 return -L4_EIO; 97 } 98 99 /* Remove a filesystem object. */ 100 101 long TestFileOpener::remove_object(fileid_t fileid) 102 { 103 (void) fileid; 104 return L4_EOK; 105 } 106 107 /* Rename a filesystem object, placing source inside the parent of target. */ 108 109 long TestFileOpener::rename_object(const char *source, const char *target) 110 { 111 (void) source; (void) target; 112 return -L4_EIO; 113 } 114 115 /* Populate a memory region with statistics metadata for a filesystem object. */ 116 117 long TestFileOpener::stat_object(const char *path, void *base, offset_t size) 118 { 119 (void) path; (void) base; (void) size; 120 return -L4_EIO; 121 } 122 123 /* Unlink a filesystem object. */ 124 125 long TestFileOpener::unlink_object(fileid_t parent_fileid, fileid_t fileid) 126 { 127 (void) parent_fileid; (void) fileid; 128 return -L4_EIO; 129 } 130 131 // vim: tabstop=4 expandtab shiftwidth=4