libsquashfs: sqfs_block_writer_t Interface Reference

libsquashfs 1.3.2 A new set of tools and libraries for working with SquashFS images

Loading...
Searching...
No Matches
sqfs_block_writer_t Interface Reference

Abstracts writing and deduplicating of data and fragment blocks. More...

`#include <block_writer.h>`

Inheritance diagram for sqfs_block_writer_t:
Collaboration diagram for sqfs_block_writer_t:

## Public Member Functions
SQFS_API sqfs_block_writer_t * | sqfs_block_writer_create (sqfs_file_t *file, size_t devblksz, sqfs_u32 flags)
| Create an instance of a default block writer implementation.

## Data Fields
sqfs_object_t | base
int(* | write_data_block )(sqfs_block_writer_t *wr, void *user, sqfs_u32 size, sqfs_u32 checksum, sqfs_u32 flags, const sqfs_u8 *data, sqfs_u64 *location)
| Submit a data block to a block writer.
sqfs_u64(* | get_block_count )(const sqfs_block_writer_t *wr)
| Get the number of blocks actually written to disk.
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)

## 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.

## Detailed Description

Abstracts writing and deduplicating of data and fragment blocks.

A default reference implementation can be obtaiend through sqfs_block_writer_create. The default implementation is not copyable, i.e. sqfs_copy will always return NULL.

Definition at line 42 of file block_writer.h.

## Member Function Documentation

## ◆ sqfs_block_writer_create()

SQFS_API sqfs_block_writer_t * sqfs_block_writer_create | ( | sqfs_file_t * | file,
|  | size_t | devblksz,
|  | sqfs_u32 | flags )

Create an instance of a default block writer implementation.

Parameters

  file | A pointer to a file object that data should be appended to.
  devblksz | The underlying device block size if output data should be aligned.
  flags | A combination of SQFS_BLOCK_WRITER_FLAGS values. If an unknown flag is set, creation will fail.

Returns
  A pointer to a new block writer on success, NULL on failure.

## Field Documentation

## ◆ base

sqfs_object_t base

Definition at line 43 of file block_writer.h.

## ◆ get_block_count

sqfs_u64(* get_block_count) (const sqfs_block_writer_t *wr)

Get the number of blocks actually written to disk.

Parameters

  wr | A pointer to a block writer.

Returns
  The number of blocks written, excluding deduplicated blocks.

Definition at line 90 of file block_writer.h.

## ◆ write_data_block

int(* write_data_block) (sqfs_block_writer_t *wr, void *user, sqfs_u32 size, sqfs_u32 checksum, sqfs_u32 flags, const sqfs_u8 *data, sqfs_u64 *location)

Submit a data block to a block writer.

If the SQFS_BLK_FIRST_BLOCK flag is set, the data block writer memorizes the starting location and block index of the block. If the SQFS_BLK_LAST_BLOCK flag is set, it uses those stored locations to do block deduplication.

If the flag SQFS_BLK_ALIGN is set in combination with the SQFS_BLK_FIRST_BLOCK, the file size is padded to a multiple of the device block size before writing. If it is set together with the SQFS_BLK_LAST_BLOCK flag, the padding is added afterwards.

Parameters

  wr | A pointer to a block writer.
  user | An optional user data pointer. The sqfs_block_processor_t can be told to pass this on to the block writer for each block.
  size | The size of the block to write.
  checksum | A 32 bit checksum of the block data.
  flags | A combination of SQFS_BLK_FLAGS flag bits describing the block. @arapm data A pointer to the data to write.
  location | Returns the location where the block has been written. If the SQFS_BLK_LAST_BLOCK flag was set, deduplication is performed and this returns the (new) location of the first block instead.

Returns
  Zero on success, an SQFS_ERROR error on failure.

Definition at line 76 of file block_writer.h.

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

- include/sqfs/block_writer.h