libsqsh v1.5.2
Loading...
Searching...
No Matches
sqsh_archive.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_ARCHIVE_H
35#define SQSH_ARCHIVE_H
36
37#include "sqsh_common.h"
38#include "sqsh_data.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44struct SqshInodeMap;
45struct SqshIdTable;
46struct SqshExportTable;
47struct SqshXattrTable;
49
50/***************************************
51 * archive/trailing_context.c
52 */
53
55
64size_t sqsh_trailing_size(const struct SqshTrailingContext *context);
65
74const uint8_t *sqsh_trailing_data(const struct SqshTrailingContext *context);
75
76/***************************************
77 * archive/inode_map.c
78 */
79
90__attribute__((deprecated("Since 1.2.0. Use sqsh_inode_map_get2() "
91 "instead."))) SQSH_NO_UNUSED uint64_t
92sqsh_inode_map_get(const struct SqshInodeMap *map, uint64_t inode_number);
93
105SQSH_NO_UNUSED uint64_t sqsh_inode_map_get2(
106 const struct SqshInodeMap *map, uint32_t inode_number, int *err);
107
119__attribute__((deprecated("Since 1.2.0. Use sqsh_inode_map_set2() "
120 "instead."))) SQSH_NO_UNUSED int
121sqsh_inode_map_set(
122 struct SqshInodeMap *map, uint64_t inode_number, uint64_t inode_ref);
123
134SQSH_NO_UNUSED int sqsh_inode_map_set2(
135 struct SqshInodeMap *map, uint32_t inode_number, uint64_t inode_ref);
136
137/***************************************
138 * archive/superblock_context.c
139 */
140
141struct SqshSuperblock;
142
153sqsh_superblock_compression_id(const struct SqshSuperblock *context);
154
165uint64_t
166sqsh_superblock_directory_table_start(const struct SqshSuperblock *context);
167
178uint64_t
179sqsh_superblock_fragment_table_start(const struct SqshSuperblock *context);
180
189uint32_t sqsh_superblock_inode_count(const struct SqshSuperblock *context);
190
200uint16_t sqsh_superblock_version_major(const struct SqshSuperblock *superblock);
201
211uint16_t sqsh_superblock_version_minor(const struct SqshSuperblock *superblock);
212
222uint64_t
223sqsh_superblock_inode_table_start(const struct SqshSuperblock *context);
224
234uint64_t sqsh_superblock_id_table_start(const struct SqshSuperblock *context);
235
244uint16_t sqsh_superblock_id_count(const struct SqshSuperblock *context);
245
255uint64_t
256sqsh_superblock_export_table_start(const struct SqshSuperblock *context);
257
267uint64_t
268sqsh_superblock_xattr_id_table_start(const struct SqshSuperblock *context);
269
279uint64_t sqsh_superblock_inode_root_ref(const struct SqshSuperblock *context);
280
289bool sqsh_superblock_has_fragments(const struct SqshSuperblock *context);
290
299bool sqsh_superblock_has_export_table(const struct SqshSuperblock *context);
300
309bool sqsh_superblock_has_xattr_table(const struct SqshSuperblock *context);
310
320bool
321sqsh_superblock_has_compression_options(const struct SqshSuperblock *context);
322
331uint32_t sqsh_superblock_block_size(const struct SqshSuperblock *context);
332
342uint32_t
343sqsh_superblock_modification_time(const struct SqshSuperblock *context);
344
354uint32_t
355sqsh_superblock_fragment_entry_count(const struct SqshSuperblock *context);
356
365uint64_t sqsh_superblock_bytes_used(const struct SqshSuperblock *context);
366
367/***************************************
368 * archive/archive.c
369 */
370
381
394 uint64_t source_size;
395
408
414
421
428#ifndef SQSH__NO_DEPRECATED_FIELD
429 __attribute__((
430 deprecated("Since 1.5.0. data_lru_size or metablock_lru_size "
431 "instead.")))
432#endif
434
440
447
454
458 char _reserved[128];
459};
460
465struct SqshArchive;
466
478 const void *source, const struct SqshConfig *config, int *err);
479
489const struct SqshConfig *sqsh_archive_config(const struct SqshArchive *archive);
490
499const struct SqshSuperblock *
501
512
524 struct SqshArchive *archive, struct SqshIdTable **id_table);
525
538 struct SqshArchive *archive, struct SqshInodeMap **inode_map);
539
552 struct SqshArchive *archive, struct SqshExportTable **export_table);
553
566 struct SqshArchive *archive, struct SqshFragmentTable **fragment_table);
567
580 struct SqshArchive *archive, struct SqshXattrTable **xattr_table);
581
590int sqsh_archive_close(struct SqshArchive *archive);
591
592/***************************************
593 * archive/compression_options_context.c
594 */
595
608
618 const struct SqshCompressionOptions *context);
628 const struct SqshCompressionOptions *context);
638 const struct SqshCompressionOptions *context);
639
649 const struct SqshCompressionOptions *context);
659 const struct SqshCompressionOptions *context);
660
670 const struct SqshCompressionOptions *context);
680 const struct SqshCompressionOptions *context);
681
691 const struct SqshCompressionOptions *context);
692
702 const struct SqshCompressionOptions *context);
712 const struct SqshCompressionOptions *context);
713
722size_t
724
734
735#ifdef __cplusplus
736}
737#endif
738#endif /* SQSH_ARCHIVE_H */
#define SQSH_NO_UNUSED
Warn if return value is unused.
Definition sqsh_common.h:59
SqshLzoAlgorithm
definitions of Lzo algorithms
Definition sqsh_data.h:117
SqshGzipStrategies
definitions of gzip strategies
Definition sqsh_data.h:84
SqshXzFilters
definitions xz filters
Definition sqsh_data.h:96
SqshSuperblockCompressionId
The compression used in the archive.
Definition sqsh_data.h:50
SQSH_NO_UNUSED int sqsh_archive_export_table(struct SqshArchive *archive, struct SqshExportTable **export_table)
Retrieves the export table of a Sqsh instance.
SQSH_NO_UNUSED int sqsh_archive_fragment_table(struct SqshArchive *archive, struct SqshFragmentTable **fragment_table)
Retrieves the fragment table of a Sqsh instance.
SQSH_NO_UNUSED struct SqshArchive * sqsh_archive_open(const void *source, const struct SqshConfig *config, int *err)
initializes a archive context in heap.
SQSH_NO_UNUSED int sqsh_archive_inode_map(struct SqshArchive *archive, struct SqshInodeMap **inode_map)
Retrieves the export table of a Sqsh instance.
struct SqshMapManager * sqsh_archive_map_manager(struct SqshArchive *archive)
sqsh_mapper returns the map manager to retrieve chunks of the archive file.
const struct SqshConfig * sqsh_archive_config(const struct SqshArchive *archive)
sqsh_superblock returns the configuration object of the archive context.
SQSH_NO_UNUSED int sqsh_archive_xattr_table(struct SqshArchive *archive, struct SqshXattrTable **xattr_table)
Retrieves the xattr table of a Sqsh instance.
int sqsh_archive_close(struct SqshArchive *archive)
Frees the resources used by a Sqsh instance.
const struct SqshSuperblock * sqsh_archive_superblock(const struct SqshArchive *archive)
sqsh_superblock returns the superblock context.
SQSH_NO_UNUSED int sqsh_archive_id_table(struct SqshArchive *archive, struct SqshIdTable **id_table)
Retrieves the id table of a Sqsh instance.
The compression options context is used to store the compression options for a specific compression a...
uint32_t sqsh_compression_options_lzo_compression_level(const struct SqshCompressionOptions *context)
returns the compression level of lzo
uint32_t sqsh_compression_options_zstd_compression_level(const struct SqshCompressionOptions *context)
returns the compression level of zstd
SQSH_NO_UNUSED struct SqshCompressionOptions * sqsh_compression_options_new(struct SqshArchive *sqsh, int *err)
Initializes a SqshCompressionOptions struct.
enum SqshLzoAlgorithm sqsh_compression_options_lzo_algorithm(const struct SqshCompressionOptions *context)
returns the algorithm of lzo
uint32_t sqsh_compression_options_xz_dictionary_size(const struct SqshCompressionOptions *context)
returns the dictionary size of xz
uint32_t sqsh_compression_options_lz4_version(const struct SqshCompressionOptions *context)
returns the version of lz4 used
int sqsh_compression_options_free(struct SqshCompressionOptions *context)
Frees a SqshCompressionOptions struct.
enum SqshGzipStrategies sqsh_compression_options_gzip_strategies(const struct SqshCompressionOptions *context)
returns the compression strategy of gzip
uint32_t sqsh_compression_options_gzip_compression_level(const struct SqshCompressionOptions *context)
returns the compression level of gzip
uint16_t sqsh_compression_options_gzip_window_size(const struct SqshCompressionOptions *context)
returns the compression window size of gzip
size_t sqsh_compression_options_size(const struct SqshCompressionOptions *context)
returns the size of the compression options struct
enum SqshXzFilters sqsh_compression_options_xz_filters(const struct SqshCompressionOptions *context)
returns the compression options of xz
uint32_t sqsh_compression_options_lz4_flags(const struct SqshCompressionOptions *context)
returns the flags of lz4
The SqshConfig struct contains all the configuration options for a sqsh session.
size_t max_symlink_depth
the maximum depth of symlinks that will be followed. If unset or 0, the max symlink depth will be 100...
int compression_lru_size
the size of the LRU cache used to cache chunks of data from the compression algorithm....
int metablock_lru_size
the size of the LRU cache used to cache chunks of data from the metablocks. If unset or 0,...
int data_lru_size
the size of the LRU cache used to cache chunks of data from the data blocks. If unset or 0,...
int mapper_block_size
the block size used to retrieve chunks of data from the mapper. If unset or 0, the block size will be...
uint64_t source_size
represents the addressable size of the source in bytes.
const struct SqshMemoryMapperImpl * source_mapper
source_mapper is the memory mapper implementation that will be used to map the archive.
uint64_t archive_offset
represents the offset in bytes where the sqsh_archive will start.
int mapper_lru_size
the size of the LRU cache used to cache chunks of data from the mapper. If unset or 0,...
The export table.
The fragment table of an archive.
The id table of an archive.
The inode map context is used to cache inodes numbers and their corresponding inode references.
The map manager.
The implementation of a memory mapper.
Definition sqsh_mapper.h:53
The superblock context is used to access the superblock of the archive.
The trailing context is used to access the trailing data of the archive.
size_t sqsh_trailing_size(const struct SqshTrailingContext *context)
Retrieves the size of the trailing data in a context.
const uint8_t * sqsh_trailing_data(const struct SqshTrailingContext *context)
Retrieves the trailing data in a context.
The extended attribute lookup table.