"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libisofs/node.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.

node.c  (xorriso-1.5.2):node.c  (xorriso-1.5.4)
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2009 - 2019 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 36 skipping to change at line 36
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
struct dir_iter_data struct dir_iter_data
{ {
/* points to the last visited child, to NULL before start */ /* points to the last visited child, to NULL before start */
IsoNode *pos; IsoNode *pos;
/* Some control flags. /* Some control flags.
* bit 0 -> 1 if next called, 0 reseted at start or on deletion * bit 0 -> 1 if next called, 0 reset at start or on deletion
*/ */
int flag; int flag;
}; };
/** /**
* Increments the reference counting of the given node. * Increments the reference counting of the given node.
*/ */
void iso_node_ref(IsoNode *node) void iso_node_ref(IsoNode *node)
{ {
++node->refcount; ++node->refcount;
} }
/** /**
* Decrements the reference couting of the given node. * Decrements the reference counting of the given node.
* If it reach 0, the node is free, and, if the node is a directory, * If it reach 0, the node is free, and, if the node is a directory,
* its children will be unref() too. * its children will be unref() too.
*/ */
void iso_node_unref(IsoNode *node) void iso_node_unref(IsoNode *node)
{ {
if (node == NULL) if (node == NULL)
return; return;
if (--node->refcount == 0) { if (--node->refcount == 0) {
switch (node->type) { switch (node->type) {
case LIBISO_DIR: case LIBISO_DIR:
skipping to change at line 585 skipping to change at line 585
* the dir where to add the node * the dir where to add the node
* @param child * @param child
* the node to add. You must ensure that the node hasn't previously added * the node to add. You must ensure that the node hasn't previously added
* to other dir, and that the node name is unique inside the child. * to other dir, and that the node name is unique inside the child.
* Otherwise this function will return a failure, and the child won't be * Otherwise this function will return a failure, and the child won't be
* inserted. * inserted.
* @param replace * @param replace
* if the dir already contains a node with the same name, whether to * if the dir already contains a node with the same name, whether to
* replace or not the old node with this. * replace or not the old node with this.
* @return * @return
* number of nodes in dir if succes, < 0 otherwise * number of nodes in dir if success, < 0 otherwise
*/ */
int iso_dir_add_node(IsoDir *dir, IsoNode *child, int iso_dir_add_node(IsoDir *dir, IsoNode *child,
enum iso_replace_mode replace) enum iso_replace_mode replace)
{ {
IsoNode **pos; IsoNode **pos;
if (dir == NULL || child == NULL) { if (dir == NULL || child == NULL) {
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
if ((IsoNode*)dir == child) { if ((IsoNode*)dir == child) {
skipping to change at line 2423 skipping to change at line 2423
memcpy(*new_data, old_data, sizeof(struct zisofs_zf_info)); memcpy(*new_data, old_data, sizeof(struct zisofs_zf_info));
return (int) sizeof(struct zisofs_zf_info); return (int) sizeof(struct zisofs_zf_info);
} }
/* Checks whether a file effectively bears a zisofs file header and eventually /* Checks whether a file effectively bears a zisofs file header and eventually
* marks this by a struct zisofs_zf_info as xinfo of the file node. * marks this by a struct zisofs_zf_info as xinfo of the file node.
* @param flag bit0= inquire the most original stream of the file * @param flag bit0= inquire the most original stream of the file
* bit1= permission to overwrite existing zisofs_zf_info * bit1= permission to overwrite existing zisofs_zf_info
* bit2= if no zisofs header is found: * bit2= if no zisofs header is found:
* create xinfo with parameters which indicate no zisofs * create xinfo with parameters which indicate no zisofs
* bit8-bit15= maximum zisofs version to be recognized (0 means 1)
* @return 1= zf xinfo added, 0= no zisofs data found , * @return 1= zf xinfo added, 0= no zisofs data found ,
* 2= found existing zf xinfo and flag bit1 was not set * 2= found existing zf xinfo and flag bit1 was not set
* <0 means error * <0 means error
*/ */
int iso_file_zf_by_magic(IsoFile *file, int flag) int iso_file_zf_by_magic(IsoFile *file, int flag)
{ {
int ret, stream_type, header_size_div4, block_size_log2; int ret, stream_type, header_size_div4, block_size_log2, version;
uint32_t uncompressed_size; uint64_t uncompressed_size;
IsoStream *stream, *input_stream; IsoStream *stream, *input_stream;
struct zisofs_zf_info *zf = NULL; struct zisofs_zf_info *zf = NULL;
void *xipt; void *xipt;
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);
ret = iso_node_get_xinfo((IsoNode *) file, zisofs_zf_xinfo_func, &xipt); ret = iso_node_get_xinfo((IsoNode *) file, zisofs_zf_xinfo_func, &xipt);
if (ret == 1) { if (ret == 1) {
if (!(flag & 2)) if (!(flag & 2))
return 2; return 2;
ret = iso_node_remove_xinfo((IsoNode *) file, zisofs_zf_xinfo_func); ret = iso_node_remove_xinfo((IsoNode *) file, zisofs_zf_xinfo_func);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
input_stream = stream = iso_file_get_stream(file); input_stream = stream = iso_file_get_stream(file);
while (flag & 1) { while (flag & 1) {
input_stream = iso_stream_get_input_stream(stream, 0); input_stream = iso_stream_get_input_stream(stream, 0);
if (input_stream == NULL) if (input_stream == NULL)
break; break;
stream = input_stream; stream = input_stream;
} }
ret = ziso_is_zisofs_stream(stream, &stream_type, &header_size_div4, version = ((flag >> 8) & 0xff);
algo[0] = algo[1] = 0;
ret = ziso_is_zisofs_stream(stream, &stream_type, algo, &header_size_div4,
&block_size_log2, &uncompressed_size, 3); &block_size_log2, &uncompressed_size, 3);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (version < 2 && ret > 0 && (algo[0] != 'p' || algo[1] != 'z'))
ret = 0;
if (ret != 1 || stream_type != 2) { if (ret != 1 || stream_type != 2) {
if (flag & 4) if (!(flag & 4))
return 0; return 0;
algo[0] = algo[1] = 0;
header_size_div4 = 0; header_size_div4 = 0;
block_size_log2 = 0; block_size_log2 = 0;
uncompressed_size = 0; uncompressed_size = 0;
} }
zf = calloc(1, sizeof(struct zisofs_zf_info)); zf = calloc(1, sizeof(struct zisofs_zf_info));
if (zf == NULL) if (zf == NULL)
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
zf->zisofs_algo[0] = algo[0];
zf->zisofs_algo[1] = algo[1];
zf->uncompressed_size = uncompressed_size; zf->uncompressed_size = uncompressed_size;
zf->header_size_div4 = header_size_div4; zf->header_size_div4 = header_size_div4;
zf->block_size_log2 = block_size_log2; zf->block_size_log2 = block_size_log2;
ret = iso_node_add_xinfo((IsoNode *) file, zisofs_zf_xinfo_func, zf); ret = iso_node_add_xinfo((IsoNode *) file, zisofs_zf_xinfo_func, zf);
return ret; return ret;
} }
/* API */ /* API */
int iso_node_zf_by_magic(IsoNode *node, int flag) int iso_node_zf_by_magic(IsoNode *node, int flag)
{ {
int ret = 1, total_ret = 0, hflag; int ret = 1, total_ret = 0, hflag;
IsoFile *file; IsoFile *file;
IsoNode *pos; IsoNode *pos;
IsoDir *dir; IsoDir *dir;
if (node->type == LIBISO_FILE) if (node->type == LIBISO_FILE)
return iso_file_zf_by_magic((IsoFile *) node, flag); return iso_file_zf_by_magic((IsoFile *) node, flag & 0xff06);
if (node->type != LIBISO_DIR || (flag & 8)) if (node->type != LIBISO_DIR || (flag & 8))
return 0; return 0;
dir = (IsoDir *) node; dir = (IsoDir *) node;
pos = dir->children; pos = dir->children;
while (pos) { while (pos) {
ret = 1; ret = 1;
if (pos->type == LIBISO_FILE) { if (pos->type == LIBISO_FILE) {
file = (IsoFile *) pos; file = (IsoFile *) pos;
if ((flag & 16) && file->from_old_session) if ((flag & 16) && file->from_old_session)
return 0; return 0;
if (!((flag & 1) && file->from_old_session)) { if (!((flag & 1) && file->from_old_session)) {
if (strncmp(file->stream->class->type, "ziso", 4) == 0) if (strncmp(file->stream->class->type, "ziso", 4) == 0)
return 1; /* The stream is enough of marking */ return 1; /* The stream is enough of marking */
if (strncmp(file->stream->class->type, "osiz", 4) == 0) { if (strncmp(file->stream->class->type, "osiz", 4) == 0) {
if (flag & 2) if (flag & 2)
iso_node_remove_xinfo(pos, zisofs_zf_xinfo_func); iso_node_remove_xinfo(pos, zisofs_zf_xinfo_func);
return 0; /* Will not be zisofs format */ return 0; /* Will not be zisofs format */
} }
} }
hflag = flag & ~6; hflag = flag & 0xff06;
if ((flag & 1) && file->from_old_session) if ((flag & 1) && file->from_old_session)
hflag |= 1; hflag |= 1;
ret = iso_file_zf_by_magic(file, hflag); ret = iso_file_zf_by_magic(file, hflag);
} else if (pos->type == LIBISO_DIR) { } else if (pos->type == LIBISO_DIR) {
ret = iso_node_zf_by_magic(pos, flag); ret = iso_node_zf_by_magic(pos, flag);
} }
if (ret < 0) { if (ret < 0) {
total_ret = ret; total_ret = ret;
ret = iso_msg_submit(-1, ret, 0, NULL); ret = iso_msg_submit(-1, ret, 0, NULL);
if (ret < 0) { if (ret < 0) {
skipping to change at line 2725 skipping to change at line 2735
IsoFile *f1 = NULL, *f2 = NULL; IsoFile *f1 = NULL, *f2 = NULL;
IsoSymlink *l1 = NULL, *l2 = NULL; IsoSymlink *l1 = NULL, *l2 = NULL;
IsoSpecial *s1 = NULL, *s2 = NULL; IsoSpecial *s1 = NULL, *s2 = NULL;
void *x1, *x2; void *x1, *x2;
if (n1 == n2) if (n1 == n2)
return 0; return 0;
if (n1->type != n2->type) if (n1->type != n2->type)
return (n1->type < n2->type ? -1 : 1); return (n1->type < n2->type ? -1 : 1);
/* Imported or explicite ISO image node id has priority */ /* Imported or explicit ISO image node id has priority */
ret1 = (iso_node_get_id(n1, &fs_id1, &dev_id1, &ino_id1, 1) > 0); ret1 = (iso_node_get_id(n1, &fs_id1, &dev_id1, &ino_id1, 1) > 0);
ret2 = (iso_node_get_id(n2, &fs_id2, &dev_id2, &ino_id2, 1) > 0); ret2 = (iso_node_get_id(n2, &fs_id2, &dev_id2, &ino_id2, 1) > 0);
if (ret1 != ret2) if (ret1 != ret2)
return (ret1 < ret2 ? -1 : 1); return (ret1 < ret2 ? -1 : 1);
if (ret1) { if (ret1) {
/* fs_id and dev_id do not matter here. /* fs_id and dev_id do not matter here.
Both nodes have explicit inode numbers of the emerging image. Both nodes have explicit inode numbers of the emerging image.
*/ */
if (ino_id1 != ino_id2) if (ino_id1 != ino_id2)
return (ino_id1 < ino_id2 ? -1 : 1); return (ino_id1 < ino_id2 ? -1 : 1);
 End of changes. 17 change blocks. 
12 lines changed or deleted 22 lines changed or added

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