int ms_user_get_thumb_store_path(uid_t uid, ms_user_storage_type_e storage_type, char **path);
int ms_user_get_media_db_path(uid_t uid, char **path);
+#ifndef _USE_TVPD_MODE
+int ms_user_get_mediashared_path(uid_t uid, char **path);
+#endif
+
#ifdef __cplusplus
}
#endif
#define MEDIA_ROOT_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE)
#define MEDIA_ROOT_PATH_SDCARD tzplatform_mkpath(TZ_SYS_STORAGE, "SDCard")
#define MEDIA_ROOT_PATH_USB tzplatform_getenv(TZ_SYS_STORAGE)
+#ifndef _USE_TVPD_MODE
+#define MEDIA_SHARE_PATH tzplatform_getenv(TZ_SYS_MEDIASHARED)
+#endif
#ifdef _USE_SENIOR_MODE
#define MEDIA_CONTENT_PATH "content" /**< user content folder name*/
INTERNAL_ROOT,
THUMB_ROOT,
THUMB_INTERNAL,
- THUMB_EXTERNAL
+ THUMB_EXTERNAL,
+ MEDIA_SHARED
} ms_user_path_type_e;
#ifdef _USE_SENIOR_MODE
case THUMB_EXTERNAL:
result = tzplatform_context_mkpath(context[idx], TZ_USER_SHARE, "media/.thumb/mmc");
break;
+ case MEDIA_SHARED:
+ result = tzplatform_context_getenv(context[idx], TZ_USER_MEDIASHARED);
+ break;
default:
MSAPI_DBG_ERR("Invalid type");
ret = MS_MEDIA_ERR_INTERNAL;
return ret;
}
+
+#ifndef _USE_TVPD_MODE
+int ms_user_get_mediashared_path(uid_t uid, char **path)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+
+ if (uid == getuid())
+ *path = g_strdup(tzplatform_getenv(TZ_USER_MEDIASHARED));
+ else
+ ret = __ms_user_get_path(MEDIA_SHARED, uid, path);
+
+ //MSAPI_DBG_SLOG("DB path [%s]", *path);
+
+ return ret;
+}
+#endif
int ms_check_file_path(const char *file_path, uid_t uid);
int ms_check_ignore_dir(const char *full_path, uid_t uid);
-int ms_check_scan_ignore(char * path);
+int ms_check_scan_ignore(char * path, uid_t uid);
bool ms_storage_mount_status(const char* start_path);
int ms_set_db_status(ms_db_status_type_t status, ms_user_storage_type_e storage_type);
int ms_set_power_mode(ms_db_status_type_t status);
}
while (1) {
- if (ms_check_scan_ignore(dir_path) != MS_MEDIA_ERR_NONE) {
+ if (ms_check_scan_ignore(dir_path, uid) != MS_MEDIA_ERR_NONE) {
ret = MS_MEDIA_ERR_INVALID_PATH;
break;
}
return ret;
}
-int ms_check_scan_ignore(char * path)
+int ms_check_scan_ignore(char * path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
const char *ignore_file = ".scan_ignore";
+ char *tmp_path = NULL;
char ignore_path[MS_FILE_PATH_LEN_MAX] = {0, };
+#ifndef _USE_TVPD_MODE
+ char replace[MS_FILE_PATH_LEN_MAX] = {0, };
+ char *mediashared = NULL;
+#endif
+
if (strstr(path, "/.")) {
MS_DBG_ERR("hidden path");
return MS_MEDIA_ERR_INVALID_PATH;
}
+ /* Check for symbolic link */
+ tmp_path = realpath(path, NULL);
+
+#ifdef _USE_TVPD_MODE
+ if (g_strcmp0(tmp_path, path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PATH;
+ }
+#else
+ if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) {
+ ms_user_get_mediashared_path(uid, &mediashared);
+ snprintf(replace, MS_FILE_PATH_LEN_MAX, "%s%s", mediashared, tmp_path + strlen(MEDIA_SHARE_PATH));
+ MS_SAFE_FREE(mediashared);
+ if (g_strcmp0(replace, path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PATH;
+ }
+ } else {
+ if (g_strcmp0(tmp_path, path) != 0) {
+ MS_SAFE_FREE(tmp_path);
+ MS_DBG_ERR("symbolic link(directory)");
+ return MS_MEDIA_ERR_INVALID_PATH;
+ }
+ }
+#endif
+ MS_SAFE_FREE(tmp_path);
+
if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
memset(ignore_path, 0, sizeof(ignore_path));
snprintf(ignore_path, sizeof(ignore_path), "%s/%s", path, ignore_file);
close(id);
return MS_MEDIA_ERR_NONE;
}
-#endif
\ No newline at end of file
+#endif
__msc_set_dir_scan_cur_path(current_path);
if (strncmp(current_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) != 0) {
- ret = ms_check_scan_ignore(current_path);
+ ret = ms_check_scan_ignore(current_path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
__msc_set_storage_scan_cur_path(current_path);
- ret = ms_check_scan_ignore(current_path);
+ ret = ms_check_scan_ignore(current_path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
current_path = g_array_index(dir_array , char*, 0);
g_array_remove_index(dir_array, 0);
- if (ms_check_scan_ignore(current_path) != MS_MEDIA_ERR_NONE) {
+ if (ms_check_scan_ignore(current_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
continue;
}
if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ /* Check symbolic link file */
+ if (g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
+ MS_DBG_WARN("Symbolic link.. Skip this file");
+ continue;
+ }
+
/* Check content.scanning.others feature */
if (!ms_check_support_media_type(handle, path)) {
MS_DBG("Unsupported media type");
current_path = g_array_index(dir_array , char*, 0);
g_array_remove_index(dir_array, 0);
- if (ms_check_scan_ignore(current_path) != MS_MEDIA_ERR_NONE) {
+ if (ms_check_scan_ignore(current_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
continue;