block: remove external-storage call if block module is not supported 95/146695/2
authorpr.jung <pr.jung@samsung.com>
Wed, 30 Aug 2017 05:37:45 +0000 (14:37 +0900)
committerpr.jung <pr.jung@samsung.com>
Wed, 30 Aug 2017 05:42:23 +0000 (14:42 +0900)
Change-Id: Ia9bbe4f66609ff566fffe3b7c4aa0e4a2698cffe
Signed-off-by: pr.jung <pr.jung@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 a955aef..c37881b 100644 (file)
@@ -74,6 +74,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 7b5a185..d5cc86a 100644 (file)
@@ -27,6 +27,7 @@
 #include "log.h"
 #include "storage-external.h"
 
+#define BLOCK_CONF_FILE         "/etc/deviced/block.conf"
 const char *dir_path[STORAGE_DIRECTORY_MAX];
 
 const int tz_id[STORAGE_DIRECTORY_MAX] = {
@@ -58,6 +59,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;
@@ -77,6 +93,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
@@ -497,6 +518,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;
@@ -531,6 +557,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;