modify internal storage path 88/77688/1 accepted/tizen/common/20160701.192913 accepted/tizen/ivi/20160701.034335 accepted/tizen/mobile/20160701.034428 accepted/tizen/tv/20160701.034304 accepted/tizen/wearable/20160701.034405 submit/tizen/20160701.012724 submit/tizen_common/20160701.180000
authorHyihong Chae <hh.chae@samsung.com>
Thu, 30 Jun 2016 13:00:40 +0000 (22:00 +0900)
committerHyihong Chae <hh.chae@samsung.com>
Thu, 30 Jun 2016 13:00:40 +0000 (22:00 +0900)
Change-Id: Ie1360521b69392ef926f17b9a2bc140afb177874
Signed-off-by: HyiHong Chae <hh.chae@samsung.com>
include/mtp_config.h
include/util/mtp_util.h
src/entity/mtp_device.c
src/entity/mtp_store.c
src/mtp_cmd_handler_util.c
src/mtp_init.c
src/mtp_inoti_handler.c
src/util/mtp_support.c
src/util/mtp_util.c

index 561e5d90e13069c5b49aeb2d4eee941e20cad4b2..b4249e16af42bea2aec70fbd19dd2a5b58ac6533 100755 (executable)
@@ -77,7 +77,7 @@
  * Transport related configuration
  */
 /* Internal Storage */
-#define MTP_STORE_PATH_CHAR            "/home/owner/content"
+#define MTP_STORE_PATH_CHAR            "/opt/home/owner/content"
 
 /* External Storage */
 #define MTP_EXTERNAL_PATH_CHAR "/opt/media/SDCardA1"
index 4e825a369a552d5ff4519319f1701a728c26784c..45064be94c8e8acb27dc1954891380d5bbe78e60 100755 (executable)
@@ -141,6 +141,6 @@ void _util_set_local_mmc_status(const phone_status_t val);
 void _util_get_usbmode_status(phone_status_t *val);
 phone_status_t _util_get_local_usbmode_status(void);
 void _util_set_local_usbmode_status(const phone_status_t val);
-void _util_get_external_path(char *ext_path);
-
+void _util_get_external_path(char *external_path);
+void _util_get_internal_path(char *internal_path);
 #endif /* _MTP_UTIL_H_ */
index c2e6f6b622c8676082669fb3eae5627fcee7681b..0539974969ee3abed7c8f8bab420155d2cc86be7 100755 (executable)
@@ -603,16 +603,17 @@ static mtp_bool __add_store_to_device(store_type_t store_type)
        mtp_char *storage_path = NULL;
        mtp_uint32 store_id = 0;
        file_attr_t attrs = { 0, };
-       char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+       char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
        switch (store_type) {
        case MTP_STORAGE_INTERNAL:
-               storage_path = MTP_STORE_PATH_CHAR;
+               _util_get_internal_path(sto_path);
+               storage_path = (mtp_char *)sto_path;
                store_id = MTP_INTERNAL_STORE_ID;
                break;
        case MTP_STORAGE_EXTERNAL:
-               _util_get_external_path(ext_path);
-               storage_path = (mtp_char *)ext_path;
+               _util_get_external_path(sto_path);
+               storage_path = (mtp_char *)sto_path;
                store_id = MTP_EXTERNAL_STORE_ID;
                break;
        default:
index 814d062aaf6178d7af5803bcc049aabaf3dde4f1..7b9cba8093b442e92153cafd5535fb4050e59aca 100755 (executable)
@@ -90,16 +90,17 @@ void _entity_update_store_info_run_time(store_info_t *info,
 
 mtp_bool _entity_get_store_path_by_id(mtp_uint32 store_id, mtp_char *path)
 {
-       char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+       char sto_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
        switch(store_id) {
        case MTP_INTERNAL_STORE_ID :
-               g_strlcpy(path, MTP_STORE_PATH_CHAR,
+               _util_get_internal_path(sto_path);
+               g_strlcpy(path, sto_path,
                                MTP_MAX_PATHNAME_SIZE + 1);
                break;
        case MTP_EXTERNAL_STORE_ID :
-               _util_get_external_path(ext_path);
-               g_strlcpy(path, ext_path,
+               _util_get_external_path(sto_path);
+               g_strlcpy(path, sto_path,
                                MTP_MAX_PATHNAME_SIZE + 1);
                break;
        default :
@@ -178,13 +179,15 @@ mtp_uint32 _entity_get_store_id_by_path(const mtp_char *path_name)
 {
        mtp_uint32 store_id = 0;
        char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+       char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
        retv_if(NULL == path_name, FALSE);
 
        _util_get_external_path(ext_path);
+       _util_get_internal_path(inter_path);
 
-       if (!strncmp(path_name, MTP_STORE_PATH_CHAR,
-                               strlen(MTP_STORE_PATH_CHAR))) {
+       if (!strncmp(path_name, inter_path,
+                               strlen(inter_path))) {
                store_id = MTP_INTERNAL_STORE_ID;
        } else if (!strncmp(path_name, ext_path,
                                strlen(ext_path))) {
@@ -1198,8 +1201,11 @@ void _entity_list_modified_files(mtp_uint32 minutes)
        mtp_char command[FIND_CMD_LEN] = { 0 };
 
        if (TRUE == _device_is_store_mounted(MTP_STORAGE_INTERNAL)) {
+               char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+               _util_get_internal_path(inter_path);
+
                g_snprintf(command, FIND_CMD_LEN, FIND_CMD,
-                               MTP_STORE_PATH_CHAR, minutes,
+                               inter_path, minutes,
                                MTP_FILES_MODIFIED_FILES);
                DBG("find query is [%s]\n", command);
                ret = system(command);
index a3661efbd559bdeabcd1bff41483e121003eaa72..a0c992784e4983459d1999c7f449400f84e49650 100755 (executable)
@@ -276,6 +276,9 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name,
                                mtp_char wmp_hidden_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
                                if (obj_info->store_id == MTP_INTERNAL_STORE_ID) {
+                                       char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+                                       _util_get_internal_path(inter_path);
+
                                        g_snprintf(wmp_hidden_path,
                                                        MTP_MAX_PATHNAME_SIZE + 1,
                                                        "%s/%s/%s", MTP_USER_DIRECTORY,
@@ -283,7 +286,7 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name,
                                                        MTP_FILE_NAME_WMPINFO_XML);
                                        g_snprintf(wmp_info_path,
                                                        MTP_MAX_PATHNAME_SIZE + 1,
-                                                       "%s/%s", MTP_STORE_PATH_CHAR,
+                                                       "%s/%s", inter_path,
                                                        MTP_FILE_NAME_WMPINFO_XML);
                                } else {
                                        char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
index bd98a3ef950d43d4699bb3f594a489108531fb5f..0cfe46ff742fe8554e36aff9d390bf938c2c59c0 100755 (executable)
@@ -95,6 +95,7 @@ void _mtp_init(add_rem_store_t sel)
        mtp_bool ret = 0;
        int vconf_ret = 0;
        mtp_int32 error = 0;
+       char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
        DBG("Initialization start!");
 
@@ -146,10 +147,11 @@ void _mtp_init(add_rem_store_t sel)
        }
 
        /* Internal Storage */
-       if (access(MTP_STORE_PATH_CHAR, F_OK) < 0) {
-               if (FALSE == _util_dir_create(MTP_STORE_PATH_CHAR, &error)) {
+       _util_get_internal_path(inter_path);
+       if (access(inter_path, F_OK) < 0) {
+               if (FALSE == _util_dir_create((const mtp_char *)inter_path, &error)) {
                        ERR("Cannot make directory!! [%s]\n",
-                                       MTP_STORE_PATH_CHAR);
+                                       inter_path);
                        goto MTP_INIT_FAIL;
                }
        }
@@ -158,7 +160,7 @@ void _mtp_init(add_rem_store_t sel)
                char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
                _util_get_external_path(ext_path);
                if (access(ext_path, F_OK) < 0) {
-                       if (FALSE == _util_dir_create(ext_path, &error)) {
+                       if (FALSE == _util_dir_create((const mtp_char *)ext_path, &error)) {
                                ERR("Cannot make directory!! [%s]\n",
                                                ext_path);
                                goto MTP_INIT_FAIL;
@@ -168,7 +170,7 @@ void _mtp_init(add_rem_store_t sel)
 #ifndef MTP_SUPPORT_HIDE_WMPINFO_XML
        /* Update WMPInfo.xml for preventing frequent saving */
        ret = _util_create_path(wmpinfopath, sizeof(wmpinfopath),
-                       MTP_STORE_PATH_CHAR, MTP_FILE_NAME_WMPINFO_XML);
+                       (const mtp_char *)inter_path, MTP_FILE_NAME_WMPINFO_XML);
        if (FALSE == ret) {
                ERR("szWMPInfoPath is too long");
                goto MTP_INIT_FAIL;
index 56dcdd456e3e122463c31df671c0dd516dfb31ed..47faeaa3b175f42d4352234159bb1ad720a92048 100755 (executable)
@@ -486,9 +486,11 @@ static void __remove_recursive_inoti_watch(mtp_char *path)
 static void __clean_up_inoti(void *data)
 {
        char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+       char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
        _util_get_external_path(ext_path);
+       _util_get_internal_path(inter_path);
 
-       __remove_recursive_inoti_watch(MTP_STORE_PATH_CHAR);
+       __remove_recursive_inoti_watch((mtp_char *)inter_path);
        __remove_recursive_inoti_watch((mtp_char *)ext_path);
        __destroy_inoti_open_files_list();
 
@@ -561,9 +563,11 @@ static void __process_object_added_event(mtp_char *fullpath,
        parent_obj = _entity_get_object_from_store_by_path(store, parent_path);
        if (NULL == parent_obj) {
                char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+               char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
                _util_get_external_path(ext_path);
+               _util_get_internal_path(inter_path);
 
-               if (!g_strcmp0(parent_path, MTP_STORE_PATH_CHAR) ||
+               if (!g_strcmp0(parent_path, inter_path) ||
                                !g_strcmp0(parent_path, ext_path))
                {
                        DBG("parent is the root folder");
index 4f715ba3acf007e8bf870f7daea81a09cc8b1d24..144c2cdbb66ea1c12e20d82c5ccbd2d005e4b42b 100755 (executable)
@@ -469,14 +469,16 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path)
        static mtp_uint32 external_store_len = 0;
 
        char ext_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
+       char inter_path[MTP_MAX_PATHNAME_SIZE + 1] = { 0 };
 
        retv_if(path == NULL, FALSE);
 
        _util_get_external_path(ext_path);
+       _util_get_internal_path(inter_path);
 
        if (!is_initialized) {
                is_initialized = TRUE;
-               internal_store_len = strlen(MTP_STORE_PATH_CHAR);
+               internal_store_len = strlen(inter_path);
                external_store_len = strlen(ext_path);
 
                max_store_len = internal_store_len > external_store_len ?
@@ -485,7 +487,7 @@ mtp_bool _util_is_path_len_valid(const mtp_char *path)
                DBG("max store len : [%u]\n", max_store_len);
        }
 
-       if (!strncmp(path, MTP_STORE_PATH_CHAR, internal_store_len)) {
+       if (!strncmp(path, inter_path, internal_store_len)) {
                root_path_len = internal_store_len;
        } else if (!strncmp(path, ext_path, external_store_len)) {
                root_path_len = external_store_len;
index ef614c6d43c36a3f58c7aeff0854ea81247fd6e9..83731f1ddc3e6e24462eacc8b6d4be4b4c31f875 100755 (executable)
@@ -293,26 +293,61 @@ void _util_set_local_usbmode_status(const phone_status_t val)
        return;
 }
 
-static bool _util_device_supported_cb(int storage_id, storage_type_e type,
+static bool _util_device_external_supported_cb(int storage_id, storage_type_e type,
        storage_state_e state, const char *path, void *user_data)
 {
-       char *ext_path = (char *)user_data;
+       char *storage_path = (char *)user_data;
+
+       DBG("storage id: %d, path: %s", storage_id, path);
 
        if (type == STORAGE_TYPE_EXTERNAL && path != NULL) {
-               strncpy(ext_path, path, strlen(path));
-               DBG("external storage path : %s", ext_path);
+               strncpy(storage_path, path, strlen(path));
+               DBG("external storage path : %s", storage_path);
        }
 
        return TRUE;
 }
 
-void _util_get_external_path(char *ext_path)
+void _util_get_external_path(char *external_path)
 {
        int error = STORAGE_ERROR_NONE;
-       error = storage_foreach_device_supported(_util_device_supported_cb, ext_path);
+       error = storage_foreach_device_supported(_util_device_external_supported_cb, external_path);
 
        if (error != STORAGE_ERROR_NONE) {
                ERR("get external storage path Fail");
-               strncpy(ext_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR));
+               strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, strlen(MTP_EXTERNAL_PATH_CHAR));
+       }
+}
+
+static bool _util_device_internal_supported_cb(int storage_id, storage_type_e type,
+       storage_state_e state, const char *path, void *user_data)
+{
+       char *storage_path = (char *)user_data;
+
+       DBG("storage id: %d, path: %s", storage_id, path);
+
+       if (type == STORAGE_TYPE_INTERNAL && path != NULL) {
+               strncpy(storage_path, path, strlen(path));
+               DBG("internal storage path : %s", storage_path);
+
+               if (storage_get_root_directory(storage_id, &storage_path) != STORAGE_ERROR_NONE) {
+                       ERR("get internal storage path Fail");
+                       return FALSE;
+               } else {
+                       DBG("get internal storage path : %s", storage_path);
+               }
+       }
+
+       return TRUE;
+}
+
+void _util_get_internal_path(char *internal_path)
+{
+       int error = STORAGE_ERROR_NONE;
+       error = storage_foreach_device_supported(_util_device_internal_supported_cb, internal_path);
+
+       if (error != STORAGE_ERROR_NONE) {
+               ERR("get internal storage path Fail");
+               strncpy(internal_path, MTP_STORE_PATH_CHAR, strlen(MTP_STORE_PATH_CHAR));
        }
 }