"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/rockridge.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

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.

rockridge.c  (xorriso-1.5.2):rockridge.c  (xorriso-1.5.4)
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2007 Mario Danic * Copyright (c) 2007 Mario Danic
* Copyright (c) 2009 - 2015 Thomas Schmitt * Copyright (c) 2009 - 2020 Thomas Schmitt
* *
* This file is part of the libisofs project; you can redistribute it and/or * This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 * modify it under the terms of the GNU General Public License version 2
* or later as published by the Free Software Foundation. * or later as published by the Free Software Foundation.
* See COPYING file for details. * See COPYING file for details.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
skipping to change at line 377 skipping to change at line 377
int ret; int ret;
if (!strcmp(input_charset, output_charset)) { if (!strcmp(input_charset, output_charset)) {
/* no conversion needed */ /* no conversion needed */
ret = iso_clone_mem(str, name, 0); ret = iso_clone_mem(str, name, 0);
return ret; return ret;
} }
ret = strconv(str, input_charset, output_charset, name); ret = strconv(str, input_charset, output_charset, name);
if (ret < 0) { if (ret < 0) {
/* TODO we should check for possible cancelation */ /* TODO we should check for possible cancellation */
if (!(flag & 1)) if (!(flag & 1))
iso_msg_submit(imgid, ISO_FILENAME_WRONG_CHARSET, ret, iso_msg_submit(imgid, ISO_FILENAME_WRONG_CHARSET, ret,
"Charset conversion error. Cannot convert %s from %s to %s", "Charset conversion error. Cannot convert %s from %s to %s",
str, input_charset, output_charset); str, input_charset, output_charset);
*name = NULL; *name = NULL;
return ISO_FILENAME_WRONG_CHARSET; return ISO_FILENAME_WRONG_CHARSET;
} }
return ISO_SUCCESS; return ISO_SUCCESS;
} }
skipping to change at line 570 skipping to change at line 570
SL[2] = total_comp_len + 5; SL[2] = total_comp_len + 5;
SL[3] = 1; SL[3] = 1;
SL[4] = 1; /* CONTINUE */ SL[4] = 1; /* CONTINUE */
pos = 5; pos = 5;
for (j = written; j < i; j++) { for (j = written; j < i; j++) {
memcpy(&SL[pos], comp[j], comp[j][1] + 2); memcpy(&SL[pos], comp[j], comp[j][1] + 2);
pos += comp[j][1] + 2; pos += comp[j][1] + 2;
} }
/* /*
* In this case we are sure we're writting to CE. Check for * In this case we are sure we're writing to CE. Check for
* debug purposes * debug purposes
*/ */
if (ce == 0) { if (ce == 0) {
free(SL); free(SL);
return ISO_ASSERT_FAILURE; return ISO_ASSERT_FAILURE;
} }
ret = susp_append_ce(t, susp, SL); ret = susp_append_ce(t, susp, SL);
if (ret < 0) { if (ret < 0) {
free(SL); free(SL);
return ret; return ret;
skipping to change at line 941 skipping to change at line 941
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
pad[0] = 0; pad[0] = 0;
ret = susp_append_ce(t, susp, pad); ret = susp_append_ce(t, susp, pad);
if (ret < 0) if (ret < 0)
return ret; return ret;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/** /**
* see doc/zisofs_format.txt : "ZF System Use Entry Format" * see doc/zisofs_format.txt : "ZF System Use Entry Format"
* see doc/zisofs2_format.txt : "ZF System Use Entry Format", "Z2 ..."
*/ */
static static
int zisofs_add_ZF(Ecma119Image *t, struct susp_info *susp, int to_ce, int zisofs_add_ZF(Ecma119Image *t, struct susp_info *susp, int to_ce,
int header_size_div4, int block_size_log2, uint8_t algo[2], int header_size_div4, int block_size_log2,
uint32_t uncompressed_size, int flag) uint64_t uncompressed_size, int flag)
{ {
unsigned char *ZF = malloc(16); unsigned char *ZF = malloc(16);
/* Intimate friendship with this variable in filters/zisofs.c */
extern int iso_zisofs2_enable_susp_z2;
if (ZF == NULL) { if (ZF == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
} }
ZF[0] = 'Z'; ZF[0] = 'Z';
ZF[1] = 'F'; ZF[1] = 'F';
ZF[2] = (unsigned char) 16; ZF[2] = (unsigned char) 16;
ZF[3] = (unsigned char) 1; if (algo[0] == 'p' && algo[1] == 'z') {
ZF[4] = (unsigned char) 'p'; ZF[3] = (unsigned char) 1;
ZF[5] = (unsigned char) 'z'; } 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; ZF[6] = (unsigned char) header_size_div4;
ZF[7] = (unsigned char) block_size_log2; ZF[7] = (unsigned char) block_size_log2;
iso_bb(&ZF[8], uncompressed_size, 4); if (algo[0] == 'p' && algo[1] == 'z') {
if (uncompressed_size > (uint64_t) 0xffffffff)
return ISO_ZISOFS_TOO_LARGE;
iso_bb(&ZF[8], (uint32_t) uncompressed_size, 4);
} else {
iso_lsb64(&ZF[8], uncompressed_size);
}
if (to_ce) { if (to_ce) {
return susp_append_ce(t, susp, ZF); return susp_append_ce(t, susp, ZF);
} else { } else {
return susp_append(t, susp, ZF); return susp_append(t, susp, ZF);
} }
} }
/* @param flag bit0= Do not add data but only count sua_free and ce_len /* @param flag bit0= Do not add data but only count sua_free and ce_len
bit1= account for crossing block boundaries bit1= account for crossing block boundaries
(implied by bit0 == 0) (implied by bit0 == 0)
*/ */
static static
int add_zf_field(Ecma119Image *t, Ecma119Node *n, struct susp_info *info, int add_zf_field(Ecma119Image *t, Ecma119Node *n, struct susp_info *info,
size_t *sua_free, size_t *ce_len, size_t base_ce, int flag) size_t *sua_free, size_t *ce_len, size_t base_ce, int flag)
{ {
int ret, will_copy = 1, stream_type = 0, do_zf = 0; int ret, will_copy = 1, stream_type = 0, do_zf = 0;
int header_size_div4 = 0, block_size_log2 = 0; int header_size_div4 = 0, block_size_log2 = 0;
uint32_t uncompressed_size = 0; uint64_t uncompressed_size = 0;
IsoStream *stream = NULL, *input_stream, *last_stream, *first_stream; IsoStream *stream = NULL, *input_stream, *last_stream, *first_stream;
IsoStream *first_filter = NULL; IsoStream *first_filter = NULL;
IsoFile *file; IsoFile *file;
void *xipt; void *xipt;
struct zisofs_zf_info *zf; struct zisofs_zf_info *zf;
uint8_t algo[2];
/* Intimate friendship with this function in filters/zisofs.c */ /* Intimate friendship with this function in filters/zisofs.c */
int ziso_is_zisofs_stream(IsoStream *stream, int *stream_type, int ziso_is_zisofs_stream(IsoStream *stream, int *stream_type,
uint8_t zisofs_algo[2],
int *header_size_div4, int *block_size_log2, int *header_size_div4, int *block_size_log2,
uint32_t *uncompressed_size, int flag); uint64_t *uncompressed_size, int flag);
if (!(flag & 1)) if (!(flag & 1))
flag |= 2; flag |= 2;
if (iso_node_get_type(n->node) != LIBISO_FILE) if (iso_node_get_type(n->node) != LIBISO_FILE)
return 2; return 2;
file = (IsoFile *) n->node; file = (IsoFile *) n->node;
/* Inspect: last_stream < ... < first_filter < first_stream */ /* Inspect: last_stream < ... < first_filter < first_stream */
/* The content is in zisofs format if: /* The content is in zisofs format if:
skipping to change at line 1030 skipping to change at line 1048
first_stream = input_stream; first_stream = input_stream;
} }
if (will_copy) { if (will_copy) {
stream = last_stream; stream = last_stream;
} else { } else {
/* (the eventual osiz filter on the image stream) */ /* (the eventual osiz filter on the image stream) */
stream = first_filter; stream = first_filter;
} }
/* Determine stream type : 1=ziso , -1=osiz , 0=other */ /* Determine stream type : 1=ziso , -1=osiz , 0=other */
ret = ziso_is_zisofs_stream(stream, &stream_type, &header_size_div4, algo[0] = algo[1] = 0;
ret = ziso_is_zisofs_stream(stream, &stream_type, algo, &header_size_div4,
&block_size_log2, &uncompressed_size, 0); &block_size_log2, &uncompressed_size, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (stream_type == 1 && will_copy) { if (stream_type == 1 && will_copy) {
do_zf = 1; do_zf = 1;
} else if (stream_type == -1 && !will_copy) { } else if (stream_type == -1 && !will_copy) {
do_zf = 1; do_zf = 1;
} else if(first_stream == last_stream || !will_copy) { } else if(first_stream == last_stream || !will_copy) {
/* Try whether the image side stream remembers a ZF field */ /* Try whether the image side stream remembers a ZF field */
ret = iso_stream_get_src_zf(first_stream, &header_size_div4, ret = iso_stream_get_src_zf(first_stream, algo, &header_size_div4,
&block_size_log2, &uncompressed_size, 0); &block_size_log2, &uncompressed_size, 0);
if (ret == 1 && header_size_div4 > 0) if (ret == 1 && header_size_div4 > 0)
do_zf = 1; do_zf = 1;
} }
if (!do_zf) { if (!do_zf) {
/* Look for an xinfo mark of a zisofs header */ /* Look for an xinfo mark of a zisofs header */
ret = iso_node_get_xinfo((IsoNode *) file, zisofs_zf_xinfo_func, ret = iso_node_get_xinfo((IsoNode *) file, zisofs_zf_xinfo_func,
&xipt); &xipt);
if (ret == 1) { if (ret == 1) {
zf = xipt; zf = xipt;
header_size_div4 = zf->header_size_div4; header_size_div4 = zf->header_size_div4;
block_size_log2 = zf->block_size_log2; block_size_log2 = zf->block_size_log2;
uncompressed_size = zf->uncompressed_size; uncompressed_size = zf->uncompressed_size;
algo[0] = zf->zisofs_algo[0];
algo[1] = zf->zisofs_algo[1];
if (header_size_div4 > 0) if (header_size_div4 > 0)
do_zf = 1; do_zf = 1;
} }
} }
if (!do_zf) if (!do_zf)
return 2; return 2;
/* Account for field size */ /* Account for field size */
if (*sua_free < 16 || *ce_len > 0) { if (*sua_free < 16 || *ce_len > 0) {
susp_calc_add_to_ce(ce_len, base_ce, 16, flag & 2); susp_calc_add_to_ce(ce_len, base_ce, 16, flag & 2);
} else { } else {
*sua_free -= 16; *sua_free -= 16;
} }
if (flag & 1) if (flag & 1)
return 1; return 1;
/* write ZF field */ /* write ZF field */
ret = zisofs_add_ZF(t, info, (*ce_len > 0), header_size_div4, ret = zisofs_add_ZF(t, info, (*ce_len > 0), algo, header_size_div4,
block_size_log2, uncompressed_size, 0); block_size_log2, uncompressed_size, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;
return 1; return 1;
} }
/* API */ /* API */
int aaip_xinfo_func(void *data, int flag) int aaip_xinfo_func(void *data, int flag)
{ {
if (flag & 1) { if (flag & 1) {
skipping to change at line 1236 skipping to change at line 1257
/* flags and len for each component record (RRIP, 4.1.3.1) */ /* flags and len for each component record (RRIP, 4.1.3.1) */
clen += 2; clen += 2;
if (!cew) { if (!cew) {
/* we are still writing to the SUA */ /* we are still writing to the SUA */
if (*su_size + sl_len + clen > space) { if (*su_size + sl_len + clen > space) {
/* /*
* ok, we need a Continuation Area anyway * ok, we need a Continuation Area anyway
* TODO this can be handled better, but for now SL * TODO this can be handled better, but for now SL
* will be completelly moved into the CA * will be completely moved into the CA
*/ */
if (!(flag & 1)) { if (!(flag & 1)) {
free(dest); free(dest);
goto unannounced_ca; goto unannounced_ca;
} }
cew = 1; cew = 1;
} else { } else {
sl_len += clen; sl_len += clen;
} }
} }
skipping to change at line 1584 skipping to change at line 1605
* *
* @param type * @param type
* 0 normal entry, 1 "." entry for that node (it is a dir), 2 ".." * 0 normal entry, 1 "." entry for that node (it is a dir), 2 ".."
* for that node (i.e., it will refer to the parent) * for that node (i.e., it will refer to the parent)
* @param used_up * @param used_up
* Already occupied space in the directory record. * Already occupied space in the directory record.
* @param info * @param info
* Pointer to the struct susp_info where the entries will be stored. * Pointer to the struct susp_info where the entries will be stored.
* If some entries need to go to a Continuation Area, they will be added * If some entries need to go to a Continuation Area, they will be added
* to the existing ce_susp_fields, and ce_len will be incremented * to the existing ce_susp_fields, and ce_len will be incremented
* propertly. Please ensure ce_block is initialized propertly. * properly. Please ensure ce_block is initialized properly.
* @return * @return
* 1 success, < 0 error * 1 success, < 0 error
*/ */
int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type, int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
size_t used_up, struct susp_info *info) size_t used_up, struct susp_info *info)
{ {
int ret; int ret;
size_t i; size_t i;
Ecma119Node *node; Ecma119Node *node;
char *name = NULL; char *name = NULL;
skipping to change at line 1821 skipping to change at line 1842
/* flags and len for each component record (RRIP, 4.1.3.1) */ /* flags and len for each component record (RRIP, 4.1.3.1) */
clen += 2; clen += 2;
if (!cew) { if (!cew) {
/* we are still writing to the SUA */ /* we are still writing to the SUA */
if (sl_len + clen > sua_free) { if (sl_len + clen > sua_free) {
/* /*
* ok, we need a Continuation Area anyway * ok, we need a Continuation Area anyway
* TODO this can be handled better, but for now SL * TODO this can be handled better, but for now SL
* will be completelly moved into the CA * will be completely moved into the CA
*/ */
/* sua_free, ce_len, nm_type already account for CE */ /* sua_free, ce_len, nm_type already account for CE */
cew = 1; cew = 1;
} else { } else {
/* add the component */ /* add the component */
ret = rrip_SL_append_comp(&n_comp, &comps, prev, ret = rrip_SL_append_comp(&n_comp, &comps, prev,
clen - 2, cflag); clen - 2, cflag);
if (ret < 0) { if (ret < 0) {
skipping to change at line 2181 skipping to change at line 2202
iso_bb(curr_ce + 20, size, 4); iso_bb(curr_ce + 20, size, 4);
} }
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/** /**
* Write the given SUSP fields into buf. Note that Continuation Area * Write the given SUSP fields into buf. Note that Continuation Area
* fields are not written. * fields are not written.
* If info does not contain any SUSP entry this function just return. * If info does not contain any SUSP entry this function just return.
* After written, the info susp_fields array will be freed, and the counters * After written, the info susp_fields array will be freed, and the counters
* updated propertly. * updated properly.
*/ */
void rrip_write_susp_fields(Ecma119Image *t, struct susp_info *info, void rrip_write_susp_fields(Ecma119Image *t, struct susp_info *info,
uint8_t *buf) uint8_t *buf)
{ {
size_t i; size_t i;
size_t pos = 0; size_t pos = 0;
int ret; int ret;
if (info->n_susp_fields == 0) { if (info->n_susp_fields == 0) {
return; return;
 End of changes. 20 change blocks. 
18 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)