New option -zisofs, builtin filters --zisofs and --zisofs-decode

This commit is contained in:
Thomas Schmitt 2009-04-11 17:26:48 +00:00
parent 1aeaaed0ed
commit 8bb5a1f21e
7 changed files with 179 additions and 7 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps .\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1) .\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Apr 07, 2009" .TH XORRISO 1 "Apr 11, 2009"
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.\" .\"
.\" Some roff macros, for reference: .\" Some roff macros, for reference:
@ -61,6 +61,8 @@ Can restore files from ISO image to disk filesystem (see osirrox).
.br .br
Can record and restore ACL of disk files. Can record and restore ACL of disk files.
.br .br
Content may get zisofs compressed or filtered by external processes.
.br
Can issue commands to mount older sessions on Linux or FreeBSD. Can issue commands to mount older sessions on Linux or FreeBSD.
.br .br
Can check media for damages and copy readable blocks to disk. Can check media for damages and copy readable blocks to disk.
@ -1135,7 +1137,8 @@ External filters may also be banned totally at compile time of xorriso.
By default they are banned if xorriso runs under setuid permission. By default they are banned if xorriso runs under setuid permission.
.TP .TP
\fB\-set_filter\fR name iso_rr_path [***] \fB\-set_filter\fR name iso_rr_path [***]
Apply an -external_filter to the given data files in the ISO image. Apply an -external_filter or a builtin filter to the given data files in the
ISO image.
If the filter suffix is not empty , then it will be applied to the file name. If the filter suffix is not empty , then it will be applied to the file name.
Renaming only happens if the filter really gets attached and is not revoked by Renaming only happens if the filter really gets attached and is not revoked by
its options. its options.
@ -1145,8 +1148,8 @@ If the filter has option "remove_suffix", then the filter will only be
applied if the suffix is present and can be removed. applied if the suffix is present and can be removed.
Name oversize or collision caused by suffix change will prevent filtering. Name oversize or collision caused by suffix change will prevent filtering.
.br .br
This command will immediately run the filter once for each file With most filter types this command will immediately run the filter once for
in order to determine the output size. each file in order to determine the output size.
Content reading operations like -extract , -compare and image generation will Content reading operations like -extract , -compare and image generation will
perform further filter runs and deliver filtered content. perform further filter runs and deliver filtered content.
.br .br
@ -1158,6 +1161,10 @@ effect (i.e -indev and -outdev are identical).
The reserved filter name "--remove-all-filters" revokes filtering. This will The reserved filter name "--remove-all-filters" revokes filtering. This will
revoke eventual suffix renamings as well. Use "--remove-all-filters+" to revoke eventual suffix renamings as well. Use "--remove-all-filters+" to
prevent any suffix renaming. prevent any suffix renaming.
.br
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.
.TP .TP
\fB\-set_filter_r\fR name isuffix iso_rr_path [***] \fB\-set_filter_r\fR name isuffix iso_rr_path [***]
Like -set_filter but affecting all data files below eventual directories. Like -set_filter but affecting all data files below eventual directories.
@ -1791,6 +1798,18 @@ User id to be used for all files when the new ISO tree gets written to media.
\fB\-gid\fR gid \fB\-gid\fR gid
Group id to be used for all files when the new ISO tree gets written to media. Group id to be used for all files when the new ISO tree gets written to media.
.TP .TP
\fB\-zisofs\fR option[:options]
Set global parameters for zisofs compression. This data format is recognized
and transparently uncompressed by some Linux kernels. It is to be applied
via option -set_filter with builtin filter "--zisofs".
Parameters are:
.br
"level="[0-9] zlib compression: 0=none, 1=fast,..., 9=slow
.br
"block_size="32k|64k|128k size of compression blocks
.br
"default" same as "level=6:block_size=32k"
.TP
\fB\-speed\fR number[k|m|c|d|b] \fB\-speed\fR number[k|m|c|d|b]
Set the burn speed. Default is 0 = maximum speed. Set the burn speed. Default is 0 = maximum speed.
Speed can be given in media dependent numbers or as a Speed can be given in media dependent numbers or as a

View File

@ -4122,6 +4122,8 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->global_file_mode= 0444; m->global_file_mode= 0444;
m->filters= NULL; m->filters= NULL;
m->filter_list_closed= 0; m->filter_list_closed= 0;
m->zlib_level_default= m->zlib_level= 6;
m->zisofs_block_size= m->zisofs_block_size_default= (1 << 15);
m->do_overwrite= 2; m->do_overwrite= 2;
m->do_reassure= 0; m->do_reassure= 0;
m->drive_blacklist= NULL; m->drive_blacklist= NULL;
@ -6228,6 +6230,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
} }
Xorriso_status_extf(xorriso, filter, fp, flag & 2); Xorriso_status_extf(xorriso, filter, fp, flag & 2);
Xorriso_status_zisofs(xorriso, filter, fp, flag & 3);
is_default= !xorriso->allow_graft_points; is_default= !xorriso->allow_graft_points;
sprintf(line,"-pathspecs %s\n", xorriso->allow_graft_points ? "on" : "off"); sprintf(line,"-pathspecs %s\n", xorriso->allow_graft_points ? "on" : "off");
@ -14311,7 +14314,14 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" E.g. by ./configure option --enable-external-filters", " E.g. by ./configure option --enable-external-filters",
#endif /* ! Xorriso_allow_external_filterS */ #endif /* ! Xorriso_allow_external_filterS */
"",
"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",
"the user, and by \"--zisofs-decode\" which is applied automatically when",
"compressed content is detected with a file in the ISO image.",
" -zisofs option[:options]",
" Set global zisofs parameters:",
" level=0|...|9 , block_size=32k|64k|128k",
"", "",
"Write-to-media options:", "Write-to-media options:",
" -rollback Discard the manipulated ISO image and reload it.", " -rollback Discard the manipulated ISO image and reload it.",
@ -17037,6 +17047,75 @@ int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag)
} }
/* Option -zisofs */
int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag)
{
int was_level, was_blocksize, ret, l;
double num;
char *cpt, *npt, text[16];
was_level= xorriso->zlib_level;
was_blocksize= xorriso->zisofs_block_size;
npt= cpt= mode;
for(cpt= mode; npt!=NULL; cpt= npt+1) {
npt= strchr(cpt,':');
if(npt==NULL)
l= strlen(cpt);
else
l= npt-cpt;
if(l==0)
goto unknown_mode;
if(strncmp(cpt, "level=", 6) == 0) {
sscanf(cpt + 6, "%lf", &num);
if(num < 0 || num > 9) {
sprintf(xorriso->info_text,
"-zisofs: Wrong zlib compression level '%s' (allowed 0...9)",
cpt + 6);
goto sorry_ex;
}
xorriso->zlib_level= num;
} else if(strncmp(cpt, "ziso_used=", 10) == 0 ||
strncmp(cpt, "osiz_used=", 10) == 0) {
/* (ignored info from -status) */;
} else if(strncmp(cpt, "block_size=", 11)==0) {
num= 0.0;
if(l > 11 && l < 27) {
strncpy(text, cpt + 11, l - 11);
text[l - 11]= 0;
num= Scanf_io_size(text, 0);
}
if (num != (1 << 15) && num != (1 << 16) && num != (1 << 17)) {
sprintf(xorriso->info_text,
"-zisofs: Unsupported block size (allowed 32k, 64k, 128k)");
goto sorry_ex;
}
xorriso->zisofs_block_size= num;
} else if(strncmp(cpt, "default", l)==0) {
xorriso->zlib_level= xorriso->zlib_level_default;
xorriso->zisofs_block_size= xorriso->zisofs_block_size_default;
} else {
unknown_mode:;
if(l<SfileadrL)
sprintf(xorriso->info_text, "-zisofs: unknown mode '%s'", cpt);
else
sprintf(xorriso->info_text, "-zisofs: oversized mode parameter (%d)",l);
sorry_ex:
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
xorriso->zlib_level= was_level;
xorriso->zisofs_block_size= was_blocksize;
return(0);
}
}
ret= Xorriso_set_zisofs_params(xorriso, 0);
return(ret);
}
/* ---------------------------- End Options API ------------------------ */ /* ---------------------------- End Options API ------------------------ */
@ -17104,7 +17183,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"reassure","report_about","rom_toc_scan", "reassure","report_about","rom_toc_scan",
"session_log","speed","split_size","status","status_history_max", "session_log","speed","split_size","status","status_history_max",
"stream_recording","temp_mem_limit", "stream_recording","temp_mem_limit",
"uid","unregister_filter","use_readline","volid","xattr", "uid","unregister_filter","use_readline","volid","xattr","zisofs",
"" ""
}; };
static char arg2_commands[][40]= { static char arg2_commands[][40]= {
@ -17882,6 +17961,10 @@ next_command:;
(*idx)++; (*idx)++;
ret= Xorriso_option_xattr(xorriso, arg1, 0); ret= Xorriso_option_xattr(xorriso, arg1, 0);
} else if(strcmp(cmd,"zisofs")==0) {
(*idx)++;
ret= Xorriso_option_zisofs(xorriso, arg1, 0);
} else if(strcmp(cmd, xorriso->list_delimiter)==0){ } else if(strcmp(cmd, xorriso->list_delimiter)==0){
/* tis ok */; /* tis ok */;

View File

@ -761,6 +761,10 @@ int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag);
/* Option -xattr "on"|"off" */ /* Option -xattr "on"|"off" */
int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag); int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag);
/* Option -zisofs */
int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag);
#endif /* Xorriso_includeD */ #endif /* Xorriso_includeD */

View File

@ -130,6 +130,11 @@ struct XorrisO { /* the global context of xorriso */
struct Xorriso_lsT *filters; struct Xorriso_lsT *filters;
int filter_list_closed; int filter_list_closed;
int zlib_level;
int zlib_level_default;
int zisofs_block_size;
int zisofs_block_size_default;
int do_overwrite; /* 0=off, 1=on, 2=nondir */ int do_overwrite; /* 0=off, 1=on, 2=nondir */
int do_reassure; /* 0=off, 1=on, 2=tree */ int do_reassure; /* 0=off, 1=on, 2=tree */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.04.11.125331" #define Xorriso_timestamP "2009.04.11.172644"

View File

@ -135,6 +135,7 @@ int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag)
int ret, major, minor, micro; int ret, major, minor, micro;
char *handler_prefix= NULL; char *handler_prefix= NULL;
char *queue_sev, *print_sev, reason[1024]; char *queue_sev, *print_sev, reason[1024];
struct iso_zisofs_ctrl zisofs_ctrl= {0, 6, 15};
/* First an ugly compile time check for header version compatibility. /* First an ugly compile time check for header version compatibility.
@ -231,6 +232,14 @@ LIBISOBURN_MISCONFIGURATION_ = 0;
sprintf(handler_prefix, "%s : ", xorriso->progname); sprintf(handler_prefix, "%s : ", xorriso->progname);
burn_set_signal_handling(handler_prefix, NULL, 0); burn_set_signal_handling(handler_prefix, NULL, 0);
ret = iso_zisofs_get_params(&zisofs_ctrl, 0);
if (ret == 1) {
xorriso->zisofs_block_size= xorriso->zisofs_block_size_default=
(1 << zisofs_ctrl.block_size_log2);
xorriso->zlib_level= xorriso->zlib_level_default=
zisofs_ctrl.compression_level;
}
Xorriso_process_msg_queues(xorriso,0); Xorriso_process_msg_queues(xorriso,0);
if(reason[0]) { if(reason[0]) {
sprintf(xorriso->info_text, "%s", reason); sprintf(xorriso->info_text, "%s", reason);
@ -10022,6 +10031,7 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
xorriso->volset_change_pending= 1; xorriso->volset_change_pending= 1;
*/ */
ret= filter_ret; ret= filter_ret;
ex:; ex:;
if(old_name != NULL) if(old_name != NULL)
free(old_name); free(old_name);
@ -10326,3 +10336,49 @@ ex:;
return(ret); return(ret);
} }
int Xorriso_set_zisofs_params(struct XorrisO *xorriso, int flag)
{
int ret;
struct iso_zisofs_ctrl ctrl;
ctrl.version= 0;
ctrl.compression_level= xorriso->zlib_level;
if(xorriso->zisofs_block_size == (1 << 16))
ctrl.block_size_log2= 16;
else if(xorriso->zisofs_block_size == (1 << 17))
ctrl.block_size_log2= 17;
else
ctrl.block_size_log2= 15;
ret= iso_zisofs_set_params(&ctrl, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret < 0) {
Xorriso_report_iso_error(xorriso, "", ret,
"Error when setting zisofs parameters", 0, "FAILURE", 1);
return(0);
}
return(1);
}
int Xorriso_status_zisofs(struct XorrisO *xorriso, char *filter, FILE *fp,
int flag)
/*
bit1= do only report to fp
*/
{
off_t ziso_count= 0, osiz_count= 0;
iso_zisofs_get_refcounts(&ziso_count, &osiz_count, 0);
if((flag & 1) && xorriso->zlib_level == xorriso->zlib_level_default &&
xorriso->zisofs_block_size == xorriso->zisofs_block_size_default &&
ziso_count == 0 && osiz_count == 0)
return 2;
sprintf(xorriso->result_line,
"-zisofs level=%d:block_size=%dk:ziso_used=%.f:osiz_used=%.f\n",
xorriso->zlib_level, xorriso->zisofs_block_size / 1024,
(double) ziso_count, (double) osiz_count);
Xorriso_status_result(xorriso, filter, fp, flag&2);
return(1);
}

View File

@ -448,6 +448,11 @@ int Xorriso_destroy_all_extf(struct XorrisO *xorriso, int flag);
int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node,
char *path, int flag); char *path, int flag);
int Xorriso_set_zisofs_params(struct XorrisO *xorriso, int flag);
int Xorriso_status_zisofs(struct XorrisO *xorriso, char *filter, FILE *fp,
int flag);
/* A pseudo file type for El-Torito bootsectors as in man 2 stat : /* A pseudo file type for El-Torito bootsectors as in man 2 stat :
For now take the highest possible value. For now take the highest possible value.