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

Abstracts writing of extended attributes to a SquashFS filesystem. More...

#include <xattr_writer.h>

Inheritance diagram for sqfs_xattr_writer_t:
Inheritance graph
Collaboration diagram for sqfs_xattr_writer_t:
Collaboration graph

Public Member Functions

SQFS_API sqfs_xattr_writer_tsqfs_xattr_writer_create (sqfs_u32 flags)
 Create an xattr writer instance.
 
SQFS_API int sqfs_xattr_writer_begin (sqfs_xattr_writer_t *xwr, sqfs_u32 flags)
 Begin recording a block of key-value pairs.
 
SQFS_API int sqfs_xattr_writer_add (sqfs_xattr_writer_t *xwr, const char *key, const void *value, size_t size)
 Add a key-value pair to the current block.
 
SQFS_API int sqfs_xattr_writer_end (sqfs_xattr_writer_t *xwr, sqfs_u32 *out)
 Finish a generating a key-value block.
 
SQFS_API int sqfs_xattr_writer_flush (const sqfs_xattr_writer_t *xwr, sqfs_file_t *file, sqfs_super_t *super, sqfs_compressor_t *cmp)
 Write all recorded key-value pairs to disk.
 

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 writing of extended attributes to a SquashFS filesystem.

This data structure provides a simple, abstract interface to recording extended attributes that hads out 32 bit tokens required for inodes to refere to them.

Use sqfs_xattr_writer_begin to start a block of key-value pairs, then add the individual pairs with sqfs_xattr_writer_add and finaly use sqfs_xattr_writer_end which returns the required token.

Finally, use sqfs_xattr_writer_flush to have the extended attributes written to disk.

The writer internally takes care of propper deduplication and packaging everything up in compressed meta data blocks in the multi-level hierarchy used by SquashFS. See sqfs_xattr_reader_t for a brief overview on how SquashFS stores extended attributes.

Member Function Documentation

◆ sqfs_xattr_writer_add()

SQFS_API int sqfs_xattr_writer_add ( sqfs_xattr_writer_t xwr,
const char *  key,
const void *  value,
size_t  size 
)

Add a key-value pair to the current block.

Parameters
xwrA pointer to an xattr writer instance.
keyThe xattr key string.
valueThe associated value to store.
sizeThe size of the value blob.
Returns
Zero on success, a negative SQFS_ERROR value on failure.

◆ sqfs_xattr_writer_begin()

SQFS_API int sqfs_xattr_writer_begin ( sqfs_xattr_writer_t xwr,
sqfs_u32  flags 
)

Begin recording a block of key-value pairs.

Use sqfs_xattr_writer_add to add the individual pairs. Call sqfs_xattr_writer_end when you are done.

Parameters
xwrA pointer to an xattr writer instance.
flagsCurrently must be zero, or the function will fail.
Returns
Zero on success, a negative SQFS_ERROR value on failure.

◆ sqfs_xattr_writer_create()

SQFS_API sqfs_xattr_writer_t * sqfs_xattr_writer_create ( sqfs_u32  flags)

Create an xattr writer instance.

Parameters
flagsCurrently must be zero or the function fails.
Returns
A pointer to a new xattr writer, NULL on allocation failure.

◆ sqfs_xattr_writer_end()

SQFS_API int sqfs_xattr_writer_end ( sqfs_xattr_writer_t xwr,
sqfs_u32 *  out 
)

Finish a generating a key-value block.

This function internally takes care of deduplicating the current block and generates the coresponding 32 bit xattr token used by SquashFS inodes. The token it returns can be one it returned previously if the block turns out to be a duplicate of a previous block.

Parameters
xwrA pointer to an xattr writer instance.
outReturns an ID that has to be set to the inode that the block of key-value pairs belongs to.
Returns
Zero on success, a negative SQFS_ERROR value on failure.

◆ sqfs_xattr_writer_flush()

SQFS_API int sqfs_xattr_writer_flush ( const sqfs_xattr_writer_t xwr,
sqfs_file_t file,
sqfs_super_t super,
sqfs_compressor_t cmp 
)

Write all recorded key-value pairs to disk.

This function takes care of generating the extended attribute tables used by SquashFS. Call it after you are donew with all other meta data tables, since SquashFS requires it to be the very last thing in the file system.

Parameters
xwrA pointer to an xattr writer instance.
fileThe output file to write the tables to.
superThe super block to update with the table locations and flags.
cmpThe compressor to user to compress the tables.
Returns
Zero on success, a negative SQFS_ERROR value on failure.

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