diff options
-rw-r--r-- | tools/perf/util/util.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 23504ad5d6dd..e08b9a092a23 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -97,20 +97,17 @@ int rm_rf(char *path) | |||
97 | scnprintf(namebuf, sizeof(namebuf), "%s/%s", | 97 | scnprintf(namebuf, sizeof(namebuf), "%s/%s", |
98 | path, d->d_name); | 98 | path, d->d_name); |
99 | 99 | ||
100 | ret = stat(namebuf, &statbuf); | 100 | /* We have to check symbolic link itself */ |
101 | ret = lstat(namebuf, &statbuf); | ||
101 | if (ret < 0) { | 102 | if (ret < 0) { |
102 | pr_debug("stat failed: %s\n", namebuf); | 103 | pr_debug("stat failed: %s\n", namebuf); |
103 | break; | 104 | break; |
104 | } | 105 | } |
105 | 106 | ||
106 | if (S_ISREG(statbuf.st_mode)) | 107 | if (S_ISDIR(statbuf.st_mode)) |
107 | ret = unlink(namebuf); | ||
108 | else if (S_ISDIR(statbuf.st_mode)) | ||
109 | ret = rm_rf(namebuf); | 108 | ret = rm_rf(namebuf); |
110 | else { | 109 | else |
111 | pr_debug("unknown file: %s\n", namebuf); | 110 | ret = unlink(namebuf); |
112 | ret = -1; | ||
113 | } | ||
114 | } | 111 | } |
115 | closedir(dir); | 112 | closedir(dir); |
116 | 113 | ||