xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

zisofs.c File Reference
#include "../libisofs.h"
#include "../filter.h"
#include "../fsource.h"
#include "../util.h"
#include "../stream.h"
#include "../messages.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
Include dependency graph for zisofs.c:

Go to the source code of this file.

Data Structures

struct  ZisofsFilterRuntime
 
struct  ZisofsFilterStreamData
 
struct  ZisofsComprStreamData
 
struct  ZisofsUncomprStreamData
 

Macros

#define ISO_ZISOFS_V1_LIMIT   4294967296
 
#define ISO_ZISOFS_V1_MIN_LOG2   15
 
#define ISO_ZISOFS_V1_MAX_LOG2   17
 
#define ISO_ZISOFS_V2_MIN_LOG2   15
 
#define ISO_ZISOFS_V2_MAX_LOG2   20
 
#define ISO_ZISOFS_MAX_BLOCKS_T   0x2000000
 
#define ISO_ZISOFS_MAX_BLOCKS_F   0x2000000
 
#define ISO_ZISOFS_MANY_BLOCKS   0
 
#define ISO_ZISOFS_KBF_RATIO   -1.0
 

Functions

static uint64_t ziso_block_pointer_mgt (uint64_t num, int mode)
 
static int ziso_decide_v2_usage (off_t orig_size)
 
static int ziso_decide_bs_log2 (off_t orig_size)
 
static int ziso_running_destroy (ZisofsFilterRuntime **running, int flag)
 
static int ziso_running_new (ZisofsFilterRuntime **running, off_t orig_size, int flag)
 
static int ziso_stream_uncompress (IsoStream *stream, void *buf, size_t desired)
 
static int ziso_stream_compress (IsoStream *stream, void *buf, size_t desired)
 
static int ziso_discard_bpt (IsoStream *stream, int flag)
 
static int ziso_stream_close_flag (IsoStream *stream, int flag)
 
static int ziso_stream_close (IsoStream *stream)
 
static int ziso_stream_open_flag (IsoStream *stream, int flag)
 
static int ziso_stream_open (IsoStream *stream)
 
static off_t ziso_stream_measure_size (IsoStream *stream, int flag)
 
static int ziso_num_to_algo (uint8_t num, uint8_t zisofs_algo[2])
 
static int ziso_parse_zisofs_head (IsoStream *stream, uint8_t *ziso_algo_num, int *header_size_div4, int *block_size_log2, uint64_t *uncompressed_size, int flag)
 
static off_t ziso_stream_get_size (IsoStream *stream)
 
static int ziso_stream_is_repeatable (IsoStream *stream)
 
static void ziso_stream_get_id (IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
 
static void ziso_stream_free (IsoStream *stream)
 
static int ziso_update_size (IsoStream *stream)
 
static IsoStreamziso_get_input_stream (IsoStream *stream, int flag)
 
static int ziso_clone_stream (IsoStream *old_stream, IsoStream **new_stream, int flag)
 
static int ziso_cmp_ino (IsoStream *s1, IsoStream *s2)
 
static int ziso_uncompress_cmp_ino (IsoStream *s1, IsoStream *s2)
 
int ziso_add_filter (IsoFile *file, int flag)
 
int iso_file_add_zisofs_filter (IsoFile *file, int flag)
 
int iso_zisofs_get_refcounts (off_t *ziso_count, off_t *osiz_count, int flag)
 
int ziso_add_osiz_filter (IsoFile *file, uint8_t zisofs_algo[2], uint8_t header_size_div4, uint8_t block_size_log2, uint64_t uncompressed_size, int flag)
 
int ziso_is_zisofs_stream (IsoStream *stream, int *stream_type, uint8_t zisofs_algo[2], int *header_size_div4, int *block_size_log2, uint64_t *uncompressed_size, int flag)
 
int iso_zisofs_set_params (struct iso_zisofs_ctrl *params, int flag)
 
int iso_zisofs_get_params (struct iso_zisofs_ctrl *params, int flag)
 
int iso_stream_get_zisofs_par (IsoStream *stream, int *stream_type, uint8_t zisofs_algo[2], uint8_t *algo_num, int *block_size_log2, int flag)
 
int iso_stream_zisofs_discard_bpt (IsoStream *stream, int flag)
 
int iso_zisofs_ctrl_susp_z2 (int enable)
 

Variables

static uint8_t ziso_block_size_log2 = 15
 
static int ziso_v2_enabled = 0
 
static int ziso_v2_block_size_log2 = 17
 
static int64_t ziso_block_number_target = -1
 
static int64_t ziso_max_total_blocks = 0x2000000
 
static int64_t ziso_max_file_blocks = 0x2000000
 
static int64_t ziso_many_block_limit = 0
 
static double ziso_keep_blocks_free_ratio = -1.0
 
static int ziso_early_bpt_discard = 0
 
int iso_zisofs2_enable_susp_z2 = 0
 
static unsigned char zisofs_magic [9]
 
static unsigned char zisofs2_magic [9]
 
static off_t ziso_ref_count = 0
 
static off_t ziso_osiz_ref_count = 0
 
static ino_t ziso_ino_id = 0
 
IsoStreamIface ziso_stream_compress_class
 
IsoStreamIface ziso_stream_uncompress_class
 

Macro Definition Documentation

◆ ISO_ZISOFS_KBF_RATIO

#define ISO_ZISOFS_KBF_RATIO   -1.0

Definition at line 90 of file zisofs.c.

◆ ISO_ZISOFS_MANY_BLOCKS

#define ISO_ZISOFS_MANY_BLOCKS   0

Definition at line 84 of file zisofs.c.

◆ ISO_ZISOFS_MAX_BLOCKS_F

#define ISO_ZISOFS_MAX_BLOCKS_F   0x2000000

Definition at line 75 of file zisofs.c.

◆ ISO_ZISOFS_MAX_BLOCKS_T

#define ISO_ZISOFS_MAX_BLOCKS_T   0x2000000

Definition at line 67 of file zisofs.c.

◆ ISO_ZISOFS_V1_LIMIT

#define ISO_ZISOFS_V1_LIMIT   4294967296

Definition at line 49 of file zisofs.c.

◆ ISO_ZISOFS_V1_MAX_LOG2

#define ISO_ZISOFS_V1_MAX_LOG2   17

Definition at line 57 of file zisofs.c.

◆ ISO_ZISOFS_V1_MIN_LOG2

#define ISO_ZISOFS_V1_MIN_LOG2   15

Definition at line 56 of file zisofs.c.

◆ ISO_ZISOFS_V2_MAX_LOG2

#define ISO_ZISOFS_V2_MAX_LOG2   20

Definition at line 59 of file zisofs.c.

◆ ISO_ZISOFS_V2_MIN_LOG2

#define ISO_ZISOFS_V2_MIN_LOG2   15

Definition at line 58 of file zisofs.c.

Function Documentation

◆ iso_file_add_zisofs_filter()

int iso_file_add_zisofs_filter ( IsoFile file,
int  flag 
)

Install a zisofs filter on top of the content stream of a data file. zisofs is a compression format which is decompressed by some Linux kernels. See also doc/zisofs_format.txt and doc/zisofs2_format.txt. The filter will not be installed if its output size is not smaller than the size of the input stream. This is only enabled if the use of libz was enabled at compile time.

Parameters
fileThe data file node which shall show filtered content.
flagBitfield for control purposes bit0= Do not install filter if the number of output blocks is not smaller than the number of input blocks. Block size is 2048. bit1= Install a decompression filter rather than one for compression. bit2= Only inquire availability of zisofs filtering. file may be NULL. If available return 2, else return error. bit3= is reserved for internal use and will be forced to 0
Returns
1 on success, 2 if filter available but installation revoked <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
Since
0.6.18

Definition at line 1547 of file zisofs.c.

References ziso_add_filter().

Referenced by Xorriso_list_extras(), and Xorriso_set_filter().

◆ iso_stream_get_zisofs_par()

int iso_stream_get_zisofs_par ( IsoStream stream,
int *  stream_type,
uint8_t  zisofs_algo[2],
uint8_t *  algo_num,
int *  block_size_log2,
int  flag 
)

Obtain the parameters of a zisofs filter stream.

Parameters
streamThe stream to be inquired.
stream_type1=compressing ("ziso") -1=uncompressing ("osiz") 0 other (any obtained parameters have invalid content)
zisofs_algoAlgorithm as of ZF field: {'p', 'z'} = zisofs version 1 (Zlib) {'P', 'Z'} = zisofs version 2 (Zlib)
algo_numAlgorithm as of zisofs header: 0 = zisofs version 1 (Zlib) 1 = zisofs version 2 (Zlib)
block_size_log2Log2 of the compression block size 15 = 32 kiB , 16 = 64 kiB , 17 = 128 kiB, ...
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, 0 if the stream has not class->type "ziso" or "osiz" <0 on error
Since
1.5.4

Definition at line 1755 of file zisofs.c.

References ISO_NULL_POINTER, ISO_ZLIB_NOT_ENABLED, and ziso_is_zisofs_stream().

Referenced by Xorriso_stream_type().

◆ iso_stream_zisofs_discard_bpt()

int iso_stream_zisofs_discard_bpt ( IsoStream stream,
int  flag 
)

Discard the buffered zisofs compression block pointers of a stream, if the stream is a zisofs compression stream and not currently opened.

Parameters
streamThe stream to be manipulated.
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, 0 if no block pointers were reoved, <0 on error
Since
1.5.4

Definition at line 1785 of file zisofs.c.

References ISO_NULL_POINTER, ISO_ZLIB_NOT_ENABLED, and ziso_discard_bpt().

Referenced by iso_dir_zisofs_discard_bpt().

◆ iso_zisofs_ctrl_susp_z2()

int iso_zisofs_ctrl_susp_z2 ( int  enable)

Enable or disable the production of "Z2" SUSP entries instead of "ZF" entries for zisofs2 compressed files. "ZF" with zisofs2 causes unaware Linux kernels to complain like: isofs: Unknown ZF compression algorithm: PZ "Z2" is silently ignored by unaware Linux kernels.

Parameters
enable1 = produce "Z2" , 0 = only "ZF" , -1 = do not change
Returns
1 = enabled , 0 = not enabled
Since
1.5.4

Definition at line 1807 of file zisofs.c.

References iso_zisofs2_enable_susp_z2.

Referenced by Xorriso_set_zisofs_params(), and Xorriso_startup_libraries().

◆ iso_zisofs_get_params()

int iso_zisofs_get_params ( struct iso_zisofs_ctrl params,
int  flag 
)

Get the current global parameters for zisofs filtering.

Parameters
paramsPointer to a caller provided structure which shall take the settings. The caller sets params->version to indicate which set of members shall be filled. I.e. params->version == 0 leaves all members after params->block_size_log2 untouched.
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, <0 on error
Since
0.6.18

Definition at line 1723 of file zisofs.c.

References ISO_WRONG_ARG_VALUE, ISO_ZLIB_NOT_ENABLED, ziso_block_number_target, ziso_block_pointer_mgt(), ziso_block_size_log2, ziso_keep_blocks_free_ratio, ziso_many_block_limit, ziso_max_file_blocks, ziso_max_total_blocks, ziso_v2_block_size_log2, and ziso_v2_enabled.

Referenced by Xorriso_set_zisofs_params(), Xorriso_startup_libraries(), and Xorriso_zisofs_current_blocks().

◆ iso_zisofs_get_refcounts()

int iso_zisofs_get_refcounts ( off_t *  ziso_count,
off_t *  osiz_count,
int  flag 
)

Inquire the number of zisofs compression and uncompression filters which are in use.

Parameters
ziso_countWill return the number of currently installed compression filters.
osiz_countWill return the number of currently installed uncompression filters.
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, <0 on error
Since
0.6.18

Definition at line 1554 of file zisofs.c.

References ISO_SUCCESS, ziso_osiz_ref_count, and ziso_ref_count.

Referenced by Xorriso_status_zisofs().

◆ iso_zisofs_set_params()

int iso_zisofs_set_params ( struct iso_zisofs_ctrl params,
int  flag 
)

Set the global parameters for zisofs filtering. This is only allowed while no zisofs compression filters are installed. i.e. ziso_count returned by iso_zisofs_get_refcounts() has to be 0.

Parameters
paramsPointer to a structure with the intended settings. The caller sets params->version to indicate which set of members has been filled. I.e. params->version == 0 causes all members after params->block_size_log2 to be ignored.
flagBitfield for control purposes, unused yet, submit 0
Returns
1 on success, <0 on error
Since
0.6.18

Definition at line 1669 of file zisofs.c.

References ISO_WRONG_ARG_VALUE, ISO_ZISOFS_PARAM_LOCK, ISO_ZISOFS_V1_MAX_LOG2, ISO_ZISOFS_V1_MIN_LOG2, ISO_ZISOFS_V2_MAX_LOG2, ISO_ZISOFS_V2_MIN_LOG2, ISO_ZLIB_NOT_ENABLED, ziso_block_number_target, ziso_block_size_log2, ziso_keep_blocks_free_ratio, ziso_many_block_limit, ziso_max_file_blocks, ziso_max_total_blocks, ziso_ref_count, ziso_v2_block_size_log2, and ziso_v2_enabled.

Referenced by Xorriso_set_zisofs_params().

◆ ziso_add_filter()

◆ ziso_add_osiz_filter()

int ziso_add_osiz_filter ( IsoFile file,
uint8_t  zisofs_algo[2],
uint8_t  header_size_div4,
uint8_t  block_size_log2,
uint64_t  uncompressed_size,
int  flag 
)

◆ ziso_block_pointer_mgt()

static uint64_t ziso_block_pointer_mgt ( uint64_t  num,
int  mode 
)
static

◆ ziso_clone_stream()

◆ ziso_cmp_ino()

static int ziso_cmp_ino ( IsoStream s1,
IsoStream s2 
)
static

◆ ziso_decide_bs_log2()

◆ ziso_decide_v2_usage()

static int ziso_decide_v2_usage ( off_t  orig_size)
static

Definition at line 122 of file zisofs.c.

References ISO_ZISOFS_V1_LIMIT, and ziso_v2_enabled.

Referenced by ziso_decide_bs_log2(), ziso_is_zisofs_stream(), and ziso_stream_compress().

◆ ziso_discard_bpt()

◆ ziso_get_input_stream()

static IsoStream* ziso_get_input_stream ( IsoStream stream,
int  flag 
)
static

Definition at line 1204 of file zisofs.c.

References iso_stream::data, and ZisofsFilterStreamData::orig.

◆ ziso_is_zisofs_stream()

◆ ziso_num_to_algo()

static int ziso_num_to_algo ( uint8_t  num,
uint8_t  zisofs_algo[2] 
)
static

Definition at line 844 of file zisofs.c.

Referenced by ziso_is_zisofs_stream().

◆ ziso_parse_zisofs_head()

static int ziso_parse_zisofs_head ( IsoStream stream,
uint8_t *  ziso_algo_num,
int *  header_size_div4,
int *  block_size_log2,
uint64_t *  uncompressed_size,
int  flag 
)
static

◆ ziso_running_destroy()

◆ ziso_running_new()

◆ ziso_stream_close()

static int ziso_stream_close ( IsoStream stream)
static

Definition at line 468 of file zisofs.c.

References ziso_stream_close_flag().

Referenced by ziso_stream_free().

◆ ziso_stream_close_flag()

◆ ziso_stream_compress()

static int ziso_stream_compress ( IsoStream stream,
void *  buf,
size_t  desired 
)
static

◆ ziso_stream_free()

◆ ziso_stream_get_id()

static void ziso_stream_get_id ( IsoStream stream,
unsigned int *  fs_id,
dev_t *  dev_id,
ino_t *  ino_id 
)
static

◆ ziso_stream_get_size()

static off_t ziso_stream_get_size ( IsoStream stream)
static

◆ ziso_stream_is_repeatable()

static int ziso_stream_is_repeatable ( IsoStream stream)
static

Definition at line 1143 of file zisofs.c.

◆ ziso_stream_measure_size()

static off_t ziso_stream_measure_size ( IsoStream stream,
int  flag 
)
static

◆ ziso_stream_open()

static int ziso_stream_open ( IsoStream stream)
static

Definition at line 524 of file zisofs.c.

References ziso_stream_open_flag().

◆ ziso_stream_open_flag()

◆ ziso_stream_uncompress()

◆ ziso_uncompress_cmp_ino()

static int ziso_uncompress_cmp_ino ( IsoStream s1,
IsoStream s2 
)
static

◆ ziso_update_size()

static int ziso_update_size ( IsoStream stream)
static

Definition at line 1196 of file zisofs.c.

Variable Documentation

◆ iso_zisofs2_enable_susp_z2

int iso_zisofs2_enable_susp_z2 = 0

Definition at line 118 of file zisofs.c.

Referenced by iso_zisofs_ctrl_susp_z2(), and zisofs_add_ZF().

◆ ziso_block_number_target

int64_t ziso_block_number_target = -1
static

Definition at line 101 of file zisofs.c.

Referenced by iso_zisofs_get_params(), iso_zisofs_set_params(), and ziso_decide_bs_log2().

◆ ziso_block_size_log2

uint8_t ziso_block_size_log2 = 15
static

Definition at line 96 of file zisofs.c.

Referenced by iso_zisofs_get_params(), iso_zisofs_set_params(), and ziso_decide_bs_log2().

◆ ziso_early_bpt_discard

int ziso_early_bpt_discard = 0
static

Definition at line 113 of file zisofs.c.

Referenced by ziso_discard_bpt(), ziso_stream_compress(), and ziso_stream_free().

◆ ziso_ino_id

ino_t ziso_ino_id = 0
static

Definition at line 375 of file zisofs.c.

Referenced by ziso_clone_stream().

◆ ziso_keep_blocks_free_ratio

double ziso_keep_blocks_free_ratio = -1.0
static

Definition at line 107 of file zisofs.c.

Referenced by iso_zisofs_get_params(), iso_zisofs_set_params(), and ziso_discard_bpt().

◆ ziso_many_block_limit

int64_t ziso_many_block_limit = 0
static

Definition at line 106 of file zisofs.c.

Referenced by iso_zisofs_get_params(), iso_zisofs_set_params(), and ziso_discard_bpt().

◆ ziso_max_file_blocks

int64_t ziso_max_file_blocks = 0x2000000
static

◆ ziso_max_total_blocks

int64_t ziso_max_total_blocks = 0x2000000
static

◆ ziso_osiz_ref_count

off_t ziso_osiz_ref_count = 0
static

Definition at line 308 of file zisofs.c.

Referenced by iso_zisofs_get_refcounts(), and ziso_stream_free().

◆ ziso_ref_count

off_t ziso_ref_count = 0
static

Definition at line 305 of file zisofs.c.

Referenced by iso_zisofs_get_refcounts(), iso_zisofs_set_params(), and ziso_stream_free().

◆ ziso_stream_compress_class

IsoStreamIface ziso_stream_compress_class
Initial value:
= {
4,
"ziso",
}
static IsoStream * ziso_get_input_stream(IsoStream *stream, int flag)
Definition: zisofs.c:1204
static void ziso_stream_free(IsoStream *stream)
Definition: zisofs.c:1164
static int ziso_stream_open(IsoStream *stream)
Definition: zisofs.c:524
static int ziso_stream_is_repeatable(IsoStream *stream)
Definition: zisofs.c:1143
static int ziso_update_size(IsoStream *stream)
Definition: zisofs.c:1196
static int ziso_stream_close(IsoStream *stream)
Definition: zisofs.c:468
static int ziso_clone_stream(IsoStream *old_stream, IsoStream **new_stream, int flag)
Definition: zisofs.c:1216
static void ziso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id)
Definition: zisofs.c:1151
static int ziso_stream_compress(IsoStream *stream, void *buf, size_t desired)
Definition: zisofs.c:577
static int ziso_cmp_ino(IsoStream *s1, IsoStream *s2)
Definition: zisofs.c:1316
static off_t ziso_stream_get_size(IsoStream *stream)
Definition: zisofs.c:1127

Definition at line 1281 of file zisofs.c.

Referenced by ziso_cmp_ino(), and ziso_is_zisofs_stream().

◆ ziso_stream_uncompress_class

IsoStreamIface ziso_stream_uncompress_class
Initial value:
= {
4,
"osiz",
}
static int ziso_uncompress_cmp_ino(IsoStream *s1, IsoStream *s2)
Definition: zisofs.c:1334
static int ziso_stream_uncompress(IsoStream *stream, void *buf, size_t desired)
Definition: zisofs.c:944

Definition at line 1298 of file zisofs.c.

Referenced by ziso_cmp_ino(), ziso_is_zisofs_stream(), and ziso_uncompress_cmp_ino().

◆ ziso_v2_block_size_log2

int ziso_v2_block_size_log2 = 17
static

Definition at line 99 of file zisofs.c.

Referenced by iso_zisofs_get_params(), iso_zisofs_set_params(), and ziso_decide_bs_log2().

◆ ziso_v2_enabled

int ziso_v2_enabled = 0
static

◆ zisofs2_magic

unsigned char zisofs2_magic[9]
static
Initial value:
=
{0xEF, 0x22, 0x55, 0xA1, 0xBC, 0x1B, 0x95, 0xA0}

Definition at line 301 of file zisofs.c.

Referenced by ziso_parse_zisofs_head(), and ziso_stream_compress().

◆ zisofs_magic

unsigned char zisofs_magic[9]
static
Initial value:
=
{0x37, 0xE4, 0x53, 0x96, 0xC9, 0xDB, 0xD6, 0x07}

Definition at line 297 of file zisofs.c.

Referenced by ziso_parse_zisofs_head(), and ziso_stream_compress().