Blame SOURCES/libcgroup-0.41-config.c-xfs-file-system-sets-item-d_type-to-zero-st.patch

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