#include <sys/statvfs.h>
#include <vconf.h>
#include <tzplatform_config.h>
+#include <libsyscommon/list.h>
#include "common.h"
-#include "list.h"
#include "log.h"
#include "storage-external-dbus.h"
-#define EXTERNAL_STORAGE_PATH "/run/external-storage"
-#define EXTENDED_INTERNAL_PATH "/run/extended-internal-sd"
+#define EXTERNAL_STORAGE_PATH "/run/storaged/external-storage"
+#define EXTENDED_INTERNAL_PATH "/run/storaged/extended-internal-sd"
#define PATH_LEN 55
#define LUKS_NAME "crypto_LUKS"
-static dd_list *cb_list[STORAGE_CALLBACK_MAX];
+static GList *cb_list[STORAGE_CALLBACK_MAX];
static int storage_ext_get_dev_state(storage_ext_device *dev,
enum storage_ext_state blk_state,
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;
+ goto out; //LCOV_EXCL_LINE
}
ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
if (ret < 0) {
_E("Failed to get state of storage (id:%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
- goto out;
+ goto out; //LCOV_EXCL_LINE
}
if (state >= STORAGE_STATE_MOUNTED) {
#endif
if (ret < 0) {
_E("Failed to get external memory size of (%s)(ret:%d)", dev->mount_point, ret); //LCOV_EXCL_LINE
- goto out;
+ goto out; //LCOV_EXCL_LINE
}
t = (unsigned long long)s.f_frsize*s.f_blocks;
int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *user_data)
{
- int ret;
+ int ret_val;
bool ret_cb;
- dd_list *list = NULL, *elem;
+ GList *list = NULL, *elem;
storage_ext_device *dev;
storage_state_e state;
if (!callback)
return -EINVAL;
- ret = storage_ext_get_list(&list);
- if (ret < 0) {
+ ret_val = storage_ext_get_list(&list);
+ if (ret_val < 0) {
_E("Failed to get external storage list from deviced (%d)", errno); //LCOV_EXCL_LINE
- return ret;
+ return ret_val; //LCOV_EXCL_LINE
}
- DD_LIST_FOREACH(list, elem, dev) {
- ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
- if (ret < 0) {
- _E("Failed to get storage state (devnode:%s, ret:%d)", dev->devnode, ret); //LCOV_EXCL_LINE
- continue;
+ SYS_G_LIST_FOREACH(list, elem, dev) {
+ ret_val = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
+ if (ret_val < 0) {
+ _E("Failed to get storage state (devnode:%s, ret_val:%d)", dev->devnode, ret_val); //LCOV_EXCL_LINE
+ continue; //LCOV_EXCL_LINE
}
if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
{
enum storage_cb_type type = (enum storage_cb_type)data;
struct storage_cb_info *cb_info;
- dd_list *elem;
+ GList *elem;
storage_state_e state;
int ret;
return ret;
}
- DD_LIST_FOREACH(cb_list[STORAGE_CALLBACK_ID], elem, cb_info)
+ SYS_G_LIST_FOREACH(cb_list[STORAGE_CALLBACK_ID], elem, cb_info)
cb_info->state_cb(cb_info->id, state, cb_info->user_data);
return 0;
{
enum storage_cb_type type = (enum storage_cb_type)data;
struct storage_cb_info *cb_info;
- dd_list *elem;
+ GList *elem;
storage_state_e state;
- int ret;
+ int ret_val;
storage_dev_e strdev;
storage_type_e storage_type;
const char *fstype, *fsuuid, *mountpath;
if (type != STORAGE_CALLBACK_TYPE)
return -EINVAL;
- ret = storage_ext_get_dev_state(dev, blk_state, &state);
- if (ret < 0) {
- _E("Failed to get storage state (devnode:%s, ret:%d)", dev->devnode, ret);
- return ret;
+ ret_val = storage_ext_get_dev_state(dev, blk_state, &state);
+ if (ret_val < 0) {
+ _E("Failed to get storage state (devnode:%s, ret_val:%d)", dev->devnode, ret_val);
+ return ret_val;
}
if (dev->type == STORAGE_EXT_SCSI) {
if (!strncmp(fstype, LUKS_NAME, strlen(LUKS_NAME)))
storage_type = STORAGE_TYPE_EXTENDED_INTERNAL;
- DD_LIST_FOREACH(cb_list[STORAGE_CALLBACK_TYPE], elem, cb_info) {
+ SYS_G_LIST_FOREACH(cb_list[STORAGE_CALLBACK_TYPE], elem, cb_info) {
if (cb_info->type != storage_type)
continue;
if (cb_info->type_cb)
struct storage_cb_info *info, struct storage_cb_info **cb_data)
{
struct storage_cb_info *cb_info;
- dd_list *elem;
+ GList *elem;
if (!info)
return false;
if (type == STORAGE_CALLBACK_ID) {
- DD_LIST_FOREACH(cb_list[type], elem, cb_info) {
+ SYS_G_LIST_FOREACH(cb_list[type], elem, cb_info) {
if (cb_info->id == info->id &&
cb_info->state_cb == info->state_cb) {
goto out;
}
if (type == STORAGE_CALLBACK_TYPE) {
- DD_LIST_FOREACH(cb_list[type], elem, cb_info) {
+ SYS_G_LIST_FOREACH(cb_list[type], elem, cb_info) {
if (cb_info->type == info->type &&
cb_info->type_cb == info->type_cb)
goto out;
int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *info)
{
struct storage_cb_info *cb_info;
- int n, ret;
+ int n, ret_val;
storage_ext_changed_cb callback;
if (!info)
return -EINVAL;
}
- n = DD_LIST_LENGTH(cb_list[type]);
+ n = SYS_G_LIST_LENGTH(cb_list[type]);
if (n == 0) {
- ret = storage_ext_register_device_change(callback, (void *)type);
- if (ret < 0)
+ ret_val = storage_ext_register_device_change(callback, (void *)type);
+ if (ret_val < 0)
return -EPERM;
}
/* add device changed callback to list (local) */
cb_info = malloc(sizeof(struct storage_cb_info));
if (!cb_info)
- return -errno;
+ return -errno; //LCOV_EXCL_LINE
memcpy(cb_info, info, sizeof(struct storage_cb_info));
- DD_LIST_APPEND(cb_list[type], cb_info);
+ SYS_G_LIST_APPEND(cb_list[type], cb_info);
return 0;
}
}
if (!check_if_callback_exist(type, info, &cb_info)) {
+ //LCOV_EXCL_START Callbacked is not registered case
_E("The callback is not registered");
return 0;
+ //LCOV_EXCL_STOP
}
/* remove device callback from list (local) */
if (cb_info) {
- DD_LIST_REMOVE(cb_list[type], cb_info);
+ SYS_G_LIST_REMOVE(cb_list[type], cb_info);
free(cb_info);
}
/* check if this callback is last element */
- n = DD_LIST_LENGTH(cb_list[type]);
+ n = SYS_G_LIST_LENGTH(cb_list[type]);
if (n == 0)
storage_ext_unregister_device_change(callback);
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
+ //LCOV_EXCL_START File operation error
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
ret = -ENODEV;
goto out;
+ //LCOV_EXCL_STOP
}
tmp = fgets(path, len, fp);
fclose(fp);
if (!tmp) {
+ //LCOV_EXCL_START File operation error
ret = -ENODEV;
_D("Failed to get path");
goto out;
+ //LCOV_EXCL_STOP
}
*extendedinternal = false;
} else if (access(file_name2, R_OK) == 0) {
fp = fopen(file_name2, "r");
if (!fp) {
- _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+ //LCOV_EXCL_START File operation error
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
ret = -ENODEV;
goto out;
+ //LCOV_EXCL_STOP
}
tmp = fgets(path, len, fp);
fclose(fp);
if (!tmp) {
+ //LCOV_EXCL_START File operation error
ret = -ENODEV;
_D("Failed to get path");
goto out;
+ //LCOV_EXCL_STOP
}
*extendedinternal = true;
} else {
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
+ //LCOV_EXCL_START
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
storage_ext_release_device(&dev);
goto out;
+ //LCOV_EXCL_STOP
}
snprintf(path, len, "%s", dev->mount_point);
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
+ //LCOV_EXCL_START
+ _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
goto out;
+ //LCOV_EXCL_STOP
}
ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, state);
int storage_ext_get_primary_mmc_path(char *path, size_t len)
{
- dd_list *list = NULL, *elem;
+ GList *list = NULL, *elem;
storage_ext_device *dev;
int ret;
ret = storage_ext_get_list(&list);
if (ret < 0) {
- _E("Failed to get external storage list from deviced (%d)", errno); //LCOV_EXCL_LINE
+ //LCOV_EXCL_START
+ _E("Failed to get external storage list from deviced (%d)", errno);
return ret;
+ //LCOV_EXCL_STOP
}
- DD_LIST_FOREACH(list, elem, dev) {
+ SYS_G_LIST_FOREACH(list, elem, dev) {
if (dev->primary) {
snprintf(path, len, "%s", dev->mount_point);
ret = 0;