libsqsh v1.5.1
Loading...
Searching...
No Matches
sqsh_file_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_FILE_PRIVATE_H
35#define SQSH_FILE_PRIVATE_H
36
37#include "sqsh_file.h"
38
40#include "sqsh_mapper_private.h"
42#include "sqsh_reader_private.h"
43#include <stdint.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49struct SqshArchive;
50struct SqshDataInode;
51
52/***************************************
53 * file/fragment_view.c
54 */
55
63 const struct SqshFragmentTable *fragment_table;
64 struct SqshMapReader map_reader;
65 struct SqshExtractView extract_view;
66 const uint8_t *data;
67 size_t size;
68};
69
82 struct SqshFragmentView *view, const struct SqshFile *file);
83
93SQSH_NO_EXPORT const uint8_t *
95
105SQSH_NO_EXPORT size_t
107
118
119/***************************************
120 * file/file_iterator.c
121 */
122
130 const struct SqshFile *file;
131 struct SqshExtractManager *compression_manager;
132 struct SqshMapReader map_reader;
133 struct SqshExtractView extract_view;
134 struct SqshFragmentView fragment_view;
135 size_t sparse_size;
136 size_t block_size;
137 uint32_t block_index;
138 const uint8_t *data;
139 size_t size;
140};
141
153 struct SqshFileIterator *iterator, const struct SqshFile *file);
154
166
167/***************************************
168 * context/file_reader.c
169 */
170
178 struct SqshFileIterator iterator;
179 struct SqshReader reader;
180};
181
193 struct SqshFileReader *reader, const struct SqshFile *file);
194
205
206/***************************************
207 * file/file.c
208 */
209
210#define SQSH_INODE_REF_NULL UINT64_MAX
211
217 size_t (*payload_size)(
218 const struct SqshDataInode *inode,
219 const struct SqshArchive *archive);
220
221 uint32_t (*hard_link_count)(const struct SqshDataInode *inode);
222 uint64_t (*size)(const struct SqshDataInode *inode);
223
224 uint64_t (*blocks_start)(const struct SqshDataInode *inode);
225 uint32_t (*block_size_info)(
226 const struct SqshDataInode *inode, sqsh_index_t index);
227 uint32_t (*fragment_block_index)(const struct SqshDataInode *inode);
228 uint32_t (*fragment_block_offset)(const struct SqshDataInode *inode);
229
230 uint32_t (*directory_block_start)(const struct SqshDataInode *inode);
231 uint16_t (*directory_block_offset)(const struct SqshDataInode *inode);
232 uint32_t (*directory_parent_inode)(const struct SqshDataInode *inode);
233
234 const char *(*symlink_target_path)(const struct SqshDataInode *inode);
235 uint32_t (*symlink_target_size)(const struct SqshDataInode *inode);
236
237 uint32_t (*device_id)(const struct SqshDataInode *inode);
238
239 uint32_t (*xattr_index)(const struct SqshDataInode *inode);
240};
241
245struct SqshFile {
249 uint64_t inode_ref;
250 struct SqshMetablockReader metablock;
251 struct SqshArchive *archive;
252 const struct SqshInodeImpl *impl;
253 enum SqshFileType type;
254 uint64_t parent_inode_ref;
255};
256
271 struct SqshFile *context, struct SqshArchive *sqsh, uint64_t inode_ref);
272
281 struct SqshFile *context, uint64_t parent_inode_ref);
282
292SQSH_NO_EXPORT uint64_t
293sqsh__file_parent_inode_ref(struct SqshFile *context, int *err);
294
305
306/***************************************
307 * file/inode_directory.c
308 */
309
312
313/***************************************
314 * file/inode_file.c
315 */
316
319
320/***************************************
321 * file/inode_symlink.c
322 */
323
326
327/***************************************
328 * file/inode_device.c
329 */
330
333
334/***************************************
335 * file/inode_ipc.c
336 */
337
340
341/***************************************
342 * file/inode_null.c
343 */
344
345SQSH_NO_EXPORT uint32_t
346sqsh__file_inode_null_directory_block_start(const struct SqshDataInode *inode);
347
348SQSH_NO_EXPORT uint16_t
349sqsh__file_inode_null_directory_block_offset(const struct SqshDataInode *inode);
350
351SQSH_NO_EXPORT uint32_t
352sqsh__file_inode_null_directory_parent_inode(const struct SqshDataInode *inode);
353
354SQSH_NO_EXPORT uint64_t
355sqsh__file_inode_null_blocks_start(const struct SqshDataInode *inode);
356
358 const struct SqshDataInode *inode, sqsh_index_t index);
359
360SQSH_NO_EXPORT uint32_t
361sqsh__file_inode_null_fragment_block_index(const struct SqshDataInode *inode);
362
363SQSH_NO_EXPORT uint32_t
364sqsh__file_inode_null_fragment_block_offset(const struct SqshDataInode *inode);
365
366SQSH_NO_EXPORT const char *
367sqsh__file_inode_null_symlink_target_path(const struct SqshDataInode *inode);
368
369SQSH_NO_EXPORT uint32_t
370sqsh__file_inode_null_symlink_target_size(const struct SqshDataInode *inode);
371
372SQSH_NO_EXPORT uint32_t
373sqsh__file_inode_null_device_id(const struct SqshDataInode *inode);
374
375SQSH_NO_EXPORT uint32_t
376sqsh__file_inode_null_xattr_index(const struct SqshDataInode *inode);
377
378#ifdef __cplusplus
379}
380#endif
381#endif /* SQSH_FILE_PRIVATE_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
SqshFileType
enum that represents the file type.
Definition sqsh_file.h:315
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_directory_impl
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_device_ext_impl
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_symlink_ext_impl
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_device_id(const struct SqshDataInode *inode)
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_ipc_impl
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_symlink_impl
SQSH_NO_EXPORT int sqsh__file_cleanup(struct SqshFile *context)
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_directory_ext_impl
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__file_iterator_init(struct SqshFileIterator *iterator, const struct SqshFile *file)
SQSH_NO_EXPORT int sqsh__fragment_view_init(struct SqshFragmentView *view, const struct SqshFile *file)
SQSH_NO_EXPORT int sqsh__file_reader_cleanup(struct SqshFileReader *reader)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_fragment_block_offset(const struct SqshDataInode *inode)
SQSH_NO_EXPORT int sqsh__fragment_view_cleanup(struct SqshFragmentView *view)
SQSH_NO_EXPORT size_t sqsh__fragment_view_size(const struct SqshFragmentView *view)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_symlink_target_size(const struct SqshDataInode *inode)
SQSH_NO_EXPORT uint64_t sqsh__file_inode_null_blocks_start(const struct SqshDataInode *inode)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_xattr_index(const struct SqshDataInode *inode)
SQSH_NO_EXPORT uint16_t sqsh__file_inode_null_directory_block_offset(const struct SqshDataInode *inode)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_fragment_block_index(const struct SqshDataInode *inode)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_directory_parent_inode(const struct SqshDataInode *inode)
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_device_impl
SQSH_NO_EXPORT const uint8_t * sqsh__fragment_view_data(const struct SqshFragmentView *view)
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_ipc_ext_impl
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_file_ext_impl
SQSH_NO_EXPORT const struct SqshInodeImpl sqsh__inode_file_impl
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_block_size_info(const struct SqshDataInode *inode, sqsh_index_t index)
SQSH_NO_EXPORT const char * sqsh__file_inode_null_symlink_target_path(const struct SqshDataInode *inode)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__file_reader_init(struct SqshFileReader *reader, const struct SqshFile *file)
SQSH_NO_EXPORT uint32_t sqsh__file_inode_null_directory_block_start(const struct SqshDataInode *inode)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__file_init(struct SqshFile *context, struct SqshArchive *sqsh, uint64_t inode_ref)
SQSH_NO_EXPORT int sqsh__file_iterator_cleanup(struct SqshFileIterator *iterator)
Manages chunks of compressed areas from an archive.
A fiew into compressed memory managed by a SqshExtractManager.
An iterator over the contents of a file.
A reader over the contents of a file.
The Inode context.
SQSH_NO_EXPORT uint64_t sqsh__file_parent_inode_ref(struct SqshFile *context, int *err)
returns the parent inode reference if possible.
SQSH_NO_EXPORT void sqsh__file_set_parent_inode_ref(struct SqshFile *context, uint64_t parent_inode_ref)
sets the parent inode reference.
The fragment table of an archive.
A view over the contents of a fragment.
The file type implementation.
uint32_t(* directory_block_start)(const struct SqshDataInode *inode)
uint32_t(* symlink_target_size)(const struct SqshDataInode *inode)
uint16_t(* directory_block_offset)(const struct SqshDataInode *inode)
uint64_t(* size)(const struct SqshDataInode *inode)
uint32_t(* hard_link_count)(const struct SqshDataInode *inode)
uint32_t(* fragment_block_offset)(const struct SqshDataInode *inode)
uint32_t(* directory_parent_inode)(const struct SqshDataInode *inode)
uint32_t(* block_size_info)(const struct SqshDataInode *inode, sqsh_index_t index)
uint64_t(* blocks_start)(const struct SqshDataInode *inode)
uint32_t(* fragment_block_index)(const struct SqshDataInode *inode)
uint32_t(* device_id)(const struct SqshDataInode *inode)
uint32_t(* xattr_index)(const struct SqshDataInode *inode)
size_t(* payload_size)(const struct SqshDataInode *inode, const struct SqshArchive *archive)
A reader over a mapping of data.
Reader over metablocks.