libsqsh v1.5.2
Loading...
Searching...
No Matches
sqsh_mapper_private.h
Go to the documentation of this file.
1/******************************************************************************
2 * *
3 * Copyright (c) 2023-2024, Enno Boland <g@s01.de> *
4 * *
5 * Redistribution and use in source and binary forms, with or without *
6 * modification, are permitted provided that the following conditions are *
7 * met: *
8 * *
9 * * Redistributions of source code must retain the above copyright notice, *
10 * this list of conditions and the following disclaimer. *
11 * * Redistributions in binary form must reproduce the above copyright *
12 * notice, this list of conditions and the following disclaimer in the *
13 * documentation and/or other materials provided with the distribution. *
14 * *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS *
16 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, *
17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR *
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26 * *
27 ******************************************************************************/
28
34#ifndef SQSH_PRIVATE_MAPPER_H
35#define SQSH_PRIVATE_MAPPER_H
36
37#include <sqsh_mapper.h>
38
39#include "sqsh_reader_private.h"
40#include "sqsh_utils_private.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46struct SqshArchive;
47struct SqshConfig;
48
49/***************************************
50 * mapper/mapper.c
51 */
52
53struct SqshMapSlice;
54
58struct SqshMapper {
62 const struct SqshMemoryMapperImpl *impl;
63 size_t block_size;
64 uint64_t archive_size;
65 void *user_data;
66};
67
80 struct SqshMapper *mapper, const void *source,
81 const struct SqshConfig *config);
82
93
94/***************************************
95 * mapper/map_slice.c
96 */
97
105 struct SqshMapper *mapper;
106 uint64_t index;
107 uint8_t *data;
108 size_t size;
109};
110
120SQSH_NO_EXPORT const uint8_t *
121sqsh__map_slice_data(const struct SqshMapSlice *mapping);
122
133
158 struct SqshMapSlice *mapping, struct SqshMapper *mapper,
159 uint64_t address, uint64_t offset, size_t size);
160
161/***************************************
162 * mapper/map_manager.c
163 */
164
172 struct SqshMapper mapper;
173 struct CxLru lru;
174 struct CxRcRadixTree maps;
175 uint64_t archive_offset;
176 uint64_t block_count;
177 sqsh__mutex_t lock;
178};
179
192 struct SqshMapManager *manager, const void *input,
193 const struct SqshConfig *config);
194
204SQSH_NO_EXPORT uint64_t
206
216SQSH_NO_EXPORT size_t
218
231 struct SqshMapManager *manager, sqsh_index_t index,
232 const struct SqshMapSlice **target);
233
245 struct SqshMapManager *manager, const struct SqshMapSlice *mapping);
256
257/***************************************
258 * mapper/map_iterator.c
259 */
260
269 sqsh_index_t next_index;
270 uint64_t segment_count;
271 struct SqshMapManager *map_manager;
272 const struct SqshMapSlice *mapping;
273 const uint8_t *data;
274 size_t size;
275};
276
288 struct SqshMapIterator *iterator, struct SqshMapManager *manager,
289 uint64_t address);
290
305sqsh__map_iterator_next(struct SqshMapIterator *iterator, int *err);
306
320sqsh__map_iterator_skip(struct SqshMapIterator *iterator, uint64_t *offset);
321
330SQSH_NO_EXPORT const uint8_t *
332
341SQSH_NO_EXPORT size_t
343
352SQSH_NO_EXPORT size_t
354
364
365/***************************************
366 * mapper/map_reader.c
367 */
368
376 uint64_t address;
377 uint64_t upper_limit;
378 struct SqshMapIterator iterator;
379 struct SqshReader reader;
380};
381
394 struct SqshMapReader *reader, struct SqshMapManager *mapper,
395 const uint64_t start_address, uint64_t upper_limit);
396
405SQSH_NO_EXPORT size_t
407
419
431 struct SqshMapReader *reader, uint64_t offset, size_t size);
432
444
453SQSH_NO_EXPORT const uint8_t *
455
465
475
476#ifdef __cplusplus
477}
478#endif
479#endif /* SQSH_PRIVATE_MAPPER_H */
#define SQSH_NO_EXPORT
Do not export symbol.
Definition sqsh_common.h:64
#define SQSH_NO_UNUSED
Warn if return value is unused.
Definition sqsh_common.h:59
size_t sqsh_index_t
typedef used for indexing
Definition sqsh_common.h:69
SQSH_NO_EXPORT size_t sqsh__map_reader_remaining_direct(const struct SqshMapReader *reader)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_reader_init(struct SqshMapReader *reader, struct SqshMapManager *mapper, const uint64_t start_address, uint64_t upper_limit)
SQSH_NO_EXPORT int sqsh__map_iterator_cleanup(struct SqshMapIterator *iterator)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_manager_init(struct SqshMapManager *manager, const void *input, const struct SqshConfig *config)
SQSH_NO_EXPORT SQSH_NO_UNUSED bool sqsh__map_iterator_next(struct SqshMapIterator *iterator, int *err)
SQSH_NO_EXPORT SQSH_NO_UNUSED uint64_t sqsh__map_reader_address(const struct SqshMapReader *reader)
SQSH_NO_EXPORT const uint8_t * sqsh__map_reader_data(const struct SqshMapReader *reader)
SQSH_NO_EXPORT size_t sqsh__map_iterator_block_size(const struct SqshMapIterator *iterator)
SQSH_NO_EXPORT size_t sqsh__map_reader_size(const struct SqshMapReader *reader)
SQSH_NO_EXPORT size_t sqsh__map_iterator_size(const struct SqshMapIterator *iterator)
SQSH_NO_EXPORT int sqsh__mapper_cleanup(struct SqshMapper *mapper)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_reader_advance(struct SqshMapReader *reader, uint64_t offset, size_t size)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_iterator_init(struct SqshMapIterator *iterator, struct SqshMapManager *manager, uint64_t address)
SQSH_NO_EXPORT int sqsh__map_manager_release(struct SqshMapManager *manager, const struct SqshMapSlice *mapping)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_reader_all(struct SqshMapReader *reader)
SQSH_NO_EXPORT int sqsh__map_reader_cleanup(struct SqshMapReader *reader)
SQSH_NO_EXPORT const uint8_t * sqsh__map_iterator_data(const struct SqshMapIterator *iterator)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__mapper_init(struct SqshMapper *mapper, const void *source, const struct SqshConfig *config)
SQSH_NO_EXPORT int sqsh__map_slice_cleanup(struct SqshMapSlice *mapping)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_manager_get(struct SqshMapManager *manager, sqsh_index_t index, const struct SqshMapSlice **target)
SQSH_NO_EXPORT const uint8_t * sqsh__map_slice_data(const struct SqshMapSlice *mapping)
SQSH_NO_EXPORT int sqsh__map_manager_cleanup(struct SqshMapManager *manager)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_slice_init(struct SqshMapSlice *mapping, struct SqshMapper *mapper, uint64_t address, uint64_t offset, size_t size)
SQSH_NO_EXPORT size_t sqsh__map_slice_size(const struct SqshMapSlice *mapping)
SQSH_NO_EXPORT uint64_t sqsh__map_manager_size(const struct SqshMapManager *manager)
SQSH_NO_EXPORT size_t sqsh__map_manager_block_size(const struct SqshMapManager *manager)
The SqshConfig struct contains all the configuration options for a sqsh session.
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__map_iterator_skip(struct SqshMapIterator *iterator, uint64_t *offset)
Skips blocks until the block containing the offset is reached. Note that calling this function will i...
The map manager.
A reader over a mapping of data.
Represents a view into the data of an archive.
The mapper that is used to map chunks of the archive into memory.
The implementation of a memory mapper.
Definition sqsh_mapper.h:53