From patchwork Tue Jul 17 16:03:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2, 3/3] connman: Add patches to fix connman on fs with no d_type support Date: Tue, 17 Jul 2012 16:03:09 -0000 From: Andrei Gherzan X-Patchwork-Id: 32267 Message-Id: To: openembedded-core@lists.openembedded.org When there is not d_type avalaible on filesystem, fstatat (stat) can be used to check if path is directory. storage.c and timezone.c were modified accordingly. Signed-off-by: Andrei Gherzan --- ....c-If-there-is-no-d_type-support-use-stat.patch | 44 +++++++++++++++ ....c-If-there-is-no-d_type-support-use-stat.patch | 56 ++++++++++++++++++++ meta/recipes-connectivity/connman/connman_1.3.bb | 6 ++- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-connectivity/connman/connman/0001-storage.c-If-there-is-no-d_type-support-use-stat.patch create mode 100644 meta/recipes-connectivity/connman/connman/0002-timezone.c-If-there-is-no-d_type-support-use-stat.patch diff --git a/meta/recipes-connectivity/connman/connman/0001-storage.c-If-there-is-no-d_type-support-use-stat.patch b/meta/recipes-connectivity/connman/connman/0001-storage.c-If-there-is-no-d_type-support-use-stat.patch new file mode 100644 index 0000000..c542867 --- /dev/null +++ b/meta/recipes-connectivity/connman/connman/0001-storage.c-If-there-is-no-d_type-support-use-stat.patch @@ -0,0 +1,44 @@ +From c167bfd6b5edd01dbbb4794f3851933b2650db0e Mon Sep 17 00:00:00 2001 +From: Andrei Gherzan +Date: Tue, 17 Jul 2012 16:07:17 +0300 +Subject: [PATCH V3 1/2] storage.c: If there is no d_type support use stat() + +This is usefull for filesystems where d_type is always DT_UNKNOWN. +In this case use stat() function. +--- + src/storage.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/storage.c b/src/storage.c +index 47bd0cb..0cffa0a 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 ++ */ ++ ret = fstatat(dirfd(dir), d->d_name, &buf, 0); ++ if (ret < 0) ++ continue; ++ if (!buf.st_mode & S_IFDIR) ++ continue; ++ 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 + diff --git a/meta/recipes-connectivity/connman/connman/0002-timezone.c-If-there-is-no-d_type-support-use-stat.patch b/meta/recipes-connectivity/connman/connman/0002-timezone.c-If-there-is-no-d_type-support-use-stat.patch new file mode 100644 index 0000000..b8da25a --- /dev/null +++ b/meta/recipes-connectivity/connman/connman/0002-timezone.c-If-there-is-no-d_type-support-use-stat.patch @@ -0,0 +1,56 @@ +From 4fcb5991362ed0473572d1d8e17d77c067ad98a9 Mon Sep 17 00:00:00 2001 +From: Andrei Gherzan +Date: Tue, 17 Jul 2012 17:27:39 +0300 +Subject: [PATCH V3 2/2] timezone.c: If there is no d_type support use stat() + +This is usefull for filesystems where d_type is always DT_UNKNOWN. +In this case use stat() function. +--- + src/timezone.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/src/timezone.c b/src/timezone.c +index 173d658..73aefbd 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 stat() ++ * 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 + diff --git a/meta/recipes-connectivity/connman/connman_1.3.bb b/meta/recipes-connectivity/connman/connman_1.3.bb index 1e3d138..a9faf74 100644 --- a/meta/recipes-connectivity/connman/connman_1.3.bb +++ b/meta/recipes-connectivity/connman/connman_1.3.bb @@ -5,6 +5,8 @@ SRCREV = "3c0fa84091524c7cd6237744f2088ffee2f1d5ad" SRC_URI = "git://git.kernel.org/pub/scm/network/connman/connman.git \ file://0001-plugin.h-Change-visibility-to-default-for-debug-symb.patch \ file://add_xuser_dbus_permission.patch \ - file://connman" + file://connman \ + file://0001-storage.c-If-there-is-no-d_type-support-use-stat.patch \ + file://0002-timezone.c-If-there-is-no-d_type-support-use-stat.patch" S = "${WORKDIR}/git" -PR = "${INC_PR}.0" +PR = "${INC_PR}.1"