This is usefull for filesystems where d_type is always DT_UNKNOWN.
In this case use stat() function.
---
src/timezone.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/timezone.c b/src/timezone.c
index 173d658..3d99afe 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -157,6 +157,8 @@ static char *find_origin(void *src_map, struct stat *src_st,
DIR *dir;
struct dirent *d;
char *str, pathname[PATH_MAX];
+ struct stat buf;
+ int ret;
if (subpath == NULL)
strncpy(pathname, basepath, sizeof(pathname));
@@ -205,6 +207,30 @@ static char *find_origin(void *src_map, struct stat
*src_st,
return str;
}
break;
+ case DT_UNKNOWN:
+ /*
+ * If there is no d_type support use stat()
+ * to check if directory
+ */
+ str = g_strdup_printf("%s/%s", pathname, d->d_name);
+ ret = stat(pathname, &buf);
+ g_free(str);
+ if (ret < 0)
+ continue;
+ if (buf.st_mode & S_IFDIR) {
+ if (subpath == NULL)
+ strncpy(pathname, d->d_name,
sizeof(pathname));
+ else
+ snprintf(pathname, sizeof(pathname),
+ "%s/%s", subpath,
d->d_name);
+
+ str = find_origin(src_map, src_st, basepath,
pathname);
+ if (str != NULL) {
+ closedir(dir);
+ return str;
+ }
+ }
+ break;
}
}
--
1.7.9.5
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman