On xfs file system, item->d_type is set to zero for all types. Adding additional or test using stat() and S_ISREG() fixes this problem.
Signed-off-by: Jan Chaloupka<jchal...@redhat.com> --- src/tools/tools-common.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/tools/tools-common.c b/src/tools/tools-common.c index 211a49a..48aed59 100644 --- a/src/tools/tools-common.c +++ b/src/tools/tools-common.c @@ -201,17 +201,24 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list, do { errno = 0; item = readdir(d); - if (item && (item->d_type == DT_REG - || item->d_type == DT_LNK)) { - char *tmp; - ret = asprintf(&tmp, "%s/%s", dirname, item->d_name); + + struct stat st; + + char * tmp; + + if (item) { + ret = asprintf(&tmp, "%s/%s", dirname, item->d_name); if (ret < 0) { fprintf(stderr, "%s: out of memory\n", program_name); exit(1); } - ret = cgroup_string_list_add_item(list, tmp); - free(tmp); + } + + if (item && (item->d_type == DT_REG + || item->d_type == DT_LNK + || (stat(tmp, &st) >= 0 && S_ISREG(st.st_mode)) ) ) { + ret = cgroup_string_list_add_item(list, tmp); count++; if (ret) { fprintf(stderr, "%s: %s\n", @@ -225,6 +232,10 @@ int cgroup_string_list_add_directory(struct cgroup_string_list *list, program_name, dirname, strerror(errno)); exit(1); } + + if (item) { + free(tmp); + } } while (item != NULL); closedir(d); ------------------------------------------------------------------------------ _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel