|
|
4b3140 |
From 982a59755252f8a263e8004a09eceb6fdfbd5242 Mon Sep 17 00:00:00 2001
|
|
|
4b3140 |
From: Jan Chaloupka <jchaloup@redhat.com>
|
|
|
4b3140 |
Date: Sat, 20 Sep 2014 21:06:33 +0200
|
|
|
4b3140 |
Subject: [PATCH] config.c: xfs file system sets item->d_type to zero, stat()
|
|
|
4b3140 |
and S_ISREG() test added
|
|
|
4b3140 |
|
|
|
4b3140 |
---
|
|
|
4b3140 |
src/tools/tools-common.c | 21 ++++++++++++++++-----
|
|
|
4b3140 |
1 file changed, 16 insertions(+), 5 deletions(-)
|
|
|
4b3140 |
|
|
|
4b3140 |
diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c
|
|
|
4b3140 |
index 211a49a..f1b7711 100644
|
|
|
4b3140 |
--- a/src/tools/tools-common.c
|
|
|
4b3140 |
+++ b/src/tools/tools-common.c
|
|
|
4b3140 |
@@ -201,17 +201,24 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list,
|
|
|
4b3140 |
do {
|
|
|
4b3140 |
errno = 0;
|
|
|
4b3140 |
item = readdir(d);
|
|
|
4b3140 |
- if (item && (item->d_type == DT_REG
|
|
|
4b3140 |
- || item->d_type == DT_LNK)) {
|
|
|
4b3140 |
- char *tmp;
|
|
|
4b3140 |
+
|
|
|
4b3140 |
+ struct stat st;
|
|
|
4b3140 |
+
|
|
|
4b3140 |
+ char * tmp;
|
|
|
4b3140 |
+
|
|
|
4b3140 |
+ if (item) {
|
|
|
4b3140 |
ret = asprintf(&tmp, "%s/%s", dirname, item->d_name);
|
|
|
4b3140 |
if (ret < 0) {
|
|
|
4b3140 |
fprintf(stderr, "%s: out of memory\n",
|
|
|
4b3140 |
program_name);
|
|
|
4b3140 |
exit(1);
|
|
|
4b3140 |
}
|
|
|
4b3140 |
- ret = cgroup_string_list_add_item(list, tmp);
|
|
|
4b3140 |
- free(tmp);
|
|
|
4b3140 |
+ }
|
|
|
4b3140 |
+
|
|
|
4b3140 |
+ if (item && (item->d_type == DT_REG
|
|
|
4b3140 |
+ || item->d_type == DT_LNK
|
|
|
4b3140 |
+ || (stat(tmp, &st) >= 0 && S_ISREG(st.st_mode)) ) ) {
|
|
|
4b3140 |
+ ret = cgroup_string_list_add_item(list, tmp);
|
|
|
4b3140 |
count++;
|
|
|
4b3140 |
if (ret) {
|
|
|
4b3140 |
fprintf(stderr, "%s: %s\n",
|
|
|
4b3140 |
@@ -225,6 +232,10 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list,
|
|
|
4b3140 |
program_name, dirname, strerror(errno));
|
|
|
4b3140 |
exit(1);
|
|
|
4b3140 |
}
|
|
|
4b3140 |
+
|
|
|
4b3140 |
+ if (item) {
|
|
|
4b3140 |
+ free(tmp);
|
|
|
4b3140 |
+ }
|
|
|
4b3140 |
} while (item != NULL);
|
|
|
4b3140 |
closedir(d);
|
|
|
4b3140 |
|
|
|
4b3140 |
--
|
|
|
4b3140 |
1.9.3
|
|
|
4b3140 |
|