libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
|
A generic inode structure that combines all others and provides additional information. More...
#include <inode.h>
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. | |
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.
|
static |
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.
inode | A pointer to an inode. |
location | Returns the location. |
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.
inode | A pointer to an inode. |
size | Returns the file size. |
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.
inode | A pointer to an inode. |
index | Returns the fragment index. |
offset | Returns the fragment offset. |
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.
inode | A pointer to an inode. |
out | Returns the extended attribute index on success. |
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.
inode | A pointer to an inode. |
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.
inode | A pointer to an 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.
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.
inode | A pointer to an inode. |
location | The new location to set. |
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.
inode | A pointer to an inode. |
size | The new size to set. |
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.
inode | A pointer to an inode. |
index | The new fragment index to set. |
offset | The new fragment offset to set. |
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.
inode | A pointer to an inode. |
index | The extended attribute index. |
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.
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. |
sqfs_inode_t base |
sqfs_inode_dev_t dev |
sqfs_inode_dev_ext_t dev_ext |
sqfs_inode_dir_t dir |
sqfs_inode_dir_ext_t dir_ext |
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.
sqfs_inode_file_t file |
sqfs_inode_file_ext_t file_ext |
sqfs_inode_ipc_t ipc |
sqfs_inode_ipc_ext_t ipc_ext |
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.
sqfs_u32 payload_bytes_used |
sqfs_inode_slink_t slink |
sqfs_inode_slink_ext_t slink_ext |