summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman/connman/0001-timezone.c-If-there-is-no-d_type-support-use-fstatat.patch
blob: 3bced520542387ead144288e0a66f1758fa23b96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From f2094e6b2e4542adf458d8fa58d7bccd5edb762e Mon Sep 17 00:00:00 2001
From: Andrei Gherzan <andrei@gherzan.ro>
Date: Tue, 17 Jul 2012 17:27:39 +0300
Subject: [PATCH V3 1/2] timezone.c: If there is no d_type support use
 fstatat()

This is useful for filesystems where d_type is always DT_UNKNOWN.
In this case use fstatat() function.

Signed-off-by: Andrei Gherzan <andrei.gherzan@windriver.com>
Upstream-Status: Submitted
 
---
 src/timezone.c |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/timezone.c b/src/timezone.c
index 173d658..f951f6b 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,28 @@ 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 directory
+			 */
+			ret = fstatat(dirfd(dir), d->d_name, &buf, 0);
+			if (ret < 0)
+				continue;
+			if (!(buf.st_mode & S_IFDIR))
+				continue;
+			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