From 87a7d3d22e011ad0e6eacb3908e8e694c9409e73 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 7 Nov 2016 19:32:44 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 From 923dc023a0ec3604c1c3a76ee63b421d773dc173 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 29 Nov 2016 14:17:43 +0900 Subject: [PATCH 11/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 21bf3856aa4584c79dede6f33796879b24ade7cb Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 12 Jan 2017 17:25:16 +0900 Subject: [PATCH 12/16] Apply line coverage comments Change-Id: Iaf69e7622e24e0663aa74415a97fc0a574f71fc9 Signed-off-by: pr.jung --- src/statvfs.c | 10 ++++++---- src/storage-common.c | 4 ++++ src/storage-external-dbus.c | 12 +++++++----- src/storage-inhouse.c | 16 +++++++++++++--- src/storage.c | 4 +++- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/statvfs.c b/src/statvfs.c index 80984d1..eda17bd 100644 --- a/src/statvfs.c +++ b/src/statvfs.c @@ -222,7 +222,7 @@ static int get_memory_size(const char *path, struct statvfs_32 *buf) ret = statvfs(path, &s); if (ret) - return -errno; + return -errno; //LCOV_EXCL_LINE System Error memset(buf, 0, sizeof(struct statvfs_32)); @@ -255,7 +255,7 @@ API int storage_get_internal_memory_size(struct statvfs *buf) ret = get_memory_size(tzplatform_getenv(TZ_SYS_HOME), &temp); if (ret || temp.f_bsize == 0) { _E("fail to get memory size"); //LCOV_EXCL_LINE - return -errno; + return -errno; //LCOV_EXCL_LINE System Error } if (reserved == 0) { @@ -288,7 +288,7 @@ API int storage_get_internal_memory_size64(struct statvfs *buf) ret = statvfs(tzplatform_getenv(TZ_SYS_HOME), buf); if (ret) { _E("fail to get memory size"); //LCOV_EXCL_LINE - return -errno; + return -errno; //LCOV_EXCL_LINE System Error } if (reserved == 0) { @@ -361,7 +361,7 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf) ret = get_memory_size(ext_path, &temp); if (ret) { _E("fail to get memory size"); //LCOV_EXCL_LINE - return -errno; + return -errno; //LCOV_EXCL_LINE System Error } memcpy(buf, &temp, sizeof(temp)); @@ -400,8 +400,10 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf ret = statvfs(ext_path, buf); if (ret) { + //LCOV_EXCL_START System Error _E("fail to get memory size"); return -errno; + //LCOV_EXCL_STOP } return 0; diff --git a/src/storage-common.c b/src/storage-common.c index c6321fd..ba76cc8 100644 --- a/src/storage-common.c +++ b/src/storage-common.c @@ -32,8 +32,10 @@ int is_compat_bind_mount(void) r = mnt_table_parse_mtab(t, NULL); if (r < 0) { + //LCOV_EXCL_START System Error mnt_free_table(t); return 0; + //LCOV_EXCL_STOP } fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); @@ -43,6 +45,8 @@ int is_compat_bind_mount(void) return 1; } + //LCOV_EXCL_START System Error mnt_free_table(t); return 0; + //LCOV_EXCL_STOP } diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index a3a7c52..be20d3f 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -205,7 +205,7 @@ int storage_ext_get_list(dd_list **list) out: if (ret < 0) - storage_ext_release_list(list); + storage_ext_release_list(list); //LCOV_EXCL_LINE System Error g_variant_iter_free(iter); g_variant_unref(result); return ret; @@ -320,19 +320,19 @@ int storage_ext_register_device_change(storage_ext_changed_cb func, void *data) callback = (struct storage_ext_callback *)malloc(sizeof(struct storage_ext_callback)); if (!callback) { -//LCOV_EXCL_START System Error + //LCOV_EXCL_START System Error _E("malloc() failed"); return -ENOMEM; -//LCOV_EXCL_STOP + //LCOV_EXCL_STOP } conn = get_dbus_connection(); if (!conn) { -//LCOV_EXCL_START System Error + //LCOV_EXCL_START System Error free(callback); _E("Failed to get dbus connection"); return -EPERM; -//LCOV_EXCL_STOP + //LCOV_EXCL_STOP } block_id = g_dbus_connection_signal_subscribe(conn, @@ -346,9 +346,11 @@ int storage_ext_register_device_change(storage_ext_changed_cb func, void *data) NULL, NULL); if (block_id == 0) { + //LCOV_EXCL_START System Error free(callback); _E("Failed to subscrive bus signal"); return -EPERM; + //LCOV_EXCL_STOP } callback->func = func; diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 6dfd4f1..636a9c1 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -60,8 +60,10 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp // this API works on place where compat path is bind-mounted if (!is_compat_bind_mount()) { + //LCOV_EXCL_START System Error _E("No compat bind mount"); return -1; + //LCOV_EXCL_STOP } str = tzplatform_getenv(TZ_USER_CONTENT); @@ -73,8 +75,10 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp r = snprintf(compat, len, "%s%s", COMPAT_DIR, origin + str_len); if (r < 0) { + //LCOV_EXCL_START System Error _E("Failed to create new path"); return -1; + //LCOV_EXCL_STOP } return 0; @@ -111,8 +115,10 @@ API int storage_get_origin_internal_path(const char* compat, int len, char* orig // this API works on place where compat path is bind-mounted if (!is_compat_bind_mount()) { + //LCOV_EXCL_START System Error _E("no compat bind mount"); return -1; + //LCOV_EXCL_STOP } compat_len = strlen(COMPAT_DIR); @@ -123,8 +129,10 @@ API int storage_get_origin_internal_path(const char* compat, int len, char* orig r = snprintf(origin, len, "%s%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len); if (r < 0) { + //LCOV_EXCL_START System Error _E("failed to create new path"); return -1; + //LCOV_EXCL_STOP } return 0; @@ -144,8 +152,10 @@ API int storage_get_primary_sdcard(int *storage_id, char **path) "GetMmcPrimary", NULL); if (!result) { + //LCOV_EXCL_START System Error _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE + //LCOV_EXCL_STOP } g_variant_get(result, "(issssssisibii)", @@ -163,7 +173,7 @@ API int storage_get_primary_sdcard(int *storage_id, char **path) *path = strdup(info.mount_point); if (*path == NULL) - return STORAGE_ERROR_OUT_OF_MEMORY; + return STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error *storage_id = info.storage_id; @@ -200,10 +210,10 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e ext_dev = calloc(1, sizeof(storage_ext_device)); if (!ext_dev) { -//LCOV_EXCL_START System Error + //LCOV_EXCL_START System Error _E("calloc failed"); return STORAGE_ERROR_OUT_OF_MEMORY; -//LCOV_EXCL_STOP + //LCOV_EXCL_STOP } ret = storage_ext_get_device_info(storage_id, ext_dev); diff --git a/src/storage.c b/src/storage.c index 42aaec2..69dd87f 100644 --- a/src/storage.c +++ b/src/storage.c @@ -122,7 +122,7 @@ API int storage_get_root_directory(int storage_id, char **path) *path = strdup(root); if (!*path) { - _E("Failed to copy the root string : %d", errno); + _E("Failed to copy the root string : %d", errno); //LCOV_EXCL_LINE System Error return STORAGE_ERROR_OUT_OF_MEMORY; } @@ -263,6 +263,7 @@ API int storage_get_state(int storage_id, storage_state_e *state) return STORAGE_ERROR_NONE; } +//LCOV_EXCL_START Not called Callback static void compat_cb(int storage_id, storage_dev_e dev, storage_state_e state, const char *fstype, const char *fsuuid, const char *mountpath, @@ -275,6 +276,7 @@ static void compat_cb(int storage_id, DD_LIST_FOREACH(compat_cb_list, elem, ccb_info) ccb_info->user_cb(storage_id, state, ccb_info->user_data); } +//LCOV_EXCL_STOP API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb callback, void *user_data) { -- 2.7.4 From 761468bf7854d7e5a366d9c651ba598de1a216cb Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Thu, 9 Feb 2017 17:51:56 +0900 Subject: [PATCH 13/16] Change the name of Camera directory According to UX guide, the name of Camera directory needs to be changed to DCIM. Change-Id: I794f4a990b62bd17049384ac3f4f2f95cb6af576 Signed-off-by: Sunmin Lee --- src/storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage.c b/src/storage.c index 69dd87f..fa719ec 100644 --- a/src/storage.c +++ b/src/storage.c @@ -30,7 +30,7 @@ const char *dir_path[STORAGE_DIRECTORY_MAX] = { [STORAGE_DIRECTORY_IMAGES] = "Images", [STORAGE_DIRECTORY_SOUNDS] = "Sounds", [STORAGE_DIRECTORY_VIDEOS] = "Videos", - [STORAGE_DIRECTORY_CAMERA] = "Camera", + [STORAGE_DIRECTORY_CAMERA] = "DCIM", [STORAGE_DIRECTORY_DOWNLOADS] = "Downloads", [STORAGE_DIRECTORY_MUSIC] = "Music", [STORAGE_DIRECTORY_DOCUMENTS] = "Documents", -- 2.7.4 From 6b91f2f077f9b4ed493b1bacae577eff595b2e3c Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Thu, 16 Feb 2017 16:43:55 +0900 Subject: [PATCH 14/16] Proofread header file Change-Id: I4422a9601b3c45d5d23670198bc22d073c605154 Signed-off-by: Kichan Kwon --- include/storage-expand.h | 222 +++++++++++++++++++---------------------------- include/storage.h | 28 +++--- 2 files changed, 102 insertions(+), 148 deletions(-) diff --git a/include/storage-expand.h b/include/storage-expand.h index bd134ac..48c26b8 100644 --- a/include/storage-expand.h +++ b/include/storage-expand.h @@ -31,21 +31,22 @@ extern "C" { #include + /** - * @brief Enumeration of error codes for Storage. + * @brief Enumeration for Storage of error codes. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - STORAGE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - STORAGE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - STORAGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - STORAGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NO_SUCH_DEVICE, /**< Storage not supported */ + STORAGE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + STORAGE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + STORAGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + STORAGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NO_SUCH_DEVICE, /**< Storage not supported */ STORAGE_ERROR_OPERATION_FAILED = TIZEN_ERROR_SYSTEM_CLASS | 0x12, /**< Operation failed */ } storage_error_e; /** - * @brief Enumeration of the storage types. + * @brief Enumeration for the storage types. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -55,7 +56,7 @@ typedef enum { /** - * @brief Enumeration of the state of storage devices. + * @brief Enumeration for storage devices state. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -65,228 +66,197 @@ typedef enum { STORAGE_STATE_MOUNTED_READ_ONLY = 1, /**< Storage is present and mounted with read only access */ } storage_state_e; + /** * @brief Called to get information once for each supported storage. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The unique storage ID * @param[in] type The type of the storage * @param[in] state The current state of the storage * @param[in] path The absolute path to the root directory of the storage * @param[in] user_data The user data passed from the foreach function - * * @return @c true to continue with the next iteration of the loop, \n * otherwise @c false to break out of the loop - * * @pre storage_foreach_device_supported() will invoke this callback function. * @see storage_foreach_device_supported() */ typedef bool (*storage_device_supported_cb)(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data); + /** - * @brief Retrieves all storage in a device. + * @brief Retrieves all the storage in a device. * @details This function invokes the callback function once for each storage in a device. \n * If storage_device_supported_cb() returns @c false, then the iteration will be finished. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] callback The iteration callback function * @param[in] user_data The user data to be passed to the callback function - * * @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_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter * @post This function invokes storage_device_supported_cb() repeatedly for each supported device. * @see storage_device_supported_cb() */ int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data); + /** * @brief Gets the absolute path to the root directory of the given storage. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n - * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n - * If you want to access files or directories in internal storage, you must declare http://tizen.org/privilege/mediastorage.\n - * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n - * You must release @a path using free(). - * + * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n + * If you want to access files or directories in internal storage, you must declare http://tizen.org/privilege/mediastorage.\n + * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n + * You must release @a path using free(). * @param[in] storage_id The storage device * @param[out] path The absolute path to the storage directory - * * @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_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 * @see storage_get_state() */ int storage_get_root_directory(int storage_id, char **path); + /** - * @brief Enumeration of the storage directory types + * @brief Enumeration for the storage directory types. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - STORAGE_DIRECTORY_IMAGES, /**< Image directory */ - STORAGE_DIRECTORY_SOUNDS, /**< Sounds directory */ - STORAGE_DIRECTORY_VIDEOS, /**< Videos directory */ - STORAGE_DIRECTORY_CAMERA, /**< Camera directory */ - STORAGE_DIRECTORY_DOWNLOADS, /**< Downloads directory */ - STORAGE_DIRECTORY_MUSIC, /**< Music directory */ - STORAGE_DIRECTORY_DOCUMENTS, /**< Documents directory */ - STORAGE_DIRECTORY_OTHERS, /**< Others directory */ + STORAGE_DIRECTORY_IMAGES, /**< Image directory */ + STORAGE_DIRECTORY_SOUNDS, /**< Sounds directory */ + STORAGE_DIRECTORY_VIDEOS, /**< Videos directory */ + STORAGE_DIRECTORY_CAMERA, /**< Camera directory */ + STORAGE_DIRECTORY_DOWNLOADS, /**< Downloads directory */ + STORAGE_DIRECTORY_MUSIC, /**< Music directory */ + STORAGE_DIRECTORY_DOCUMENTS, /**< Documents directory */ + STORAGE_DIRECTORY_OTHERS, /**< Others directory */ STORAGE_DIRECTORY_SYSTEM_RINGTONES, /**< System ringtones directory. Only available for internal storage. */ STORAGE_DIRECTORY_MAX } storage_directory_e; + /** * @brief Gets the absolute path to the each directory of the given storage. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @remarks Files saved on the internal/external storage are readable or writable by all applications.\n - * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n - * The directory path may not exist, so you must make sure that it exists before using it.\n - * If you want to access files or directories in internal storage except #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare http://tizen.org/privilege/mediastorage.\n - * If you want to access files or directories in #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare %http://tizen.org/privilege/systemsettings.\n - * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n - * You must release @a path using free(). - * + * When an application is uninstalled, the files written by that application are not removed from the internal/external storage.\n + * The directory path may not exist, so you must make sure that it exists before using it.\n + * If you want to access files or directories in internal storage except #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare http://tizen.org/privilege/mediastorage.\n + * If you want to access files or directories in #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare %http://tizen.org/privilege/systemsettings.\n + * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n + * You must release @a path using free(). * @param[in] storage_id The storage device * @param[in] type The directory type * @param[out] path The absolute path to the directory type - * * @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_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 * @see storage_get_state() */ int storage_get_directory(int storage_id, storage_directory_e type, char **path); + /** * @brief Gets the type of the given storage. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device * @param[out] type The type of the storage - * * @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_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported */ int storage_get_type(int storage_id, storage_type_e *type); + /** * @brief Gets the current state of the given storage. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device * @param[out] state The current state of the storage - * * @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_NOT_SUPPORTED Storage not supported - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported * @see storage_get_root_directory() * @see storage_get_total_space() * @see storage_get_available_space() */ int storage_get_state(int storage_id, storage_state_e *state); + /** - * @brief Called when the state of storage changes - * + * @brief Called when the state of storage changes. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The unique storage ID * @param[in] state The current state of the storage * @param[in] user_data The user data passed from the foreach function - * * @pre storage_set_state_changed_cb() will invoke this callback function. * @see storage_set_state_changed_cb() * @see storage_unset_state_changed_cb() */ typedef void (*storage_state_changed_cb)(int storage_id, storage_state_e state, void *user_data); + /** * @brief Registers a callback function to be invoked when the state of the storage changes. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function - * * @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_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * * @post storage_state_changed_cb() will be invoked if the state of the registered storage changes. * @see storage_state_changed_cb() * @see storage_unset_state_changed_cb() */ int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb callback, void *user_data); + /** * @brief Unregisters the callback function. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device to monitor * @param[in] callback The callback function to register - * * @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_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed * @see storage_state_changed_cb() * @see storage_set_state_changed_cb() */ int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb callback); + /** - * @brief Enumeration of storage device types + * @brief Enumeration for storage device types. * @since_tizen 3.0 */ typedef enum { - STORAGE_DEV_EXT_SDCARD = 1001, /**< sdcard device (external storage) */ - STORAGE_DEV_EXT_USB_MASS_STORAGE, /**< USB storage device (external storage) */ + STORAGE_DEV_EXT_SDCARD = 1001, /**< sdcard device (external storage) */ + STORAGE_DEV_EXT_USB_MASS_STORAGE, /**< USB storage device (external storage) */ } storage_dev_e; + /** * @brief Called when the state of a storage type changes. - * * @since_tizen 3.0 - * * @param[in] storage_id The unique storage ID * @param[in] type The type of the storage device * @param[in] state The state of the storage @@ -296,7 +266,6 @@ typedef enum { * @param[in] primary The primary partition * @param[in] flags The flags for the storage status * @param[in] user_data The user data - * * @pre storage_set_changed_cb() will invoke this callback function. * @see storage_set_changed_cb() * @see storage_unset_changed_cb() @@ -306,92 +275,77 @@ typedef void (*storage_changed_cb)(int storage_id, const char *fstype, const char *fsuuid, const char *mountpath, bool primary, int flags, void *user_data); + /** * @brief Registers a callback function to be invoked when the state of the specified storage device type changes. - * * @since_tizen 3.0 - * * @param[in] type The type of the storage device * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function - * * @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_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed * @post storage_changed_cb() will be invoked if the state of the registered storage type changes. * @see storage_changed_cb() * @see storage_unset_changed_cb() */ int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback, void *user_data); + /** * @brief Unregisters the callback function for storage type state changes. - * * @since_tizen 3.0 - * * @param[in] type The type of the the storage device * @param[in] callback The callback function to unregister - * * @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_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed * @see storage_changed_cb() * @see storage_set_changed_cb() */ int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callback); + /** * @brief Gets the total space of the given storage in bytes. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device * @param[out] bytes The total space size of the storage (bytes) - * * @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_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed * @see storage_get_state() * @see storage_get_available_space() */ int storage_get_total_space(int storage_id, unsigned long long *bytes); + /** * @brief Gets the available space size of the given storage in bytes. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[in] storage_id The storage device * @param[out] bytes The available space size of the storage (bytes) - * * @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_NOT_SUPPORTED Storage not supported - * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed - * + * @retval #STORAGE_ERROR_NONE Successful + * @retval #STORAGE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STORAGE_ERROR_NOT_SUPPORTED Storage not supported + * @retval #STORAGE_ERROR_OPERATION_FAILED Operation failed * @see storage_get_state() * @see storage_get_total_space() */ int storage_get_available_space(int storage_id, unsigned long long *bytes); + /** * @} */ diff --git a/include/storage.h b/include/storage.h index 235c72b..0665cf3 100644 --- a/include/storage.h +++ b/include/storage.h @@ -23,33 +23,34 @@ extern "C" { #endif + /** - * @file storage.h - * @ingroup FRAMEWORK/SYSTEM - * @brief This file contains the API for the status of devices. - * @author TIZEN - * @date 2013-02-15 - * @version 0.1 + * @file storage.h + * @ingroup FRAMEWORK/SYSTEM + * @brief This file contains the API for the status of devices. + * @author TIZEN + * @date 2013-02-15 + * @version 0.1 */ + /** * @addtogroup CAPI_SYSTEM_STORAGE_MODULE * @{ */ + #include #include "storage-expand.h" + /** - * @fn int storage_get_internal_memory_size(struct statvfs *buf) + * @brief int storage_get_internal_memory_size(struct statvfs *buf). * @brief This generic API is used to get the internal memory size. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[out] buf A pointer to a statvfs structure * @return @c 0 on success, * otherwise a negative error value on failure - * @see * @par Example: * @code * ... @@ -72,16 +73,14 @@ extern int storage_get_internal_memory_size(struct statvfs *buf); extern int storage_get_internal_memory_size64(struct statvfs *buf); #endif + /** - * @fn int storage_get_external_memory_size(struct statvfs *buf) + * @brief int storage_get_external_memory_size(struct statvfs *buf). * @brief This generic API is used to get the external memory size. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * * @param[out] buf A pointer to a statvfs structure * @return @c 0 on success, * otherwise a negative error value on failure - * @see * @par Example: * @code * ... @@ -110,6 +109,7 @@ extern int __REDIRECT_NTH(storage_get_external_memory_size, extern int storage_get_external_memory_size64(struct statvfs *buf); #endif + /** * @} */ -- 2.7.4 From 6eff2491ebfbb3276c614c501d21721ba324ccdf Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Tue, 14 Mar 2017 14:58:26 +0900 Subject: [PATCH 15/16] Add comment for untested codes It will be covered when test infra is ready. Change-Id: I8ce5ae89d2a8f12ef8b45702181ce12cffff392f Signed-off-by: Sunmin Lee --- src/storage-inhouse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 636a9c1..a736890 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -47,6 +47,7 @@ else // can convert. use dest path */ +//LCOV_EXCL_START Untested function API int storage_get_compat_internal_path(const char* origin, int len, char* compat) { int r = -1; @@ -83,6 +84,7 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp return 0; } +//LCOV_EXCL_STOP /* Get Multi-user path from compat path -- 2.7.4 From 93dcd5be520fdeae6d472c54a069b5534aba176c Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Wed, 26 Apr 2017 15:20:01 +0900 Subject: [PATCH 16/16] Fix document Change-Id: I093c1063017a867d8d44b041204602d0d68487aa Signed-off-by: pr.jung --- include/storage-expand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/storage-expand.h b/include/storage-expand.h index 48c26b8..b432382 100644 --- a/include/storage-expand.h +++ b/include/storage-expand.h @@ -258,7 +258,7 @@ typedef enum { * @brief Called when the state of a storage type changes. * @since_tizen 3.0 * @param[in] storage_id The unique storage ID - * @param[in] type The type of the storage device + * @param[in] dev The type of the external storage device * @param[in] state The state of the storage * @param[in] fstype The type of the file system * @param[in] fsuuid The uuid of the file system -- 2.7.4