block: remove external-storage call if block module is not supported 32/134032/1 accepted/tizen_3.0_common accepted/tizen_3.0_ivi accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable accepted/tizen/3.0/common/20170616.064213 accepted/tizen/3.0/ivi/20170615.080916 accepted/tizen/3.0/mobile/20170615.080909 accepted/tizen/3.0/tv/20170615.080904 accepted/tizen/3.0/wearable/20170615.080907 submit/tizen_3.0/20170614.085258
authorpr.jung <pr.jung@samsung.com>
Thu, 20 Apr 2017 05:25:28 +0000 (14:25 +0900)
committerpr.jung <pr.jung@samsung.com>
Wed, 14 Jun 2017 08:38:45 +0000 (17:38 +0900)
Do not send dbus method call for external storage if block module
is not supported

Change-Id: I05be8e80aba6e512067e1d5e9d0d6ba462a2aa1e
Signed-off-by: pr.jung <pr.jung@samsung.com>
Signed-off-by: Jeong Donghwan <dh.jeong@samsung.com>
src/statvfs.c
src/storage-external-dbus.h
src/storage.c

index eda17bd..7b50dc4 100644 (file)
@@ -346,6 +346,10 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
        if (path)
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       goto out_nodev;
+               }
                ret = get_external_path(ext_path, sizeof(ext_path));
                if (ret == -ENODEV)
                        goto out_nodev;
@@ -386,6 +390,10 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf
        if (path)
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       goto out_nodev;
+               }
                ret = get_external_path(ext_path, sizeof(ext_path));
                if (ret == -ENODEV)
                        goto out_nodev;
index 0589959..e216e8e 100644 (file)
@@ -73,6 +73,7 @@ typedef struct _storage_ext_device {
 
 typedef int (*storage_ext_changed_cb)(storage_ext_device *dev, enum storage_ext_state state, void *data);
 
+int storage_ext_is_supported(void);
 void storage_ext_release_device(storage_ext_device **dev);
 void storage_ext_release_list(dd_list **list);
 int storage_ext_get_list(dd_list **list);
index fa719ec..9f68ca9 100644 (file)
@@ -26,6 +26,8 @@
 #include "log.h"
 #include "storage-external.h"
 
+#define BLOCK_CONF_FILE         "/etc/deviced/block.conf"
+
 const char *dir_path[STORAGE_DIRECTORY_MAX] = {
        [STORAGE_DIRECTORY_IMAGES] = "Images",
        [STORAGE_DIRECTORY_SOUNDS] = "Sounds",
@@ -56,6 +58,21 @@ 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;
@@ -75,6 +92,11 @@ API int storage_foreach_device_supported(storage_device_supported_cb callback, v
                        break;
        }
 
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NONE;
+       }
+
        ret = storage_ext_foreach_device_list(callback, user_data);
        if (ret < 0) {
                _E("Failed to iterate external devices (%d)", ret); //LCOV_EXCL_LINE
@@ -479,6 +501,11 @@ API int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback,
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
+       if(!storage_ext_is_supported()) {
+               _E("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        /* external storage */
        info.type = type;
        info.type_cb = callback;
@@ -513,6 +540,11 @@ API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callbac
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
+       if(!storage_ext_is_supported()) {
+               _E("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        /* external storage */
        info.type = type;
        info.type_cb = callback;