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

Abstracts generating of meta data blocks, either in memory or directly on disk. More...

#include <meta_writer.h>

Inheritance diagram for sqfs_meta_writer_t:
Inheritance graph
Collaboration diagram for sqfs_meta_writer_t:
Collaboration graph

Public Member Functions

SQFS_API sqfs_meta_writer_tsqfs_meta_writer_create (sqfs_file_t *file, sqfs_compressor_t *cmp, sqfs_u32 flags)
 Create a meta data writer.
 
SQFS_API int sqfs_meta_writer_flush (sqfs_meta_writer_t *m)
 Finish the current block, even if it isn't full yet.
 
SQFS_API int sqfs_meta_writer_append (sqfs_meta_writer_t *m, const void *data, size_t size)
 Finish the current block, even if it isn't full yet.
 
SQFS_API void sqfs_meta_writer_get_position (const sqfs_meta_writer_t *m, sqfs_u64 *block_start, sqfs_u32 *offset)
 Query the current block start position and offset within the block.
 
SQFS_API void sqfs_meta_writer_reset (sqfs_meta_writer_t *m)
 Reset all internal state, including the current block start position.
 
SQFS_API int sqfs_meta_write_write_to_file (sqfs_meta_writer_t *m)
 Write all blocks collected in memory to disk.
 
SQFS_API int sqfs_meta_writer_write_inode (sqfs_meta_writer_t *iw, const sqfs_inode_generic_t *n)
 A convenience function for encoding and writing an inode.
 

Additional Inherited Members

- Static Public Member Functions inherited from sqfs_object_t
static SQFS_INLINE void sqfs_destroy (void *obj)
 Destroy an object and free all its memory.
 
static SQFS_INLINE void * sqfs_copy (const void *obj)
 Create a deep copy of an object if possible.
 
- Data Fields inherited from sqfs_object_t
void(* destroy )(struct sqfs_object_t *instance)
 
struct sqfs_object_t *(* copy )(const struct sqfs_object_t *orig)
 

Detailed Description

Abstracts generating of meta data blocks, either in memory or directly on disk.

SquashFS stores meta data by dividing it into fixed size (8k) chunks that are written to disk with a small header indicating the on-disk size and whether it is compressed or not.

Data written to meta data blocks doesn't have to be aligned, i.e. SquashFS doesn't care if an object is written across two blocks.

The main task of the meta data writer is to provide a simple append function that transparently takes care of chopping data up into blocks, compressing the blocks and pre-pending a header.

This object is not copyable, i.e. sqfs_copy will always return NULL.

Member Function Documentation

◆ sqfs_meta_write_write_to_file()

SQFS_API int sqfs_meta_write_write_to_file ( sqfs_meta_writer_t m)

Write all blocks collected in memory to disk.

If the meta writer was created with the flag set to store blocks in memory instead of writing them to disk, calling this function forces the meta writer to write out all blocks it collected so far.

Returns
Zero on success, an SQFS_ERROR value on failure.

◆ sqfs_meta_writer_append()

SQFS_API int sqfs_meta_writer_append ( sqfs_meta_writer_t m,
const void *  data,
size_t  size 
)

Finish the current block, even if it isn't full yet.

This function forces reads a speicifed number of bytes from a given data block and appends it to the meta data block that the writer is currently working on. If the block becomes full, it is compressed, written to disk and a new block is started that the remaining data is written to.

Parameters
mA pointer to a meta data writer.
dataA pointer to a chunk of data to append to the writer.
sizeThe number of data bytes to append.
Returns
Zero on success, an SQFS_ERROR value on failure.

◆ sqfs_meta_writer_create()

SQFS_API sqfs_meta_writer_t * sqfs_meta_writer_create ( sqfs_file_t file,
sqfs_compressor_t cmp,
sqfs_u32  flags 
)

Create a meta data writer.

Note
The meta writer internally keeps references to the pointers passed to this function, so don't destroy them before destroying the meta writer.
Parameters
fileAn output file to write the data to.
cmpA compressor to use.
flagsA combination of SQFS_META_WRITER_FLAGS.
Returns
A pointer to a meta writer on success, NULL on allocation failure or if an unknown flag was set.

◆ sqfs_meta_writer_flush()

SQFS_API int sqfs_meta_writer_flush ( sqfs_meta_writer_t m)

Finish the current block, even if it isn't full yet.

This function forces the meta writer to compress and store the block it is currently writing to, even if it isn't full yet, and either write it out to disk (or append it to the in memory chain if told to keep blocks in memory).

Parameters
mA pointer to a meta data writer.
Returns
Zero on success, an SQFS_ERROR value on failure.

◆ sqfs_meta_writer_get_position()

SQFS_API void sqfs_meta_writer_get_position ( const sqfs_meta_writer_t m,
sqfs_u64 *  block_start,
sqfs_u32 *  offset 
)

Query the current block start position and offset within the block.

Get the byte offset relative to the first block that the current block will start at once it is written to disk and get the byte offset within this block that the next call to sqfs_meta_writer_append will start writing data at.

Parameters
mA pointer to a meta data writer.
block_startReturns the offset of the current block from the first.
offsetReturns an offset into the current block where the next write starts.

◆ sqfs_meta_writer_reset()

SQFS_API void sqfs_meta_writer_reset ( sqfs_meta_writer_t m)

Reset all internal state, including the current block start position.

This functions forces the meta data writer to forget everything that happened since it was created, so it can be recycled.

The data written is not lost, unless it was kept in memory and never written out to disk.

◆ sqfs_meta_writer_write_inode()

SQFS_API int sqfs_meta_writer_write_inode ( sqfs_meta_writer_t iw,
const sqfs_inode_generic_t n 
)

A convenience function for encoding and writing an inode.

The SquashFS inode table is essentially a series of meta data blocks containing variable sized inodes. This function takes a generic inode structure, encodes it and writes the result to a meta data writer using sqfs_meta_writer_append internally.

Parameters
iwA pointer to a meta data writer.
nA pointer to an inode.
Returns
Zero on success, an SQFS_ERROR value on failure.

The documentation for this struct was generated from the following file: