libsqsh v1.5.1
|
The Inode context. More...
#include <sqsh_file_private.h>
Public Member Functions | |
SQSH_NO_EXPORT void | sqsh__file_set_parent_inode_ref (struct SqshFile *context, uint64_t parent_inode_ref) |
sets the parent inode reference. | |
SQSH_NO_EXPORT uint64_t | sqsh__file_parent_inode_ref (struct SqshFile *context, int *err) |
returns the parent inode reference if possible. | |
SQSH_NO_UNUSED struct SqshFile * | sqsh_open (struct SqshArchive *archive, const char *path, int *err) |
Initialize the file context from a path. | |
SQSH_NO_UNUSED struct SqshFile * | sqsh_lopen (struct SqshArchive *archive, const char *path, int *err) |
Initialize the file context from a path. This function is identical to sqsh_open() but if the path is a symlink, the symlink target not resolved. | |
SQSH_NO_UNUSED struct SqshFile * | sqsh_open_by_ref (struct SqshArchive *archive, uint64_t inode_ref, int *err) |
Initializes a file context in heap. | |
bool | sqsh_file_is_extended (const struct SqshFile *context) |
returns whether the file is an extended structure. | |
uint32_t | sqsh_file_hard_link_count (const struct SqshFile *context) |
Getter for the inode hard link count. | |
uint64_t | sqsh_file_size (const struct SqshFile *context) |
Getter for the file size. 0 if the file has no size. | |
uint16_t | sqsh_file_permission (const struct SqshFile *context) |
Getter for the permissions of the file. | |
uint32_t | sqsh_file_inode (const struct SqshFile *context) |
Getter for the inode number. | |
uint32_t | sqsh_file_modified_time (const struct SqshFile *context) |
Getter for the file modification time in seconds since epoch. | |
uint64_t | sqsh_file_blocks_start (const struct SqshFile *context) |
Getter for the start block of the file content. This is only internally used and will be used while retrieving the file content. | |
uint32_t | sqsh_file_block_count (const struct SqshFile *context) |
Getter for the amount of blocks of the file content. This is only internally used and will be used while retrieving the file content. | |
uint64_t | sqsh_file_block_count2 (const struct SqshFile *context) |
Getter for the amount of blocks of the file content. This is only internally used and will be used while retrieving the file content. | |
uint32_t | sqsh_file_block_size (const struct SqshFile *context, uint32_t index) |
Getter the size of a block of the file content. This is only internally used and will be used while retrieving the file content. | |
bool | sqsh_file_block_is_compressed (const struct SqshFile *context, uint32_t index) |
Checks whether a certain block is compressed. | |
uint32_t | sqsh_file_fragment_block_index (const struct SqshFile *context) |
retrieve the fragment block index. This is only internally used | |
uint32_t | sqsh_file_fragment_block_offset (const struct SqshFile *context) |
retrieve the fragment block offset. This is only internally used and will be used while retrieving the file content. | |
uint32_t | sqsh_file_directory_block_start (const struct SqshFile *context) |
retrieve the directory block start. This is only internally used and will be used while iterating over the directory entries. | |
uint32_t | sqsh_file_directory_block_offset (const struct SqshFile *context) |
retrieve the directory block offset. This is only internally used and will be used while iterating over the directory entries. | |
uint16_t | sqsh_file_directory_block_offset2 (const struct SqshFile *context) |
retrieve the directory block offset. This is only internally used and will be used while iterating over the directory entries. | |
uint32_t | sqsh_file_directory_parent_inode (const struct SqshFile *context) |
retrieve the parent inode of the directory. | |
bool | sqsh_file_has_fragment (const struct SqshFile *context) |
returns true if the file has a fragment block. | |
enum SqshFileType | sqsh_file_type (const struct SqshFile *context) |
returns the type of the file. | |
int | sqsh_file_symlink_resolve (struct SqshFile *context) |
resolves the symlink target. After calling this function the file is in place changed to the target of the symlink. | |
int | sqsh_file_symlink_resolve_all (struct SqshFile *context) |
resolves all symlink target targets until a file is hit. This function is similar to sqsh_file_symlink_resolve() but resolves symlinks recursively until a file is hit. | |
const char * | sqsh_file_symlink (const struct SqshFile *context) |
returns the target of a symbolic link. Be aware that the returned value is not zero terminated. | |
SQSH_NO_UNUSED char * | sqsh_file_symlink_dup (const struct SqshFile *context) |
creates a heap allocated copy of the target of a symbolic link. | |
uint32_t | sqsh_file_symlink_size (const struct SqshFile *context) |
returns the length of the target of a symbolic link in bytes. | |
uint32_t | sqsh_file_device_id (const struct SqshFile *context) |
returns the device id of the device inode. | |
uint32_t | sqsh_file_uid (const struct SqshFile *context) |
returns the owner user id of the file. | |
uint32_t | sqsh_file_gid (const struct SqshFile *context) |
returns the owner group id of the file. | |
uint64_t | sqsh_file_inode_ref (const struct SqshFile *context) |
returns the inode reference to this file. | |
uint32_t | sqsh_file_xattr_index (const struct SqshFile *context) |
returns index of the extended attribute inside of the xattr table. | |
int | sqsh_close (struct SqshFile *file) |
cleans up an file context and frees the memory. | |
int | sqsh_file_to_stream (const struct SqshFile *file, FILE *stream) |
writes data to a file descriptor. | |
SQSH_NO_UNUSED int | sqsh_file_to_stream_mt (const struct SqshFile *file, struct SqshThreadpool *threadpool, FILE *stream, sqsh_file_to_stream_mt_cb cb, void *data) |
writes data to a file descriptor. | |
void | sqsh_file_iterator_mt (const struct SqshFile *file, struct SqshThreadpool *threadpool, sqsh_file_iterator_mt_cb cb, void *data) |
creates a file descriptor from a file and calls a callback for each block. | |
The Inode context.
Definition at line 245 of file sqsh_file_private.h.
SQSH_NO_EXPORT uint64_t sqsh__file_parent_inode_ref | ( | struct SqshFile * | context, |
int * | err ) |
returns the parent inode reference if possible.
[in] | context | The file context. |
[out] | err | Pointer to an int where the error code will be stored. |
SQSH_NO_EXPORT void sqsh__file_set_parent_inode_ref | ( | struct SqshFile * | context, |
uint64_t | parent_inode_ref ) |
sets the parent inode reference.
[in] | context | The file context. |
[in] | parent_inode_ref | The inode reference of the parent directory. |
int sqsh_close | ( | struct SqshFile * | file | ) |
cleans up an file context and frees the memory.
[in] | file | The file context. |
uint32_t sqsh_file_block_count | ( | const struct SqshFile * | context | ) |
Getter for the amount of blocks of the file content. This is only internally used and will be used while retrieving the file content.
[in] | context | The file context. |
uint64_t sqsh_file_block_count2 | ( | const struct SqshFile * | context | ) |
Getter for the amount of blocks of the file content. This is only internally used and will be used while retrieving the file content.
[in] | context | The file context. |
bool sqsh_file_block_is_compressed | ( | const struct SqshFile * | context, |
uint32_t | index ) |
Checks whether a certain block is compressed.
[in] | context | The file context. |
index | The index of the block. |
uint32_t sqsh_file_block_size | ( | const struct SqshFile * | context, |
uint32_t | index ) |
Getter the size of a block of the file content. This is only internally used and will be used while retrieving the file content.
[in] | context | The file context. |
index | The index of the block. |
uint64_t sqsh_file_blocks_start | ( | const struct SqshFile * | context | ) |
Getter for the start block of the file content. This is only internally used and will be used while retrieving the file content.
[in] | context | The file context. |
uint32_t sqsh_file_device_id | ( | const struct SqshFile * | context | ) |
returns the device id of the device inode.
[in] | context | The file context. |
uint32_t sqsh_file_directory_block_offset | ( | const struct SqshFile * | context | ) |
retrieve the directory block offset. This is only internally used and will be used while iterating over the directory entries.
[in] | context | The file context. |
uint16_t sqsh_file_directory_block_offset2 | ( | const struct SqshFile * | context | ) |
retrieve the directory block offset. This is only internally used and will be used while iterating over the directory entries.
[in] | context | The file context. |
uint32_t sqsh_file_directory_block_start | ( | const struct SqshFile * | context | ) |
retrieve the directory block start. This is only internally used and will be used while iterating over the directory entries.
[in] | context | The file context. |
uint32_t sqsh_file_directory_parent_inode | ( | const struct SqshFile * | context | ) |
retrieve the parent inode of the directory.
[in] | context | The file context. |
uint32_t sqsh_file_fragment_block_index | ( | const struct SqshFile * | context | ) |
retrieve the fragment block index. This is only internally used
and will be used while retrieving the file content.
[in] | context | The file context. |
uint32_t sqsh_file_fragment_block_offset | ( | const struct SqshFile * | context | ) |
retrieve the fragment block offset. This is only internally used and will be used while retrieving the file content.
[in] | context | The file context. |
uint32_t sqsh_file_gid | ( | const struct SqshFile * | context | ) |
returns the owner group id of the file.
[in] | context | The file context. |
uint32_t sqsh_file_hard_link_count | ( | const struct SqshFile * | context | ) |
Getter for the inode hard link count.
[in] | context | The file context. |
bool sqsh_file_has_fragment | ( | const struct SqshFile * | context | ) |
returns true if the file has a fragment block.
[in] | context | The file context. |
uint32_t sqsh_file_inode | ( | const struct SqshFile * | context | ) |
Getter for the inode number.
[in] | context | The file context. |
uint64_t sqsh_file_inode_ref | ( | const struct SqshFile * | context | ) |
returns the inode reference to this file.
The owner reference is an encoded physical location of the inode inside of the archive.
To decode this value use the following code:
The outer address is the physical location of the metablock within the archive.
The inner address is the physical location of the inode inside of the decompressed metablock.
[in] | context | The file context. |
bool sqsh_file_is_extended | ( | const struct SqshFile * | context | ) |
returns whether the file is an extended structure.
[in] | context | The file context. |
void sqsh_file_iterator_mt | ( | const struct SqshFile * | file, |
struct SqshThreadpool * | threadpool, | ||
sqsh_file_iterator_mt_cb | cb, | ||
void * | data ) |
creates a file descriptor from a file and calls a callback for each block.
[in] | file | The file context. |
[in] | threadpool | The threadpool to use. |
[in] | cb | The callback to call for each block. |
[in] | data | The data to pass to the callback. |
uint32_t sqsh_file_modified_time | ( | const struct SqshFile * | context | ) |
Getter for the file modification time in seconds since epoch.
[in] | context | The file context. |
uint16_t sqsh_file_permission | ( | const struct SqshFile * | context | ) |
Getter for the permissions of the file.
[in] | context | The file context. |
uint64_t sqsh_file_size | ( | const struct SqshFile * | context | ) |
Getter for the file size. 0 if the file has no size.
[in] | context | The file context. |
const char * sqsh_file_symlink | ( | const struct SqshFile * | context | ) |
returns the target of a symbolic link. Be aware that the returned value is not zero terminated.
To get the length of the target use sqsh_file_symlink_size().
If you need a zero terminated string use sqsh_file_symlink_dup().
[in] | context | The file context. |
SQSH_NO_UNUSED char * sqsh_file_symlink_dup | ( | const struct SqshFile * | context | ) |
creates a heap allocated copy of the target of a symbolic link.
The caller is responsible for calling free() on the returned pointer.
The returned string is 0 terminated.
[in] | context | The file context. |
int sqsh_file_symlink_resolve | ( | struct SqshFile * | context | ) |
resolves the symlink target. After calling this function the file is in place changed to the target of the symlink.
[in] | context | The file context. |
int sqsh_file_symlink_resolve_all | ( | struct SqshFile * | context | ) |
resolves all symlink target targets until a file is hit. This function is similar to sqsh_file_symlink_resolve() but resolves symlinks recursively until a file is hit.
[in] | context | The file context. |
uint32_t sqsh_file_symlink_size | ( | const struct SqshFile * | context | ) |
returns the length of the target of a symbolic link in bytes.
[in] | context | The file context. |
int sqsh_file_to_stream | ( | const struct SqshFile * | file, |
FILE * | stream ) |
writes data to a file descriptor.
[in] | file | The file context. |
[in] | stream | The descriptor to write the file contents to. |
SQSH_NO_UNUSED int sqsh_file_to_stream_mt | ( | const struct SqshFile * | file, |
struct SqshThreadpool * | threadpool, | ||
FILE * | stream, | ||
sqsh_file_to_stream_mt_cb | cb, | ||
void * | data ) |
writes data to a file descriptor.
[in] | file | The file context. |
[in] | threadpool | The threadpool to use. |
[in] | stream | The descriptor to write the file contents to. |
[in] | cb | The callback to call when the operation is done. |
[in] | data | The data to pass to the callback. |
enum SqshFileType sqsh_file_type | ( | const struct SqshFile * | context | ) |
returns the type of the file.
[in] | context | The file context. |
uint32_t sqsh_file_uid | ( | const struct SqshFile * | context | ) |
returns the owner user id of the file.
[in] | context | The file context. |
uint32_t sqsh_file_xattr_index | ( | const struct SqshFile * | context | ) |
returns index of the extended attribute inside of the xattr table.
[in] | context | The file context. |
SQSH_NO_UNUSED struct SqshFile * sqsh_lopen | ( | struct SqshArchive * | archive, |
const char * | path, | ||
int * | err ) |
Initialize the file context from a path. This function is identical to sqsh_open()
but if the path is a symlink, the symlink target not resolved.
[in] | archive | The sqsh archive context. |
[in] | path | The path the file or directory. |
[out] | err | Pointer to an int where the error code will be stored. |
SQSH_NO_UNUSED struct SqshFile * sqsh_open | ( | struct SqshArchive * | archive, |
const char * | path, | ||
int * | err ) |
Initialize the file context from a path.
[in] | archive | The sqsh archive context. |
[in] | path | The path the file or directory. |
[out] | err | Pointer to an int where the error code will be stored. |
SQSH_NO_UNUSED struct SqshFile * sqsh_open_by_ref | ( | struct SqshArchive * | archive, |
uint64_t | inode_ref, | ||
int * | err ) |
Initializes a file context in heap.
archive | The sqsh context to use. | |
inode_ref | The inode reference to initialize the context with. | |
[out] | err | Pointer to an int where the error code will be stored. |