Implemented options -chown_r, -chgrp_r, -chmod_r, -alter_date_r

This commit is contained in:
Thomas Schmitt 2007-12-31 13:53:39 +00:00
parent 289269010a
commit 73151be9ed
4 changed files with 131 additions and 33 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 "December 30, 2007" .TH XORRISO 1 "December 31, 2007"
.\" 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:
@ -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 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. number or the name of a user known to the operating system.
.TP .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 [***] \fB\-chgrp\fR gid iso_rr_path [***]
Set group attribute of file objects in the ISO image. gid may either be a 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. decimal number or the name of a group known to the operating system.
.TP .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 [***] \fB\-chmod\fR mode iso_rr_path [***]
Equivalent to shell command chmod in the ISO image. Equivalent to shell command chmod in the ISO image.
mode is either an octal number beginning with "0" or a comma separated 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 .br
For octal numbers see man 2 stat. For octal numbers see man 2 stat.
.TP .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 [***] \fB\-alter_date\fR type timestring iso_rr_path [***]
Alter the date entries of a file in the ISO image. type is Alter the date entries of a file in the ISO image. type is
one of "a", "m", "b" for access time, modification time, one of "a", "m", "b" for access time, modification time,
@ -578,6 +587,9 @@ scdbackup timestamps:
.br .br
where "A0" is year 2000, "B0" is 2010, etc. where "A0" is year 2000, "B0" is 2010, etc.
.TP .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 [...] \fB\-mkdir\fR iso_rr_path [...]
Create empty directories if they do not exist yet. Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as Existence as directory generates a WARNING event, existence as

View File

@ -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 /* @param flag bit1= do not report memory usage as DEBUG
*/ */
int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag) 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, int Xorriso_option_alter_date(struct XorrisO *xorriso,
char *time_type, char *timestring, char *time_type, char *timestring,
int argc, char **argv, int *idx, int flag) int argc, char **argv, int *idx, int flag)
@ -5871,6 +5881,8 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
time_t t; time_t t;
int optc= 0; int optc= 0;
char **optv= NULL; char **optv= NULL;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring, ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring,
&t_type, &t, 0); &t_type, &t, 0);
@ -5880,6 +5892,16 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
if(ret<=0) if(ret<=0)
goto ex; goto ex;
for(i= 0; i<optc; i++) { for(i= 0; i<optc; i++) {
if(flag&1) {
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-chmod_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_ad(job, t_type, t, 0);
ret= Xorriso_findi(xorriso, job, NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else
ret= Xorriso_set_time(xorriso, optv[i], t, t_type); ret= Xorriso_set_time(xorriso, optv[i], t, t_type);
if(ret>0 && !xorriso->request_to_abort) if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */ continue; /* regular bottom of loop */
@ -5893,6 +5915,7 @@ int Xorriso_option_alter_date(struct XorrisO *xorriso,
ex:; ex:;
(*idx)= end_idx; (*idx)= end_idx;
Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256); Xorriso_opt_args(xorriso, argc, argv, *idx, &end_idx, &optc, &optv, 256);
Findjob_destroy(&job, 0);
if(ret<=0) if(ret<=0)
return(ret); return(ret);
return(!was_failure); 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 Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
int argc, char **argv, int *idx, int flag) 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; gid_t gid_number;
int optc= 0; int optc= 0;
char **optv= NULL; char **optv= NULL;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0); ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0);
if(ret<=0) if(ret<=0)
@ -6103,6 +6130,16 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
if(ret<=0) if(ret<=0)
goto ex; goto ex;
for(i= 0; i<optc; i++) { for(i= 0; i<optc; i++) {
if(flag&1) {
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-chgrp_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_chgrp(job, gid_number, 0);
ret= Xorriso_findi(xorriso, job, NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else
ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0); ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0);
if(ret>0 && !xorriso->request_to_abort) if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */ continue; /* regular bottom of loop */
@ -6118,12 +6155,13 @@ ex:;
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); /* clean up */
if(ret<=0) if(ret<=0)
return(ret); return(ret);
Findjob_destroy(&job, 0);
return(!was_failure); return(!was_failure);
} }
/* Option -chmod alias -chmodi */ /* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */
/* @param flag bit0=recursive /* @param flag bit0=recursive (-chmod_r)
*/ */
int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
int argc, char **argv, int *idx, int flag) int argc, char **argv, int *idx, int flag)
@ -6146,10 +6184,8 @@ int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
if(flag&1) { if(flag&1) {
ret= Findjob_new(&job, optv[i], 0); ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) { if(ret<=0) {
Xorriso_no_findjob(xorriso, "-chmod_r", 0);
/* >>> Xorriso_no_findjob(xorriso, "-chmod_r", 0); */ {ret= -1; goto ex;}
goto ex;
} }
Findjob_set_action_chmod(job, mode_and, mode_or, 0); Findjob_set_action_chmod(job, mode_and, mode_or, 0);
ret= Xorriso_findi(xorriso, job, NULL, optv[i], &dir_stbuf, 0, 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 */ continue; /* regular bottom of loop */
was_failure= 1; was_failure= 1;
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
if(fret<0) if(fret>=0)
goto ex; continue;
ret= 0; goto ex;
} }
ret= 1; ret= 1;
ex:; 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 Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
int argc, char **argv, int *idx, int flag) 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; uid_t uid_number;
int optc= 0; int optc= 0;
char **optv= NULL; char **optv= NULL;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0); ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0);
if(ret<=0) if(ret<=0)
@ -6191,6 +6232,16 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
if(ret<=0) if(ret<=0)
goto ex; goto ex;
for(i= 0; i<optc; i++) { for(i= 0; i<optc; i++) {
if(flag&1) {
ret= Findjob_new(&job, optv[i], 0);
if(ret<=0) {
Xorriso_no_findjob(xorriso, "-chown_r", 0);
{ret= -1; goto ex;}
}
Findjob_set_action_chown(job, uid_number, 0);
ret= Xorriso_findi(xorriso, job, NULL, optv[i], &dir_stbuf, 0, 0);
Findjob_destroy(&job, 0);
} else
ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0); ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0);
if(ret>0 && !xorriso->request_to_abort) if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */ continue; /* regular bottom of loop */
@ -6203,7 +6254,8 @@ int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
ret= 1; ret= 1;
ex:; ex:;
(*idx)= end_idx; (*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) if(ret<=0)
return(ret); return(ret);
return(!was_failure); return(!was_failure);
@ -6586,8 +6638,7 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
start_path= argv[*idx]; start_path= argv[*idx];
ret= Findjob_new(&job, start_path, 0); ret= Findjob_new(&job, start_path, 0);
if(ret<=0) { if(ret<=0) {
sprintf(xorriso->info_text, "-find[ix]: cannot set create find job object"); Xorriso_no_findjob(xorriso, "-find[ix]", 0);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= -1; goto ex;} {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.", " Blank media resp. invalidate ISO image on media.",
" -format \"full\"", " -format \"full\"",
" Format DVD-RW to overwriteable state or de-ice DVD+RW.", " 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 the whole multi-session ISO image.",
"",
" -uid uid User id to be used for all iso_rr_paths.",
" -gid gid Group id for the same purpose.", " -gid gid Group id for the same purpose.",
"", "",
" -devices Show list of available optical drives and their addresses.", " -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", " iso_rr_path=disk_path . Only \"off\" allows eventual",
" -disk_pattern expansion.", " -disk_pattern expansion.",
"", "",
"> -cpr disk_path [...] iso_rr_path", " -cpr disk_path [...] iso_rr_path",
" Insert the given files or directory trees from filesystem", " Insert the given files or directory trees from filesystem",
" into the ISO image.", " into the ISO image.",
" -rm iso_rr_path [***]", " -rm iso_rr_path [***]",
@ -6805,16 +6857,24 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" argument in the list.", " argument in the list.",
" -chown uid iso_rr_path [***]", " -chown uid iso_rr_path [***]",
" Equivalent to chown in the ISO image.", " 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 [***]", " -chgrp gid iso_rr_path [***]",
" Equivalent to chgrp in the ISO image.", " 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 [***]", " -chmod mode iso_rr_path [***]",
" Equivalent to chmod in the ISO image.", " 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_date type timestring iso_rr_path [***]",
" Alter the date entries of a file in the ISO image. type is", " Alter the date entries of a file in the ISO image. type is",
" one of \"a\", \"m\", \"b\" for:", " one of \"a\", \"m\", \"b\" for:",
" access time, modification time, both times.", " 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 [...]", " -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 [***]", " -rmdir iso_rr_path [***]",
" Delete empty directories.", " Delete empty directories.",
" -- Mark end of particular action argument list.", " -- 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", " -dusx pattern [***] like -dux but summing up subdirectories without",
" listing them explicitely.", " 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", " 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.", " -findx disk_path [-name pattern] like -find but in local filesystem.",
" Any -exec option is ignored. Action is always echo.",
"", "",
"General options:", "General options:",
" -help Print this text", " -help Print this text",
@ -8007,9 +8072,10 @@ next_command:;
} else if(strcmp(cmd,"add")==0) { } else if(strcmp(cmd,"add")==0) {
ret= Xorriso_option_add(xorriso, argc, argv, idx, 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; (*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) { } else if(strcmp(cmd,"ban_stdio_write")==0) {
ret= Xorriso_option_ban_stdio_write(xorriso, 0); ret= Xorriso_option_ban_stdio_write(xorriso, 0);
@ -8030,10 +8096,22 @@ next_command:;
(*idx)+= 1; (*idx)+= 1;
ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 0); 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) { } else if(strcmp(cmd,"chmod")==0 || strcmp(cmd,"chmodi")==0) {
(*idx)+= 1; (*idx)+= 1;
ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 0); 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) { } else if(strcmp(cmd,"chown")==0 || strcmp(cmd,"chowni")==0) {
(*idx)+= 1; (*idx)+= 1;
ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0); ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0);

View File

@ -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 Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag); 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, int Xorriso_option_alter_date(struct XorrisO *xorriso,
char *time_type, char *timestring, char *time_type, char *timestring,
int argc, char **argv, int *idx, int flag); 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 */ /* Option -cdx */
int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag); 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 Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid,
int argc, char **argv, int *idx, int flag); 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 Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode,
int argc, char **argv, int *idx, int flag); 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 Xorriso_option_chowni(struct XorrisO *xorriso, char *uid,
int argc, char **argv, int *idx, int flag); int argc, char **argv, int *idx, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.12.31.095229" #define Xorriso_timestamP "2007.12.31.135237"