1 From f2094e6b2e4542adf458d8fa58d7bccd5edb762e Mon Sep 17 00:00:00 2001
2 From: Andrei Gherzan <andrei@gherzan.ro>
3 Date: Tue, 17 Jul 2012 17:27:39 +0300
4 Subject: [PATCH V3 1/2] timezone.c: If there is no d_type support use
7 This is useful for filesystems where d_type is always DT_UNKNOWN.
8 In this case use fstatat() function.
10 Signed-off-by: Andrei Gherzan <andrei.gherzan@windriver.com>
11 Upstream-Status: Submitted
14 src/timezone.c | 24 ++++++++++++++++++++++++
15 1 file changed, 24 insertions(+)
17 diff --git a/src/timezone.c b/src/timezone.c
18 index 173d658..f951f6b 100644
21 @@ -157,6 +157,8 @@ static char *find_origin(void *src_map, struct stat *src_st,
24 char *str, pathname[PATH_MAX];
29 strncpy(pathname, basepath, sizeof(pathname));
30 @@ -205,6 +207,28 @@ static char *find_origin(void *src_map, struct stat *src_st,
36 + * If there is no d_type support use fstatat()
37 + * to check if directory
39 + ret = fstatat(dirfd(dir), d->d_name, &buf, 0);
42 + if (!(buf.st_mode & S_IFDIR))
44 + if (subpath == NULL)
45 + strncpy(pathname, d->d_name, sizeof(pathname));
47 + snprintf(pathname, sizeof(pathname),
48 + "%s/%s", subpath, d->d_name);
50 + str = find_origin(src_map, src_st, basepath, pathname);