libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
|
Abstracts generating of meta data blocks, either in memory or directly on disk. More...
#include <meta_writer.h>
Public Member Functions | |
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. | |
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) |
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.
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.
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.
m | A pointer to a meta data writer. |
data | A pointer to a chunk of data to append to the writer. |
size | The number of data bytes to append. |
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.
file | An output file to write the data to. |
cmp | A compressor to use. |
flags | A combination of SQFS_META_WRITER_FLAGS. |
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).
m | A pointer to a meta data writer. |
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.
m | A pointer to a meta data writer. |
block_start | Returns the offset of the current block from the first. |
offset | Returns an offset into the current block where the next write starts. |
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_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.
iw | A pointer to a meta data writer. |
n | A pointer to an inode. |