diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-06 15:24:11 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-06 15:24:11 +0200 |
| commit | 2dc1a9727288dd732af47e2618a791be9214dfe4 (patch) | |
| tree | 48d36577a1893bf2da7c9f410860a6cadd4d1e2d /findutils | |
| parent | 9e71e3cea59c06d40234d8f3363c3f05112e8d5a (diff) | |
| download | busybox-w32-2dc1a9727288dd732af47e2618a791be9214dfe4.tar.gz busybox-w32-2dc1a9727288dd732af47e2618a791be9214dfe4.tar.bz2 busybox-w32-2dc1a9727288dd732af47e2618a791be9214dfe4.zip | |
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')
| -rw-r--r-- | findutils/find.c | 35 |
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, | |||
| 728 | int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM)) | 728 | int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM)) |
| 729 | { | 729 | { |
| 730 | int r; | 730 | int r; |
| 731 | int same_fs = 1; | ||
| 732 | |||
| 733 | #if ENABLE_FEATURE_FIND_XDEV | ||
| 734 | if (S_ISDIR(statbuf->st_mode) && G.xdev_count) { | ||
| 735 | int i; | ||
| 736 | for (i = 0; i < G.xdev_count; i++) { | ||
| 737 | if (G.xdev_dev[i] == statbuf->st_dev) | ||
| 738 | goto found; | ||
| 739 | } | ||
| 740 | //bb_error_msg("'%s': not same fs", fileName); | ||
| 741 | same_fs = 0; | ||
| 742 | found: ; | ||
| 743 | } | ||
| 744 | #endif | ||
| 731 | 745 | ||
| 732 | #if ENABLE_FEATURE_FIND_MAXDEPTH | 746 | #if ENABLE_FEATURE_FIND_MAXDEPTH |
| 733 | if (depth < G.minmaxdepth[0]) | 747 | if (depth < G.minmaxdepth[0]) { |
| 734 | return TRUE; /* skip this, continue recursing */ | 748 | if (same_fs) |
| 749 | return TRUE; /* skip this, continue recursing */ | ||
| 750 | return SKIP; /* stop recursing */ | ||
| 751 | } | ||
| 735 | if (depth > G.minmaxdepth[1]) | 752 | if (depth > G.minmaxdepth[1]) |
| 736 | return SKIP; /* stop recursing */ | 753 | return SKIP; /* stop recursing */ |
| 737 | #endif | 754 | #endif |
| @@ -747,21 +764,11 @@ static int FAST_FUNC fileAction(const char *fileName, | |||
| 747 | return SKIP; | 764 | return SKIP; |
| 748 | } | 765 | } |
| 749 | #endif | 766 | #endif |
| 750 | #if ENABLE_FEATURE_FIND_XDEV | ||
| 751 | /* -xdev stops on mountpoints, but AFTER mountpoit itself | 767 | /* -xdev stops on mountpoints, but AFTER mountpoit itself |
| 752 | * is processed as usual */ | 768 | * is processed as usual */ |
| 753 | if (S_ISDIR(statbuf->st_mode)) { | 769 | if (!same_fs) { |
| 754 | if (G.xdev_count) { | 770 | return SKIP; |
| 755 | int i; | ||
| 756 | for (i = 0; i < G.xdev_count; i++) { | ||
| 757 | if (G.xdev_dev[i] == statbuf->st_dev) | ||
| 758 | goto found; | ||
| 759 | } | ||
| 760 | return SKIP; | ||
| 761 | found: ; | ||
| 762 | } | ||
| 763 | } | 771 | } |
| 764 | #endif | ||
| 765 | 772 | ||
| 766 | /* Cannot return 0: our caller, recursive_action(), | 773 | /* Cannot return 0: our caller, recursive_action(), |
| 767 | * will perror() and skip dirs (if called on dir) */ | 774 | * will perror() and skip dirs (if called on dir) */ |
