Created
July 17, 2012 13:19
-
-
Save agherzan/3129358 to your computer and use it in GitHub Desktop.
storage.c: If there is not d_type support use stat()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0fe016347b2cd089de34dbccd6a8df4aec4d131f Mon Sep 17 00:00:00 2001 | |
From: Andrei Gherzan <andrei@gherzan.ro> | |
Date: Tue, 17 Jul 2012 16:07:17 +0300 | |
Subject: [PATCH] storage.c: If there is not d_type support use stat() | |
This is usefull for filesystems where d_type is always DT_UNKNOWN. | |
In this case use stat() function. | |
Signed-off-by: Andrei Gherzan <andrei@gherzan.ro> | |
--- | |
src/storage.c | 19 +++++++++++++++++++ | |
1 file changed, 19 insertions(+) | |
diff --git a/src/storage.c b/src/storage.c | |
index 47bd0cb..0d3ffaa 100644 | |
--- a/src/storage.c | |
+++ b/src/storage.c | |
@@ -206,6 +206,25 @@ gchar **connman_storage_get_services() | |
g_string_append_printf(result, "%s/", d->d_name); | |
break; | |
+ case DT_UNKNOWN: | |
+ /* | |
+ * If there is no d_type support use stat() | |
+ * to check if directory | |
+ */ | |
+ str = g_strdup_printf("%s/%s", STORAGEDIR, d->d_name); | |
+ ret = stat(str, &buf); | |
+ g_free(str); | |
+ if( buf.st_mode & S_IFDIR ) { | |
+ str = g_strdup_printf("%s/%s/settings", STORAGEDIR, | |
+ d->d_name); | |
+ ret = stat(str, &buf); | |
+ g_free(str); | |
+ if (ret < 0) | |
+ continue; | |
+ | |
+ g_string_append_printf(result, "%s/", d->d_name); | |
+ } | |
+ break; | |
} | |
} | |
-- | |
1.7.9.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment