From ea3ccd13aa047b695a4a5a56d9f9c43c31e75042 Mon Sep 17 00:00:00 2001 From: Kunhoon Baik Date: Tue, 6 Sep 2016 21:09:48 -0700 Subject: [PATCH 01/16] Revert "Supporting Internal Media Path Compatibility" This reverts commit 23de75841e9bb1a712b06352b71d9107302c06e9. Change-Id: Id20c18851b7dfd2aa3f4d8dd14b446f7e7f7cc30 --- CMakeLists.txt | 1 - packaging/libstorage.spec | 1 - src/storage-internal.c | 29 +---------------------------- 3 files changed, 1 insertion(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c5f4b..55924cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ SET(dependents gio-2.0 libtzplatform-config capi-system-system-settings - mount ) SET(pc_dependents "capi-base-common") diff --git a/packaging/libstorage.spec b/packaging/libstorage.spec index ee26b84..0204e53 100644 --- a/packaging/libstorage.spec +++ b/packaging/libstorage.spec @@ -14,7 +14,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-system-system-settings) -BuildRequires: pkgconfig(mount) %description development package of library to get storage diff --git a/src/storage-internal.c b/src/storage-internal.c index 8713a12..1867def 100755 --- a/src/storage-internal.c +++ b/src/storage-internal.c @@ -22,12 +22,10 @@ #include #include #include -#include #include "common.h" #include "log.h" -#define COMPAT_DIR "/opt/usr/media" #ifndef __USE_FILE_OFFSET64 int __WEAK__ storage_get_internal_memory_size(struct statvfs *buf); @@ -62,32 +60,7 @@ static int internal_get_space(unsigned long long *total, unsigned long long *ava static const char *internal_get_root(void) { - struct libmnt_table *t = NULL; - int r = 0; - struct libmnt_fs *fs; - const char *ret; - - ret = tzplatform_getenv(TZ_USER_CONTENT); - - t = mnt_new_table(); - if(!t) - return ret; - - r = mnt_table_parse_mtab(t, NULL); - if(r < 0){ - mnt_free_table(t); - return ret; - } - - fs = mnt_table_find_target(t,COMPAT_DIR,MNT_ITER_BACKWARD); - if(fs){ - // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). - ret = COMPAT_DIR; - } - - mnt_free_table(t); - - return ret; + return tzplatform_getenv(TZ_USER_CONTENT); } const struct storage_ops internal = { -- 2.7.4 From 9ec1a4f0bfdc76fd11f387b974871d0928d21c90 Mon Sep 17 00:00:00 2001 From: Jung Date: Mon, 19 Sep 2016 20:55:46 -0700 Subject: [PATCH 02/16] Revert "Revert "Supporting Internal Media Path Compatibility"" This reverts commit ea3ccd13aa047b695a4a5a56d9f9c43c31e75042. Change-Id: I63a2a0152be707b36deba35ffc94b1c32f97538f --- CMakeLists.txt | 1 + packaging/libstorage.spec | 1 + src/storage-internal.c | 29 ++++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55924cd..a8c5f4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ SET(dependents gio-2.0 libtzplatform-config capi-system-system-settings + mount ) SET(pc_dependents "capi-base-common") diff --git a/packaging/libstorage.spec b/packaging/libstorage.spec index 0204e53..ee26b84 100644 --- a/packaging/libstorage.spec +++ b/packaging/libstorage.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-system-system-settings) +BuildRequires: pkgconfig(mount) %description development package of library to get storage diff --git a/src/storage-internal.c b/src/storage-internal.c index 1867def..9be1060 100755 --- a/src/storage-internal.c +++ b/src/storage-internal.c @@ -22,10 +22,12 @@ #include #include #include +#include #include "common.h" #include "log.h" +#define COMPAT_DIR "/opt/usr/media" #ifndef __USE_FILE_OFFSET64 int __WEAK__ storage_get_internal_memory_size(struct statvfs *buf); @@ -60,7 +62,32 @@ static int internal_get_space(unsigned long long *total, unsigned long long *ava static const char *internal_get_root(void) { - return tzplatform_getenv(TZ_USER_CONTENT); + struct libmnt_table *t = NULL; + int r = 0; + struct libmnt_fs *fs; + const char *ret; + + ret = tzplatform_getenv(TZ_USER_CONTENT); + + t = mnt_new_table(); + if(!t) + return ret; + + r = mnt_table_parse_mtab(t, NULL); + if (r < 0) { + mnt_free_table(t); + return ret; + } + + fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); + if (fs) { + // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). + ret = COMPAT_DIR; + } + + mnt_free_table(t); + + return ret; } const struct storage_ops internal = { -- 2.7.4 From 709a88f8c3f9ad24eafc2788ffa50a444f274795 Mon Sep 17 00:00:00 2001 From: Kunhoon Baik Date: Thu, 29 Sep 2016 09:38:48 +0900 Subject: [PATCH 03/16] Provide internal APIs for converting compat path Change-Id: I81aad2364f5c99a4ea252374cce4d6497093f08d --- CMakeLists.txt | 4 +- include/common.h | 3 + include/storage-internal.h | 3 + packaging/libstorage.spec | 2 +- src/storage-common.c | 29 ++++++++ src/storage-external-inhouse.c | 67 ------------------ src/storage-inhouse.c | 156 +++++++++++++++++++++++++++++++++++++++++ src/storage-internal.c | 26 +------ 8 files changed, 198 insertions(+), 92 deletions(-) create mode 100644 src/storage-common.c delete mode 100755 src/storage-external-inhouse.c create mode 100755 src/storage-inhouse.c diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c5f4b..a4feb38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,9 @@ SET(SRCS src/storage-internal.c src/storage-external.c src/storage-external-dbus.c - src/storage-external-inhouse.c) + src/storage-inhouse.c + src/storage-common.c + ) ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${TARGET_SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS}) diff --git a/include/common.h b/include/common.h index a819ecc..f208338 100644 --- a/include/common.h +++ b/include/common.h @@ -82,6 +82,9 @@ void remove_device(const struct storage_ops *st); int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf); 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); + #ifdef __cplusplus } #endif diff --git a/include/storage-internal.h b/include/storage-internal.h index 2040fc9..391a721 100644 --- a/include/storage-internal.h +++ b/include/storage-internal.h @@ -53,6 +53,9 @@ extern "C" { */ int storage_get_primary_sdcard(int *storage_id, char **path); +int storage_get_compat_internal_path(const char* origin, int len, char* compat); +int storage_get_origin_internal_path(const char* compat, int len, char* origin); + /** * @} */ diff --git a/packaging/libstorage.spec b/packaging/libstorage.spec index ee26b84..90eae50 100644 --- a/packaging/libstorage.spec +++ b/packaging/libstorage.spec @@ -1,6 +1,6 @@ Name: libstorage Summary: Library to get storage information -Version: 0.1.0 +Version: 0.1.1 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/src/storage-common.c b/src/storage-common.c new file mode 100644 index 0000000..d6d1216 --- /dev/null +++ b/src/storage-common.c @@ -0,0 +1,29 @@ +#include +#include "common.h" + +int is_compat_bind_mount(void) +{ + struct libmnt_table *t = NULL; + int r = 0; + struct libmnt_fs *fs; + + t = mnt_new_table(); + if(!t) + return 0; + + r = mnt_table_parse_mtab(t, NULL); + if (r < 0) { + mnt_free_table(t); + return 0; + } + + fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); + if (fs) { + // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). + mnt_free_table(t); + return 1; + } + + mnt_free_table(t); + return 0; +} diff --git a/src/storage-external-inhouse.c b/src/storage-external-inhouse.c deleted file mode 100755 index 6e7f5c4..0000000 --- a/src/storage-external-inhouse.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include - -#include "common.h" -#include "list.h" -#include "log.h" -#include "storage-internal.h" -#include "storage-external-dbus.h" - -API int storage_get_primary_sdcard(int *storage_id, char **path) -{ - GVariant *result; - storage_ext_device info; - - if (!storage_id || !path) - return STORAGE_ERROR_INVALID_PARAMETER; - - result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME, - STORAGE_EXT_PATH_MANAGER, - STORAGE_EXT_IFACE_MANAGER, - "GetMmcPrimary", - NULL); - if (!result) { - _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE - return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE - } - - g_variant_get(result, "(issssssisibii)", - &info.type, &info.devnode, &info.syspath, - &info.fs_usage, &info.fs_type, - &info.fs_version, &info.fs_uuid, - &info.readonly, &info.mount_point, - &info.state, &info.primary, - &info.flags, &info.storage_id); - - g_variant_unref(result); - - if (info.storage_id < 0) - return STORAGE_ERROR_NO_DEVICE; - - *path = strdup(info.mount_point); - if (*path == NULL) - return STORAGE_ERROR_OUT_OF_MEMORY; - - *storage_id = info.storage_id; - - return STORAGE_ERROR_NONE; -} diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c new file mode 100755 index 0000000..e589b14 --- /dev/null +++ b/src/storage-inhouse.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include + +#include "common.h" +#include "list.h" +#include "log.h" +#include "storage-internal.h" +#include "storage-external-dbus.h" + +/* + Get compat path from origin Multi-user path + from TZ_USER_CONTENT/.. to /opt/usr/media/.. + Input should be normalized path like /opt/usr/home/owner/media (TODO: internal normalization) + + Why this API should be provided? + In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) + However, although system daemon operates real path, + system daemon needs to provide compat path to App if the real path is converted. + + Usage: + #include + + char dest[100]; + if(storage_get_compat_internal_path(src, sizeof(dest), dest) < 0) + // cannot convert. use src path + else + // can convert. use dest path + */ +API int storage_get_compat_internal_path(const char* origin, int len, char* compat) +{ + int r=-1; + const char* str; + + // this API works on place where compat path is bind-mounted + if(!is_compat_bind_mount()){ + _E("no compat bind mount"); + return -1; + } + + str = tzplatform_getenv(TZ_USER_CONTENT); + if(strncmp(origin,str,strlen(str))!=0){ + _E("failed to match TZ_USER_CONTENT"); + return -1; + } + + r = snprintf(compat,len,"%s/%s",COMPAT_DIR,origin+strlen(str)); + if(r < 0){ + _E("failed to create new path"); + return -1; + } + + return 0; +} + +/* + Get Multi-user path from compat path + from /opt/usr/media/.. to TZ_USER_CONTENT/.. + Input should be normalized path like /opt/usr/media (TODO: internal normalization) + + Why this API should be provided? + In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) + However, although some APIs send the compat path to system daemon, + system daemon should access real path. + + Usage: + #include + + char dest[100]; + if(storage_get_origin_internal_path(src, sizeof(dest), dest) < 0) + // cannot convert. use src path + else + // can convert. use dest path +*/ +API int storage_get_origin_internal_path(const char* compat, int len, char* origin) +{ + int r; + + // this API works on place where compat path is bind-mounted + if(!is_compat_bind_mount()){ + _E("no compat bind mount"); + return -1; + } + + if(strncmp(compat,COMPAT_DIR,strlen(COMPAT_DIR))!=0){ + _E("failed to match COMPAT_DIR"); + return -1; + } + + r = snprintf(origin,len,"%s/%s",tzplatform_getenv(TZ_USER_CONTENT),compat+strlen(COMPAT_DIR)); + if(r < 0){ + _E("failed to create new path"); + return -1; + } + + return 0; +} + +API int storage_get_primary_sdcard(int *storage_id, char **path) +{ + GVariant *result; + storage_ext_device info; + + if (!storage_id || !path) + return STORAGE_ERROR_INVALID_PARAMETER; + + result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME, + STORAGE_EXT_PATH_MANAGER, + STORAGE_EXT_IFACE_MANAGER, + "GetMmcPrimary", + NULL); + if (!result) { + _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE + return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE + } + + g_variant_get(result, "(issssssisibii)", + &info.type, &info.devnode, &info.syspath, + &info.fs_usage, &info.fs_type, + &info.fs_version, &info.fs_uuid, + &info.readonly, &info.mount_point, + &info.state, &info.primary, + &info.flags, &info.storage_id); + + g_variant_unref(result); + + if (info.storage_id < 0) + return STORAGE_ERROR_NO_DEVICE; + + *path = strdup(info.mount_point); + if (*path == NULL) + return STORAGE_ERROR_OUT_OF_MEMORY; + + *storage_id = info.storage_id; + + return STORAGE_ERROR_NONE; +} diff --git a/src/storage-internal.c b/src/storage-internal.c index 9be1060..a177878 100755 --- a/src/storage-internal.c +++ b/src/storage-internal.c @@ -27,8 +27,6 @@ #include "common.h" #include "log.h" -#define COMPAT_DIR "/opt/usr/media" - #ifndef __USE_FILE_OFFSET64 int __WEAK__ storage_get_internal_memory_size(struct statvfs *buf); #else @@ -62,30 +60,12 @@ static int internal_get_space(unsigned long long *total, unsigned long long *ava static const char *internal_get_root(void) { - struct libmnt_table *t = NULL; - int r = 0; - struct libmnt_fs *fs; const char *ret; - ret = tzplatform_getenv(TZ_USER_CONTENT); - - t = mnt_new_table(); - if(!t) - return ret; - - r = mnt_table_parse_mtab(t, NULL); - if (r < 0) { - mnt_free_table(t); - return ret; - } - - fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); - if (fs) { - // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). + if(is_compat_bind_mount()) ret = COMPAT_DIR; - } - - mnt_free_table(t); + else + ret = tzplatform_getenv(TZ_USER_CONTENT); return ret; } -- 2.7.4 From 80b30d81b08c8d110108ec3b9e575482b6b96c2d Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 29 Sep 2016 11:52:25 +0900 Subject: [PATCH 04/16] Apply Tizen coding rule Change-Id: Ib8a1a4d008989f12eeff5956a9afda767cfa364a Signed-off-by: pr.jung --- src/storage-common.c | 51 ++++++++++++++++++++++++++++++++++---------------- src/storage-inhouse.c | 38 +++++++++++++++++++++++++------------ src/storage-internal.c | 2 +- 3 files changed, 62 insertions(+), 29 deletions(-) diff --git a/src/storage-common.c b/src/storage-common.c index d6d1216..3885dca 100644 --- a/src/storage-common.c +++ b/src/storage-common.c @@ -1,29 +1,48 @@ +/* + * libstorage + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #include #include "common.h" int is_compat_bind_mount(void) { - struct libmnt_table *t = NULL; - int r = 0; - struct libmnt_fs *fs; + struct libmnt_table *t = NULL; + int r = 0; + struct libmnt_fs *fs; - t = mnt_new_table(); - if(!t) - return 0; + t = mnt_new_table(); + if (!t) + return 0; - r = mnt_table_parse_mtab(t, NULL); - if (r < 0) { - mnt_free_table(t); - return 0; - } + r = mnt_table_parse_mtab(t, NULL); + if (r < 0) { + mnt_free_table(t); + return 0; + } - fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); - if (fs) { + fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); + if (fs) { // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). mnt_free_table(t); return 1; - } + } - mnt_free_table(t); - return 0; + mnt_free_table(t); + return 0; } diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index e589b14..9216393 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -48,24 +48,31 @@ */ API int storage_get_compat_internal_path(const char* origin, int len, char* compat) { - int r=-1; + int r = -1; + int str_len; const char* str; + if (!compat || !origin) { + _E("Invalid parameter"); + return -1; + } + // this API works on place where compat path is bind-mounted - if(!is_compat_bind_mount()){ - _E("no compat bind mount"); + if (!is_compat_bind_mount()) { + _E("No compat bind mount"); return -1; } str = tzplatform_getenv(TZ_USER_CONTENT); - if(strncmp(origin,str,strlen(str))!=0){ - _E("failed to match TZ_USER_CONTENT"); + str_len = strlen(str); + if (strncmp(origin, str, str_len) != 0) { + _E("Failed to match TZ_USER_CONTENT"); return -1; } - r = snprintf(compat,len,"%s/%s",COMPAT_DIR,origin+strlen(str)); - if(r < 0){ - _E("failed to create new path"); + r = snprintf(compat, len, "%s/%s", COMPAT_DIR, origin + str_len); + if (r < 0) { + _E("Failed to create new path"); return -1; } @@ -94,20 +101,27 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp API int storage_get_origin_internal_path(const char* compat, int len, char* origin) { int r; + int compat_len; + + if (!compat || !origin) { + _E("Invalid parameter"); + return -1; + } // this API works on place where compat path is bind-mounted - if(!is_compat_bind_mount()){ + if (!is_compat_bind_mount()) { _E("no compat bind mount"); return -1; } - if(strncmp(compat,COMPAT_DIR,strlen(COMPAT_DIR))!=0){ + compat_len = strlen(COMPAT_DIR); + if (strncmp(compat, COMPAT_DIR, compat_len) != 0) { _E("failed to match COMPAT_DIR"); return -1; } - r = snprintf(origin,len,"%s/%s",tzplatform_getenv(TZ_USER_CONTENT),compat+strlen(COMPAT_DIR)); - if(r < 0){ + r = snprintf(origin, len, "%s/%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len); + if (r < 0) { _E("failed to create new path"); return -1; } diff --git a/src/storage-internal.c b/src/storage-internal.c index a177878..7f5d359 100755 --- a/src/storage-internal.c +++ b/src/storage-internal.c @@ -62,7 +62,7 @@ static const char *internal_get_root(void) { const char *ret; - if(is_compat_bind_mount()) + if (is_compat_bind_mount()) ret = COMPAT_DIR; else ret = tzplatform_getenv(TZ_USER_CONTENT); -- 2.7.4 From 60b453bfda7162a373fd2c1c1b66fd7975b610e6 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Thu, 29 Sep 2016 16:19:25 +0900 Subject: [PATCH 05/16] remove unnecessary '/' from the path Change-Id: I79d42621397c468238f7c4955725fba82a897b3f Signed-off-by: taeyoung --- src/storage-inhouse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 9216393..f4698de 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -70,7 +70,7 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp return -1; } - r = snprintf(compat, len, "%s/%s", COMPAT_DIR, origin + str_len); + r = snprintf(compat, len, "%s%s", COMPAT_DIR, origin + str_len); if (r < 0) { _E("Failed to create new path"); return -1; @@ -120,7 +120,7 @@ API int storage_get_origin_internal_path(const char* compat, int len, char* orig return -1; } - r = snprintf(origin, len, "%s/%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len); + r = snprintf(origin, len, "%s%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len); if (r < 0) { _E("failed to create new path"); return -1; -- 2.7.4 From 989fdd0f29aaf4e1b22cd98a785d356778392dfd Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Wed, 26 Oct 2016 13:51:29 +0900 Subject: [PATCH 06/16] Change signal subscribe bus name Change-Id: I9f90cde86786c11a828cec09a5107c6694b93d12 Signed-off-by: pr.jung --- src/storage-external-dbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index 626feb9..92c4dc1 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -336,7 +336,7 @@ int storage_ext_register_device_change(storage_ext_changed_cb func, void *data) } block_id = g_dbus_connection_signal_subscribe(conn, - STORAGE_EXT_BUS_NAME, + NULL, STORAGE_EXT_IFACE_MANAGER, NULL, NULL, -- 2.7.4 From 87a7d3d22e011ad0e6eacb3908e8e694c9409e73 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 7 Nov 2016 19:32:44 +0900 Subject: [PATCH 07/16] Apply Tizen coding rule Change-Id: I4d96e35aa3728d8274219fdd6beab0b38f91571b Signed-off-by: pr.jung --- src/storage-common.c | 2 +- src/storage-inhouse.c | 68 +++++++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/storage-common.c b/src/storage-common.c index 3885dca..c6321fd 100644 --- a/src/storage-common.c +++ b/src/storage-common.c @@ -38,7 +38,7 @@ int is_compat_bind_mount(void) fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); if (fs) { - // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). + // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). mnt_free_table(t); return 1; } diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index f4698de..a8031bb 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -28,23 +28,23 @@ #include "storage-external-dbus.h" /* - Get compat path from origin Multi-user path - from TZ_USER_CONTENT/.. to /opt/usr/media/.. - Input should be normalized path like /opt/usr/home/owner/media (TODO: internal normalization) - - Why this API should be provided? - In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) - However, although system daemon operates real path, - system daemon needs to provide compat path to App if the real path is converted. - - Usage: - #include - - char dest[100]; - if(storage_get_compat_internal_path(src, sizeof(dest), dest) < 0) - // cannot convert. use src path - else - // can convert. use dest path + Get compat path from origin Multi-user path + from TZ_USER_CONTENT/.. to /opt/usr/media/.. + Input should be normalized path like /opt/usr/home/owner/media (TODO: internal normalization) + + Why this API should be provided? + In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) + However, although system daemon operates real path, + system daemon needs to provide compat path to App if the real path is converted. + + Usage: + #include + + char dest[100]; + if(storage_get_compat_internal_path(src, sizeof(dest), dest) < 0) + // cannot convert. use src path + else + // can convert. use dest path */ API int storage_get_compat_internal_path(const char* origin, int len, char* compat) { @@ -80,23 +80,23 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp } /* - Get Multi-user path from compat path - from /opt/usr/media/.. to TZ_USER_CONTENT/.. - Input should be normalized path like /opt/usr/media (TODO: internal normalization) - - Why this API should be provided? - In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) - However, although some APIs send the compat path to system daemon, - system daemon should access real path. - - Usage: - #include - - char dest[100]; - if(storage_get_origin_internal_path(src, sizeof(dest), dest) < 0) - // cannot convert. use src path - else - // can convert. use dest path + Get Multi-user path from compat path + from /opt/usr/media/.. to TZ_USER_CONTENT/.. + Input should be normalized path like /opt/usr/media (TODO: internal normalization) + + Why this API should be provided? + In multi-user environment, each user has own compat content direcotry.(/opt/usr/media) + However, although some APIs send the compat path to system daemon, + system daemon should access real path. + + Usage: + #include + + char dest[100]; + if(storage_get_origin_internal_path(src, sizeof(dest), dest) < 0) + // cannot convert. use src path + else + // can convert. use dest path */ API int storage_get_origin_internal_path(const char* compat, int len, char* origin) { -- 2.7.4 From 50f8d81235a4fc0781a13ff59e376df941b9af75 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 8 Nov 2016 15:08:26 +0900 Subject: [PATCH 08/16] Add inhouse api to get storage type and the kind of external device Change-Id: Iac21489f726cda37c148522d34163e97f04066a3 Signed-off-by: pr.jung --- include/storage-internal.h | 20 ++++++++++++++++++ src/storage-external-dbus.c | 17 ++++++++------- src/storage-inhouse.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/include/storage-internal.h b/include/storage-internal.h index 391a721..14e81cb 100644 --- a/include/storage-internal.h +++ b/include/storage-internal.h @@ -53,6 +53,26 @@ extern "C" { */ int storage_get_primary_sdcard(int *storage_id, char **path); +/** + * @brief Get the type and the kind of external device for given storage id. + * + * @since_tizen 3.0 + * + * @param[in] storage_id The storage id + * @param[out] storage type (internal, external). + * @param[out] the kind of storage device for external type (sdcard, usb). + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_NO_DEVICE No such device + */ +int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev); + int storage_get_compat_internal_path(const char* origin, int len, char* compat); int storage_get_origin_internal_path(const char* compat, int len, char* origin); diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index 92c4dc1..f389391 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -402,13 +402,16 @@ int storage_ext_get_device_info(int storage_id, storage_ext_device *info) return -ENODEV; } - g_variant_get(result, "(issssssisibii)", - &info->type, &info->devnode, &info->syspath, - &info->fs_usage, &info->fs_type, - &info->fs_version, &info->fs_uuid, - &info->readonly, &info->mount_point, - &info->state, &info->primary, - &info->flags, &info->storage_id); + if (g_variant_check_format_string(result, "(issssssisibii)", true)) { + g_variant_get(result, "(issssssisibii)", + &info->type, &info->devnode, &info->syspath, + &info->fs_usage, &info->fs_type, + &info->fs_version, &info->fs_uuid, + &info->readonly, &info->mount_point, + &info->state, &info->primary, + &info->flags, &info->storage_id); + } else + return -ENODEV; g_variant_unref(result); diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index a8031bb..72eddac 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -168,3 +168,53 @@ API int storage_get_primary_sdcard(int *storage_id, char **path) return STORAGE_ERROR_NONE; } + +API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev) +{ + storage_ext_device *ext_dev; + int ret; + + if (storage_id < 0) { + _E("Invalid parameger"); + return STORAGE_ERROR_NOT_SUPPORTED; + } + + if (!type) { + _E("Invalid parameger"); + return STORAGE_ERROR_INVALID_PARAMETER; + } + + if (!dev) { + _E("Invalid parameger"); + return STORAGE_ERROR_INVALID_PARAMETER; + } + + ret = storage_get_type(storage_id, type); + if (ret != STORAGE_ERROR_NONE) { + _E("Failed to get storage type: %d", ret); + return ret; + } + + ext_dev = calloc(1, sizeof(storage_ext_device)); + if (!ext_dev) { +//LCOV_EXCL_START System Error + _E("calloc failed"); + return STORAGE_ERROR_OUT_OF_MEMORY; +//LCOV_EXCL_STOP + } + + ret = storage_ext_get_device_info(storage_id, ext_dev); + if (ret < 0) { + _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE + ret = STORAGE_ERROR_NOT_SUPPORTED; + goto out; + } + + *dev = ext_dev->type; + ret = STORAGE_ERROR_NONE; + _I("type: %d(internal:0, external:1) dev: %d(sdcard: 1001, usb: 1002)", *type, *dev); + +out: + storage_ext_release_device(&ext_dev); + return ret; +} -- 2.7.4 From 694d82b66543a61cb4ed6f0648e848f4abfc4e32 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 14 Nov 2016 15:59:48 +0900 Subject: [PATCH 09/16] Fix enum for sdcard and usb on storage_get_type_dev Change-Id: Ie53cf3079cc3decc5aff560a380b81ce671f6870 Signed-off-by: pr.jung --- src/storage-inhouse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 72eddac..7b89923 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -210,7 +210,10 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e goto out; } - *dev = ext_dev->type; + if (ext_dev->type == STORAGE_EXT_SCSI) + *dev = STORAGE_DEV_EXT_USB_MASS_STORAGE; + else if (ext_dev->type == STORAGE_EXT_MMC) + *dev = STORAGE_DEV_EXT_SDCARD; ret = STORAGE_ERROR_NONE; _I("type: %d(internal:0, external:1) dev: %d(sdcard: 1001, usb: 1002)", *type, *dev); -- 2.7.4 From b1174429196eb8bc4e0ad893de7ca6b606b47e67 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 15 Nov 2016 16:52:12 +0900 Subject: [PATCH 10/16] Change the way to get root directory for external storage - When block device is mounted, deviced create a file as /run/external-storage/storage_id - The file has mount point - libstorage read file to get root directory for external storage instead to use dbus method call Change-Id: I685b9c6c8c469814be809b1bd4a8dd39204bf768 Signed-off-by: pr.jung --- src/storage-external.c | 51 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/src/storage-external.c b/src/storage-external.c index 9eba26d..b5654f2 100755 --- a/src/storage-external.c +++ b/src/storage-external.c @@ -28,6 +28,9 @@ #include "log.h" #include "storage-external-dbus.h" +#define EXTERNAL_STORAGE_PATH "/run/external-storage" +#define PATH_LEN 55 + static dd_list *cb_list[STORAGE_CALLBACK_MAX]; static int storage_ext_get_dev_state(storage_ext_device *dev, @@ -353,8 +356,10 @@ int storage_ext_unregister_cb(enum storage_cb_type type, struct storage_cb_info int storage_ext_get_root(int storage_id, char *path, size_t len) { + FILE *fp; storage_ext_device *dev; - int ret; + char file_name[PATH_LEN]; + int ret = 0; if (storage_id < 0) return -ENOTSUP; @@ -362,25 +367,47 @@ int storage_ext_get_root(int storage_id, char *path, size_t len) if (!path) return -EINVAL; - dev = calloc(1, sizeof(storage_ext_device)); - if (!dev) { + snprintf(file_name, PATH_LEN, EXTERNAL_STORAGE_PATH"/%d", storage_id); + + if (access(file_name, R_OK) == 0) { + fp = fopen(file_name, "r"); + if (!fp) { + _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE + ret = -ENODEV; + goto out; + } + + ret = fscanf(fp, "%s", path); + if (ret <= 0) { + ret = -ENODEV; + _D("Failed to get path"); + fclose(fp); + goto out; + } + fclose(fp); + } else { + dev = calloc(1, sizeof(storage_ext_device)); + if (!dev) { //LCOV_EXCL_START System Error - _E("calloc failed"); - return -ENOMEM; + _E("calloc failed"); + return -ENOMEM; //LCOV_EXCL_STOP - } + } - ret = storage_ext_get_device_info(storage_id, dev); - if (ret < 0) { - _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE - goto out; + ret = storage_ext_get_device_info(storage_id, dev); + if (ret < 0) { + _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE + storage_ext_release_device(&dev); + goto out; + } + + snprintf(path, len, "%s", dev->mount_point); + storage_ext_release_device(&dev); } - snprintf(path, len, "%s", dev->mount_point); ret = 0; out: - storage_ext_release_device(&dev); return ret; } -- 2.7.4 From 5ba631a6ff38098b621dd689940628e137a5909e Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 21 Nov 2016 13:57:57 +0900 Subject: [PATCH 11/16] Return for internal storage type in storage_get_type_dev Change-Id: I54f562eac2f1639f2e377994af1f4a9c8a26b47e Signed-off-by: pr.jung --- src/storage-external-dbus.c | 4 +++- src/storage-inhouse.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index f389391..a3a7c52 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -410,8 +410,10 @@ int storage_ext_get_device_info(int storage_id, storage_ext_device *info) &info->readonly, &info->mount_point, &info->state, &info->primary, &info->flags, &info->storage_id); - } else + } else { + _E("No storage with the storage id (%d)", storage_id); //LCOV_EXCL_LINE return -ENODEV; + } g_variant_unref(result); diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 7b89923..23ebb18 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -194,6 +194,8 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e _E("Failed to get storage type: %d", ret); return ret; } + if (*type == STORAGE_TYPE_INTERNAL) + return STORAGE_ERROR_NONE; ext_dev = calloc(1, sizeof(storage_ext_device)); if (!ext_dev) { -- 2.7.4 From 6b9445271d080e1bfe5ee211ea23996812e28cc7 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 29 Nov 2016 14:17:43 +0900 Subject: [PATCH 12/16] Remove system-settings dependency - Get Ringtone path using vconfkey Change-Id: Iea9d680f85f8c6fc3c8ed8d42b1bd47aa99ce148 Signed-off-by: pr.jung --- CMakeLists.txt | 1 - packaging/libstorage.spec | 1 - src/storage.c | 8 +++----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4feb38..3169d78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ SET(dependents glib-2.0 gio-2.0 libtzplatform-config - capi-system-system-settings mount ) SET(pc_dependents "capi-base-common") diff --git a/packaging/libstorage.spec b/packaging/libstorage.spec index 90eae50..57611e7 100644 --- a/packaging/libstorage.spec +++ b/packaging/libstorage.spec @@ -13,7 +13,6 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(mount) %description diff --git a/src/storage.c b/src/storage.c index 26b4036..42aaec2 100644 --- a/src/storage.c +++ b/src/storage.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "common.h" #include "list.h" @@ -164,11 +164,9 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p if (found && st) { snprintf(root, sizeof(root), "%s", st->root()); if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES) { - ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &temp2); - if (ret < 0) { - _E("Failed to get ringtone path : %d", ret); //LCOV_EXCL_LINE + temp2 = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR); + if (temp2 == NULL) return STORAGE_ERROR_OPERATION_FAILED; - } end = strrchr(temp2, '/'); if (end) *end = '\0'; -- 2.7.4 From 516f1dcab0b4cb47de4a9136bc321680ee73e05c Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 30 Nov 2016 14:29:22 +0900 Subject: [PATCH 13/16] common: change fscanf to fgets fscanf can occur buffer overflow issue. Thus the function is changed to fgets. Change-Id: Icd8713effc71245bf2ee61ce5e2129c285b0a2c3 Signed-off-by: taeyoung --- src/storage-external.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/storage-external.c b/src/storage-external.c index b5654f2..42ea2e8 100755 --- a/src/storage-external.c +++ b/src/storage-external.c @@ -359,6 +359,7 @@ int storage_ext_get_root(int storage_id, char *path, size_t len) FILE *fp; storage_ext_device *dev; char file_name[PATH_LEN]; + char *tmp; int ret = 0; if (storage_id < 0) @@ -377,14 +378,14 @@ int storage_ext_get_root(int storage_id, char *path, size_t len) goto out; } - ret = fscanf(fp, "%s", path); - if (ret <= 0) { + tmp = fgets(path, len, fp); + fclose(fp); + if (!tmp) { ret = -ENODEV; _D("Failed to get path"); - fclose(fp); goto out; } - fclose(fp); + } else { dev = calloc(1, sizeof(storage_ext_device)); if (!dev) { -- 2.7.4 From bf3d90469c74170299a68ff3deb473c8f000df97 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 2 Dec 2016 13:58:12 +0900 Subject: [PATCH 14/16] Move storage_get_type_dev to storage-experimental.h Change-Id: I74de7cc20ab4098a5f89f4cf1cd7b85ac5e9de01 Signed-off-by: pr.jung --- include/storage-experimental.h | 63 ++++++++++++++++++++++++++++++++++++++++++ include/storage-internal.h | 20 -------------- src/storage-inhouse.c | 1 + 3 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 include/storage-experimental.h diff --git a/include/storage-experimental.h b/include/storage-experimental.h new file mode 100644 index 0000000..65f11e1 --- /dev/null +++ b/include/storage-experimental.h @@ -0,0 +1,63 @@ +/* + * storage + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __STORAGE_EXPERIMENTAL_H__ +#define __STORAGE_EXPERIMENTAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @addtogroup CAPI_SYSTEM_STORAGE_MODULE + * @{ + */ + +#include + +#define STORAGE_ERROR_NO_DEVICE TIZEN_ERROR_NO_SUCH_DEVICE + +/** + * @brief Get the type and the kind of external device for given storage id. + * + * @since_tizen 3.0 + * + * @param[in] storage_id The storage id + * @param[out] storage type (internal, external). + * @param[out] the kind of storage device for external type (sdcard, usb). + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_NO_DEVICE No such device + */ +int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* __STORAGE_EXPERIMENTAL_H__ */ diff --git a/include/storage-internal.h b/include/storage-internal.h index 14e81cb..391a721 100644 --- a/include/storage-internal.h +++ b/include/storage-internal.h @@ -53,26 +53,6 @@ extern "C" { */ int storage_get_primary_sdcard(int *storage_id, char **path); -/** - * @brief Get the type and the kind of external device for given storage id. - * - * @since_tizen 3.0 - * - * @param[in] storage_id The storage id - * @param[out] storage type (internal, external). - * @param[out] the kind of storage device for external type (sdcard, usb). - * - * @return @c 0 on success, - * otherwise a negative error value - * - * @retval #STORAGE_ERROR_NONE Successful - * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory - * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_NO_DEVICE No such device - */ -int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev); - int storage_get_compat_internal_path(const char* origin, int len, char* compat); int storage_get_origin_internal_path(const char* compat, int len, char* origin); diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 23ebb18..37fa5a0 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -26,6 +26,7 @@ #include "log.h" #include "storage-internal.h" #include "storage-external-dbus.h" +#include "storage-experimental.h" /* Get compat path from origin Multi-user path -- 2.7.4 From b73b249e6f270ad63f78f7d47d9f6008180d1ff5 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 2 Dec 2016 14:39:32 +0900 Subject: [PATCH 15/16] Add storage-experimental.h on CMakeLists.txt Change-Id: I8ded171bdfd1fd22d57edf7dd35afc2e26e9aa62 Signed-off-by: pr.jung --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3169d78..20f7f7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,8 @@ ENDFOREACH(flag) SET(HEADERS include/storage.h include/storage-expand.h - include/storage-internal.h) + include/storage-internal.h + include/storage-experimental.h) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g") -- 2.7.4 From c9a2ee5ed1ae526d970ea84e5b9795456242c444 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 6 Dec 2016 14:44:49 +0900 Subject: [PATCH 16/16] Modify return value for invalid storage id Change-Id: I84256fb1ad79fbe2b915e10fc52d5a35ccade445 Signed-off-by: pr.jung --- include/storage-experimental.h | 5 ++--- src/storage-inhouse.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/storage-experimental.h b/include/storage-experimental.h index 65f11e1..a86b272 100644 --- a/include/storage-experimental.h +++ b/include/storage-experimental.h @@ -39,8 +39,8 @@ extern "C" { * @since_tizen 3.0 * * @param[in] storage_id The storage id - * @param[out] storage type (internal, external). - * @param[out] the kind of storage device for external type (sdcard, usb). + * @param[out] type storage type (internal or external). + * @param[out] dev the kind of storage device for external type (sdcard, usb). If type is #STORAGE_TYPE_EXTERNAL, then value of this param is invalid. * * @return @c 0 on success, * otherwise a negative error value @@ -48,7 +48,6 @@ extern "C" { * @retval #STORAGE_ERROR_NONE Successful * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STORAGE_ERROR_OUT_OF_MEMORY Out of memory - * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported * @retval #STORAGE_ERROR_NO_DEVICE No such device */ int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e *dev); diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 37fa5a0..6dfd4f1 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -177,7 +177,7 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e if (storage_id < 0) { _E("Invalid parameger"); - return STORAGE_ERROR_NOT_SUPPORTED; + return STORAGE_ERROR_NO_DEVICE; } if (!type) { @@ -209,7 +209,7 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e ret = storage_ext_get_device_info(storage_id, ext_dev); if (ret < 0) { _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE - ret = STORAGE_ERROR_NOT_SUPPORTED; + ret = STORAGE_ERROR_NO_DEVICE; goto out; } -- 2.7.4