summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Gherzan <andrei@gherzan.ro>2012-08-15 22:38:51 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-08-16 14:58:35 +0300
commit9dada2fefdb426c6551343a61ca084a22b0d6a1c (patch)
tree5ebed047a8417be7cd1df53a3f161390b24d378f
parent270d7effb72bf99dfc2003ddccdb2193b1828518 (diff)
downloadconnman-9dada2fefdb426c6551343a61ca084a22b0d6a1c.tar.gz
connman-9dada2fefdb426c6551343a61ca084a22b0d6a1c.tar.bz2
connman-9dada2fefdb426c6551343a61ca084a22b0d6a1c.zip
timezone: If there is no d_type support use fstatat()
This is useful for filesystems where d_type is always DT_UNKNOWN, for example reiserfs, jffs2 and ubifs. In this case use the fstatat() function.
-rw-r--r--src/timezone.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/timezone.c b/src/timezone.c
index 173d658a..141bad34 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));
@@ -192,6 +194,17 @@ 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 fstatat()
+ * to check if d_name is directory
+ * Let the code fall through
+ */
+ ret = fstatat(dirfd(dir), d->d_name, &buf, 0);
+ if (ret < 0)
+ continue;
+ if ((buf.st_mode & S_IFDIR) == 0)
+ continue;
case DT_DIR:
if (subpath == NULL)
strncpy(pathname, d->d_name, sizeof(pathname));