Adopted new libisofs filter module gzip.c, builtin filters --gzip, --gunzip

This commit is contained in:
Thomas Schmitt 2009-04-15 07:19:47 +00:00
parent 1ee9e2a16f
commit 41b61970bb
6 changed files with 72 additions and 26 deletions

View File

@ -90,6 +90,7 @@ libisofs="$libisofs $isofs"aaip_0_2.o
libisofs="$libisofs $isofs"filter.o
libisofs="$libisofs $isofs_filter"external.o
libisofs="$libisofs $isofs_filter"zisofs.o
libisofs="$libisofs $isofs_filter"gzip.o
echo "Version timestamp : $(sed -e 's/#define Xorriso_timestamP "//' -e 's/"$//' "$xorr"/xorriso_timestamp.h)"

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Apr 13, 2009"
.TH XORRISO 1 "Apr 14, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1117,13 +1117,13 @@ files which currently have the filter applied.
.br
Examples:
.br
-external_filter gzip suffix=.gz:if_block_reduction \\
-external_filter bzip2 suffix=.bz2:if_block_reduction \\
.br
/usr/bin/gzip --
/usr/bin/bzip2 --
.br
-external_filter gunzip suffix=.gz:remove_suffix:if_nonempty \\
-external_filter bunzip2 suffix=.bz2:remove_suffix:if_nonempty \\
.br
/usr/bin/gunzip --
/usr/bin/bunzip2 --
.TP
\fB\-unregister_filter\fR name
Remove an -external_filter registration. This is only possible if the filter
@ -1165,6 +1165,10 @@ prevent any suffix renaming.
Builtin filters are "--zisofs" and "--zisofs-decode". The former is to be
applied via -set_filter, the latter is automatically applied if zisofs
compressed content is detected with a file when loading the ISO image.
.br
Another builtin filter pair is "--gzip" and "--gunzip" with suffix ".gz".
They behave about like external gzip and gunzip but avoid forking a process
for each single file. So they are much faster if there are many small files.
.TP
\fB\-set_filter_r\fR name isuffix iso_rr_path [***]
Like -set_filter but affecting all data files below eventual directories.

View File

@ -14311,11 +14311,6 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Undefine an external filter.",
" -close_filter_list",
" Irrevocably ban -external_filter and -unregister_filter.",
" -set_filter name iso_rr_path [***]",
" Apply a defined filter to the given data files.",
" Special name \"--remove-all-filters\" revokes filtering.",
" -set_filter_r name iso_rr_path [***]",
" Like -set_filter but affecting all files below directories.",
#else
@ -14323,6 +14318,13 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" E.g. by ./configure option --enable-external-filters",
#endif /* ! Xorriso_allow_external_filterS */
" -set_filter name iso_rr_path [***]",
" Apply a defined filter to the given data files.",
" Special name \"--remove-all-filters\" revokes filtering.",
" Builtin filters are --gzip , --gunzip, --zisofs .",
" -set_filter_r name iso_rr_path [***]",
" Like -set_filter but affecting all files below directories.",
"",
"zisofs is a compression format which is recognized by some Linux kernels.",
"xorriso supports it by builtin filter \"--zisofs\" which is to be applied by",

View File

@ -103,6 +103,7 @@ xorriso_xorriso_SOURCES = \
libisofs/filter.c \
libisofs/filters/external.c \
libisofs/filters/zisofs.c \
libisofs/filters/gzip.c \
libisofs/system_area.h \
libisofs/system_area.c \
libisofs/make_isohybrid_mbr.c \

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.04.14.092306"
#define Xorriso_timestamP "2009.04.15.071944"

View File

@ -9953,6 +9953,17 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
internal_filter= 1;
} else if(strcmp(filter_name, "--zisofs-decode") == 0) {
internal_filter= 2;
} else if(strcmp(filter_name, "--gzip") == 0) {
internal_filter= 3;
suffix= ".gz";
strip_suffix= 0;
explicit_suffix= 1;
} else if(strcmp(filter_name, "--gunzip") == 0 ||
strcmp(filter_name, "--gzip-decode") == 0) {
internal_filter= 4;
suffix= ".gz";
strip_suffix= 1;
explicit_suffix= 1;
} else {
ret= Xorriso_lookup_extf(xorriso, filter_name, &found_lst, 0);
if(ret < 0)
@ -9985,19 +9996,29 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
while(1) {
if(!explicit_suffix) {
stream= iso_file_get_stream(file);
ret= iso_stream_get_external_filter(stream, &cmd, 0);
if(ret > 0) {
if(cmd->suffix[0]) {
/* >>> would need the current renaming state of path */;
ret= Xorriso_rename_suffix(xorriso, node, cmd->suffix, NULL,
new_name,
(flag & 1) | (!(cmd->behavior & 8) << 1));
if(ret <= 0 || ret == 2)
goto ex;
if(strncmp(stream->class->type, "gzip", 4) == 0) {
suffix= ".gz";
strip_suffix= 1;
} else if(strncmp(stream->class->type, "pizg", 4) == 0) {
suffix= ".gz";
strip_suffix= 0;
} else {
ret= iso_stream_get_external_filter(stream, &cmd, 0);
if(ret > 0) {
suffix= cmd->suffix;
strip_suffix= !(cmd->behavior & 8);
}
}
if(suffix[0]) {
/* >>> would need the current renaming state of path */;
ret= Xorriso_rename_suffix(xorriso, node, suffix, NULL, new_name,
(flag & 1) | (strip_suffix << 1));
if(ret <= 0 || ret == 2)
goto ex;
}
}
ret= iso_file_remove_filter(file, 0);
if(ret != 1)
@ -10012,6 +10033,14 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
Xorriso_report_iso_error(xorriso, "", filter_ret,
"Error when setting filter to ISO node", 0, "FAILURE", 1);
}
} else if (internal_filter == 3 || internal_filter == 4) {
filter_ret = iso_file_add_gzip_filter(file,
1 | ((internal_filter == 4) << 1));
if(filter_ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", filter_ret,
"Error when setting filter to ISO node", 0, "FAILURE", 1);
}
} else {
#ifndef Xorriso_allow_extf_suiD
@ -10288,6 +10317,10 @@ int Xorriso_stream_type(struct XorrisO *xorriso, IsoNode *node,
strcpy(type_text, "--zisofs");
} else if(strcmp(text, "osiz") == 0) {
strcpy(type_text, "--zisofs-decode");
} else if(strcmp(text, "gzip") == 0) {
strcpy(type_text, "--gzip");
} else if(strcmp(text, "pizg") == 0) {
strcpy(type_text, "--gunzip");
} else if(strcmp(text, "cout") == 0 || strcmp(text, "boot") == 0 ||
strcmp(text, "user") == 0 || strcmp(text, "extf") == 0) {
strcpy(type_text, text);
@ -10394,20 +10427,25 @@ int Xorriso_status_zisofs(struct XorrisO *xorriso, char *filter, FILE *fp,
*/
{
off_t ziso_count= 0, osiz_count= 0;
off_t gzip_count= 0, gunzip_count= 0;
iso_zisofs_get_refcounts(&ziso_count, &osiz_count, 0);
iso_gzip_get_refcounts(&gzip_count, &gunzip_count, 0);
if((flag & 1) && xorriso->zlib_level == xorriso->zlib_level_default &&
xorriso->zisofs_block_size == xorriso->zisofs_block_size_default &&
xorriso->zisofs_by_magic == 0 &&
ziso_count == 0 && osiz_count == 0 &&
gzip_count == 0 && gunzip_count == 0 &&
filter[0] == 0)
return 2;
sprintf(xorriso->result_line,
"-zisofs level=%d:block_size=%dk:by_magic=%s:ziso_used=%.f:osiz_used=%.f\n",
xorriso->zlib_level, xorriso->zisofs_block_size / 1024,
xorriso->zisofs_by_magic ? "on" : "off",
(double) ziso_count, (double) osiz_count);
"-zisofs level=%d:block_size=%dk:by_magic=%s:ziso_used=%.f:osiz_used=%.f",
xorriso->zlib_level, xorriso->zisofs_block_size / 1024,
xorriso->zisofs_by_magic ? "on" : "off",
(double) ziso_count, (double) osiz_count);
sprintf(xorriso->result_line + strlen(xorriso->result_line),
":gzip_used=%.f:gunzip_used=%.f\n",
(double) gzip_count, (double) gunzip_count);
Xorriso_status_result(xorriso, filter, fp, flag&2);
return(1);
}