From: Andrei Gherzan Date: Wed, 15 Aug 2012 19:38:51 +0000 (+0300) Subject: timezone: If there is no d_type support use fstatat() X-Git-Tag: 1.6~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9dada2fefdb426c6551343a61ca084a22b0d6a1c;p=platform%2Fupstream%2Fconnman.git 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. --- 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));