libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
Loading...
Searching...
No Matches
table.h File Reference

Contains helper functions for reading or writing tables. More...

#include "sqfs/predef.h"

Go to the source code of this file.

Functions

SQFS_API int sqfs_write_table (sqfs_file_t *file, sqfs_compressor_t *cmp, const void *data, size_t table_size, sqfs_u64 *start)
 Write a table to disk.
 
SQFS_API int sqfs_read_table (sqfs_file_t *file, sqfs_compressor_t *cmp, size_t table_size, sqfs_u64 location, sqfs_u64 lower_limit, sqfs_u64 upper_limit, void **out)
 Read a table from a SquashFS filesystem.
 

Detailed Description

Contains helper functions for reading or writing tables.

Definition in file table.h.

Function Documentation

◆ sqfs_read_table()

SQFS_API int sqfs_read_table ( sqfs_file_t file,
sqfs_compressor_t cmp,
size_t  table_size,
sqfs_u64  location,
sqfs_u64  lower_limit,
sqfs_u64  upper_limit,
void **  out 
)

Read a table from a SquashFS filesystem.

This function takes an absolute position and an array size as input. It then computes the number of meta data blocks required to store this array and reads that many 64 bit integers from the given start location. Each integer is interpreted as the location of a meta data block containing the respective array chunk.

The entire data encoded in that way is read and uncompressed into memory.

Parameters
fileAn input file to read from.
cmpA compressor to use for uncompressing the meta data block.
table_sizeThe size of the entire array in bytes.
locationThe absolute position of the location list.
lower_limitThe lowest "sane" position at which to expect a meta data block. Anything less than that is interpreted as an out-of-bounds read.
upper_limitThe highest "sane" position at which to expect a meta data block. Anything after that is interpreted as an out-of-bounds read.
outReturns a pointer to the table in memory.
Returns
Zero on success, an SQFS_ERROR value on failure.

◆ sqfs_write_table()

SQFS_API int sqfs_write_table ( sqfs_file_t file,
sqfs_compressor_t cmp,
const void *  data,
size_t  table_size,
sqfs_u64 *  start 
)

Write a table to disk.

This function takes an in-memory array, breaks it down into meta data blocks, compresses and writes those blocks to the given output file and then writes a raw list of 64 bit absolute locations of each meta data block. The position of the location list is returned through a pointer.

Parameters
fileThe output file to write to.
cmpA compressor to use for compressing the meta data blocks.
dataA pointer to a array to divide into blocks and write to disk.
table_sizeThe size of the input array in bytes.
startReturns the absolute position of the location list.
Returns
Zero on success, an SQFS_ERROR value on failure.