New option -clone

This commit is contained in:
Thomas Schmitt 2011-02-01 18:58:27 +00:00
parent 5ead96341e
commit ed04ef8aba
13 changed files with 255 additions and 70 deletions

View File

@ -1,6 +1,12 @@
SVN trunk (to become libisoburn-1.0.2.pl00.tar.gz)
===============================================================================
- no novelties yet
* Bug fix: Option -mkdir yielded SIGSEGV due to a NULL pointer
* Bug fix: ECMA-119 standards violation with Volume Descriptor Set Terminator
* Removed compiler obstacles of GNU xorriso on Solaris 9
* New isoburn_igopt_set_extensions() option isoburn_igopt_old_empty
* New -as mkisofs option --old-empty
* New option -clone
libisoburn-1.0.0.pl00.tar.gz Mon Jan 17 2011
===============================================================================

View File

@ -140,6 +140,7 @@ Xorriso_option_check_media_defaults;
Xorriso_option_chgrpi;
Xorriso_option_chmodi;
Xorriso_option_chowni;
Xorriso_option_clone;
Xorriso_option_close;
Xorriso_option_close_filter_list;
Xorriso_option_commit;

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2010 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2011 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -1204,6 +1204,38 @@ ex:;
}
int Xorriso_overwrite_dest(struct XorrisO *xorriso, void *boss_iter,
char *eff_dest, int dest_ret, char *activity,
int flag)
{
int ret;
char sfe[5*SfileadrL];
if(dest_ret==2 && xorriso->do_overwrite!=1) {
sprintf(xorriso->info_text, "%s: May not overwrite directory: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if (dest_ret==1 && !xorriso->do_overwrite) {
sprintf(xorriso->info_text, "%s: May not overwite: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if(dest_ret>0) {
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, eff_dest, 1|8);
if(ret<=0)
return(0);
if(ret==3) {
sprintf(xorriso->info_text, "%s: User revoked removal of: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(0);
}
}
return(1);
}
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
Set to NULL if calling this function from outside ISO world
*/
@ -1266,27 +1298,10 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
}
/* Check whether destination exists and may be not overwriteable */
if(dest_ret==2 && xorriso->do_overwrite!=1) {
sprintf(xorriso->info_text, "Renaming may not overwrite directory: %s",
Text_shellsafe(eff_dest, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if (dest_ret==1 && !xorriso->do_overwrite) {
sprintf(xorriso->info_text, "Renaming may not overwite: %s",
Text_shellsafe(eff_dest, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if(dest_ret>0) {
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, eff_dest, 1|8);
if(ret<=0)
return(0);
if(ret==3) {
sprintf(xorriso->info_text, "User revoked renaming of: %s",
Text_shellsafe(eff_origin, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(0);
}
}
ret= Xorriso_overwrite_dest(xorriso, boss_iter,
eff_dest, dest_ret, "Renaming", 0);
if(ret <= 0)
return(ret);
/* Ensure existence of destination directory */
strcpy(dir_adr, eff_dest);
@ -1362,6 +1377,101 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
}
int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
char *origin, char *dest, int flag)
{
int ret, dest_ret, l;
char eff_dest[SfileadrL], eff_origin[SfileadrL], dir_adr[SfileadrL];
char *leafname;
IsoImage *volume;
IsoDir *new_parent;
IsoNode *origin_node, *dir_node, *new_node, *dest_node= NULL;
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret <= 0)
return(ret);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0);
if(ret<=0)
return(ret);
ret= Xorriso_node_from_path(xorriso, volume, eff_origin, &origin_node, 0);
if(ret <= 0)
return(ret);
dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1);
if(dest_ret<0)
return(dest_ret);
if(dest_ret > 0) {
ret= Xorriso_node_from_path(xorriso, volume, eff_dest, &dest_node, 0);
if(ret <= 0)
return(ret);
if(dest_node == origin_node) {
sprintf(xorriso->info_text,
"Cloning: Original and copy have the same iso_rr_path: ");
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
} else {
/* obtain eff_dest address despite it does not exist */
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2);
if(ret<=0)
return(ret);
}
ret= Xorriso_overwrite_dest(xorriso, boss_iter,
eff_dest, dest_ret, "Cloning", 0);
if(ret <= 0)
return(ret);
/* Obtain parent path and leaf name */
strcpy(dir_adr, eff_dest);
for(l= strlen(dir_adr); l > 0; ) {
if(dir_adr[l - 1] == '/')
dir_adr[--l]= 0;
else
break;
}
leafname= strrchr(dir_adr, '/');
if(leafname == NULL) {
leafname= dir_adr;
if (leafname[0] == 0) {
Xorriso_msgs_submit(xorriso, 0, "Empty file name as clone destination",
0, "FAILURE", 0);
return(0);
}
} else {
*leafname= 0;
leafname++;
if(dir_adr[0] != 0) {
/* Ensure existence of destination directory */
ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr,
(off_t) 0, (off_t) 0, 1);
if(ret <= 0)
return(ret);
}
}
ret= Xorriso_node_from_path(xorriso, volume, dir_adr, &dir_node, 0);
if(ret <= 0)
return(ret);
new_parent= (IsoDir *) dir_node;
ret = iso_tree_clone(origin_node, new_parent, leafname, &new_node, 0);
Xorriso_process_msg_queues(xorriso,0);
if (ret < 0) {
Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot clone",
0, "FAILURE", 1);
sprintf(xorriso->info_text, "Failed to clone ");
Text_shellsafe(eff_origin, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
Xorriso_set_change_pending(xorriso, 0);
return(1);
}
int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path,
mode_t mode_and, mode_t mode_or, int flag)
{

View File

@ -1672,6 +1672,17 @@ ex:;
}
/* Option -clone */
int Xorriso_option_clone(struct XorrisO *xorriso, char *origin, char *dest,
int flag)
{
int ret;
ret= Xorriso_clone_tree(xorriso, NULL, origin, dest, 0);
return(ret);
}
/* Option -close "on"|"off" */
int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag)
{

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2010 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2011 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -1599,6 +1599,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Create empty directories if they do not exist yet.",
" -rmdir iso_rr_path [***]",
" Delete empty directories.",
" -clone iso_rr_path_original iso_rr_path_copy",
" Create a copy of an ISO directory tree. I.e. ISO to ISO.",
"",
" -- Default list delimiter marking the end of action argument",
" list. It may be changed by option -list_delimiter.",
"",

View File

@ -477,7 +477,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
""
};
static char arg2_commands[][40]= {
"assert_volid","boot_image","compare","compare_r","drive_class",
"assert_volid","boot_image","clone","compare","compare_r","drive_class",
"errfile_log","error_behavior","extract","extract_single",
"jigdo","load","logfile",
"map","map_single","page","return_with",
@ -748,6 +748,10 @@ next_command:;
(*idx)+= 1;
ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0);
} else if(strcmp(cmd,"clone")==0) {
(*idx)+= 2;
ret= Xorriso_option_clone(xorriso, arg1, arg2, 1);
} else if(strcmp(cmd,"close")==0) {
(*idx)++;
ret= Xorriso_option_close(xorriso, arg1, 0);

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 XORRISO 1 "Jan 19, 2011"
.TH XORRISO 1 "Jan 29, 2011"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1050,6 +1050,16 @@ Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as
other file causes a FAILURE event.
.TP
\fB\-clone\fR iso_rr_path_original iso_rr_path_copy
Create a copy of the ISO file object iso_rr_path_original with the new
address iso_rr_path_copy. If the original is a directory then copy all
files and directories underneath. Boot catalog are not copied but
silently ignored.
.br
The copied ISO file objects have the same attributes. Copied data files
refer to the same content source as their originals.
The copies may then be manipulated independendly of their originals.
.TP
.B Settings for file insertion:
.TP
\fB\-file_size_limit\fR value [value [...]] --

View File

@ -703,6 +703,10 @@ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
int argc, char **argv, int *idx, int flag);
/* Option -clone */
int Xorriso_option_clone(struct XorrisO *xorriso, char *origin, char *dest,
int flag);
/* Option -close "on"|"off" */
int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag);

View File

@ -987,6 +987,15 @@ filesystem.
directory generates a WARNING event, existence as other file
causes a FAILURE event.
-clone iso_rr_path_original iso_rr_path_copy
Create a copy of the ISO file object iso_rr_path_original with the
new address iso_rr_path_copy. If the original is a directory then
copy all files and directories underneath. Boot catalog are not
copied but silently ignored.
The copied ISO file objects have the same attributes. Copied data
files refer to the same content source as their originals. The
copies may then be manipulated independendly of their originals.

File: xorriso.info, Node: SetInsert, Next: Manip, Prev: Insert, Up: Options
@ -4018,6 +4027,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -chmod_r sets permissions in ISO image: Manip. (line 70)
* -chown sets ownership in ISO image: Manip. (line 42)
* -chown_r sets ownership in ISO image: Manip. (line 47)
* -clone copies ISO directory tree: Insert. (line 171)
* -close controls media closing: SetWrite. (line 260)
* -close_filter_list bans filter registration: Filter. (line 52)
* -commit writes pending ISO image: Writing. (line 13)
@ -4222,6 +4232,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Dialog, enable dialog mode, -dialog: DialogCtl. (line 7)
* Dialog, line editing, -use_readline: DialogCtl. (line 28)
* Dialog, terminal geometry, -page: DialogCtl. (line 19)
* Directory, copy, -clone: Insert. (line 171)
* Directory, create, -mkdir: Insert. (line 166)
* Directory, delete, -rmdir: Manip. (line 32)
* disk_path, _definition: Insert. (line 6)
@ -4440,45 +4451,45 @@ Node: Options23227
Node: AqDrive24835
Node: Loading27741
Node: Insert40885
Node: SetInsert49242
Node: Manip57809
Node: CmdFind66490
Node: Filter76914
Node: Writing81263
Node: SetWrite87552
Node: Bootable101162
Node: Jigdo113469
Node: Charset117727
Node: Exception120478
Node: DialogCtl124993
Node: Inquiry127580
Node: Navigate131913
Node: Verify139808
Node: Restore148397
Node: Emulation155053
Node: Scripting164096
Node: Frontend169658
Node: Examples170953
Node: ExDevices172122
Node: ExCreate172756
Node: ExDialog174030
Node: ExGrowing175292
Node: ExModifying176094
Node: ExBootable176595
Node: ExCharset177142
Node: ExPseudo177970
Node: ExCdrecord178864
Node: ExMkisofs179179
Node: ExGrowisofs180182
Node: ExException181306
Node: ExTime181760
Node: ExIncBackup182219
Node: ExRestore185787
Node: ExRecovery186756
Node: Files187322
Node: Seealso188550
Node: Legal189074
Node: CommandIdx189996
Node: ConceptIdx204222
Node: SetInsert49744
Node: Manip58311
Node: CmdFind66992
Node: Filter77416
Node: Writing81765
Node: SetWrite88054
Node: Bootable101664
Node: Jigdo113971
Node: Charset118229
Node: Exception120980
Node: DialogCtl125495
Node: Inquiry128082
Node: Navigate132415
Node: Verify140310
Node: Restore148899
Node: Emulation155555
Node: Scripting164598
Node: Frontend170160
Node: Examples171455
Node: ExDevices172624
Node: ExCreate173258
Node: ExDialog174532
Node: ExGrowing175794
Node: ExModifying176596
Node: ExBootable177097
Node: ExCharset177644
Node: ExPseudo178472
Node: ExCdrecord179366
Node: ExMkisofs179681
Node: ExGrowisofs180684
Node: ExException181808
Node: ExTime182262
Node: ExIncBackup182721
Node: ExRestore186289
Node: ExRecovery187258
Node: Files187824
Node: Seealso189052
Node: Legal189576
Node: CommandIdx190498
Node: ConceptIdx204797

End Tag Table

View File

@ -44,7 +44,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 XORRISO 1 "Jan 19, 2011"
@c man .TH XORRISO 1 "Jan 29, 2011"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -1311,6 +1311,18 @@ If the iso_rr_path does not begin with '/' then -cd is prepended.
Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as
other file causes a FAILURE event.
@c man .TP
@item -clone iso_rr_path_original iso_rr_path_copy
@kindex -clone copies ISO directory tree
@cindex Directory, copy, -clone
Create a copy of the ISO file object iso_rr_path_original with the new
address iso_rr_path_copy. If the original is a directory then copy all
files and directories underneath. Boot catalog are not copied but
silently ignored.
@*
The copied ISO file objects have the same attributes. Copied data files
refer to the same content source as their originals.
The copies may then be manipulated independendly of their originals.
@end table
@c man .TP
@c man .B Settings for file insertion:

View File

@ -576,7 +576,14 @@ cdrecord and mkisofs.</DT>
<DT><H3>Development snapshot, version 1.0.1 :</H3></DT>
<DD>Bug fixes towards xorriso-1.0.0:
<UL>
<LI>- none yet -</LI>
<LI>
ECMA-119 standards violation with Volume Descriptor Set Terminator
(hampers libarchive, but not mounting on Linux, FreeBSD, Solaris,
or booting by ISOLINUX or GRUB2).
</LI>
<LI>
Bug fix: Option -mkdir yielded SIGSEGV due to a NULL pointer.
</LI>
<!--
<LI>- none yet -</LI>
-->
@ -584,8 +591,9 @@ cdrecord and mkisofs.</DT>
</DD>
<DD>Enhancements towards stable version 1.0.0:
<UL>
<LI>- none yet -</LI>
<LI>New option -clone</LI>
<!--
<LI>- none yet -</LI>
-->
</UL>

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.01.31.135917"
#define Xorriso_timestamP "2011.02.01.185830"

View File

@ -556,5 +556,10 @@ int Xorriso_jigdo_interpreter(struct XorrisO *xorriso, char *aspect, char *arg,
int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job,
char *basename, mode_t st_mode, off_t st_size, int flag);
int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
char *origin, char *dest, int flag);
#endif /* Xorrisoburn_includeD */