Return NOT_SUPPORTED error when block module is disabled 82/199382/1 submit/tizen/20190211.075306
authorpr.jung <pr.jung@samsung.com>
Mon, 11 Feb 2019 05:24:09 +0000 (14:24 +0900)
committerpr.jung <pr.jung@samsung.com>
Mon, 11 Feb 2019 05:24:09 +0000 (14:24 +0900)
Change-Id: I33c0aeb2520c0414cd61e37a73a18bc687823b1a
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/storage.c

index d11e38a..314f622 100644 (file)
@@ -138,6 +138,11 @@ API int storage_get_root_directory(int storage_id, char **path)
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
        if (ret < 0) {
                _E("Failed to get root path of external storage(%d, %d", storage_id, ret); //LCOV_EXCL_LINE
@@ -220,6 +225,11 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES) {
                _E("Not support directory : id(%d) type(%d)", storage_id, type); //LCOV_EXCL_LINE
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -276,6 +286,11 @@ API int storage_get_type(int storage_id, storage_type_e *type)
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
        if (ret < 0) {
                _E("Failed to get type of external storage");
@@ -318,6 +333,11 @@ API int storage_get_state(int storage_id, storage_state_e *state)
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ret = storage_ext_get_state(storage_id, &st);
        if (ret < 0) {
                _E("Failed to get state (storage id(%d), ret(%d))", storage_id, ret); //LCOV_EXCL_LINE
@@ -368,6 +388,11 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca
 
        /* For backward compatability */
        if (storage_id == STORAGE_TYPE_EXTERNAL) {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       return STORAGE_ERROR_NOT_SUPPORTED;
+               }
+
                if (!compat_cb_init) {
                        ret = storage_set_changed_cb(STORAGE_TYPE_EXTERNAL, compat_cb, NULL);
                        if (ret == STORAGE_ERROR_NONE)
@@ -392,6 +417,11 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca
                        return STORAGE_ERROR_NONE;
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        info.id = storage_id;
        info.state_cb = callback;
        info.user_data = user_data;
@@ -422,6 +452,11 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb
 
        /* For backward compatability */
        if (storage_id == STORAGE_TYPE_EXTERNAL) {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       return STORAGE_ERROR_NOT_SUPPORTED;
+               }
+
                dd_list *elem_n;
                struct compat_cb_info* ccb_info;
 
@@ -441,6 +476,11 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb
                        return STORAGE_ERROR_NONE;
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        info.id = storage_id;
        info.state_cb = callback;
 
@@ -477,6 +517,11 @@ API int storage_get_total_space(int storage_id, unsigned long long *bytes)
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ret = storage_ext_get_space(storage_id, &total, NULL);
 
 out:
@@ -518,6 +563,11 @@ API int storage_get_available_space(int storage_id, unsigned long long *bytes)
        }
 
        /* external storage */
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ret = storage_ext_get_space(storage_id, NULL, &avail);
 
 out:
@@ -630,6 +680,11 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e
        if (*type == STORAGE_TYPE_INTERNAL || *type == STORAGE_TYPE_EXTENDED_INTERNAL)
                return STORAGE_ERROR_INVALID_PARAMETER;
 
+       if (!storage_ext_is_supported()) {
+               _D("Block module is not enabled");
+               return STORAGE_ERROR_NOT_SUPPORTED;
+       }
+
        ext_dev = calloc(1, sizeof(storage_ext_device));
        if (!ext_dev) {
                //LCOV_EXCL_START System Error