aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-09-06 15:24:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-09-06 15:24:11 +0200
commit2dc1a9727288dd732af47e2618a791be9214dfe4 (patch)
tree48d36577a1893bf2da7c9f410860a6cadd4d1e2d /findutils/find.c
parent9e71e3cea59c06d40234d8f3363c3f05112e8d5a (diff)
downloadbusybox-2dc1a9727288dd732af47e2618a791be9214dfe4.tar.gz
find: make -mindepth N -xdev correctly stop on mountpoints
function old new delta fileAction 153 193 +40 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 0ec5bdfea..b521e5b08 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -728,10 +728,27 @@ static int FAST_FUNC fileAction(const char *fileName,
int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM))
{
int r;
+ int same_fs = 1;
+
+#if ENABLE_FEATURE_FIND_XDEV
+ if (S_ISDIR(statbuf->st_mode) && G.xdev_count) {
+ int i;
+ for (i = 0; i < G.xdev_count; i++) {
+ if (G.xdev_dev[i] == statbuf->st_dev)
+ goto found;
+ }
+ //bb_error_msg("'%s': not same fs", fileName);
+ same_fs = 0;
+ found: ;
+ }
+#endif
#if ENABLE_FEATURE_FIND_MAXDEPTH
- if (depth < G.minmaxdepth[0])
- return TRUE; /* skip this, continue recursing */
+ if (depth < G.minmaxdepth[0]) {
+ if (same_fs)
+ return TRUE; /* skip this, continue recursing */
+ return SKIP; /* stop recursing */
+ }
if (depth > G.minmaxdepth[1])
return SKIP; /* stop recursing */
#endif
@@ -747,21 +764,11 @@ static int FAST_FUNC fileAction(const char *fileName,
return SKIP;
}
#endif
-#if ENABLE_FEATURE_FIND_XDEV
/* -xdev stops on mountpoints, but AFTER mountpoit itself
* is processed as usual */
- if (S_ISDIR(statbuf->st_mode)) {
- if (G.xdev_count) {
- int i;
- for (i = 0; i < G.xdev_count; i++) {
- if (G.xdev_dev[i] == statbuf->st_dev)
- goto found;
- }
- return SKIP;
- found: ;
- }
+ if (!same_fs) {
+ return SKIP;
}
-#endif
/* Cannot return 0: our caller, recursive_action(),
* will perror() and skip dirs (if called on dir) */