New -as mkisofs options --sort-weight-list and --sort-weight-patterns

This commit is contained in:
Thomas Schmitt 2013-05-28 17:58:01 +00:00
parent 47c9255ad3
commit 18936cfccf
9 changed files with 248 additions and 46 deletions

View File

@ -1775,7 +1775,7 @@ int Xorriso_afile_fopen(struct XorrisO *xorriso,
if(fp==NULL){
if(!(flag&1)) {
sprintf(xorriso->info_text,
"Failed to open file '%s' in %s mode\n", filename, mode);
"Failed to open file '%s' in %s mode", filename, mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
}
return(0);

View File

@ -619,7 +619,7 @@ int Xorriso_genisofs_count_args(struct XorrisO *xorriso, int argc, char **argv,
"-partition_sec_hd", "-partition_cyl_align", "-untranslated_name_len",
"-rr_reloc_dir", "-hfsplus-serial-no", "-prep-boot-part", "-efi-boot-part",
"-hfsplus-block-size", "-apm-block-size", "--grub2-mbr",
"--grub2-sparc-core",
"--grub2-sparc-core", "--sort-weight-list", "--sort-weight-patterns",
""
};
static char arg2_options[][41]= {
@ -850,6 +850,8 @@ int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
" isolinux_mbr=on|auto|off Control eventual isohybrid MBR generation",
#endif
" --sort-weight NUMBER FILE Set LBA weight number to file or file tree",
" --sort-weight-list DISKFILE Read list of NUMBER FILE pairs for --sort-weight",
" --sort-weight-patterns DISKFILE --sort-weight-list with pattern expansion",
" --stdio_sync on|off|number Control forced output to disk files",
" --no-emul-toc Save 64 kB size on random access output files",
" --emul-toc Multi-session history on such output files",
@ -1143,10 +1145,10 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
int root_seen= 0, do_md5_mem, option_d= 0, arg_count;
mode_t mode_and, mode_or;
int with_boot_image= 0, with_cat_path= 0, with_emul_toc= 0;
int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1;
int old_root_md5= 1, old_root_dev= 0, old_root_ino= 1, sort_file_pattern= 0;
int *weight_list= NULL, weight_count= 0;
int *delay_opt_list= NULL, delay_opt_count= 0;
char *sfe= NULL, *adr= NULL, ra_text[80], *pathspec= NULL;
char *sfe= NULL, *adr= NULL, ra_text[80], *pathspec= NULL, *sort_file= NULL;
char *ept, *add_pt, *eff_path= NULL, *indev= NULL, msc[80], *cpt;
char *old_root= NULL, *argpt, *hargv[1];
char *boot_path, partno_text[8], *iso_rr_pt, *disk_pt, *rpt, *wpt;
@ -1161,6 +1163,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
Xorriso_alloc_meM(eff_path, char, SfileadrL);
Xorriso_alloc_meM(indev, char, SfileadrL+8);
Xorriso_alloc_meM(old_root, char, SfileadrL);
Xorriso_alloc_meM(sort_file, char, SfileadrL);
for(i= 0; i<argc; i++) {
if(strcmp(argv[i], "-log-file") == 0 ||
@ -1207,7 +1210,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
if(xorriso->boot_image_cat_path[0])
with_cat_path= -1;
adr[0]= indev[0]= msc[0]= old_root[0]= 0;
adr[0]= indev[0]= msc[0]= old_root[0]= sort_file[0]= 0;
for(i= 0; i<argc; i++) {
ret= Xorriso_genisofs_strip_dash(xorriso, argv[i], &argpt, 0);
if(ret <= 0)
@ -1787,6 +1790,15 @@ not_enough_args:;
i+= 2;
/* memorize for find runs after pathspecs have been added */
weight_list[weight_count++]= i - 2;
} else if(strcmp(argpt, "--sort-weight-list") == 0 ||
strcmp(argpt, "--sort-weight-patterns") == 0) {
if(i + 1 >= argc)
goto not_enough_args;
i++;
if(Sfile_str(sort_file, argv[i], 0) <= 0)
{ret= -1; goto ex;}
sort_file_pattern= (strcmp(argpt, "--sort-weight-patterns") == 0);
} else if(strcmp(argpt, "-z")==0 ||
strcmp(argpt, "-transparent-compression")==0) {
/* was already handled in first argument scan */;
@ -2184,6 +2196,12 @@ problem_handler_2:;
goto ex;
}
if(sort_file[0]) {
ret= Xorriso_apply_sort_file(xorriso, sort_file, sort_file_pattern);
if(ret<=0)
goto ex;
}
for(j= 0; j < weight_count; j++) {
i= weight_list[j];
/* find argv[i+2] -exec sort_weight argv[i+1] */

View File

@ -3954,3 +3954,85 @@ int Xorriso_get_blessing(struct XorrisO *xorriso, IsoNode *node,
}
/* @param flag bit0= use file addresses as search patterns
*/
int Xorriso_apply_sort_file(struct XorrisO *xorriso, char *path, int flag)
{
int ret, linecount= 0, filec= 0, zero, i;
FILE *fp= NULL;
char *sret, *line= NULL, *spt, *tpt, *patterns[1], **filev= NULL;
char *sort_weight_args[4];
off_t mem= 0;
IsoImage *volume;
Xorriso_alloc_meM(line, char, SfileadrL);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
goto ex;
ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 2);
if(ret <= 0)
{ret= 0; goto ex;}
while(1) {
sret= Sfile_fgets_n(line, SfileadrL - 1, fp, 0);
if(sret == NULL) {
if(ferror(fp))
{ret= 0; goto ex;}
break;
}
linecount++;
/* Find first space or tab */
spt= strchr(line, ' ');
tpt= strchr(line, '\t');
if(spt == NULL || (tpt != NULL && tpt < spt))
spt= tpt;
if(spt == NULL) {
sprintf(xorriso->info_text,
"No space or tab character found in line %d of sort weight file ",
linecount);
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
*spt= 0;
patterns[0]= spt + 1;
if(flag & 1) {
/* Obtain list of matching files */
ret= Xorriso_expand_pattern(xorriso, 1, patterns, 0,
&filec, &filev, &mem, 4);
if(ret <= 0)
{ret= 0; goto ex;}
} else {
filec= 1;
}
/* Apply weight to file or directory tree */
for(i= 0; i < filec; i++) {
zero= 0;
if(flag & 1) {
sort_weight_args[0]= filev[i];
} else {
sort_weight_args[0]= patterns[0];
}
sort_weight_args[1]= "-exec";
sort_weight_args[2]= "sort_weight";
sort_weight_args[3]= line;
ret= Xorriso_option_find(xorriso, 4, sort_weight_args, &zero, 2);
if(ret <= 0)
{ret= 0; goto ex;}
}
if(flag & 1)
Sfile_destroy_argv(&filec, &filev, 0);
}
ret= 1;
ex:
if(fp != NULL)
fclose(fp);
Xorriso_free_meM(line);
Sfile_destroy_argv(&filec, &filev, 0);
return(ret);
}

View File

@ -1883,6 +1883,7 @@ ex:;
/* @param flag bit0= a match count !=1 is a FAILURE event
bit1= with bit0 tolerate 0 matches if pattern is a constant
bit2= do not issue debug messages about temporay memory needs
*/
int Xorriso_expand_pattern(struct XorrisO *xorriso,
int num_patterns, char **patterns, int extra_filec,
@ -1965,7 +1966,7 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso,
mem+= extra_filec*sizeof(char *);
if(count<=0)
{ret= 0; goto ex;}
ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0);
ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, !!(flag & 4));
if(ret<=0)
goto ex;
/* now store addresses */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2013.05.24.111243"
#define Xorriso_timestamP "2013.05.28.175212"

View File

@ -608,5 +608,9 @@ int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path,
int Xorriso_pretend_full_disc(struct XorrisO *xorriso, int flag);
int Xorriso_apply_sort_file(struct XorrisO *xorriso, char *path, int flag);
#endif /* Xorrisoburn_includeD */

View File

@ -9,7 +9,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 XORRISOFS 1 "Version 1.3.1, May 17, 2013"
.TH XORRISOFS 1 "Version 1.3.1, May 27, 2013"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -374,6 +374,35 @@ Currently the El Torito boot catalog has a hardcoded weight of 1 billion.
Normally it should occupy the block with the lowest possible address.
Data files get added or loaded with initial weight 0.
.TP
\fB--sort-weight-list\fR disk_path
Read pairs of weight number and iso_rr_path from a file of the
local filesystem. Apply each pair like with \-\-sort\-weight.
.br
Only the last \-\-sort\-weight\-list or
\-\-sort\-weight\-patterns of a xorrisofs run gets into effect.
.br
The weight number is read from the start of the line.
The iso_rr_path part of an input line begins immediately after the first blank
or tab character of the line.
.br
Notes for the case that this feature is used within a sequence of generic
xorriso commands (not an issue with a pure mkisofs emulation run):
.br
The addressed files must already be in the ISO image model when you execute
.br
\-as mkisofs \-\-sort\-weight\-list disk_path \-\-
.br
Several such commands may be used to apply more than one weight file.
.br
Data files which are loaded by \-indev or \-dev get a weight between 1 and
2 exp 28 = 268,435,456, depending on their block address. This shall keep
them roughly in the same order if the write method of modifying is applied.
.TP
\fB--sort-weight-patterns\fR disk_path
Like \-\-sort\-weight\-list , but expanding the iso_rr_paths as
shell parser patterns and applying \-\-sort\-weight to each
matching file.
.TP
\fB\-dir-mode\fR mode
Set the access permissions for all directories in the image to the given
mode which is either an octal number beginning with "0" or a comma separated

View File

@ -393,6 +393,31 @@ File: xorrisofs.info, Node: SetProduct, Next: SetCompl, Prev: SetInsert, Up:
the block with the lowest possible address. Data files get added
or loaded with initial weight 0.
--sort-weight-list disk_path
Read pairs of weight number and iso_rr_path from a file of the
local filesystem. Apply each pair like with --sort-weight.
Only the last --sort-weight-list or --sort-weight-patterns of a
xorrisofs run gets into effect.
The weight number is read from the start of the line. The
iso_rr_path part of an input line begins immediately after the
first blank or tab character of the line.
Notes for the case that this feature is used within a sequence of
generic xorriso commands (not an issue with a pure mkisofs
emulation run):
The addressed files must already be in the ISO image model when
you execute
-as mkisofs --sort-weight-list disk_path --
Several such commands may be used to apply more than one weight
file.
Data files which are loaded by -indev or -dev get a weight between
1 and 2 exp 28 = 268,435,456, depending on their block address.
This shall keep them roughly in the same order if the write method
of modifying is applied.
--sort-weight-patterns disk_path
Like --sort-weight-list , but expanding the iso_rr_paths as shell
parser patterns and applying --sort-weight to each matching file.
-dir-mode mode
Set the access permissions for all directories in the image to the
given mode which is either an octal number beginning with "0" or a
@ -1753,7 +1778,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* --no_rc do not execute startup files: Miscellaneous. (line 19)
* --norock disable Rock Ridge production: SetExtras. (line 25)
* --old-empty old block addresses for empty files: SetProduct.
(line 81)
(line 106)
* --old-root-devno enable disk idevno with -old-root: SetInsert.
(line 97)
* --old-root-no-ino disable disk ino with -old-root: SetInsert.
@ -1764,7 +1789,12 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* --quoted_path_list read pathspecs from disk file: SetInsert.
(line 13)
* --scdbackup_tag Recording of MD5 checksum: SetExtras. (line 101)
* --sort-weight set output file address: SetProduct. (line 49)
* --sort-weight set block address sorting weight: SetProduct.
(line 49)
* --sort-weight-list set block address sorting weight: SetProduct.
(line 60)
* --sort-weight-patterns set block address sorting weight: SetProduct.
(line 81)
* --stdio_sync control forced output to disk files: SetProduct.
(line 25)
* --xattr Recording of xattr: SetExtras. (line 77)
@ -1791,7 +1821,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* -D allow deep directory hierachies: SetExtras. (line 31)
* -d omit trailing dot in ISO file names: SetCompl. (line 56)
* -dev set path for loading existing ISO image: Loading. (line 25)
* -dir-mode permissions for all directories: SetProduct. (line 60)
* -dir-mode permissions for all directories: SetProduct. (line 85)
* -disable-deep-relocation allow deep directory hierachies: SetExtras.
(line 44)
* -disallow_dir_id_ext enforce ISO level 1 directory names: SetCompl.
@ -1809,7 +1839,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* -exclude-list exclude disk files from inserting: SetInsert.
(line 51)
* -f follow symbolic links on disk: SetInsert. (line 24)
* -file-mode permissions for all data files: SetProduct. (line 66)
* -file-mode permissions for all data files: SetProduct. (line 91)
* -follow-links follow symbolic links on disk: SetInsert. (line 28)
* -full-iso9660-filenames allow 31 characters in ISO file names: SetCompl.
(line 66)
@ -1873,7 +1903,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
* -mipsel-boot MIPS Little Endian boot image: SystemArea. (line 178)
* -N omit version number in ISO file names: SetCompl. (line 73)
* -no-emul-boot El Torito boot image emulation: Bootable. (line 72)
* -no-pad do not add zeros to ISO tree: SetProduct. (line 76)
* -no-pad do not add zeros to ISO tree: SetProduct. (line 101)
* -o set output file address: SetProduct. (line 8)
* -old-exclude exclude disk files from inserting: SetInsert.
(line 48)
@ -1887,7 +1917,7 @@ File: xorrisofs.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: T
(line 21)
* -p set Preparer Id: ImageId. (line 54)
* -P set Publisher Id: ImageId. (line 30)
* -pad add 300 KiB of zeros to ISO tree: SetProduct. (line 69)
* -pad add 300 KiB of zeros to ISO tree: SetProduct. (line 94)
* -partition_cyl_align Image size alignment: SystemArea. (line 116)
* -partition_hd_cyl MBR heads per cylinder: SystemArea. (line 99)
* -partition_offset Make mountable by partition 1: SystemArea.
@ -1945,7 +1975,12 @@ File: xorrisofs.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Application Id, set, -A, -appid: ImageId. (line 38)
* Backup, enable fidelity, --for_backup: SetExtras. (line 67)
* Biblio File, set path, -biblio: ImageId. (line 72)
* Block address, set sort weight, --sort-weight: SetProduct. (line 49)
* Block address, set sorting weight, --sort-weight: SetProduct.
(line 49)
* Block address, set sorting weight, --sort-weight-list: SetProduct.
(line 60)
* Block address, set sorting weight, --sort-weight-patterns: SetProduct.
(line 81)
* Bootability, boot catalog hidden, --boot-catalog-hide: Bootable.
(line 114)
* Bootability, boot catalog name, -c, -eltorito-catalog: Bootable.
@ -2087,15 +2122,15 @@ File: xorrisofs.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
(line 87)
* Options, list, -help: Miscellaneous. (line 23)
* Output file, set address, -o, -output: SetProduct. (line 8)
* Padding, 300 KiB, -pad: SetProduct. (line 69)
* Padding, disable, --old-empty: SetProduct. (line 81)
* Padding, disable, -no-pad: SetProduct. (line 76)
* Padding, 300 KiB, -pad: SetProduct. (line 94)
* Padding, disable, --old-empty: SetProduct. (line 106)
* Padding, disable, -no-pad: SetProduct. (line 101)
* pathspec, _definition: Insert. (line 12)
* pathspec, enable target=source, -graft-points: SetInsert. (line 31)
* pathspec, read list of, --quoted_path_list: SetInsert. (line 13)
* pathspec, read list of, -path-list: SetInsert. (line 8)
* Permissions, for all data files, -file-mode: SetProduct. (line 66)
* Permissions, for all directories, -dir-mode: SetProduct. (line 60)
* Permissions, for all data files, -file-mode: SetProduct. (line 91)
* Permissions, for all directories, -dir-mode: SetProduct. (line 85)
* Preparer Id, set, -p: ImageId. (line 54)
* Problems, reporting: Bugreport. (line 6)
* Program version, report, -version: Miscellaneous. (line 42)
@ -2135,28 +2170,28 @@ Node: Options6709
Node: Loading7436
Node: SetInsert9732
Node: SetProduct14148
Node: SetCompl17855
Node: SetExtras20451
Node: SetHide28860
Node: ImageId30168
Node: Bootable33673
Node: SystemArea38667
Node: Charset48964
Node: Jigdo49990
Node: Miscellaneous54257
Node: Examples55813
Node: ExSimple56299
Node: ExGraft56778
Node: ExMkisofs58025
Node: ExGrowisofs59278
Node: ExIncBackup60450
Node: ExIncBckAcc63558
Node: ExBootable65234
Node: Files67326
Node: Seealso68400
Node: Bugreport69056
Node: Legal69637
Node: CommandIdx70532
Node: ConceptIdx84598
Node: SetCompl19092
Node: SetExtras21688
Node: SetHide30097
Node: ImageId31405
Node: Bootable34910
Node: SystemArea39904
Node: Charset50201
Node: Jigdo51227
Node: Miscellaneous55494
Node: Examples57050
Node: ExSimple57536
Node: ExGraft58015
Node: ExMkisofs59262
Node: ExGrowisofs60515
Node: ExIncBackup61687
Node: ExIncBckAcc64795
Node: ExBootable66471
Node: Files68563
Node: Seealso69637
Node: Bugreport70293
Node: Legal70874
Node: CommandIdx71769
Node: ConceptIdx86187

End Tag Table

View File

@ -50,7 +50,7 @@
@c man .\" First parameter, NAME, should be all caps
@c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
@c man .\" other parameters are allowed: see man(7), man(1)
@c man .TH XORRISOFS 1 "Version 1.3.1, May 17, 2013"
@c man .TH XORRISOFS 1 "Version 1.3.1, May 27, 2013"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -545,8 +545,8 @@ files.
This is the default.
@c man .TP
@item @minus{}@minus{}sort-weight weight_number iso_rr_path
@kindex @minus{}@minus{}sort-weight set output file address
@cindex Block address, set sort weight, @minus{}@minus{}sort-weight
@kindex @minus{}@minus{}sort-weight set block address sorting weight
@cindex Block address, set sorting weight, @minus{}@minus{}sort-weight
Attribute a LBA weight number to regular files. If iso_rr_path leads
to a directory then all regular files underneath will get the weight_number.
@*
@ -557,6 +557,39 @@ Currently the El Torito boot catalog has a hardcoded weight of 1 billion.
Normally it should occupy the block with the lowest possible address.
Data files get added or loaded with initial weight 0.
@c man .TP
@item @minus{}@minus{}sort-weight-list disk_path
@kindex @minus{}@minus{}sort-weight-list set block address sorting weight
@cindex Block address, set sorting weight, @minus{}@minus{}sort-weight-list
Read pairs of weight number and iso_rr_path from a file of the
local filesystem. Apply each pair like with @minus{}@minus{}sort-weight.
@*
Only the last @minus{}@minus{}sort-weight-list or
@minus{}@minus{}sort-weight-patterns of a xorrisofs run gets into effect.
@*
The weight number is read from the start of the line.
The iso_rr_path part of an input line begins immediately after the first blank
or tab character of the line.
@*
Notes for the case that this feature is used within a sequence of generic
xorriso commands (not an issue with a pure mkisofs emulation run):
@*
The addressed files must already be in the ISO image model when you execute
@*
-as mkisofs @minus{}@minus{}sort-weight-list disk_path @minus{}@minus{}
@*
Several such commands may be used to apply more than one weight file.
@*
Data files which are loaded by -indev or -dev get a weight between 1 and
2 exp 28 = 268,435,456, depending on their block address. This shall keep
them roughly in the same order if the write method of modifying is applied.
@c man .TP
@item @minus{}@minus{}sort-weight-patterns disk_path
@kindex @minus{}@minus{}sort-weight-patterns set block address sorting weight
@cindex Block address, set sorting weight, @minus{}@minus{}sort-weight-patterns
Like @minus{}@minus{}sort-weight-list , but expanding the iso_rr_paths as
shell parser patterns and applying @minus{}@minus{}sort-weight to each
matching file.
@c man .TP
@item -dir-mode mode
@kindex -dir-mode permissions for all directories
@cindex Permissions, for all directories, -dir-mode