diff --git a/libisofs/filters/zisofs.c b/libisofs/filters/zisofs.c index 600c2dc..16435e9 100644 --- a/libisofs/filters/zisofs.c +++ b/libisofs/filters/zisofs.c @@ -112,6 +112,11 @@ static double ziso_keep_blocks_free_ratio = ISO_ZISOFS_KBF_RATIO; */ static int ziso_early_bpt_discard = 0; +/* 1 = produce Z2 entries for zisofs2 , 0 = produce ZF for zisofs2 + * This is used as extern variable in rockridge.c + */ +int iso_zisofs2_enable_susp_z2 = 0; + static int ziso_decide_v2_usage(off_t orig_size) @@ -1796,3 +1801,12 @@ int iso_stream_zisofs_discard_bpt(IsoStream *stream, int flag) #endif /* ! Libisofs_with_zliB */ } + + +/* API */ +int iso_zisofs_ctrl_susp_z2(int enable) +{ + if (enable == 0 || enable == 1) + iso_zisofs2_enable_susp_z2 = enable; + return iso_zisofs2_enable_susp_z2; +} diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 4021517..a054289 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -1596,7 +1596,8 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent, while ((ret = susp_iter_next(iter, &sue, 0)) > 0) { /* ignore entries from different version */ - if (sue->version[0] != 1 && !(SUSP_SIG(sue, 'Z', 'F'))) + if (sue->version[0] != 1 && + !(SUSP_SIG(sue, 'Z', 'F') || SUSP_SIG(sue, 'Z', '2'))) continue; if (SUSP_SIG(sue, 'P', 'X')) { @@ -1803,7 +1804,7 @@ if (name != NULL && !namecont) { #ifdef Libisofs_with_zliB - } else if (SUSP_SIG(sue, 'Z', 'F')) { + } else if (SUSP_SIG(sue, 'Z', 'F') || SUSP_SIG(sue, 'Z', '2')) { ret = read_zisofs_ZF(sue, zisofs_alg, &zisofs_hs4, &zisofs_bsl2, &zisofs_usize, 0); @@ -1811,7 +1812,9 @@ if (name != NULL && !namecont) { invalid_zf: /* notify and continue */ ret = iso_rr_msg_submit(fsdata, 13, ISO_WRONG_RR_WARN, ret, - "Invalid ZF entry"); + SUSP_SIG(sue, 'Z', 'F') ? + "Invalid ZF entry" : + "Invalid Z2 entry"); zisofs_hs4 = 0; continue; } diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 712415f..74959ea 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -8182,6 +8182,21 @@ int iso_zisofs_set_params(struct iso_zisofs_ctrl *params, int flag); int iso_zisofs_get_params(struct iso_zisofs_ctrl *params, int flag); +/** + * Enable or disable the production and recognition of "Z2" SUSP entries + * instead of "ZF" entries for zisofs2 compressed files. + * "ZF" with zisofs2 causes unaware Linux kernels to complian like: + * isofs: Unknown ZF compression algorithm: PZ + * "Z2" is silently ignored by unaware Linux kernels. + * @param enable + * 1 = produce and recognize "Z2" , 0 = only "ZF" , -1 = do not change + * @return + * 1 = enabled , 0 = not enabled + * @since 1.5.4 + */ +int iso_zisofs_ctrl_susp_z2(int enable); + + /** * Check for the given node or for its subtree whether the data file content * effectively bears zisofs file headers and eventually mark the outcome diff --git a/libisofs/libisofs.ver b/libisofs/libisofs.ver index be454a0..f2525c0 100644 --- a/libisofs/libisofs.ver +++ b/libisofs/libisofs.ver @@ -370,6 +370,7 @@ iso_write_opts_set_system_area; iso_write_opts_set_tail_blocks; iso_write_opts_set_untranslated_name_len; iso_write_opts_set_will_cancel; +iso_zisofs_ctrl_susp_z2; iso_zisofs_get_params; iso_zisofs_get_refcounts; iso_zisofs_set_params; diff --git a/libisofs/rockridge.c b/libisofs/rockridge.c index a7da5d9..22c6485 100644 --- a/libisofs/rockridge.c +++ b/libisofs/rockridge.c @@ -961,16 +961,22 @@ int zisofs_add_ZF(Ecma119Image *t, struct susp_info *susp, int to_ce, { unsigned char *ZF = malloc(16); + /* Intimate friendship with this variable in filters/zisofs.c */ + extern int iso_zisofs2_enable_susp_z2; + if (ZF == NULL) { return ISO_OUT_OF_MEM; } ZF[0] = 'Z'; ZF[1] = 'F'; ZF[2] = (unsigned char) 16; - if (algo[0] == 'p' && algo[1] == 'z') + if (algo[0] == 'p' && algo[1] == 'z') { ZF[3] = (unsigned char) 1; - else + } else { ZF[3] = (unsigned char) 2; + if (iso_zisofs2_enable_susp_z2) + ZF[1] = '2'; + } ZF[4] = (unsigned char) algo[0]; ZF[5] = (unsigned char) algo[1]; ZF[6] = (unsigned char) header_size_div4; diff --git a/libisofs/rockridge_read.c b/libisofs/rockridge_read.c index 9741799..db27a5d 100644 --- a/libisofs/rockridge_read.c +++ b/libisofs/rockridge_read.c @@ -629,9 +629,9 @@ int read_zisofs_ZF(struct susp_sys_user_entry *zf, uint8_t algorithm[2], if (zf == NULL) { return ISO_NULL_POINTER; } - if (zf->sig[0] != 'Z' || zf->sig[1] != 'F') { + if ((zf->sig[0] != 'Z' || zf->sig[1] != 'F') && + (zf->sig[0] != 'Z' || zf->sig[1] != '2')) return ISO_WRONG_ARG_VALUE; - } if (zf->len_sue[0] != 16) { return ISO_WRONG_RR; }