From 73151be9edb6344d4443e40d85dccd2c4c171c8e Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 31 Dec 2007 13:53:39 +0000 Subject: [PATCH] Implemented options -chown_r, -chgrp_r, -chmod_r, -alter_date_r --- test/xorriso.1 | 14 ++++- test/xorriso.c | 132 +++++++++++++++++++++++++++++++-------- test/xorriso.h | 16 +++-- test/xorriso_timestamp.h | 2 +- 4 files changed, 131 insertions(+), 33 deletions(-) diff --git a/test/xorriso.1 b/test/xorriso.1 index c0b35450..9cae592d 100644 --- a/test/xorriso.1 +++ b/test/xorriso.1 @@ -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 "December 30, 2007" +.TH XORRISO 1 "December 31, 2007" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -526,10 +526,16 @@ command fails with a SORRY event. Set ownership of file objects in the ISO image. uid may either be a decimal number or the name of a user known to the operating system. .TP +\fB\-chown_r\fR uid iso_rr_path [***] +Like -chown but affecting all files below eventual directories. +.TP \fB\-chgrp\fR gid iso_rr_path [***] Set group attribute of file objects in the ISO image. gid may either be a decimal number or the name of a group known to the operating system. .TP +\fB\-chgrp_r\fR gid iso_rr_path [***] +Like -chgrp but affecting all files below eventual directories. +.TP \fB\-chmod\fR mode iso_rr_path [***] Equivalent to shell command chmod in the ISO image. mode is either an octal number beginning with "0" or a comma separated @@ -547,6 +553,9 @@ r=read, w=write, x=execute|inspect, s=setuid|setgid, t=sticky bit .br For octal numbers see man 2 stat. .TP +\fB\-chmod_r\fR mode iso_rr_path [***] +Like -chmod but affecting all files below eventual directories. +.TP \fB\-alter_date\fR type timestring iso_rr_path [***] Alter the date entries of a file in the ISO image. type is one of "a", "m", "b" for access time, modification time, @@ -578,6 +587,9 @@ scdbackup timestamps: .br where "A0" is year 2000, "B0" is 2010, etc. .TP +\fB\-alter_date_r\fR type timestring iso_rr_path [***] +Like -alter_date but affecting all files below eventual directories. +.TP \fB\-mkdir\fR iso_rr_path [...] Create empty directories if they do not exist yet. Existence as directory generates a WARNING event, existence as diff --git a/test/xorriso.c b/test/xorriso.c index e7bf8a9b..ef9c5b91 100644 --- a/test/xorriso.c +++ b/test/xorriso.c @@ -4942,6 +4942,14 @@ int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag) } +int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag) +{ + sprintf(xorriso->info_text, "%s: cannot set create find job object", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + /* @param flag bit1= do not report memory usage as DEBUG */ int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag) @@ -5862,7 +5870,9 @@ ex:; } -/* Option -alter_date */ +/* Option -alter_date , -alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ int Xorriso_option_alter_date(struct XorrisO *xorriso, char *time_type, char *timestring, int argc, char **argv, int *idx, int flag) @@ -5871,6 +5881,8 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso, time_t t; int optc= 0; char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring, &t_type, &t, 0); @@ -5880,7 +5892,17 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso, if(ret<=0) goto ex; for(i= 0; i0 && !xorriso->request_to_abort) continue; /* regular bottom of loop */ was_failure= 1; @@ -5893,6 +5915,7 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso, ex:; (*idx)= end_idx; Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); + Findjob_destroy(&job, 0); if(ret<=0) return(ret); return(!was_failure); @@ -6087,7 +6110,9 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag) } -/* Option -chgrp alias -chgrpi */ +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, int argc, char **argv, int *idx, int flag) { @@ -6095,6 +6120,8 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, gid_t gid_number; int optc= 0; char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0); if(ret<=0) @@ -6103,7 +6130,17 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, if(ret<=0) goto ex; for(i= 0; i0 && !xorriso->request_to_abort) continue; /* regular bottom of loop */ was_failure= 1; @@ -6118,12 +6155,13 @@ ex:; Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */ if(ret<=0) return(ret); + Findjob_destroy(&job, 0); return(!was_failure); } -/* Option -chmod alias -chmodi */ -/* @param flag bit0=recursive +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) */ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, int argc, char **argv, int *idx, int flag) @@ -6146,10 +6184,8 @@ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, if(flag&1) { ret= Findjob_new(&job, optv[i], 0); if(ret<=0) { - - /* >>> Xorriso_no_findjob(xorriso, "-chmod_r", 0); */ - - goto ex; + Xorriso_no_findjob(xorriso, "-chmod_r", 0); + {ret= -1; goto ex;} } Findjob_set_action_chmod(job, mode_and, mode_or, 0); ret= Xorriso_findi(xorriso, job, NULL, optv[i], &dir_stbuf, 0, 0); @@ -6161,8 +6197,9 @@ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, continue; /* regular bottom of loop */ was_failure= 1; fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); - if(fret<0) - goto ex; + if(fret>=0) + continue; + ret= 0; goto ex; } ret= 1; ex:; @@ -6175,7 +6212,9 @@ ex:; } -/* Option -chown alias -chowni */ +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, int argc, char **argv, int *idx, int flag) { @@ -6183,6 +6222,8 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, uid_t uid_number; int optc= 0; char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0); if(ret<=0) @@ -6191,7 +6232,17 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, if(ret<=0) goto ex; for(i= 0; i0 && !xorriso->request_to_abort) continue; /* regular bottom of loop */ was_failure= 1; @@ -6203,7 +6254,8 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, ret= 1; ex:; (*idx)= end_idx; - Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); /* clean up */ + Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); + Findjob_destroy(&job, 0); if(ret<=0) return(ret); return(!was_failure); @@ -6586,8 +6638,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, start_path= argv[*idx]; ret= Findjob_new(&job, start_path, 0); if(ret<=0) { - sprintf(xorriso->info_text, "-find[ix]: cannot set create find job object"); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + Xorriso_no_findjob(xorriso, "-find[ix]", 0); {ret= -1; goto ex;} } @@ -6757,11 +6808,12 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " Blank media resp. invalidate ISO image on media.", " -format \"full\"", " Format DVD-RW to overwriteable state or de-ice DVD+RW.", -"> -V volume_id Specifies the volume ID text.", +" -volid volume_id", +" Specifies the volume ID text.", +" -joliet \"on\"|\"off\"", +" Generate Joliet info additional to Rock Ridge info.", "", -" -J Generate Joliet info additional to Rock Ridge info.", -"", -" -uid uid User id to be used for all iso_rr_paths.", +" -uid uid User id to be used for the whole multi-session ISO image.", " -gid gid Group id for the same purpose.", "", " -devices Show list of available optical drives and their addresses.", @@ -6793,7 +6845,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " iso_rr_path=disk_path . Only \"off\" allows eventual", " -disk_pattern expansion.", "", -"> -cpr disk_path [...] iso_rr_path", +" -cpr disk_path [...] iso_rr_path", " Insert the given files or directory trees from filesystem", " into the ISO image.", " -rm iso_rr_path [***]", @@ -6805,16 +6857,24 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " argument in the list.", " -chown uid iso_rr_path [***]", " Equivalent to chown in the ISO image.", +" -chown_r uid iso_rr_path [***]", +" Like -chown but affecting all files below directories.", " -chgrp gid iso_rr_path [***]", " Equivalent to chgrp in the ISO image.", +" -chgrp_r gid iso_rr_path [***]", +" Like -chgrp but affecting all files below directories.", " -chmod mode iso_rr_path [***]", " Equivalent to chmod in the ISO image.", +" -chmod_r mode iso_rr_path [***]", +" Like -chmod but affecting all files below directories.", " -alter_date type timestring iso_rr_path [***]", " Alter the date entries of a file in the ISO image. type is", " one of \"a\", \"m\", \"b\" for:", " access time, modification time, both times.", +" -alter_date_r type timestring iso_rr_path [***]", +" Like -alter_date but affecting all files below directories.", " -mkdir iso_rr_path [...]", -" Create empty directories if they do not exist yet", +" Create empty directories if they do not exist yet.", " -rmdir iso_rr_path [***]", " Delete empty directories.", " -- Mark end of particular action argument list.", @@ -6892,10 +6952,15 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " -dusx pattern [***] like -dux but summing up subdirectories without", " listing them explicitely.", "", -" -find iso_r_path [-name pattern] lists files below the current working", +" -find iso_r_path [-name pattern] [-exec action [params]]", +" performs an action on files below the current working", " directory in the ISO image. If -name pattern is given", -" then only files with matching leaf names are given out.", +" then only files with matching leaf names are processes.", +" action may be one of: echo, chown, chgrp, chmod, alter_date", +" lsdl. params are their arguments up to iso_rr_path.", +" I.e. echo and lsdl have no params at all.", " -findx disk_path [-name pattern] like -find but in local filesystem.", +" Any -exec option is ignored. Action is always echo.", "", "General options:", " -help Print this text", @@ -8007,9 +8072,10 @@ next_command:; } else if(strcmp(cmd,"add")==0) { ret= Xorriso_option_add(xorriso, argc, argv, idx, 0); - } else if(strcmp(cmd,"alter_date")==0) { + } else if(strcmp(cmd,"alter_date")==0 || strcmp(cmd,"alter_date_r")==0) { (*idx)+= 2; - ret= Xorriso_option_alter_date(xorriso, arg1, arg2, argc, argv, idx, 0); + ret= Xorriso_option_alter_date(xorriso, arg1, arg2, argc, argv, idx, + strlen(cmd)>10); } else if(strcmp(cmd,"ban_stdio_write")==0) { ret= Xorriso_option_ban_stdio_write(xorriso, 0); @@ -8030,10 +8096,22 @@ next_command:; (*idx)+= 1; ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 0); + } else if(strcmp(cmd,"chgrp_r")==0 || strcmp(cmd,"chgrp_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 1); + } else if(strcmp(cmd,"chmod")==0 || strcmp(cmd,"chmodi")==0) { (*idx)+= 1; ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 0); + } else if(strcmp(cmd,"chmod_r")==0 || strcmp(cmd,"chmod_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chown_r")==0 || strcmp(cmd,"chown_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 1); + } else if(strcmp(cmd,"chown")==0 || strcmp(cmd,"chowni")==0) { (*idx)+= 1; ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0); diff --git a/test/xorriso.h b/test/xorriso.h index 7a5744be..7297b56f 100644 --- a/test/xorriso.h +++ b/test/xorriso.h @@ -130,7 +130,9 @@ int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag); int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, int *idx, int flag); -/* Option -alter_date */ +/* Option -alter_date, alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ int Xorriso_option_alter_date(struct XorrisO *xorriso, char *time_type, char *timestring, int argc, char **argv, int *idx, int flag); @@ -148,15 +150,21 @@ int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag); /* Option -cdx */ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag); -/* Option -chgrp alias -chgrpi */ +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, int argc, char **argv, int *idx, int flag); -/* Option -chmod alias -chmodi */ +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) +*/ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, int argc, char **argv, int *idx, int flag); -/* Option -chown alias -chowni */ +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, int argc, char **argv, int *idx, int flag); diff --git a/test/xorriso_timestamp.h b/test/xorriso_timestamp.h index 964a73a2..29b2e4ca 100644 --- a/test/xorriso_timestamp.h +++ b/test/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2007.12.31.095229" +#define Xorriso_timestamP "2007.12.31.135237"