sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size)
{
msg_file_priv_t file_priv = MSG_file_priv(fd);
- sg_size_t write_size;
+ sg_size_t write_size, offset;
/* Find the host where the file is physically located (remote or local)*/
msg_storage_t storage_src =(msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId);
}
}
/* Write file on local or remote host */
+ offset = simcall_file_tell(file_priv->simdata->smx_file);
write_size = simcall_file_write(file_priv->simdata->smx_file, size, attached_host);
+ file_priv->size = offset+write_size;
return write_size;
}
return fd;
}
-/**
- * \brief Frees private data of a file (internal call only)
- */
-void __MSG_file_priv_free(msg_file_priv_t priv)
-{
- xbt_free(&priv->simdata->smx_file);
- free(priv);
-}
-
/** \ingroup msg_file_management
* \brief Close the file
*
*/
msg_error_t MSG_file_unlink(msg_file_t fd)
{
- msg_file_priv_t priv = MSG_file_priv(fd);
- int res = simcall_file_unlink(priv->simdata->smx_file);
+ msg_file_priv_t file_priv = MSG_file_priv(fd);
+ /* Find the host where the file is physically located (remote or local)*/
+ 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);
+ msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+ int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host);
return res;
}
* MSG_TASK_CANCELED (=8).
*
*/
-msg_error_t MSG_file_seek(msg_file_t fd, sg_size_t offset, int origin)
+msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin)
{
msg_file_priv_t priv = MSG_file_priv(fd);
return simcall_file_seek(priv->simdata->smx_file, offset, origin);
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);
msg_host_t attached_host = MSG_get_host_by_name(storage_priv_src->hostname);
+ MSG_file_seek(file, 0, SEEK_SET);
read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host);
/* Find the real host destination where the file will be physically stored */
}
free(file_mount_name);
}
+ xbt_dict_free(&storage_list);
+
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);