]> code.ossystems Code Review - openembedded-core.git/blob
7315545c2614600c473ed545ef870885c26b4c6d
[openembedded-core.git] /
1 From 7007ef32a959ac4717c19339a24fd90a68638a19 Mon Sep 17 00:00:00 2001
2 From: Andrei Gherzan <andrei@gherzan.ro>
3 Date: Tue, 17 Jul 2012 16:07:17 +0300
4 Subject: [PATCH V3 2/2] storage.c: If there is no d_type support use
5  fstatat()
6
7 This is useful for filesystems where d_type is always DT_UNKNOWN.
8 In this case use fstatat() function.
9
10 Signed-off-by: Andrei Gherzan <andrei.gherzan@windriver.com>
11 Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
12 Upstream-Status: Submitted
13  
14 ---
15  src/storage.c |   19 +++++++++++++++++++
16  1 file changed, 19 insertions(+)
17
18 Index: git/src/storage.c
19 ===================================================================
20 --- git.orig/src/storage.c
21 +++ git/src/storage.c
22 @@ -193,7 +193,6 @@ gchar **connman_storage_get_services()
23  
24                 switch (d->d_type) {
25                 case DT_DIR:
26 -               case DT_UNKNOWN:
27                         /*
28                          * If the settings file is not found, then
29                          * assume this directory is not a services dir.
30 @@ -203,6 +202,25 @@ gchar **connman_storage_get_services()
31                         ret = stat(str, &buf);
32                         g_free(str);
33                         if (ret < 0)
34 +                               continue;
35 +
36 +                       g_string_append_printf(result, "%s/", d->d_name);
37 +                       break;
38 +               case DT_UNKNOWN:
39 +                       /*
40 +                        * If there is no d_type support use fstatat()
41 +                        * to check if directory
42 +                        */
43 +                       ret = fstatat(dirfd(dir), d->d_name, &buf, 0);
44 +                       if (ret < 0)
45 +                               continue;
46 +                       if (!(buf.st_mode & S_IFDIR))
47 +                               continue;
48 +                       str = g_strdup_printf("%s/%s/settings", STORAGEDIR,
49 +                                                       d->d_name);
50 +                       ret = stat(str, &buf);
51 +                       g_free(str);
52 +                       if (ret < 0)
53                                 continue;
54  
55                         g_string_append_printf(result, "%s/", d->d_name);