diff --git a/test/xorriso.1 b/test/xorriso.1 index 17820bf1..33e65a79 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 "January 1, 2008" +.TH XORRISO 1 "January 2, 2008" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -590,7 +590,7 @@ where "A0" is year 2000, "B0" is 2010, etc. \fB\-alter_date_r\fR type timestring iso_rr_path [***] Like -alter_date but affecting all files below eventual directories. .TP -\fB\-find\fR iso_rr_path [-name pattern] [-exec action [params]] -- +\fB\-find\fR iso_rr_path [-name pattern] [-type t] [-exec action [params]] -- A very restricted substitute for shell command find in the ISO image. It performs an action on matching file objects at or below iso_rr_path. .br @@ -598,32 +598,47 @@ Optional -name pattern is not expanded but used for comparison with the particular file names of the eventual directory tree underneath iso_rr_path. If no -name pattern is given, then any file name matches. .br +The optional -type test restricts matching to files of the given type: +"block", "char", "dir", "pipe", "file", "link", "socket", "Xotic", +where "X" eventually matches what is not matched by the other types. +.br +Only the first letter is interpreted. E.g.: -find / -type d +.br If a file matches then the action is performed. Default action is "echo", i.e. to print the address of the found file. Other actions are certain xorriso commands which get performed on the found files. These commands may have specific parameters. See also their particular descriptions. .br -"chown" and "chown_r" change the ownership and get the user id as param. -E.g.: -find -exec chown thomas +"chown" and "chown_r" change the ownership and get the user id as param. E.g.: +.br + -find / -exec chown thomas .br "chgrp" and "chgrp_r" change the group attribute and get the group id as param. -E.g.: -find -exec chgrp_r staff +E.g.: +.br + -find / name 'news*' -type d --exec chgrp_r staff .br "chmod" and "chmod_r" change access permissions and get a mode string as param. -E.g.: -find -exec chmod a-w,a+r +E.g.: .br -"alter_date" changes the timestamps. -It gets a type character and a timestring as params. + -find / -exec chmod a-w,a+r .br -E.g.: -find -exec alter_date_r "m" "Dec 30 19:34:12 2007" +"alter_date" and "alter_date_r" change the timestamps. +They get a type character and a timestring as params. +E.g.: .br -"lsdl" prints file information like shell command ls -dl. It gets no params. -E.g.: -find -exec lsdl + -find / -exec alter_date "m" "Dec 30 19:34:12 2007" +.br +"lsdl" prints file information like shell command ls -dl. +E.g.: +.br + -find / -exec lsdl .br "find" performs another run of -find on the matching file address. It accepts the same params as -find, except iso_rr_path. +E.g.: .br -E.g.: -find -name '???' -exec find -name '[abc]*' -exec chmod a-w,a+r + -find / -name '???' -type d -exec find -name '[abc]*' -exec chmod a-w,a+r .br If not used as last command in the line then the argument list needs to get terminated by "--". diff --git a/test/xorriso.c b/test/xorriso.c index b0da42d0..0b066578 100644 --- a/test/xorriso.c +++ b/test/xorriso.c @@ -2491,6 +2491,12 @@ struct FindjoB { regmatch_t name_match; #endif + /* b = blockdev, c = chardev, d = directory, p = fifo, f = reg , - = reg, + s = socket, X = other , 0x0 = test inactive + */ + char file_type; + + /* 0= echo >>> 1= rm >>> 2= rm_r @@ -2529,6 +2535,7 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag) return(-1); m->start_path= NULL; m->name_expr= NULL; + m->file_type= 0; m->action= 0; /* print */ m->target= NULL; /* a mere pointer, not managed memory */ m->user= 0; @@ -2605,6 +2612,18 @@ int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) } +int Findjob_set_file_type(struct FindjoB *o, char file_type, int flag) +{ + static char known[]= {"bcdpf-lsX"}; + + if(file_type!=0) + if(strchr(known, file_type)==NULL) + return(0); + o->file_type= file_type; + return(1); +} + + /* @return 0=no match , 1=match , <0 = error */ int Findjob_test(struct FindjoB *o, char *name, @@ -2623,6 +2642,34 @@ int Findjob_test(struct FindjoB *o, char *name, return(0); } + if(o->file_type!=0) { + if(S_ISBLK(stbuf->st_mode)) { + if(o->file_type!='b') + return(0); + } else if(S_ISCHR(stbuf->st_mode)) { + if(o->file_type!='c') + return(0); + } else if(S_ISDIR(stbuf->st_mode)) { + if(o->file_type!='d') + return(0); + } else if(S_ISFIFO(stbuf->st_mode)) { + if(o->file_type!='p') + return(0); + } else if(S_ISREG(stbuf->st_mode)) { + if(o->file_type!='f' && o->file_type!='-') + return(0); + } else if(((stbuf->st_mode)&S_IFMT)==S_IFLNK) { + if(o->file_type!='l') + return(0); + } else if(((stbuf->st_mode)&S_IFMT)==S_IFSOCK) { + if(o->file_type!='s') + return(0); + } else { + if(o->file_type!='X') + return(0); + } + } + /* ??? >>> more tests to come ?*/; return(1); @@ -6871,6 +6918,15 @@ not_enough_arguments:; Text_shellsafe(argv[i], sfe, 0)); goto sorry_ex; } + } else if(strcmp(argv[i], "-type")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_file_type(job, argv[i][0], 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-find[ix]: unknown -type '%c'",argv[i][0]); + goto sorry_ex; + } } else { sprintf(xorriso->info_text, "-find[ix]: unknown option %s", Text_shellsafe(argv[i], sfe, 0)); @@ -7023,6 +7079,16 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag) " access time, modification time, both times.", " -alter_date_r type timestring iso_rr_path [***]", " Like -alter_date but affecting all files below directories.", +" -find iso_rr_path [-name pattern] [-type t] [-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 processed.", +" If -type is given then only files with matching type are", +" processed. Types: block,char,dir,pipe,file,link,socket.", +" action may be one of: echo, chown, chown_r, chgrp, chgrp_r", +" chmod, chmod_r, alter_date, alter_date_r, lsdl, find.", +" params are their arguments except iso_rr_path.", +" I.e. echo and lsdl have no params at all.", " -mkdir iso_rr_path [...]", " Create empty directories if they do not exist yet.", " -rmdir iso_rr_path [***]", @@ -7102,13 +7168,6 @@ 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] [-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 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.", "", diff --git a/test/xorriso_timestamp.h b/test/xorriso_timestamp.h index 02c07b0b..f502eb21 100644 --- a/test/xorriso_timestamp.h +++ b/test/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.01.01.123118" +#define Xorriso_timestamP "2008.01.02.175011"