123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- diff -Nur busybox-1.17.0.orig/findutils/find.c busybox-1.17.0/findutils/find.c
- --- busybox-1.17.0.orig/findutils/find.c 2010-06-24 04:40:43.000000000 +0200
- +++ busybox-1.17.0/findutils/find.c 2010-07-08 12:33:55.759015289 +0200
- @@ -133,6 +133,14 @@
- //config: help
- //config: Support the 'find -inum' option for searching by inode number.
- //config:
- +//config:config FEATURE_FIND_EMPTY
- +//config: bool "Enable -empty option matching empty files and directories"
- +//config: default y
- +//config: depends on FIND
- +//config: help
- +//config: Support the 'find -empty' option for searching empty files
- +//config: and directories.
- +//config:
- //config:config FEATURE_FIND_EXEC
- //config: bool "Enable -exec: execute commands"
- //config: default y
- @@ -270,6 +278,7 @@
- IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;))
- IF_FEATURE_FIND_PAREN( ACTS(paren, action ***subexpr;))
- IF_FEATURE_FIND_PRUNE( ACTS(prune))
- +IF_FEATURE_FIND_EMPTY( ACTS(empty))
- IF_FEATURE_FIND_DELETE( ACTS(delete))
- IF_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; unsigned *subst_count; int exec_argc;))
- IF_FEATURE_FIND_GROUP( ACTS(group, gid_t gid;))
- @@ -519,6 +528,34 @@
- return exec_actions(ap->subexpr, fileName, statbuf);
- }
- #endif
- +#if ENABLE_FEATURE_FIND_EMPTY
- +ACTF(empty)
- +{
- + DIR *d;
- + struct dirent *dp;
- + bool empty = TRUE;
- +
- + if (S_ISDIR(statbuf->st_mode)) {
- + d = opendir(fileName);
- + if (d == NULL)
- + bb_simple_perror_msg(fileName);
- + for (dp = readdir(d); dp; dp = readdir(d)) {
- + if (dp->d_name[0] != '.' ||
- + (dp->d_name[1] != '\0' &&
- + (dp->d_name[1] != '.' ||
- + dp->d_name[2] != '\0'))) {
- + empty = FALSE;
- + break;
- + }
- + }
- + closedir(d);
- + return(empty);
- + } else if (S_ISREG(statbuf->st_mode))
- + return (statbuf->st_size == 0);
- + else
- + return FALSE;
- +}
- +#endif
- #if ENABLE_FEATURE_FIND_SIZE
- ACTF(size)
- {
- @@ -686,6 +723,7 @@
- IF_FEATURE_FIND_PRINT0( PARM_print0 ,)
- IF_FEATURE_FIND_DEPTH( PARM_depth ,)
- IF_FEATURE_FIND_PRUNE( PARM_prune ,)
- + IF_FEATURE_FIND_EMPTY( PARM_empty ,)
- IF_FEATURE_FIND_DELETE( PARM_delete ,)
- IF_FEATURE_FIND_EXEC( PARM_exec ,)
- IF_FEATURE_FIND_PAREN( PARM_char_brace,)
- @@ -720,6 +758,7 @@
- IF_FEATURE_FIND_PRINT0( "-print0\0" )
- IF_FEATURE_FIND_DEPTH( "-depth\0" )
- IF_FEATURE_FIND_PRUNE( "-prune\0" )
- + IF_FEATURE_FIND_EMPTY( "-empty\0" )
- IF_FEATURE_FIND_DELETE( "-delete\0" )
- IF_FEATURE_FIND_EXEC( "-exec\0" )
- IF_FEATURE_FIND_PAREN( "(\0" )
- @@ -839,6 +878,12 @@
- (void) ALLOC_ACTION(prune);
- }
- #endif
- +#if ENABLE_FEATURE_FIND_EMPTY
- + else if (parm == PARM_empty) {
- + IF_FEATURE_FIND_NOT( invert_flag = 0; )
- + (void) ALLOC_ACTION(empty);
- + }
- +#endif
- #if ENABLE_FEATURE_FIND_DELETE
- else if (parm == PARM_delete) {
- G.need_print = 0;
|