Making use of libjte if installed and if not ./configure --disable-libjte

This commit is contained in:
Thomas Schmitt 2010-09-27 18:22:05 +02:00
parent 59ab73c57f
commit 8725baa55f
7 changed files with 350 additions and 4 deletions

View File

@ -16,7 +16,9 @@ libisofs_libisofs_la_LDFLAGS = \
# Eventually enabling system adapters for ACL and EA. # Eventually enabling system adapters for ACL and EA.
# ts A90409: Eventually enabling use of zlib. # ts A90409: Eventually enabling use of zlib.
libisofs_libisofs_la_CFLAGS = $(LIBACL_DEF) $(XATTR_DEF) $(ZLIB_DEF) # ts B00927: Eventually enabling use of libjte (Jigdo Template Extraction)
libisofs_libisofs_la_CFLAGS = $(LIBACL_DEF) $(XATTR_DEF) $(ZLIB_DEF) \
$(LIBJTE_DEF)
# ts A90114 : added aaip_0_2.* # ts A90114 : added aaip_0_2.*

View File

@ -205,6 +205,18 @@ else
fi fi
AC_SUBST(ZLIB_DEF) AC_SUBST(ZLIB_DEF)
dnl ts B00927
AC_ARG_ENABLE(libjte,
[ --enable-libjte Enable use of libjte by libisofs, default=yes],
, enable_libjte=yes)
if test "x$enable_libjte" = xyes; then
LIBJTE_DEF="-DLibisofs_with_libjtE"
AC_CHECK_HEADER(libjte/libjte.h, AC_CHECK_LIB(jte, libjte_new, , LIBJTE_DEF= ), LIBJTE_DEF= )
else
LIBJTE_DEF=
fi
AC_SUBST(LIBJTE_DEF)
# Library versioning normally serves a complex purpose. # Library versioning normally serves a complex purpose.
# Since libisofs obeys strict ABI backward compatibility, it needs only the # Since libisofs obeys strict ABI backward compatibility, it needs only the
# simple feature to declare function names "global:" or "local:". Only the # simple feature to declare function names "global:" or "local:". Only the

View File

@ -41,6 +41,10 @@
#include <langinfo.h> #include <langinfo.h>
#include <stdio.h> #include <stdio.h>
#ifdef Libisofs_with_libjtE
#include <libjte/libjte.h>
#endif
/* /*
* TODO #00011 : guard against bad path table usage with more than 65535 dirs * TODO #00011 : guard against bad path table usage with more than 65535 dirs
* image with more than 65535 directories have path_table related problems * image with more than 65535 directories have path_table related problems
@ -91,6 +95,29 @@ void ecma119_image_free(Ecma119Image *t)
free(t); free(t);
} }
static int show_chunk_to_jte(Ecma119Image *target, char *buf, int count)
{
#ifdef Libisofs_with_libjtE
int ret;
if (target->libjte_handle == NULL)
return ISO_SUCCESS;
/* >>> What is the meaning of libjte_show_data_chunk(islast) ? */
ret = libjte_show_data_chunk(target->libjte_handle, buf, BLOCK_SIZE,
count / BLOCK_SIZE, 0,
target->bytes_written + (off_t) count == target->total_size);
if (ret <= 0)
return ISO_LIBJTE_FILE_FAILED;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}
/** /**
* Check if we should add version number ";" to the given node name. * Check if we should add version number ";" to the given node name.
*/ */
@ -1136,6 +1163,26 @@ int write_head_part(Ecma119Image *target, int flag)
return ISO_SUCCESS; return ISO_SUCCESS;
} }
/* Eventually end Jigdo Template Extraction */
static int finish_libjte(Ecma119Image *target)
{
#ifdef Libisofs_with_libjtE
int ret;
if (target->libjte_handle != NULL) {
ret = libjte_write_footer(target->libjte_handle);
if (ret <= 0)
return ISO_LIBJTE_END_FAILED;
}
#endif /* Libisofs_with_libjtE */
return 1;
}
static static
void *write_function(void *arg) void *write_function(void *arg)
{ {
@ -1167,6 +1214,10 @@ void *write_function(void *arg)
iso_ring_buffer_writer_close(target->buffer, 0); iso_ring_buffer_writer_close(target->buffer, 0);
res = finish_libjte(target);
if (res <= 0)
goto write_error;
#ifdef Libisofs_with_pthread_exiT #ifdef Libisofs_with_pthread_exiT
pthread_exit(NULL); pthread_exit(NULL);
#else #else
@ -1174,6 +1225,8 @@ void *write_function(void *arg)
#endif #endif
write_error: ; write_error: ;
if (res != ISO_LIBJTE_END_FAILED)
finish_libjte(target);
target->eff_partition_offset = 0; target->eff_partition_offset = 0;
if (res == ISO_CANCELED) { if (res == ISO_CANCELED) {
/* canceled */ /* canceled */
@ -1412,7 +1465,6 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->j_part_root = NULL; target->j_part_root = NULL;
target->j_part_l_path_table_pos = 0; target->j_part_l_path_table_pos = 0;
target->j_part_m_path_table_pos = 0; target->j_part_m_path_table_pos = 0;
target->input_charset = strdup(iso_get_local_charset(0)); target->input_charset = strdup(iso_get_local_charset(0));
if (target->input_charset == NULL) { if (target->input_charset == NULL) {
ret = ISO_OUT_OF_MEM; ret = ISO_OUT_OF_MEM;
@ -1446,6 +1498,11 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->checksum_range_size = 0; target->checksum_range_size = 0;
target->opts_overwrite = NULL; target->opts_overwrite = NULL;
#ifdef Libisofs_with_libjtE
target->libjte_handle = opts->libjte_handle;
#endif /* Libisofs_with_libjtE */
/* /*
* 2. Based on those options, create needed writers: iso, joliet... * 2. Based on those options, create needed writers: iso, joliet...
* Each writer inits its structures and stores needed info into * Each writer inits its structures and stores needed info into
@ -1726,6 +1783,20 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->total_size = (off_t) target->vol_space_size * BLOCK_SIZE; target->total_size = (off_t) target->vol_space_size * BLOCK_SIZE;
#ifdef Libisofs_with_libjtE
/* Eventually start Jigdo Template Extraction */
if (target->libjte_handle != NULL) {
ret = libjte_write_header(target->libjte_handle);
if (ret <= 0) {
ret = ISO_LIBJTE_START_FAILED;
goto target_cleanup;
}
}
#endif /* Libisofs_with_libjtE */
/* 4. Create and start writing thread */ /* 4. Create and start writing thread */
if (target->md5_session_checksum) { if (target->md5_session_checksum) {
/* After any fake writes are done: Initialize image checksum context */ /* After any fake writes are done: Initialize image checksum context */
@ -1910,6 +1981,11 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
target->checksum_counter += count; target->checksum_counter += count;
iso_md5_compute(target->checksum_ctx, (char *) buf, (int) count); iso_md5_compute(target->checksum_ctx, (char *) buf, (int) count);
} }
ret = show_chunk_to_jte(target, buf, count);
if (ret != ISO_SUCCESS)
return ret;
/* total size is 0 when writing the overwrite buffer */ /* total size is 0 when writing the overwrite buffer */
if (ret > 0 && (target->total_size != (off_t) 0)){ if (ret > 0 && (target->total_size != (off_t) 0)){
unsigned int kbw, kbt; unsigned int kbw, kbt;
@ -1987,6 +2063,10 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
wopts->partition_secs_per_head = 0; wopts->partition_secs_per_head = 0;
wopts->partition_heads_per_cyl = 0; wopts->partition_heads_per_cyl = 0;
#ifdef Libisofs_with_libjtE
wopts->libjte_handle = NULL;
#endif /* Libisofs_with_libjtE */
*opts = wopts; *opts = wopts;
return ISO_SUCCESS; return ISO_SUCCESS;
} }
@ -1998,8 +2078,14 @@ void iso_write_opts_free(IsoWriteOpts *opts)
} }
free(opts->output_charset); free(opts->output_charset);
if(opts->system_area_data != NULL) if (opts->system_area_data != NULL)
free(opts->system_area_data); free(opts->system_area_data);
#ifdef Libisofs_with_libjtE
if (opts->libjte_handle != NULL)
libjte_destroy(&(opts->libjte_handle));
#endif /* Libisofs_with_libjtE */
free(opts); free(opts);
} }
@ -2425,3 +2511,137 @@ int iso_write_opts_set_part_offset(IsoWriteOpts *opts,
return ISO_SUCCESS; return ISO_SUCCESS;
} }
static int iso_write_opts_assert_jte_handle(IsoWriteOpts *opts)
{
#ifdef Libisofs_with_libjtE
int ret;
if (opts->libjte_handle == NULL) {
ret = libjte_new(&(opts->libjte_handle), 0);
if (ret <= 0 || opts->libjte_handle == NULL)
return ISO_OUT_OF_MEM;
}
return ISO_SUCCESS;
#else
return ISO_LIBJTE_NOT_ENABLED;
#endif /* ! Libisofs_with_libjtE */
}
/* >>> documentation: mandatory are iso_path, template_path, jigdo_path
*/
int iso_write_opts_set_jte_files(IsoWriteOpts *opts, char *iso_path,
char *template_path, char *jigdo_path,
char *md5_list_path)
{
int ret;
ret = iso_write_opts_assert_jte_handle(opts);
if (ret != ISO_SUCCESS)
return ret;
#ifdef Libisofs_with_libjtE
if (libjte_set_outfile(opts->libjte_handle, iso_path) <= 0)
return ISO_OUT_OF_MEM;
if (libjte_set_template_out(opts->libjte_handle, template_path) <= 0)
return ISO_OUT_OF_MEM;
if (libjte_set_jjigdo_out(opts->libjte_handle, jigdo_path) <= 0)
return ISO_OUT_OF_MEM;
if (libjte_set_jmd5_list(opts->libjte_handle, md5_list_path) <= 0)
return ISO_OUT_OF_MEM;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}
/* >>> documentation : this call is not mandatory
>>> need representations for algorithm macros of libjte
*/
int iso_write_opts_set_jte_params(IsoWriteOpts *opts,
int verbose, int min_size,
char *template_compression,
char *template_checksums,
char *jigdo_checksums)
{
int ret;
ret = iso_write_opts_assert_jte_handle(opts);
if (ret != ISO_SUCCESS)
return ret;
#ifdef Libisofs_with_libjtE
libjte_set_verbose(opts->libjte_handle, verbose);
libjte_set_jte_min_size(opts->libjte_handle, min_size);
/* >>> Interpret template_compression , template_checksums ,
jigdo_checksums
*/;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}
int iso_write_opts_add_jte_exclude(IsoWriteOpts *opts, char *pattern)
{
int ret;
ret = iso_write_opts_assert_jte_handle(opts);
if (ret != ISO_SUCCESS)
return ret;
#ifdef Libisofs_with_libjtE
ret = libjte_add_exclude(opts->libjte_handle, pattern);
if (ret <= 0)
return ISO_OUT_OF_MEM;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}
int iso_write_opts_add_jte_include(IsoWriteOpts *opts, char *pattern)
{
int ret;
ret = iso_write_opts_assert_jte_handle(opts);
if (ret != ISO_SUCCESS)
return ret;
#ifdef Libisofs_with_libjtE
ret = libjte_add_include(opts->libjte_handle, pattern);
if (ret <= 0)
return ISO_OUT_OF_MEM;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}
int iso_write_opts_add_jte_mapping(IsoWriteOpts *opts, char *arg)
{
int ret;
ret = iso_write_opts_assert_jte_handle(opts);
if (ret != ISO_SUCCESS)
return ret;
#ifdef Libisofs_with_libjtE
ret = libjte_add_mapping(opts->libjte_handle, arg);
if (ret <= 0)
return ISO_OUT_OF_MEM;
#endif /* Libisofs_with_libjtE */
return ISO_SUCCESS;
}

View File

@ -324,6 +324,12 @@ struct iso_write_opts {
/* 1 to 255, 0= disabled/default */ /* 1 to 255, 0= disabled/default */
int partition_heads_per_cyl; int partition_heads_per_cyl;
#ifdef Libisofs_with_libjtE
/* Parameters and state of Jigdo Template Export environment.
*/
struct libjte_env *libjte_handle;
#endif /* Libisofs_with_libjtE */
}; };
typedef struct ecma119_image Ecma119Image; typedef struct ecma119_image Ecma119Image;
@ -567,6 +573,10 @@ struct ecma119_image
uint32_t j_part_l_path_table_pos; uint32_t j_part_l_path_table_pos;
uint32_t j_part_m_path_table_pos; uint32_t j_part_m_path_table_pos;
#ifdef Libisofs_with_libjtE
struct libjte_env *libjte_handle;
#endif /* Libisofs_with_libjtE */
}; };
#define BP(a,b) [(b) - (a) + 1] #define BP(a,b) [(b) - (a) + 1]

View File

@ -25,6 +25,11 @@
#include <limits.h> #include <limits.h>
#ifdef Libisofs_with_libjtE
#include <libjte/libjte.h>
#endif
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX Libisofs_default_path_maX #define PATH_MAX Libisofs_default_path_maX
#endif #endif
@ -317,6 +322,9 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
void *ctx= NULL; void *ctx= NULL;
char md5[16], pre_md5[16]; char md5[16], pre_md5[16];
int pre_md5_valid = 0; int pre_md5_valid = 0;
#ifdef Libisofs_with_libjtE
int jte_begun = 0;
#endif
if (writer == NULL) { if (writer == NULL) {
return ISO_ASSERT_FAILURE; return ISO_ASSERT_FAILURE;
@ -380,6 +388,19 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
} }
#endif #endif
#ifdef Libisofs_with_libjtE
if (t->libjte_handle != NULL) {
res = libjte_begin_data_file(t->libjte_handle, name,
BLOCK_SIZE, file_size);
if (res <= 0) {
filesrc_close(file);
ret = ISO_LIBJTE_FILE_FAILED;
goto ex;
}
jte_begun = 1;
}
#endif /* Libisofs_with_libjtE */
if (file->checksum_index > 0) { if (file->checksum_index > 0) {
/* initialize file checksum */ /* initialize file checksum */
res = iso_md5_start(&ctx); res = iso_md5_start(&ctx);
@ -481,12 +502,30 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
/* Write md5 into checksum buffer at file->checksum_index */ /* Write md5 into checksum buffer at file->checksum_index */
memcpy(t->checksum_buffer + 16 * file->checksum_index, md5, 16); memcpy(t->checksum_buffer + 16 * file->checksum_index, md5, 16);
} }
#ifdef Libisofs_with_libjtE
if (t->libjte_handle != NULL) {
res = libjte_end_data_file(t->libjte_handle);
if (res <= 0) {
ret = ISO_LIBJTE_FILE_FAILED;
goto ex;
}
jte_begun = 0;
}
#endif /* Libisofs_with_libjtE */
} }
ret = ISO_SUCCESS; ret = ISO_SUCCESS;
ex:; ex:;
if (ctx != NULL) /* avoid any memory leak */ if (ctx != NULL) /* avoid any memory leak */
iso_md5_end(&ctx, md5); iso_md5_end(&ctx, md5);
#ifdef Libisofs_with_libjtE
if (jte_begun)
libjte_end_data_file(t->libjte_handle);
#endif /* Libisofs_with_libjtE */
return ret; return ret;
} }

View File

@ -1848,6 +1848,48 @@ int iso_write_opts_set_part_offset(IsoWriteOpts *opts,
int secs_512_per_head, int heads_per_cyl); int secs_512_per_head, int heads_per_cyl);
/** >>> ts B00927
* Mandatory are iso_path, template_path, jigdo_path.
* md5_list_path is allowed to be NULL.
* @since 0.6.38
*/
int iso_write_opts_set_jte_files(IsoWriteOpts *opts, char *iso_path,
char *template_path, char *jigdo_path,
char *md5_list_path);
/** >>> ts B00927
>>> need representations for algorithm macros of libjte
* @since 0.6.38
*/
int iso_write_opts_set_jte_params(IsoWriteOpts *opts,
int verbose, int min_size,
char *template_compression,
char *template_checksums,
char *jigdo_checksums);
/** >>> ts B00927
* @since 0.6.38
*/
int iso_write_opts_add_jte_exclude(IsoWriteOpts *opts, char *pattern);
/** >>> ts B00927
* @since 0.6.38
*/
int iso_write_opts_add_jte_include(IsoWriteOpts *opts, char *pattern);
/** >>> ts B00927
* @since 0.6.38
*/
int iso_write_opts_add_jte_mapping(IsoWriteOpts *opts, char *arg);
/** /**
* Inquire the start address of the file data blocks after having used * Inquire the start address of the file data blocks after having used
* IsoWriteOpts with iso_image_create_burn_source(). * IsoWriteOpts with iso_image_create_burn_source().
@ -6149,6 +6191,19 @@ int iso_md5_match(char first_md5[16], char second_md5[16]);
*/ */
#define ISO_OVWRT_FIFO_TOO_SMALL 0xE830FE96 #define ISO_OVWRT_FIFO_TOO_SMALL 0xE830FE96
/** Use of libjte was not enabled at compile time (FAILURE, HIGH, -363) */
#define ISO_LIBJTE_NOT_ENABLED 0xE830FE95
/** Failed to start up Jigdo Template Extraction (FAILURE, HIGH, -364) */
#define ISO_LIBJTE_START_FAILED 0xE830FE94
/** Failed to finish Jigdo Template Extraction (FAILURE, HIGH, -365) */
#define ISO_LIBJTE_END_FAILED 0xE830FE93
/** Failed to process file for Jigdo Template Extraction
(FAILURE, HIGH, -366) */
#define ISO_LIBJTE_FILE_FAILED 0xE830FE92
/* Internal developer note: /* Internal developer note:
Place new error codes directly above this comment. Place new error codes directly above this comment.

View File

@ -292,6 +292,14 @@ const char *iso_error_to_msg(int errcode)
return "Partition offset too small for first tree root."; return "Partition offset too small for first tree root.";
case ISO_OVWRT_FIFO_TOO_SMALL: case ISO_OVWRT_FIFO_TOO_SMALL:
return "The ring buffer is too small for overwrite buffer"; return "The ring buffer is too small for overwrite buffer";
case ISO_LIBJTE_NOT_ENABLED:
return "Use of libjte was not enabled at compile time";
case ISO_LIBJTE_START_FAILED:
return "Failed to start up Jigdo Template Extraction";
case ISO_LIBJTE_END_FAILED:
return "Failed to finish Jigdo Template Extraction";
case ISO_LIBJTE_FILE_FAILED:
return "Failed process file for Jigdo Template Extraction";
default: default:
return "Unknown error"; return "Unknown error";
} }