libsquashfs: sqfs_meta_reader_t Struct Reference

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

Loading...
Searching...
No Matches
sqfs_meta_reader_t Struct Reference

Abstracts reading of meta data blocks. More...

`#include <meta_reader.h>`

Inheritance diagram for sqfs_meta_reader_t:
Collaboration diagram for sqfs_meta_reader_t:

## Public Member Functions
SQFS_API sqfs_meta_reader_t * | sqfs_meta_reader_create (sqfs_file_t *file, sqfs_compressor_t *cmp, sqfs_u64 start, sqfs_u64 limit)
| Create a meta data reader.
SQFS_API int | sqfs_meta_reader_seek (sqfs_meta_reader_t *m, sqfs_u64 block_start, size_t offset)
| Seek to a specific meta data block and offset.
SQFS_API void | sqfs_meta_reader_get_position (const sqfs_meta_reader_t *m, sqfs_u64 *block_start, size_t *offset)
| Get the current position that the next read will read from.
SQFS_API int | sqfs_meta_reader_read (sqfs_meta_reader_t *m, void *data, size_t size)
| Read a chunk of data from a meta data reader.
SQFS_API int | sqfs_meta_reader_read_dir_header (sqfs_meta_reader_t *m, sqfs_dir_header_t *hdr)
| Read and decode a directory header from a meta data reader.
SQFS_API int | sqfs_meta_reader_read_dir_ent (sqfs_meta_reader_t *m, sqfs_dir_entry_t **ent)
| Read and decode a directory header from a meta data reader.
SQFS_API int | sqfs_meta_reader_readdir (sqfs_meta_reader_t *m, sqfs_readdir_state_t *s, sqfs_dir_entry_t **ent, sqfs_u32 *inum, sqfs_u64 *iref)
| Simple directory reading interface.
SQFS_API int | sqfs_meta_reader_read_inode (sqfs_meta_reader_t *ir, const sqfs_super_t *super, sqfs_u64 block_start, size_t offset, sqfs_inode_generic_t **out)
| Read and decode an inode from a meta data reader.

## 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 reading of meta data blocks.

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 read is to provide a simple read and seek functions that transparently take care of fetching and uncompressing blocks from disk and reading transparently across block boarders if required.

## Member Function Documentation

## ◆ sqfs_meta_reader_create()

SQFS_API sqfs_meta_reader_t * sqfs_meta_reader_create | ( | sqfs_file_t * | file,
|  | sqfs_compressor_t * | cmp,
|  | sqfs_u64 | start,
|  | sqfs_u64 | limit )

Create a meta data reader.

Parameters

  file | A pointer to a file object to read from
  cmp | A compressor to use for unpacking compressed meta data blocks
  start | A lower limit for the blocks to be read. Every seek to an offset below that is interpreted as an out-of-bounds read.
  limit | An upper limit for the blocks to read. Every seek to an offset afer that is interpreted as an out-of-bounds read.

Returns
  A pointer to a meta data reader on success, NULL on allocation failure.

## ◆ sqfs_meta_reader_get_position()

SQFS_API void sqfs_meta_reader_get_position | ( | const sqfs_meta_reader_t * | m,
|  | sqfs_u64 * | block_start,
|  | size_t * | offset )

Get the current position that the next read will read from.

Parameters

  m | A pointer to a meta data reader.
  block_start | Absolute position where the current block is.
  offset | A byte offset into the uncompressed block.

## ◆ sqfs_meta_reader_read()

SQFS_API int sqfs_meta_reader_read | ( | sqfs_meta_reader_t * | m,
|  | void * | data,
|  | size_t | size )

Read a chunk of data from a meta data reader.

If the meta data reader reaches the end of the current block before filling the destination buffer, it transparently reads the next block from disk and uncompresses it.

Parameters

  m | A pointer to a meta data reader.
  data | A pointer to copy the data to.
  size | The numbre of bytes to read.

Returns
  Zero on success, an SQFS_ERROR value on failure.

## ◆ sqfs_meta_reader_read_dir_ent()

SQFS_API int sqfs_meta_reader_read_dir_ent | ( | sqfs_meta_reader_t * | m,
|  | sqfs_dir_entry_t ** | ent )

Read and decode a directory header from a meta data reader.

This is a convenience function on to of sqfs_meta_reader_read that reads and decodes a directory entry.

Parameters

  m | A pointer to a meta data reader.
  ent | Returns a pointer to a directory entry. Can be released with a single sqfs_free call.

Returns
  Zero on success, an SQFS_ERROR value on failure.

## ◆ sqfs_meta_reader_read_dir_header()

SQFS_API int sqfs_meta_reader_read_dir_header | ( | sqfs_meta_reader_t * | m,
|  | sqfs_dir_header_t * | hdr )

Read and decode a directory header from a meta data reader.

This is a convenience function on to of sqfs_meta_reader_read that reads and decodes a directory header from a meta data block.

Parameters

  m | A pointer to a meta data reader.
  hdr | A pointer to a directory header to fill.

Returns
  Zero on success, an SQFS_ERROR value on failure.

## ◆ sqfs_meta_reader_read_inode()

SQFS_API int sqfs_meta_reader_read_inode | ( | sqfs_meta_reader_t * | ir,
|  | const sqfs_super_t * | super,
|  | sqfs_u64 | block_start,
|  | size_t | offset,
|  | sqfs_inode_generic_t ** | out )

Read and decode an inode from a meta data reader.

This is a convenience function on to of sqfs_meta_reader_seek and sqfs_meta_reader_read that reads and decodes an inode.

Parameters

  ir | A pointer to a meta data reader.
  super | A pointer to the super block, required for figuring out the size of file inodes.
  block_start | The meta data block to seek to for reading the inode.
  offset | A byte offset within the uncompressed block where the inode is.
  out | Returns a pointer to an inode. Can be released with a single sqfs_free call.

Returns
  Zero on success, an SQFS_ERROR value on failure.

## ◆ sqfs_meta_reader_readdir()

SQFS_API int sqfs_meta_reader_readdir | ( | sqfs_meta_reader_t * | m,
|  | sqfs_readdir_state_t * | s,
|  | sqfs_dir_entry_t ** | ent,
|  | sqfs_u32 * | inum,
|  | sqfs_u64 * | iref )

Simple directory reading interface.

This function successively reads directory entries, transparently parsing and skipping across headers. The state is encapsulated in an external object that is passed in and the function seeks to the location, so one can swap between multiple states and read several directories interchangeably.

Parameters

  m | A pointer to a meta data reader.
  s | A pointer to a directory state that is used and updated.
  ent | Returns a pointer to a directory entry. Can be released with a single sqfs_free call.
  inum | If not NULL, returns the decoded inode number.
  iref | If not NULL, returns a reference to the inode.

Returns
  Zero on success, a negative SQFS_ERROR number on failure, a positive number if the end of the directory is reached.

## ◆ sqfs_meta_reader_seek()

SQFS_API int sqfs_meta_reader_seek | ( | sqfs_meta_reader_t * | m,
|  | sqfs_u64 | block_start,
|  | size_t | offset )

Seek to a specific meta data block and offset.

The underlying block is fetched from disk and uncompressed, unless it already is the current block.

Parameters

  m | A pointer to a meta data reader.
  block_start | Absolute position where the block header can be found.
  offset | A byte offset into the uncompressed block.

Returns
  Zero on success, an SQFS_ERROR value on failure.

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

- include/sqfs/meta_reader.h