libsquashfs: sqfs_inode_generic_t Struct Reference

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

Loading...
Searching...
No Matches
sqfs_inode_generic_t Struct Reference

A generic inode structure that combines all others and provides additional information. More...

`#include <inode.h>`

Collaboration diagram for sqfs_inode_generic_t:

## Public Member Functions
SQFS_API int | sqfs_inode_get_xattr_index (const sqfs_inode_generic_t *inode, sqfs_u32 *out)
| Get the extended attribute index of an inode.
SQFS_API int | sqfs_inode_set_xattr_index (sqfs_inode_generic_t *inode, sqfs_u32 index)
| Set the extended attribute index of an inode.
SQFS_API int | sqfs_inode_make_extended (sqfs_inode_generic_t *inode)
| Convert a basic inode to an extended inode.
SQFS_API int | sqfs_inode_make_basic (sqfs_inode_generic_t *inode)
| Convert an extended inode to a basic inode if possible.
SQFS_API int | sqfs_inode_set_file_size (sqfs_inode_generic_t *inode, sqfs_u64 size)
| Update the file size of a regular file inode.
SQFS_API int | sqfs_inode_set_file_block_start (sqfs_inode_generic_t *inode, sqfs_u64 location)
| Update the location of the first data block of a regular file inode.
SQFS_API int | sqfs_inode_set_frag_location (sqfs_inode_generic_t *inode, sqfs_u32 index, sqfs_u32 offset)
| Update the file fragment location of a regular file inode.
SQFS_API int | sqfs_inode_get_file_size (const sqfs_inode_generic_t *inode, sqfs_u64 *size)
| Get the file size of a regular file inode.
SQFS_API int | sqfs_inode_get_frag_location (const sqfs_inode_generic_t *inode, sqfs_u32 *index, sqfs_u32 *offset)
| Get the file fragment location of a regular file inode.
SQFS_API int | sqfs_inode_get_file_block_start (const sqfs_inode_generic_t *inode, sqfs_u64 *location)
| Get the location of the first data block of a regular file inode.
SQFS_API int | sqfs_inode_unpack_dir_index_entry (const sqfs_inode_generic_t *inode, sqfs_dir_index_t **out, size_t index)
| Unpack the a directory index structure from an inode.

## Static Public Member Functions
static SQFS_INLINE size_t | sqfs_inode_get_file_block_count (const sqfs_inode_generic_t *inode)
| Get the number of file blocks in a regular file inode.

## Data Fields
sqfs_inode_t | base
| The common fields for all inodes.
sqfs_u32 | payload_bytes_available
| Maximum number of available data bytes in the payload.
sqfs_u32 | payload_bytes_used
| Number of used data bytes in the payload.
union { |
sqfs_inode_dev_t dev |
sqfs_inode_dev_ext_t dev_ext |
sqfs_inode_ipc_t ipc |
sqfs_inode_ipc_ext_t ipc_ext |
sqfs_inode_slink_t slink |
sqfs_inode_slink_ext_t slink_ext |
sqfs_inode_file_t file |
sqfs_inode_file_ext_t file_ext |
sqfs_inode_dir_t dir |
sqfs_inode_dir_ext_t dir_ext |
} | data
| Type specific inode data.
sqfs_u32 | extra []
| Holds type specific extra data, such as symlink target.

## Detailed Description

A generic inode structure that combines all others and provides additional information.

A few helper functions exist for working with this. For instance, sqfs_meta_reader_read_inode can read an inode from disk and assemble it into an instance of this structure. Similarly, the sqfs_meta_writer_write_inode function can break it down into encoded, on-disk structures and write them to disk.

Definition at line 488 of file inode.h.

## Member Function Documentation

## ◆ sqfs_inode_get_file_block_count()

SQFS_INLINE size_t sqfs_inode_get_file_block_count | ( | const sqfs_inode_generic_t * | inode | ) |
| static

Get the number of file blocks in a regular file inode.

Parameters

  inode | A pointer to an inode.

Returns
  The number of blocks.

Definition at line 552 of file inode.h.

## ◆ sqfs_inode_get_file_block_start()

SQFS_API int sqfs_inode_get_file_block_start | ( | const sqfs_inode_generic_t * | inode,
|  | sqfs_u64 * | location )

Get the location of the first data block of a regular file inode.

Parameters

  inode | A pointer to an inode.
  location | Returns the location.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_get_file_size()

SQFS_API int sqfs_inode_get_file_size | ( | const sqfs_inode_generic_t * | inode,
|  | sqfs_u64 * | size )

Get the file size of a regular file inode.

Parameters

  inode | A pointer to an inode.
  size | Returns the file size.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_get_frag_location()

SQFS_API int sqfs_inode_get_frag_location | ( | const sqfs_inode_generic_t * | inode,
|  | sqfs_u32 * | index,
|  | sqfs_u32 * | offset )

Get the file fragment location of a regular file inode.

Parameters

  inode | A pointer to an inode.
  index | Returns the fragment index.
  offset | Returns the fragment offset.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_get_xattr_index()

SQFS_API int sqfs_inode_get_xattr_index | ( | const sqfs_inode_generic_t * | inode,
|  | sqfs_u32 * | out )

Get the extended attribute index of an inode.

For basic inodes, this returns the inode index 0xFFFFFFFF, i.e. the sentinel value indicating that there are no xattrs.

Parameters

  inode | A pointer to an inode.
  out | Returns the extended attribute index on success.

Returns
  Zero on success, an SQFS_ERROR_CORRUPTED if the node has an unknown type set.

## ◆ sqfs_inode_make_basic()

SQFS_API int sqfs_inode_make_basic | ( | sqfs_inode_generic_t * | inode | ) |

Convert an extended inode to a basic inode if possible.

For inodes that already have a basic type, this is a no-op. If the inode has values set that the coresponding basic type doesn't support (e.g. it has an xattr index set or a regular file which requires 64 bit size counter), it is left as an extended type and success state is returned.

Parameters

  inode | A pointer to an inode.

Returns
  Zero on success, an SQFS_ERROR_CORRUPTED if the node has an unknown type set.

## ◆ sqfs_inode_make_extended()

SQFS_API int sqfs_inode_make_extended | ( | sqfs_inode_generic_t * | inode | ) |

Convert a basic inode to an extended inode.

For inodes that already have an extended type, this is a no-op.

Parameters

  inode | A pointer to an inode.

Returns
  Zero on success, an SQFS_ERROR_CORRUPTED if the node has an unknown type set.

## ◆ sqfs_inode_set_file_block_start()

SQFS_API int sqfs_inode_set_file_block_start | ( | sqfs_inode_generic_t * | inode,
|  | sqfs_u64 | location )

Update the location of the first data block of a regular file inode.

If the new location is wider than 32 bit, a basic file inode is transparently promoted to an extended file inode. For extended inodes, if the new size is small enough and was the only requirement for the extended type, the node is transparently demoted to a basic file inode.

Parameters

  inode | A pointer to an inode.
  location | The new location to set.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_set_file_size()

SQFS_API int sqfs_inode_set_file_size | ( | sqfs_inode_generic_t * | inode,
|  | sqfs_u64 | size )

Update the file size of a regular file inode.

If the new size is wider than 32 bit, a basic file inode is transparently promoted to an extended file inode. For extended inodes, if the new size is small enough and was the only requirement for the extended type, the node is transparently demoted to a basic file inode.

Parameters

  inode | A pointer to an inode.
  size | The new size to set.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_set_frag_location()

SQFS_API int sqfs_inode_set_frag_location | ( | sqfs_inode_generic_t * | inode,
|  | sqfs_u32 | index,
|  | sqfs_u32 | offset )

Update the file fragment location of a regular file inode.

Parameters

  inode | A pointer to an inode.
  index | The new fragment index to set.
  offset | The new fragment offset to set.

Returns
  Zero on success, SQFS_ERROR_NOT_FILE if the node is not a regular file.

## ◆ sqfs_inode_set_xattr_index()

SQFS_API int sqfs_inode_set_xattr_index | ( | sqfs_inode_generic_t * | inode,
|  | sqfs_u32 | index )

Set the extended attribute index of an inode.

For basic inodes, this function promotes the inodes to extended inodes if the index is not 0xFFFFFFFF. The function does not try to demote extended inodes if the index is 0xFFFFFFFF, because that would cause additional information like a directory index to be lost.

Parameters

  inode | A pointer to an inode.
  index | The extended attribute index.

Returns
  Zero on success, an SQFS_ERROR_CORRUPTED if the node has an unknown type set.

## ◆ sqfs_inode_unpack_dir_index_entry()

SQFS_API int sqfs_inode_unpack_dir_index_entry | ( | const sqfs_inode_generic_t * | inode,
|  | sqfs_dir_index_t ** | out,
|  | size_t | index )

Unpack the a directory index structure from an inode.

The generic inode contains in its payload the raw directory index (with bytes swapped to host enian), but still with single byte alignment. This function seeks through the blob using an integer index (not offset) and fiddles the raw data out into a propperly aligned, external structure.

Parameters

  inode | A pointer to an inode.
  out | Returns the index entry. Can be freed with a single sqfs_free call.
  index | An index value between 0 and inodex_count.

Returns
  Zero on success, SQFS_ERROR_OUT_OF_BOUNDS if the given index points outside the directory index. Can return other error codes (e.g. if the inode isn't a directory or allocation failed).

## Field Documentation

## ◆ base

sqfs_inode_t base

The common fields for all inodes.

Examples
  list_files.c.

Definition at line 492 of file inode.h.

## ◆ dev

sqfs_inode_dev_t dev

Definition at line 515 of file inode.h.

## ◆ dev_ext

sqfs_inode_dev_ext_t dev_ext

Definition at line 516 of file inode.h.

## ◆ dir

sqfs_inode_dir_t dir

Definition at line 523 of file inode.h.

## ◆ dir_ext

sqfs_inode_dir_ext_t dir_ext

Definition at line 524 of file inode.h.

## ◆ extra

sqfs_u32 extra[]

Holds type specific extra data, such as symlink target.

For regular file inodes, this is an array of block sizes. For symlink inodes, this is actually a string holding the target. For extended directory inodes, this is actually a blob of tightly packed directory index entries.

Examples
  list_files.c.

Definition at line 535 of file inode.h.

## ◆ file

sqfs_inode_file_t file

Definition at line 521 of file inode.h.

## ◆ file_ext

sqfs_inode_file_ext_t file_ext

Definition at line 522 of file inode.h.

## ◆ ipc

sqfs_inode_ipc_t ipc

Definition at line 517 of file inode.h.

## ◆ ipc_ext

sqfs_inode_ipc_ext_t ipc_ext

Definition at line 518 of file inode.h.

## ◆ payload_bytes_available

sqfs_u32 payload_bytes_available

Maximum number of available data bytes in the payload.

This is used for dynamically growing an inode. The actual number of used payload bytes is stored in payload_bytes_used.

Definition at line 500 of file inode.h.

## ◆ payload_bytes_used

sqfs_u32 payload_bytes_used

Number of used data bytes in the payload.

For file inodes, stores the number of blocks used. For extended directory inodes, stores the number of payload bytes following for the directory index.

Definition at line 509 of file inode.h.

## ◆ slink

sqfs_inode_slink_t slink

Examples
  list_files.c.

Definition at line 519 of file inode.h.

## ◆ slink_ext

sqfs_inode_slink_ext_t slink_ext

Examples
  list_files.c.

Definition at line 520 of file inode.h.

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

- include/sqfs/inode.h