From 924ade1b560e5798eb261dc1187df77eaa8f3410 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 12 Jul 2018 13:29:48 +0900 Subject: [PATCH] Check block module enabled before sending GetMmcPrimary dbus method Change-Id: I2634ba2130c35f7c3ccca9e8164ac9c73a9d47a3 Signed-off-by: pr.jung --- include/common.h | 1 + src/storage-common.c | 20 +++++++++++++++++++- src/storage-inhouse.c | 3 +++ src/storage.c | 16 ---------------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/common.h b/include/common.h index f208338..dd6f966 100644 --- a/include/common.h +++ b/include/common.h @@ -84,6 +84,7 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf #define COMPAT_DIR "/opt/usr/media" int is_compat_bind_mount(void); +int storage_ext_is_supported(void); #ifdef __cplusplus } diff --git a/src/storage-common.c b/src/storage-common.c index ba76cc8..ea8e174 100644 --- a/src/storage-common.c +++ b/src/storage-common.c @@ -16,10 +16,12 @@ * limitations under the License. */ - +#include #include #include "common.h" +#define BLOCK_CONF_FILE "/etc/storaged/block.conf" + int is_compat_bind_mount(void) { struct libmnt_table *t = NULL; @@ -50,3 +52,19 @@ int is_compat_bind_mount(void) return 0; //LCOV_EXCL_STOP } + +int storage_ext_is_supported(void) +{ + static int support = -1; + + if (support >= 0) + return support; + + if (access(BLOCK_CONF_FILE, R_OK) == 0) + support = 1; + else + support = 0; + + return support; +} + diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index d5ed6b5..2023a56 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -149,6 +149,9 @@ API int storage_get_primary_sdcard(int *storage_id, char **path) if (!storage_id || !path) return STORAGE_ERROR_INVALID_PARAMETER; + if (!storage_ext_is_supported()) + return STORAGE_ERROR_NO_DEVICE; + result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME, STORAGE_EXT_PATH_MANAGER, STORAGE_EXT_IFACE_MANAGER, diff --git a/src/storage.c b/src/storage.c index 9a45507..6dfef6d 100644 --- a/src/storage.c +++ b/src/storage.c @@ -27,7 +27,6 @@ #include "log.h" #include "storage-external.h" -#define BLOCK_CONF_FILE "/etc/storaged/block.conf" #define USER_UID_START 5000 const char *dir_path[STORAGE_DIRECTORY_MAX]; @@ -61,21 +60,6 @@ void remove_device(const struct storage_ops *st) DD_LIST_REMOVE(st_int_head, st); } -int storage_ext_is_supported(void) -{ - static int support = -1; - - if (support >= 0) - return support; - - if (access(BLOCK_CONF_FILE, R_OK) == 0) - support = 1; - else - support = 0; - - return support; -} - API int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data) { const struct storage_ops *st; -- 2.7.4