libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
|
Abstracts writing of extended attributes to a SquashFS filesystem. More...
#include <xattr_writer.h>
Public Member Functions | |
SQFS_API sqfs_xattr_writer_t * | sqfs_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) |
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.
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.
xwr | A pointer to an xattr writer instance. |
key | The xattr key string. |
value | The associated value to store. |
size | The size of the value blob. |
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.
xwr | A pointer to an xattr writer instance. |
flags | Currently must be zero, or the function will fail. |
SQFS_API sqfs_xattr_writer_t * sqfs_xattr_writer_create | ( | sqfs_u32 | flags | ) |
Create an xattr writer instance.
flags | Currently must be zero or the function fails. |
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.
xwr | A pointer to an xattr writer instance. |
out | Returns an ID that has to be set to the inode that the block of key-value pairs belongs to. |
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.
xwr | A pointer to an xattr writer instance. |
file | The output file to write the tables to. |
super | The super block to update with the table locations and flags. |
cmp | The compressor to user to compress the tables. |