*/
+#include <unistd.h>
+#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "storage-internal.h"
#include "storage-external-dbus.h"
+#include "storage-experimental.h"
/*
Get compat path from origin Multi-user path
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;
return -1;
}
+ if (getuid() <= USER_UID_START) {
+ //LCOV_EXCL_START System Error
+ _E("Only apps and user session daemons are allowed "
+ "to use storage_get_compat_internal_path()");
+ return -1;
+ //LCOV_EXCL_STOP
+ }
+
// 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);
+ str = tzplatform_uid_getenv(getuid(), TZ_USER_CONTENT);
str_len = strlen(str);
if (strncmp(origin, str, str_len) != 0) {
_E("Failed to match TZ_USER_CONTENT");
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;
}
+//LCOV_EXCL_STOP
/*
Get Multi-user path from compat path
return -1;
}
+ if (getuid() <= USER_UID_START) {
+ //LCOV_EXCL_START System Error
+ _E("Only apps and user session daemons are allowed "
+ "to use storage_get_origin_internal_path()");
+ return -1;
+ //LCOV_EXCL_STOP
+ }
+
// 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);
return -1;
}
- r = snprintf(origin, len, "%s%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len);
+ r = snprintf(origin, len, "%s%s", tzplatform_uid_getenv(getuid(), 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;
if (!storage_id || !path)
return STORAGE_ERROR_INVALID_PARAMETER;
+ if (!storage_ext_is_supported())
+ return STORAGE_ERROR_NOT_SUPPORTED;
+
result = dbus_method_call_sync(STORAGE_EXT_BUS_NAME,
STORAGE_EXT_PATH_MANAGER,
STORAGE_EXT_IFACE_MANAGER,
"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)",
*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;
if (storage_id < 0) {
_E("Invalid parameger");
- return STORAGE_ERROR_NOT_SUPPORTED;
+ return STORAGE_ERROR_NO_DEVICE;
}
if (!type) {
_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) {
-//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);
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;
}