aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-06 21:04:41 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-06 21:04:41 +0200
commit008e73b5728b19c7ba6e746e279c4bc8a1935f0d (patch)
tree6fa1e81657b38aa9412d89c30af0b6830c5c410d /findutils
parent9be4d4fe442aa9e23675b1c0a8b1394e77998961 (diff)
downloadbusybox-w32-008e73b5728b19c7ba6e746e279c4bc8a1935f0d.tar.gz
busybox-w32-008e73b5728b19c7ba6e746e279c4bc8a1935f0d.tar.bz2
busybox-w32-008e73b5728b19c7ba6e746e279c4bc8a1935f0d.zip
find: implement -executable
function old new delta func_executable - 19 +19 parse_params 1505 1519 +14 static.params 216 228 +12 packed_usage 32847 32855 +8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 53/0) Total: 53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils')
-rw-r--r--findutils/find.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 72732615b..6407c6c5a 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -95,6 +95,11 @@
95//config: Enable searching based on file type (file, 95//config: Enable searching based on file type (file,
96//config: directory, socket, device, etc.). 96//config: directory, socket, device, etc.).
97//config: 97//config:
98//config:config FEATURE_FIND_EXECUTABLE
99//config: bool "Enable -executable: file is executable"
100//config: default y
101//config: depends on FIND
102//config:
98//config:config FEATURE_FIND_XDEV 103//config:config FEATURE_FIND_XDEV
99//config: bool "Enable -xdev: 'stay in filesystem'" 104//config: bool "Enable -xdev: 'stay in filesystem'"
100//config: default y 105//config: default y
@@ -272,6 +277,9 @@
272//usage: IF_FEATURE_FIND_TYPE( 277//usage: IF_FEATURE_FIND_TYPE(
273//usage: "\n -type X File type is X (one of: f,d,l,b,c,s,p)" 278//usage: "\n -type X File type is X (one of: f,d,l,b,c,s,p)"
274//usage: ) 279//usage: )
280//usage: IF_FEATURE_FIND_EXECUTABLE(
281//usage: "\n -executable File is executable"
282//usage: )
275//usage: IF_FEATURE_FIND_PERM( 283//usage: IF_FEATURE_FIND_PERM(
276//usage: "\n -perm MASK At least one mask bit (+MASK), all bits (-MASK)," 284//usage: "\n -perm MASK At least one mask bit (+MASK), all bits (-MASK),"
277//usage: "\n or exactly MASK bits are set in file's mode" 285//usage: "\n or exactly MASK bits are set in file's mode"
@@ -375,6 +383,7 @@ IF_FEATURE_FIND_PATH( ACTS(path, const char *pattern; bool ipath;))
375IF_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;)) 383IF_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;))
376IF_FEATURE_FIND_PRINT0( ACTS(print0)) 384IF_FEATURE_FIND_PRINT0( ACTS(print0))
377IF_FEATURE_FIND_TYPE( ACTS(type, int type_mask;)) 385IF_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
386IF_FEATURE_FIND_EXECUTABLE(ACTS(executable))
378IF_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;)) 387IF_FEATURE_FIND_PERM( ACTS(perm, char perm_char; mode_t perm_mask;))
379IF_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;)) 388IF_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; unsigned mtime_days;))
380IF_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;)) 389IF_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;))
@@ -578,6 +587,12 @@ ACTF(type)
578 return ((statbuf->st_mode & S_IFMT) == ap->type_mask); 587 return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
579} 588}
580#endif 589#endif
590#if ENABLE_FEATURE_FIND_EXECUTABLE
591ACTF(executable)
592{
593 return access(fileName, X_OK) == 0;
594}
595#endif
581#if ENABLE_FEATURE_FIND_PERM 596#if ENABLE_FEATURE_FIND_PERM
582ACTF(perm) 597ACTF(perm)
583{ 598{
@@ -975,6 +990,7 @@ static action*** parse_params(char **argv)
975 IF_FEATURE_FIND_QUIT( PARM_quit ,) 990 IF_FEATURE_FIND_QUIT( PARM_quit ,)
976 IF_FEATURE_FIND_DELETE( PARM_delete ,) 991 IF_FEATURE_FIND_DELETE( PARM_delete ,)
977 IF_FEATURE_FIND_EXEC( PARM_exec ,) 992 IF_FEATURE_FIND_EXEC( PARM_exec ,)
993 IF_FEATURE_FIND_EXECUTABLE(PARM_executable,)
978 IF_FEATURE_FIND_PAREN( PARM_char_brace,) 994 IF_FEATURE_FIND_PAREN( PARM_char_brace,)
979 /* All options/actions starting from here require argument */ 995 /* All options/actions starting from here require argument */
980 PARM_name , 996 PARM_name ,
@@ -1019,6 +1035,7 @@ static action*** parse_params(char **argv)
1019 IF_FEATURE_FIND_QUIT( "-quit\0" ) 1035 IF_FEATURE_FIND_QUIT( "-quit\0" )
1020 IF_FEATURE_FIND_DELETE( "-delete\0" ) 1036 IF_FEATURE_FIND_DELETE( "-delete\0" )
1021 IF_FEATURE_FIND_EXEC( "-exec\0" ) 1037 IF_FEATURE_FIND_EXEC( "-exec\0" )
1038 IF_FEATURE_FIND_EXECUTABLE("-executable\0")
1022 IF_FEATURE_FIND_PAREN( "(\0" ) 1039 IF_FEATURE_FIND_PAREN( "(\0" )
1023 /* All options/actions starting from here require argument */ 1040 /* All options/actions starting from here require argument */
1024 "-name\0" 1041 "-name\0"
@@ -1288,6 +1305,11 @@ static action*** parse_params(char **argv)
1288 dbg("created:type mask:%x", ap->type_mask); 1305 dbg("created:type mask:%x", ap->type_mask);
1289 } 1306 }
1290#endif 1307#endif
1308#if ENABLE_FEATURE_FIND_EXECUTABLE
1309 else if (parm == PARM_executable) {
1310 (void) ALLOC_ACTION(executable);
1311 }
1312#endif
1291#if ENABLE_FEATURE_FIND_PERM 1313#if ENABLE_FEATURE_FIND_PERM
1292/* -perm BITS File's mode bits are exactly BITS (octal or symbolic). 1314/* -perm BITS File's mode bits are exactly BITS (octal or symbolic).
1293 * Symbolic modes use mode 0 as a point of departure. 1315 * Symbolic modes use mode 0 as a point of departure.