#include "log.h"
#include "storage-external.h"
+#define BLOCK_CONF_FILE "/etc/storaged/block.conf"
+#define USER_UID_START 5000
+
const char *dir_path[STORAGE_DIRECTORY_MAX];
const int tz_id[STORAGE_DIRECTORY_MAX] = {
DD_LIST_REMOVE(st_int_head, st);
}
+int storage_ext_is_supported(void)
+{
+ static int support = -1;
+
+ if (support >= 0)
+ return support;
+
+ if (access(BLOCK_CONF_FILE, R_OK) == 0)
+ support = 1;
+ else
+ support = 0;
+
+ return support;
+}
+
API int storage_foreach_device_supported(storage_device_supported_cb callback, void *user_data)
{
const struct storage_ops *st;
dd_list *elem;
int ret;
+ bool user = true;
if (!callback) {
_E("Invalid parameter");
return STORAGE_ERROR_INVALID_PARAMETER;
}
+ if (getuid() < USER_UID_START)
+ user = false;
+
DD_LIST_FOREACH(st_int_head, elem, st) {
- ret = callback(st->storage_id, st->type, st->get_state(),
- st->root(), user_data);
- /* if the return value is false, will be stop to iterate */
- if (!ret)
- break;
+ if (user) {
+ ret = callback(st->storage_id, st->type, st->get_state(),
+ st->root(), user_data);
+ /* if the return value is false, will be stop to iterate */
+ if (!ret)
+ break;
+ }
+ }
+
+ if (!storage_ext_is_supported()) {
+ _D("Block module is not enabled");
+ return STORAGE_ERROR_NONE;
}
ret = storage_ext_foreach_device_list(callback, user_data);
dd_list *elem;
char root[PATH_MAX];
int ret;
+ bool extendedint;
+ bool user = true;
if (storage_id < 0)
return STORAGE_ERROR_NOT_SUPPORTED;
return STORAGE_ERROR_INVALID_PARAMETER;
}
+ if (getuid() < USER_UID_START)
+ user = false;
+
/* internal storage */
DD_LIST_FOREACH(st_int_head, elem, st) {
if (st->storage_id != storage_id)
continue;
+ if (!user) {
+ _E("Only Tizen applications and user session daemons can use \
+ storage_get_root_directory(id , ...)");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
*path = strdup(st->root());
if (!*path) {
//LCOV_EXCL_START System Error
}
/* external storage */
- ret = storage_ext_get_root(storage_id, root, sizeof(root));
+ ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
if (ret < 0) {
_E("Failed to get root path of external storage(%d, %d", storage_id, ret); //LCOV_EXCL_LINE
return STORAGE_ERROR_INVALID_PARAMETER;
int ret;
dd_list *elem;
bool found;
+ bool extendedint;
+ bool user = true;
if (storage_id < 0)
return STORAGE_ERROR_NOT_SUPPORTED;
break;
}
+ if (getuid() < USER_UID_START)
+ user = false;
+
if (found && st) {
+ if (!user) {
+ _E("Only Tizen applications and user session daemons can use \
+ storage_get_directory(id, ...)");
+ return STORAGE_ERROR_INVALID_PARAMETER;
+ }
+
snprintf(root, sizeof(root), "%s", st->root());
if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES) {
temp2 = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
return STORAGE_ERROR_NOT_SUPPORTED;
}
- ret = storage_ext_get_root(storage_id, root, sizeof(root));
+ ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
if (ret < 0) {
_E("Failed to get root dir for external storage(id:%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
- return STORAGE_ERROR_OPERATION_FAILED;
+ return STORAGE_ERROR_NOT_SUPPORTED;
}
+ /* The operation is not decided */
+ if (extendedint)
+ return STORAGE_ERROR_NOT_SUPPORTED;
snprintf(temp, sizeof(temp), "%s/%s", root, dir_path[type]);
{
const struct storage_ops *st;
dd_list *elem;
+ char root[PATH_MAX];
+ int ret;
+ bool extendedint;
if (storage_id < 0)
return STORAGE_ERROR_NOT_SUPPORTED;
}
/* external storage */
- *type = STORAGE_TYPE_EXTERNAL;
+ ret = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint);
+ if (ret < 0) {
+ _E("Failed to get type of external storage");
+ return STORAGE_ERROR_NOT_SUPPORTED;
+ }
+ if (extendedint)
+ *type = STORAGE_TYPE_EXTENDED_INTERNAL;
+ else
+ *type = STORAGE_TYPE_EXTERNAL;
return STORAGE_ERROR_NONE;
}
return STORAGE_ERROR_NOT_SUPPORTED;
}
- if (type != STORAGE_TYPE_EXTERNAL) {
+ if (type != STORAGE_TYPE_EXTERNAL && type != STORAGE_TYPE_EXTENDED_INTERNAL) {
_E("Invalid type (%d)", type);
return STORAGE_ERROR_INVALID_PARAMETER;
}
return STORAGE_ERROR_INVALID_PARAMETER;
}
+ if (!storage_ext_is_supported()) {
+ _E("Block module is not enabled");
+ return STORAGE_ERROR_NOT_SUPPORTED;
+ }
+
/* external storage */
info.type = type;
info.type_cb = callback;
return STORAGE_ERROR_NOT_SUPPORTED;
}
- if (type != STORAGE_TYPE_EXTERNAL) {
+ if (type != STORAGE_TYPE_EXTERNAL && type != STORAGE_TYPE_EXTENDED_INTERNAL) {
_E("Invalid type (%d)", type);
return STORAGE_ERROR_INVALID_PARAMETER;
}
return STORAGE_ERROR_INVALID_PARAMETER;
}
+ if (!storage_ext_is_supported()) {
+ _E("Block module is not enabled");
+ return STORAGE_ERROR_NOT_SUPPORTED;
+ }
+
/* external storage */
info.type = type;
info.type_cb = callback;