+
+ /* Find the host source where the file is physically located */
+ msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
+
+ msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src);
+ const char *host_name_src, *host_name_dest;
+ host_name_src = storage_priv_src->host;
+
+ /* Find the real host destination where the file will be physically stored */
+ xbt_dict_cursor_t cursor = NULL;
+ char *mount_name, *storage_name, *file_mount_name;
+ msg_storage_t storage_dest;
+ size_t longest_prefix_length = 0;
+
+ xbt_dict_t storage_list = simcall_host_get_mounted_storage_list(host);
+ xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
+ file_mount_name = (char *) xbt_malloc ((strlen(mount_name)+1));
+ strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
+ file_mount_name[strlen(mount_name)] = '\0';
+
+ if(!strcmp(file_mount_name,mount_name) && strlen(mount_name)>longest_prefix_length){
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = strlen(mount_name);
+ storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
+ }
+ free(file_mount_name);
+ }
+ if(longest_prefix_length>0){
+ /* Mount point found, retrieve the host the storage is attached to */
+ msg_storage_priv_t storage_dest_priv = MSG_storage_priv(storage_dest);
+ host_name_dest = storage_dest_priv->host;
+
+ }else{
+ XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, SIMIX_host_get_name(host));
+ return MSG_TASK_CANCELED;
+ }
+ XBT_INFO("HOST SRC %s HOST DEST %s", host_name_src, host_name_dest);
+
+ /* Try to send file calling SIMIX network layer */
+
+ size_t file_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, MSG_get_host_by_name(host_name_src));
+ xbt_ex_t e;
+ msg_error_t ret = MSG_OK;
+
+ TRY {
+ msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(host_name_dest);
+ simcall_comm_isend(mailbox, (double) file_size, -1.0, file, sizeof(void *), NULL, NULL, (void*)file, 0);
+ simcall_comm_irecv(mailbox, file, NULL, NULL, NULL, -1.0);
+ }
+ CATCH(e) {
+ switch (e.category) {
+ case cancel_error:
+ ret = MSG_HOST_FAILURE;
+ break;
+ case network_error:
+ ret = MSG_TRANSFER_FAILURE;
+ break;
+ case timeout_error:
+ ret = MSG_TIMEOUT;
+ break;
+ default:
+ RETHROW;
+ }
+ xbt_ex_free(e);
+ }
+ return ret;