New command -lns for creating symbolic links

This commit is contained in:
Thomas Schmitt 2012-10-19 08:19:02 +00:00
parent a34914798f
commit 3d5c45892c
10 changed files with 147 additions and 51 deletions

View File

@ -215,6 +215,7 @@ Xorriso_option_list_extras;
Xorriso_option_list_formats;
Xorriso_option_list_profiles;
Xorriso_option_list_speeds;
Xorriso_option_lnsi;
Xorriso_option_load;
Xorriso_option_logfile;
Xorriso_option_lsi;

View File

@ -723,6 +723,24 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
}
int Xorriso_add_symlink(struct XorrisO *xorriso, IsoDir *parent,
char *link_target, char *leaf_name,
char *nominal_path, int flag)
{
int ret= 0;
IsoSymlink *link= NULL;
ret= iso_tree_add_new_symlink(parent, leaf_name, link_target, &link);
Xorriso_process_msg_queues(xorriso,0);
if(ret < 0) {
Xorriso_report_iso_error(xorriso, nominal_path, ret,
"Cannot create symbolic link", 0, "FATAL", 1);
ret= 0;
}
return(ret);
}
/* @param boss_iter Opaque handle to be forwarded to actions in ISO image
Set to NULL if calling this function from outside ISO world
@param flag bit0= mkdir: graft in as empty directory, not as copy from disk
@ -735,6 +753,8 @@ int Xorriso_copy_properties(struct XorrisO *xorriso,
bit7= no special handling of split file directories
bit8= hide in iso_rr
bit9= hide in joliet
bit10= ln -s: graft in as symbolic link.
Link target is handed over in parameter disk_path.
@return <=0 = error , 1 = added simple node , 2 = added directory ,
3 = rejected
*/
@ -822,7 +842,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
path[SfileadrL - 1]= 0;
apt= npt= path;
if(!(flag&1)) {
if(!(flag & (1 | 1024))) {
ret= lstat(disk_path, &stbuf);
if(ret!=-1) {
if(S_ISDIR(stbuf.st_mode))
@ -951,6 +971,12 @@ attach_source:;
if(flag&1) {
/* directory node was created above */;
} else if(flag & 1024) {
ret= Xorriso_add_symlink(xorriso, dir, disk_path, apt, img_path, 0);
if(ret <= 0)
goto ex;
Xorriso_set_change_pending(xorriso, 0);
} else if(is_dir) {
Xorriso_transfer_properties(xorriso, &stbuf, disk_path,
(IsoNode *) dir, 4 | 32);
@ -1102,6 +1128,11 @@ attach_source:;
if(flag&1) {
/* directory node was created above */;
} else if(flag & 1024) {
ret= Xorriso_add_symlink(xorriso, dir, disk_path, apt, img_path, 0);
if(ret <= 0)
goto ex;
} else if(is_dir) {
Xorriso_transfer_properties(xorriso, &stbuf, disk_path,
(IsoNode *) dir, 4 | 32);

View File

@ -1796,6 +1796,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" params are their parameters except iso_rr_path.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet.",
" -lns target_text iso_rr_path",
" Create a symbolic link pointing to target_text",
" -rmdir iso_rr_path [***]",
" Delete empty directories.",
" -clone iso_rr_path_original iso_rr_path_copy",

View File

@ -182,6 +182,38 @@ int Xorriso_option_list_profiles(struct XorrisO *xorriso, char *which,
}
/* Command -lns alias -lnsi */
int Xorriso_option_lnsi(struct XorrisO *xorriso, char *target, char *path,
int flag)
{
int ret;
char *eff_path= NULL;
Xorriso_alloc_meM(eff_path, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
if(ret < 0)
{ret= 0; goto ex;}
if(ret > 0) {
sprintf(xorriso->info_text, "-lns: Address already existing: ");
Text_shellsafe(eff_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2);
if(ret < 0)
{ret= 0; goto ex;}
ret= Xorriso_graft_in(xorriso, NULL, target, eff_path, (off_t) 0, (off_t) 0,
1024);
if(ret <= 0)
{ret= 0; goto ex;}
ret= 1;
ex:;
Xorriso_free_meM(eff_path);
return(ret);
}
/* Option -load session|track|sbsector value */
/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high
@return <=0 error , 1 success, 2 revoked by -reassure

View File

@ -528,7 +528,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"assert_volid","boot_image","clone","compare","compare_r","drive_class",
"data_cache_size",
"errfile_log","error_behavior","extract","extract_single",
"jigdo","load","logfile",
"jigdo","lns","lnsi","load","logfile",
"map","map_single","page","return_with",
"scdbackup_tag","update","update_r","volume_date",
""
@ -671,7 +671,7 @@ int Xorriso_cmd_sorting_rank(struct XorrisO *xorriso,
"* Inserting files into ISO image:",
"disk_pattern", "add_plainly",
"mkdir", "add", "path_list", "quoted_path_list",
"mkdir", "lns", "add", "path_list", "quoted_path_list",
"map", "map_single", "map_l", "update", "update_r", "update_l",
"cut_out", "cpr",
"clone", "cp_clone",
@ -1371,6 +1371,10 @@ next_command:;
} else if(strcmp(cmd,"list_speeds")==0) {
ret= Xorriso_option_list_speeds(xorriso, 0);
} else if(strcmp(cmd, "lns") == 0 || strcmp(cmd, "lnsi") == 0) {
(*idx)+= 2;
ret= Xorriso_option_lnsi(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"load")==0) {
(*idx)+= 2;
ret= Xorriso_option_load(xorriso, arg1, arg2, 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 "Version 1.2.5, Sep 21, 2012"
.TH XORRISO 1 "Version 1.2.5, Oct 18, 2012"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1174,6 +1174,12 @@ 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\-lns\fR target_text iso_rr_path
Create a symbolic link with address iso_rr_path which points to target_text.
iso_rr_path may not exist yet.
.br
Hint: Command \-clone produces the ISO equivalent of a hard link.
.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

View File

@ -1186,6 +1186,11 @@ int Xorriso_option_list_profiles(struct XorrisO *xorriso, char *which,
/* @since 1.1.2 */
int Xorriso_option_list_speeds(struct XorrisO *xorriso, int flag);
/* Command -lns alias -lnsi */
/* @since 1.2.6 */
int Xorriso_option_lnsi(struct XorrisO *xorriso, char *target, char *path,
int flag);
/* Command -load session|track|sbsector value */
/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high
@return <=0 error , 1 success, 2 revoked by -reassure

View File

@ -1087,6 +1087,11 @@ filesystem.
directory generates a WARNING event, existence as other file
causes a FAILURE event.
-lns target_text iso_rr_path
Create a symbolic link with address iso_rr_path which points to
target_text. iso_rr_path may not exist yet.
Hint: Command -clone produces the ISO equivalent of a hard link.
-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
@ -4553,7 +4558,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 174)
* -clone copies ISO directory tree: Insert. (line 179)
* -close controls media closing: SetWrite. (line 333)
* -close_damaged closes damaged track and session: Writing. (line 152)
* -close_filter_list bans filter registration: Filter. (line 52)
@ -4564,7 +4569,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -compare_r reports ISO/disk differences: Navigate. (line 159)
* -compliance controls standard compliance: SetWrite. (line 58)
* -copyright_file sets copyright file name: SetWrite. (line 225)
* -cp_clone copies ISO directory tree: Insert. (line 186)
* -cp_clone copies ISO directory tree: Insert. (line 191)
* -cp_rx copies file trees to disk: Restore. (line 108)
* -cpax copies files to disk: Restore. (line 104)
* -cpr inserts like with cp -r: Insert. (line 155)
@ -4627,6 +4632,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
* -list_formats lists available formats: Writing. (line 126)
* -list_profiles lists supported media: Writing. (line 166)
* -list_speeds lists available write speeds: Writing. (line 138)
* -lns creates ISO symbolic link: Insert. (line 174)
* -load addresses a particular session as input: Loading. (line 11)
* -local_charset sets terminal character set: Charset. (line 47)
* -logfile logs output channels to file: Frontend. (line 20)
@ -4788,8 +4794,8 @@ 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)
* Directories, copy, -cp_clone: Insert. (line 186)
* Directory, copy, -clone: Insert. (line 174)
* Directories, copy, -cp_clone: Insert. (line 191)
* Directory, copy, -clone: Insert. (line 179)
* Directory, create, -mkdir: Insert. (line 169)
* Directory, delete, -rmdir: Manip. (line 32)
* disk_path, _definition: Insert. (line 6)
@ -4976,6 +4982,7 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top
* Sorting order, for -x, -list_arg_sorting: ArgSort. (line 27)
* SUN Disk Label, production: Bootable. (line 210)
* SUN SPARC boot images, activation: Bootable. (line 255)
* Symbolic link, create, -lns: Insert. (line 174)
* System area, _definition: Bootable. (line 121)
* Table-of-content, search sessions, -rom_toc_scan: Loading. (line 211)
* Table-of-content, show, -toc: Inquiry. (line 28)
@ -5034,46 +5041,46 @@ Node: ArgSort26154
Node: AqDrive27644
Node: Loading30688
Node: Insert46143
Node: SetInsert56059
Node: Manip64635
Node: CmdFind73458
Node: Filter88162
Node: Writing92717
Node: SetWrite101681
Node: Bootable120314
Node: Jigdo135707
Node: Charset139953
Node: Exception142714
Node: DialogCtl148833
Node: Inquiry151430
Node: Navigate156296
Node: Verify164593
Node: Restore173624
Node: Emulation180533
Node: Scripting190344
Node: Frontend197504
Node: Examples198804
Node: ExDevices199981
Node: ExCreate200640
Node: ExDialog201925
Node: ExGrowing203190
Node: ExModifying203995
Node: ExBootable204499
Node: ExCharset205051
Node: ExPseudo205872
Node: ExCdrecord206770
Node: ExMkisofs207087
Node: ExGrowisofs208427
Node: ExException209562
Node: ExTime210016
Node: ExIncBackup210475
Node: ExRestore214467
Node: ExRecovery215427
Node: Files215997
Node: Seealso217296
Node: Bugreport218019
Node: Legal218600
Node: CommandIdx219611
Node: ConceptIdx235483
Node: SetInsert56278
Node: Manip64854
Node: CmdFind73677
Node: Filter88381
Node: Writing92936
Node: SetWrite101900
Node: Bootable120533
Node: Jigdo135926
Node: Charset140172
Node: Exception142933
Node: DialogCtl149052
Node: Inquiry151649
Node: Navigate156515
Node: Verify164812
Node: Restore173843
Node: Emulation180752
Node: Scripting190563
Node: Frontend197723
Node: Examples199023
Node: ExDevices200200
Node: ExCreate200859
Node: ExDialog202144
Node: ExGrowing203409
Node: ExModifying204214
Node: ExBootable204718
Node: ExCharset205270
Node: ExPseudo206091
Node: ExCdrecord206989
Node: ExMkisofs207306
Node: ExGrowisofs208646
Node: ExException209781
Node: ExTime210235
Node: ExIncBackup210694
Node: ExRestore214686
Node: ExRecovery215646
Node: Files216216
Node: Seealso217515
Node: Bugreport218238
Node: Legal218819
Node: CommandIdx219830
Node: ConceptIdx235775

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 XORRISO 1 "Version 1.2.5, Sep 21, 2012"
@c man .TH XORRISO 1 "Version 1.2.5, Oct 18, 2012"
@c man .\" Please adjust this date whenever revising the manpage.
@c man .\"
@c man .\" Some roff macros, for reference:
@ -1463,6 +1463,14 @@ 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 -lns target_text iso_rr_path
@kindex -lns creates ISO symbolic link
@cindex Symbolic link, create, -lns
Create a symbolic link with address iso_rr_path which points to target_text.
iso_rr_path may not exist yet.
@*
Hint: Command -clone produces the ISO equivalent of a hard link.
@c man .TP
@item -clone iso_rr_path_original iso_rr_path_copy
@kindex -clone copies ISO directory tree
@cindex Directory, copy, -clone

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.10.14.190352"
#define Xorriso_timestamP "2012.10.19.081758"