+ 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 = (char*)storage_dest_priv->hostname;
+ host_dest = MSG_get_host_by_name(host_name_dest);
+
+ }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_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, host_name_dest);
+ msg_host_t *m_host_list = NULL;
+ m_host_list = calloc(2, sizeof(msg_host_t));
+
+ m_host_list[0] = attached_host;
+ m_host_list[1] = host_dest;
+ double computation_amount[] = { 0, 0 };
+ double communication_amount[] = { 0, (double)read_size, 0, 0 };
+
+ msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, computation_amount, communication_amount, NULL);
+ msg_error_t transfer = MSG_parallel_task_execute(task);
+ MSG_task_destroy(task);
+ free(m_host_list);
+ if(transfer != MSG_OK){
+ if (transfer == MSG_HOST_FAILURE)
+ XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
+ if (transfer == MSG_TASK_CANCELED)
+ XBT_WARN("Transfer error, task has been canceled!");
+
+ return -1;
+ }
+
+ /* Create file on remote host, write it and close it */
+ smx_file_t smx_file = simcall_file_open(fullpath, host_dest);
+ simcall_file_write(smx_file, read_size, host_dest);
+ simcall_file_close(smx_file, host_dest);
+ return MSG_OK;