]> code.ossystems Code Review - openembedded-core.git/blob
d3205c0e6840cf5907f7b25365816c3465beaac9
[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 Upstream-Status: Submitted
12  
13 ---
14  src/storage.c |   19 +++++++++++++++++++
15  1 file changed, 19 insertions(+)
16
17 diff --git a/src/storage.c b/src/storage.c
18 index 47bd0cb..0491a52 100644
19 --- a/src/storage.c
20 +++ b/src/storage.c
21 @@ -206,6 +206,25 @@ gchar **connman_storage_get_services()
22  
23                         g_string_append_printf(result, "%s/", d->d_name);
24                         break;
25 +               case DT_UNKNOWN:
26 +                       /*
27 +                        * If there is no d_type support use fstatat()
28 +                        * to check if directory
29 +                        */
30 +                       ret = fstatat(dirfd(dir), d->d_name, &buf, 0);
31 +                       if (ret < 0)
32 +                               continue;
33 +                       if (!(buf.st_mode & S_IFDIR))
34 +                               continue;
35 +                       str = g_strdup_printf("%s/%s/settings", STORAGEDIR,
36 +                                                       d->d_name);
37 +                       ret = stat(str, &buf);
38 +                       g_free(str);
39 +                       if (ret < 0)
40 +                               continue;
41 +
42 +                       g_string_append_printf(result, "%s/", d->d_name);
43 +                       break;
44                 }
45         }
46  
47 -- 
48 1.7.9.5
49