Removed development macro Libisofs_with_checksumS
and made the affected code unconditional.
This commit is contained in:
parent
9cf460a3b1
commit
3528493b92
@ -27,10 +27,7 @@
|
||||
#include "rockridge.h"
|
||||
#include "util.h"
|
||||
#include "system_area.h"
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
#include "md5.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
@ -76,16 +73,12 @@ void ecma119_image_free(Ecma119Image *t)
|
||||
free(t->bootsrc);
|
||||
if (t->system_area_data != NULL)
|
||||
free(t->system_area_data);
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
if (t->checksum_ctx != NULL) { /* dispose checksum context */
|
||||
char md5[16];
|
||||
iso_md5_end(&(t->checksum_ctx), md5);
|
||||
}
|
||||
if (t->checksum_buffer != NULL)
|
||||
free(t->checksum_buffer);
|
||||
#endif
|
||||
|
||||
if (t->writers != NULL)
|
||||
free(t->writers);
|
||||
free(t);
|
||||
@ -256,17 +249,11 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
target->m_path_table_pos = target->curblock;
|
||||
target->curblock += DIV_UP(path_table_size, BLOCK_SIZE);
|
||||
target->path_table_size = path_table_size;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (target->md5_session_checksum) {
|
||||
/* Account for tree checksum tag */
|
||||
target->checksum_tree_tag_pos = target->curblock;
|
||||
target->curblock++;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -737,16 +724,10 @@ int ecma119_writer_write_data(IsoImageWriter *writer)
|
||||
ret = write_path_tables(t);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (t->md5_session_checksum) {
|
||||
/* Write tree checksum tag */
|
||||
ret = iso_md5_write_tag(t, 3);
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -934,8 +915,6 @@ void *write_function(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* Write superblock checksum tag */
|
||||
if (target->md5_session_checksum && target->checksum_ctx != NULL) {
|
||||
res = iso_md5_write_tag(target, 2);
|
||||
@ -943,9 +922,6 @@ void *write_function(void *arg)
|
||||
goto write_error;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
/* write data for each writer */
|
||||
for (i = 0; i < target->nwriters; ++i) {
|
||||
writer = target->writers[i];
|
||||
@ -955,13 +931,9 @@ void *write_function(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* Transplant checksum buffer from Ecma119Image to IsoImage */
|
||||
transplant_checksum_buffer(target, 0);
|
||||
|
||||
#endif
|
||||
|
||||
iso_ring_buffer_writer_close(target->buffer, 0);
|
||||
|
||||
#ifdef Libisofs_with_pthread_exiT
|
||||
@ -981,15 +953,11 @@ void *write_function(void *arg)
|
||||
}
|
||||
iso_ring_buffer_writer_close(target->buffer, 1);
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* Transplant checksum buffer away from Ecma119Image */
|
||||
transplant_checksum_buffer(target, 0);
|
||||
/* Invalidate the transplanted checksum buffer in IsoImage */
|
||||
iso_image_free_checksums(target->image, 0);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef Libisofs_with_pthread_exiT
|
||||
pthread_exit(NULL);
|
||||
#else
|
||||
@ -999,9 +967,6 @@ void *write_function(void *arg)
|
||||
}
|
||||
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
|
||||
static
|
||||
int checksum_prepare_image(IsoImage *src, int flag)
|
||||
{
|
||||
@ -1096,9 +1061,6 @@ int checksum_prepare_nodes(Ecma119Image *target, IsoNode *node, int flag)
|
||||
}
|
||||
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
static
|
||||
int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
{
|
||||
@ -1222,8 +1184,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
goto target_cleanup;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
target->md5_file_checksums = opts->md5_file_checksums;
|
||||
target->md5_session_checksum = opts->md5_session_checksum;
|
||||
strcpy(target->scdbackup_tag_parm, opts->scdbackup_tag_parm);
|
||||
@ -1241,8 +1201,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
target->checksum_range_size = 0;
|
||||
target->opts_overwrite = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 2. Based on those options, create needed writers: iso, joliet...
|
||||
* Each writer inits its structures and stores needed info into
|
||||
@ -1266,9 +1224,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
nwriters++;
|
||||
}
|
||||
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if ((target->md5_file_checksums & 1) || target->md5_session_checksum) {
|
||||
nwriters++;
|
||||
image_checksums_mad = 1; /* from here on the loaded checksums are
|
||||
@ -1285,9 +1240,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
target->checksum_idx_counter = 0;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
target->writers = malloc(nwriters * sizeof(void*));
|
||||
if (target->writers == NULL) {
|
||||
ret = ISO_OUT_OF_MEM;
|
||||
@ -1345,19 +1297,12 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
goto target_cleanup;
|
||||
}
|
||||
file_src_writer_index = target->nwriters - 1;
|
||||
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if ((target->md5_file_checksums & 1) || target->md5_session_checksum) {
|
||||
ret = checksum_writer_create(target);
|
||||
if (ret < 0)
|
||||
goto target_cleanup;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
/*
|
||||
* 3.
|
||||
* Call compute_data_blocks() in each Writer.
|
||||
@ -1456,8 +1401,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
memcpy(vol->std_identifier, "CD001", 5);
|
||||
vol->vol_desc_version[0] = 1;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* Write relocated superblock checksum tag */
|
||||
tag_pos = voldesc_size / BLOCK_SIZE + 16 + 1;
|
||||
if (target->md5_session_checksum) {
|
||||
@ -1489,9 +1432,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
if (ret > 0)
|
||||
opts->overwrite[i * 2048] = 0;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1503,8 +1443,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
|
||||
|
||||
/* 4. Create and start writing thread */
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
if (target->md5_session_checksum) {
|
||||
/* After any fake writes are done: Initialize image checksum context */
|
||||
if (target->checksum_ctx != NULL)
|
||||
@ -1518,8 +1456,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
iso_image_free_checksums(target->image, 0);
|
||||
image_checksums_mad = 0;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* ensure the thread is created joinable */
|
||||
pthread_attr_init(&(target->th_attr));
|
||||
pthread_attr_setdetachstate(&(target->th_attr), PTHREAD_CREATE_JOINABLE);
|
||||
@ -1544,14 +1480,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
return ISO_SUCCESS;
|
||||
|
||||
target_cleanup: ;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if(image_checksums_mad) /* No checksums is better than mad checksums */
|
||||
iso_image_free_checksums(target->image, 0);
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
ecma119_image_free(target);
|
||||
return ret;
|
||||
}
|
||||
@ -1691,17 +1621,11 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
|
||||
/* reader cancelled */
|
||||
return ISO_CANCELED;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (target->checksum_ctx != NULL) {
|
||||
/* Add to image checksum */
|
||||
target->checksum_counter += count;
|
||||
iso_md5_compute(target->checksum_ctx, (char *) buf, (int) count);
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* total size is 0 when writing the overwrite buffer */
|
||||
if (ret > 0 && (target->total_size != (off_t) 0)){
|
||||
unsigned int kbw, kbt;
|
||||
@ -1977,14 +1901,8 @@ int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort)
|
||||
|
||||
int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
opts->md5_session_checksum = session & 1;
|
||||
opts->md5_file_checksums = files & 3;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1992,9 +1910,6 @@ int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
|
||||
char *name, char *timestamp,
|
||||
char *tag_written)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
char eff_name[81], eff_time[19];
|
||||
int i;
|
||||
|
||||
@ -2020,9 +1935,6 @@ int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
|
||||
opts->scdbackup_tag_written = tag_written;
|
||||
if (tag_written != NULL)
|
||||
tag_written[0] = 0;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,6 @@ struct iso_write_opts {
|
||||
*/
|
||||
unsigned int dir_rec_mtime :1;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/**
|
||||
* Compute MD5 checksum for the whole session and record it as index 0 of
|
||||
* the checksum blocks after the data area of the session. The layout and
|
||||
@ -174,8 +172,6 @@ struct iso_write_opts {
|
||||
*/
|
||||
unsigned int md5_file_checksums :2;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/** If files should be sorted based on their weight. */
|
||||
unsigned int sort_files :1;
|
||||
|
||||
@ -373,13 +369,9 @@ struct ecma119_image
|
||||
/* Store in ECMA-119 timestamp mtime of source */
|
||||
unsigned int dir_rec_mtime :1;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
unsigned int md5_session_checksum :1;
|
||||
unsigned int md5_file_checksums :2;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/*
|
||||
* Mode replace. If one of these flags is set, the correspodent values are
|
||||
* replaced with values below.
|
||||
@ -498,8 +490,6 @@ struct ecma119_image
|
||||
/* tree of files sources */
|
||||
IsoRBTree *files;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
unsigned int checksum_idx_counter;
|
||||
void *checksum_ctx;
|
||||
off_t checksum_counter;
|
||||
@ -525,8 +515,6 @@ struct ecma119_image
|
||||
char scdbackup_tag_parm[100];
|
||||
char *scdbackup_tag_written;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* Buffer for communication between burn_source and writer thread */
|
||||
IsoRingBuffer *buffer;
|
||||
|
||||
|
@ -14,10 +14,7 @@
|
||||
#include "messages.h"
|
||||
#include "image.h"
|
||||
#include "stream.h"
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
#include "md5.h"
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -53,11 +50,8 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
|
||||
unsigned int fs_id;
|
||||
dev_t dev_id;
|
||||
ino_t ino_id;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
int cret, no_md5= 0;
|
||||
void *xipt = NULL;
|
||||
#endif
|
||||
|
||||
if (img == NULL || file == NULL || src == NULL) {
|
||||
return ISO_NULL_POINTER;
|
||||
@ -103,9 +97,6 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
|
||||
/* insert the filesrc in the tree */
|
||||
ret = iso_rbtree_insert(img->files, fsrc, (void**)src);
|
||||
if (ret <= 0) {
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (ret == 0 && (*src)->checksum_index > 0) {
|
||||
/* Duplicate file source was mapped to previously registered source
|
||||
*/
|
||||
@ -113,17 +104,12 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
|
||||
if (cret < 0)
|
||||
ret = cret;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
free(fsrc->sections);
|
||||
free(fsrc);
|
||||
return ret;
|
||||
}
|
||||
iso_stream_ref(fsrc->stream);
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if ((img->md5_file_checksums & 1) &&
|
||||
file->from_old_session && img->appendable) {
|
||||
ret = iso_node_get_xinfo((IsoNode *) file, checksum_md5_xinfo_func,
|
||||
@ -149,8 +135,6 @@ int iso_file_src_create(Ecma119Image *img, IsoFile *file, IsoFileSrc **src)
|
||||
return cret;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -304,21 +288,16 @@ int filesrc_read(IsoFileSrc *file, char *buf, size_t count)
|
||||
return iso_stream_read_buffer(file->stream, buf, count, &got);
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* @return 1=ok, md5 is valid,
|
||||
0= not ok, go on,
|
||||
<0 fatal error, abort
|
||||
*/
|
||||
|
||||
static
|
||||
int filesrc_make_md5(Ecma119Image *t, IsoFileSrc *file, char md5[16], int flag)
|
||||
{
|
||||
return iso_stream_make_md5(file->stream, md5, 0);
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
static
|
||||
int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
{
|
||||
@ -331,13 +310,9 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
char buffer[BLOCK_SIZE];
|
||||
off_t file_size;
|
||||
uint32_t nblocks;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
void *ctx= NULL;
|
||||
char md5[16], pre_md5[16];
|
||||
int pre_md5_valid = 0;
|
||||
#endif
|
||||
|
||||
|
||||
if (writer == NULL) {
|
||||
return ISO_ASSERT_FAILURE;
|
||||
@ -353,17 +328,11 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
was_error = 0;
|
||||
file_size = iso_file_src_get_size(file);
|
||||
nblocks = DIV_UP(file_size, BLOCK_SIZE);
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
pre_md5_valid = 0;
|
||||
if (file->checksum_index > 0 && (t->md5_file_checksums & 2)) {
|
||||
/* Obtain an MD5 of content by a first read pass */
|
||||
pre_md5_valid = filesrc_make_md5(t, file, pre_md5, 0);
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
res = filesrc_open(file);
|
||||
iso_stream_get_file_name(file->stream, name);
|
||||
if (res < 0) {
|
||||
@ -407,18 +376,12 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (file->checksum_index > 0) {
|
||||
/* initialize file checksum */
|
||||
res = iso_md5_start(&ctx);
|
||||
if (res <= 0)
|
||||
file->checksum_index = 0;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* write file contents to image */
|
||||
for (b = 0; b < nblocks; ++b) {
|
||||
int wres;
|
||||
@ -434,9 +397,6 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
ret = wres;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (file->checksum_index > 0) {
|
||||
/* Add to file checksum */
|
||||
if (file_size - b * BLOCK_SIZE > BLOCK_SIZE)
|
||||
@ -447,9 +407,6 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
if (res <= 0)
|
||||
file->checksum_index = 0;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
filesrc_close(file);
|
||||
@ -484,9 +441,6 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
ret = res;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (file->checksum_index > 0) {
|
||||
/* Add to file checksum */
|
||||
if (file_size - b * BLOCK_SIZE > BLOCK_SIZE)
|
||||
@ -497,14 +451,8 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
if (res <= 0)
|
||||
file->checksum_index = 0;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (file->checksum_index > 0 &&
|
||||
file->checksum_index <= t->checksum_idx_counter) {
|
||||
/* Obtain checksum and dispose checksum context */
|
||||
@ -529,19 +477,12 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
/* Write md5 into checksum buffer at file->checksum_index */
|
||||
memcpy(t->checksum_buffer + 16 * file->checksum_index, md5, 16);
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
ret = ISO_SUCCESS;
|
||||
ex:;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
if (ctx != NULL) /* avoid any memory leak */
|
||||
iso_md5_end(&ctx, md5);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,8 @@
|
||||
struct Iso_File_Src
|
||||
{
|
||||
unsigned int prev_img :1; /**< if the file comes from a previous image */
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
unsigned int checksum_index :31;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
/** File Sections of the file in the image */
|
||||
struct iso_file_section *sections;
|
||||
int nsections;
|
||||
|
@ -2439,9 +2439,6 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
ifs->free = ifs_fs_free;
|
||||
|
||||
/* read Volume Descriptors and ensure it is a valid image */
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (data->md5_load) {
|
||||
/* From opts->block on : check for superblock and tree tags */;
|
||||
ret = iso_src_check_sb_tree(src, opts->block, 0);
|
||||
@ -2456,8 +2453,6 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* 1. first, open the filesystem */
|
||||
ifs_fs_open(ifs);
|
||||
|
||||
@ -3128,8 +3123,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
uint8_t *rpt;
|
||||
IsoFileSource *boot_src;
|
||||
IsoNode *node;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
uint32_t old_checksum_start_lba;
|
||||
uint32_t old_checksum_end_lba;
|
||||
uint32_t old_checksum_idx_count;
|
||||
@ -3139,7 +3132,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
size_t size;
|
||||
void *ctx = NULL;
|
||||
char md5[16];
|
||||
#endif
|
||||
|
||||
if (image == NULL || src == NULL || opts == NULL) {
|
||||
return ISO_NULL_POINTER;
|
||||
@ -3181,14 +3173,11 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
oldroot = image->root;
|
||||
oldbootcat = image->bootcat; /* could be NULL */
|
||||
image->bootcat = NULL;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
old_checksum_start_lba = image->checksum_start_lba;
|
||||
old_checksum_end_lba = image->checksum_end_lba;
|
||||
old_checksum_idx_count = image->checksum_idx_count;
|
||||
old_checksum_array = image->checksum_array;
|
||||
image->checksum_array = NULL;
|
||||
#endif
|
||||
|
||||
/* create new builder */
|
||||
ret = iso_image_builder_new(blback, &image->builder);
|
||||
@ -3363,8 +3352,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
(*features)->size = data->nblocks;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (data->md5_load) {
|
||||
/* Read checksum array */
|
||||
ret = iso_root_get_isofsca((IsoNode *) image->root,
|
||||
@ -3417,8 +3404,6 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
ret = iso_image_eval_boot_info_table(image, opts, src, data->nblocks, 0);
|
||||
if (ret < 0)
|
||||
goto import_revert;
|
||||
@ -3432,14 +3417,11 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
el_torito_boot_catalog_free(image->bootcat);
|
||||
image->root = oldroot;
|
||||
image->bootcat = oldbootcat;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
old_checksum_start_lba = image->checksum_start_lba;
|
||||
old_checksum_end_lba = image->checksum_end_lba;
|
||||
old_checksum_idx_count = image->checksum_idx_count;
|
||||
image->checksum_array = old_checksum_array;
|
||||
old_checksum_array = NULL;
|
||||
#endif
|
||||
|
||||
import_cleanup:;
|
||||
|
||||
@ -3450,14 +3432,10 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
|
||||
iso_file_source_unref(newroot);
|
||||
fs->close(fs);
|
||||
iso_filesystem_unref(fs);
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
if (old_checksum_array != NULL)
|
||||
free(old_checksum_array);
|
||||
if (ctx != NULL)
|
||||
iso_md5_end(&ctx, md5);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -81,14 +81,10 @@ int iso_image_new(const char *name, IsoImage **image)
|
||||
img->inode_counter = 0;
|
||||
img->used_inodes = NULL;
|
||||
img->used_inodes_start = 0;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
img->checksum_start_lba = 0;
|
||||
img->checksum_end_lba = 0;
|
||||
img->checksum_idx_count = 0;
|
||||
img->checksum_array = NULL;
|
||||
#endif
|
||||
|
||||
*image = img;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
@ -145,17 +141,12 @@ void iso_image_unref(IsoImage *image)
|
||||
|
||||
int iso_image_free_checksums(IsoImage *image, int flag)
|
||||
{
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
image->checksum_start_lba = 0;
|
||||
image->checksum_end_lba = 0;
|
||||
image->checksum_idx_count = 0;
|
||||
if (image->checksum_array != NULL)
|
||||
free(image->checksum_array);
|
||||
image->checksum_array = NULL;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -592,39 +583,23 @@ ex:;
|
||||
int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba,
|
||||
uint32_t *end_lba, char md5[16], int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
if (image->checksum_array == NULL || image->checksum_idx_count < 1)
|
||||
return 0;
|
||||
*start_lba = image->checksum_start_lba;
|
||||
*end_lba = image->checksum_end_lba;
|
||||
memcpy(md5, image->checksum_array, 16);
|
||||
return ISO_SUCCESS;
|
||||
|
||||
#else
|
||||
|
||||
return 0;
|
||||
|
||||
#endif /* ! Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
int iso_image_set_checksums(IsoImage *image, char *checksum_array,
|
||||
uint32_t start_lba, uint32_t end_lba,
|
||||
uint32_t idx_count, int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
iso_image_free_checksums(image, 0);
|
||||
image->checksum_array = checksum_array;
|
||||
image->checksum_start_lba = start_lba;
|
||||
image->checksum_end_lba = end_lba;
|
||||
image->checksum_idx_count = idx_count;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,6 @@ struct Iso_Image
|
||||
uint8_t *used_inodes;
|
||||
ino_t used_inodes_start;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/**
|
||||
* Array of MD5 checksums as announced by xattr "isofs.ca" of the
|
||||
* root node. Array element 0 contains an overall image checksum for the
|
||||
@ -168,8 +166,6 @@ struct Iso_Image
|
||||
uint32_t checksum_idx_count;
|
||||
char *checksum_array;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -6160,13 +6160,7 @@ struct burn_source {
|
||||
|
||||
/* ---------------------------- Improvements --------------------------- */
|
||||
|
||||
|
||||
/* Checksums : During image writing equip IsoFile objects with MD5 checksums
|
||||
and compute an overall checksum of the session. Store them in
|
||||
a separate checksum block area after the data area of the
|
||||
session.
|
||||
*/
|
||||
#define Libisofs_with_checksumS yes
|
||||
/* currently none being tested */
|
||||
|
||||
|
||||
/* ---------------------------- Experiments ---------------------------- */
|
||||
|
@ -430,8 +430,6 @@ int checksum_md5_xinfo_func(void *data, int flag)
|
||||
|
||||
/* MD5 checksum image writer */
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/*
|
||||
@flag bit0= recursion
|
||||
bit1= session will be appended to an existing image
|
||||
@ -508,15 +506,10 @@ int checksum_copy_old_nodes(Ecma119Image *target, IsoNode *node, int flag)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
||||
static
|
||||
int checksum_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
size_t size;
|
||||
Ecma119Image *t;
|
||||
int ret;
|
||||
@ -557,9 +550,6 @@ int checksum_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
t->checksum_idx_counter + 2, 16, "MD5", 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -580,9 +570,6 @@ int checksum_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
static
|
||||
int checksum_writer_write_data(IsoImageWriter *writer)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
int wres, res;
|
||||
size_t i, size;
|
||||
Ecma119Image *t;
|
||||
@ -649,12 +636,6 @@ ex:;
|
||||
if (ctx != NULL)
|
||||
iso_md5_end(&ctx, md5);
|
||||
return(res);
|
||||
|
||||
#else /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
|
||||
#endif /* ! Libisofs_with_checksumS */
|
||||
}
|
||||
|
||||
|
||||
@ -684,17 +665,11 @@ int checksum_writer_create(Ecma119Image *target)
|
||||
|
||||
/* add this writer to image */
|
||||
target->writers[target->nwriters++] = writer;
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
/* Account for superblock checksum tag */
|
||||
if (target->md5_session_checksum) {
|
||||
target->checksum_sb_tag_pos = target->curblock;
|
||||
target->curblock++;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -702,9 +677,6 @@ int checksum_writer_create(Ecma119Image *target)
|
||||
static
|
||||
int iso_md5_write_scdbackup_tag(Ecma119Image *t, char *tag_block, int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
void *ctx = NULL;
|
||||
off_t pos = 0, line_start;
|
||||
int record_len, block_len, res, i;
|
||||
@ -753,12 +725,6 @@ ex:;
|
||||
if (ctx != NULL)
|
||||
iso_md5_end(&ctx, md5);
|
||||
return res;
|
||||
|
||||
#else
|
||||
|
||||
return ISO_SUCCESS;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
}
|
||||
|
||||
|
||||
@ -772,9 +738,6 @@ ex:;
|
||||
*/
|
||||
int iso_md5_write_tag(Ecma119Image *t, int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
int res, mode, l, i, wres, tag_id_len;
|
||||
void *ctx = NULL;
|
||||
char md5[16], tag_block[2048], *tag_id;
|
||||
@ -863,13 +826,6 @@ ex:;
|
||||
if (ctx != NULL)
|
||||
iso_md5_end(&ctx, md5);
|
||||
return res;
|
||||
|
||||
#else /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
|
||||
#endif /* ! Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2660,9 +2660,6 @@ ex:;
|
||||
/* API */
|
||||
int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
int ret, i;
|
||||
size_t value_len;
|
||||
char *value = NULL;
|
||||
@ -2702,21 +2699,12 @@ ex:;
|
||||
if (value != NULL)
|
||||
free(value);
|
||||
return ret;
|
||||
|
||||
#else
|
||||
|
||||
return 0;
|
||||
|
||||
#endif /* ! Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* API */
|
||||
int iso_file_make_md5(IsoFile *file, int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
int ret, dig = 0;
|
||||
char *md5 = NULL;
|
||||
|
||||
@ -2737,13 +2725,6 @@ int iso_file_make_md5(IsoFile *file, int flag)
|
||||
ret = 1;
|
||||
ex:;
|
||||
return ret;
|
||||
|
||||
#else
|
||||
|
||||
return ISO_ERROR;
|
||||
|
||||
#endif /* ! Libisofs_with_checksumS */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -864,9 +864,6 @@ int iso_stream_read_buffer(IsoStream *stream, char *buf, size_t count,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
|
||||
/* @param flag bit0= dig out most original stream (e.g. because from old image)
|
||||
@return 1=ok, md5 is valid,
|
||||
0= not ok,
|
||||
@ -923,6 +920,3 @@ ex:;
|
||||
iso_md5_end(&ctx, md5);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user