{
msg_file_t file = NULL;
s_msg_stat_t stat;
-
- char* mount = bprintf("C:");
+ void *ptr;
+ char* mount = bprintf("/home");
size_t read,write;
+
if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
file = MSG_file_open(mount,FILENAME1,"rw");
else if(!strcmp(MSG_process_get_name(MSG_process_self()),"1"))
XBT_INFO("\tOpen file '%s'",file->name);
- read = MSG_file_read(mount,NULL,10000000,sizeof(char*),file); // Read for 10Mo
+ read = MSG_file_read(ptr,10000000,sizeof(char*),file); // Read for 10Mo
XBT_INFO("\tHaving read %zu \ton %s",read,file->name);
- write = MSG_file_write(mount,NULL,100000,sizeof(char*),file); // Write for 100Ko
+ write = MSG_file_write(ptr,100000,sizeof(char*),file); // Write for 100Ko
XBT_INFO("\tHaving write %zu \ton %s",write,file->name);
- read = MSG_file_read(mount,NULL,10000000,sizeof(char*),file); // Read for 10Mo
+ read = MSG_file_read(ptr,10000000,sizeof(char*),file); // Read for 10Mo
XBT_INFO("\tHaving read %zu \ton %s",read,file->name);
- MSG_file_stat(mount,file,&stat);
+ MSG_file_stat(file,&stat);
XBT_INFO("\tFile %s Size %d",file->name,(int)stat.size);
XBT_INFO("\tClose file '%s'",file->name);
- MSG_file_close(mount,file);
+ MSG_file_close(file);
free(mount);
return 0;
<storage id="Disk4" typeId="wdigital"/>
<host id="bob" power="1000000000">
- <mount id="Disk1" name="C:"/>
+ <mount id="Disk1" name="/home"/>
</host>
<host id="alice" power="1000000000">
- <mount id="Disk2" name="C:"/>
+ <mount id="Disk2" name="/home"/>
</host>
<host id="carl" power="1000000000">
- <mount id="Disk3" name="C:"/>
+ <mount id="Disk3" name="/home"/>
</host>
<host id="denise" power="1000000000">
- <mount id="Disk4" name="C:"/>
+ <mount id="Disk4" name="/home"/>
</host>
<link id="link1" bandwidth="125000000" latency="5E-5" />
/************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, msg_file_t stream);
-XBT_PUBLIC(size_t) MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
-XBT_PUBLIC(msg_file_t) MSG_file_open(const char* storage, const char* path, const char* mode);
-XBT_PUBLIC(int) MSG_file_close(const char* storage, msg_file_t fp);
-XBT_PUBLIC(int) MSG_file_stat(const char* storage, msg_file_t fd, s_msg_stat_t *buf);
+XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream);
+XBT_PUBLIC(msg_file_t) MSG_file_open(const char* mount, const char* path, const char* mode);
+XBT_PUBLIC(int) MSG_file_close(msg_file_t fp);
+XBT_PUBLIC(int) MSG_file_stat(msg_file_t fd, s_msg_stat_t *buf);
/************************** Host handling ***********************************/
XBT_PUBLIC(unsigned int) simcall_sem_acquire_any(xbt_dynar_t sems);
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
-XBT_PUBLIC(size_t) simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(size_t) simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
-XBT_PUBLIC(int) simcall_file_close(const char* storage, smx_file_t fp);
-XBT_PUBLIC(int) simcall_file_stat(const char* storage, smx_file_t fd, s_file_stat_t *buf);
+XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
+XBT_PUBLIC(int) simcall_file_stat(smx_file_t fd, s_file_stat_t *buf);
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */
*/
typedef struct surf_storage_model_extension_public {
- surf_action_t(*open) (void *storage, const char* path, const char* mode);
+ surf_action_t(*open) (void *storage, const char* mount, const char* path, const char* mode);
surf_action_t(*close) (void *storage, surf_file_t fp);
surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
surf_action_t(*open) (void *workstation, const char* storage, const char* path, const char* mode);
- surf_action_t(*close) (void *workstation, const char* storage, surf_file_t fp);
- surf_action_t(*read) (void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*write) (void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
- surf_action_t(*stat) (void *workstation, const char* storage, surf_file_t stream);
+ surf_action_t(*close) (void *workstation, surf_file_t fp);
+ surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
+ surf_action_t(*stat) (void *workstation, surf_file_t stream);
int (*link_shared) (const void *link);
xbt_dict_t(*get_properties) (const void *resource);
void* (*link_create_resource) (const char *name,
/** \ingroup msg_file_management
* \brief Read elements of a file
*
- * \param storage is the name where find the stream
* \param ptr buffer to where the data is copied
* \param size of each element
* \param nmemb is the number of elements of data to read
* \param stream to read
* \return the number of items successfully read
*/
-size_t MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, msg_file_t stream)
+size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, msg_file_t stream)
{
- return simcall_file_read(storage, ptr, size, nmemb, stream->simdata->smx_file);
+ return simcall_file_read(ptr, size, nmemb, stream->simdata->smx_file);
}
/** \ingroup msg_file_management
* \brief Write elements into a file
*
- * \param storage is the name where find the stream
* \param ptr buffer from where the data is copied
* \param size of each element
* \param nmemb is the number of elements of data to write
* \param stream to write
* \return the number of items successfully write
*/
-size_t MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, msg_file_t stream)
+size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t stream)
{
- return simcall_file_write(storage, ptr, size, nmemb, stream->simdata->smx_file);
+ return simcall_file_write(ptr, size, nmemb, stream->simdata->smx_file);
}
/** \ingroup msg_file_management
* \brief Opens the file whose name is the string pointed to by path
*
- * \param storage is the name where find the file to open
+ * \param mount is the mount point where find the file is located
* \param path is the file location on the storage
* \param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.):
* r Open text file for reading. The stream is positioned at the beginning of the file.
*
* \return An #msg_file_t associated to the file
*/
-msg_file_t MSG_file_open(const char* storage, const char* path, const char* mode)
+msg_file_t MSG_file_open(const char* mount, const char* path, const char* mode)
{
msg_file_t file = xbt_new(s_msg_file_t,1);
file->name = strdup(path);
file->simdata = xbt_new0(s_simdata_file_t,1);
- file->simdata->smx_file = simcall_file_open(storage, path, mode);
+ file->simdata->smx_file = simcall_file_open(mount, path, mode);
return file;
}
/** \ingroup msg_file_management
* \brief Close the file
*
- * \param storage is the name where find the stream
* \param fp is the file to close
* \return 0 on success or 1 on error
*/
-int MSG_file_close(const char* storage, msg_file_t fp)
+int MSG_file_close(msg_file_t fp)
{
- return simcall_file_close(storage, fp->simdata->smx_file);
+ return simcall_file_close(fp->simdata->smx_file);
}
/** \ingroup msg_file_management
* \brief Stats the file pointed by fd
*
- * \param storage is the name where find the stream
* \param fd is the file descriptor (#msg_file_t)
* \param buf is the return structure with informations
* \return 0 on success or 1 on error
*/
-int MSG_file_stat(const char* storage, msg_file_t fd, s_msg_stat_t *buf)
+int MSG_file_stat(msg_file_t fd, s_msg_stat_t *buf)
{
int res;
- res = simcall_file_stat(storage, fd->simdata->smx_file, buf);
+ res = simcall_file_stat(fd->simdata->smx_file, buf);
return res;
}
void SIMIX_pre_file_read(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_read(simcall->issuer,
- simcall->file_read.storage,
simcall->file_read.ptr,
simcall->file_read.size,
simcall->file_read.nmemb,
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, storage, ptr, size, nmemb, stream->surf_file),
+ action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, ptr, size, nmemb, stream->surf_file),
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_write(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_write(simcall->issuer,
- simcall->file_write.storage,
simcall->file_write.ptr,
simcall->file_write.size,
simcall->file_write.nmemb,
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, storage, ptr, size, nmemb, stream->surf_file);
+ action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, ptr, size, nmemb, stream->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_open(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_open(simcall->issuer,
- simcall->file_open.storage,
+ simcall->file_open.mount,
simcall->file_open.path,
simcall->file_open.mode);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_open(smx_process_t process ,const char* storage, const char* path, const char* mode)
+smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const char* path, const char* mode)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, storage, path, mode);
+ action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, mount, path, mode);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_close(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_close(simcall->issuer,
- simcall->file_close.storage,
simcall->file_close.fp);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_close(smx_process_t process ,const char* storage, smx_file_t fp)
+smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, storage, fp->surf_file);
+ action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, fp->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_stat(smx_simcall_t simcall)
{
smx_action_t action = SIMIX_file_stat(simcall->issuer,
- simcall->file_stat.storage,
simcall->file_stat.fd,
simcall->file_stat.buf);
xbt_fifo_push(action->simcalls, simcall);
simcall->issuer->waiting_action = action;
}
-smx_action_t SIMIX_file_stat(smx_process_t process ,const char* storage, smx_file_t fd, s_file_stat_t buf)
+smx_action_t SIMIX_file_stat(smx_process_t process, smx_file_t fd, s_file_stat_t buf)
{
smx_action_t action;
smx_host_t host = process->smx_host;
#endif
action->io.host = host;
- action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, storage, fd->surf_file);
+ action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, fd->surf_file);
surf_workstation_model->action_data_set(action->io.surf_io, action);
XBT_DEBUG("Create io action %p", action);
void SIMIX_pre_file_close(smx_simcall_t simcall);
void SIMIX_pre_file_stat(smx_simcall_t simcall);
-smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path, const char* mode);
-smx_action_t SIMIX_file_close(smx_process_t process, const char* storage, smx_file_t fp);
-smx_action_t SIMIX_file_stat(smx_process_t process, const char* storage, smx_file_t fd, s_file_stat_t buf);
+smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp);
+smx_action_t SIMIX_file_stat(smx_process_t process, smx_file_t fd, s_file_stat_t buf);
void SIMIX_post_io(smx_action_t action);
void SIMIX_io_destroy(smx_action_t action);
} sem_get_capacity;
struct {
- const char* storage;
void *ptr;
size_t size;
size_t nmemb;
} file_read;
struct {
- const char* storage;
const void *ptr;
size_t size;
size_t nmemb;
} file_write;
struct {
- const char* storage;
+ const char* mount;
const char* path;
const char* mode;
smx_file_t result;
} file_open;
struct {
- const char* storage;
smx_file_t fp;
int result;
} file_close;
struct {
- const char* storage;
smx_file_t fd;
s_file_stat_t buf;
int result;
return simcall->sem_get_capacity.result;
}
-size_t simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_READ;
- simcall->file_read.storage = storage;
simcall->file_read.ptr = ptr;
simcall->file_read.size = size;
simcall->file_read.nmemb = nmemb;
return simcall->file_read.result;
}
-size_t simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_WRITE;
- simcall->file_write.storage = storage;
simcall->file_write.ptr = ptr;
simcall->file_write.size = size;
simcall->file_write.nmemb = nmemb;
return simcall->file_write.result;
}
-smx_file_t simcall_file_open(const char* storage, const char* path, const char* mode)
+smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_OPEN;
- simcall->file_open.storage = storage;
+ simcall->file_open.mount = mount;
simcall->file_open.path = path;
simcall->file_open.mode = mode;
SIMIX_simcall_push(simcall->issuer);
return simcall->file_open.result;
}
-int simcall_file_close(const char* storage, smx_file_t fp)
+int simcall_file_close(smx_file_t fp)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_CLOSE;
- simcall->file_close.storage = storage;
simcall->file_close.fp = fp;
SIMIX_simcall_push(simcall->issuer);
return simcall->file_close.result;
}
-int simcall_file_stat(const char* storage, smx_file_t fd, s_file_stat_t *buf)
+int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_STAT;
- simcall->file_stat.storage = storage;
simcall->file_stat.fd = fd;
SIMIX_simcall_push(simcall->issuer);
return action;
}
-static surf_action_t storage_action_open(void *storage, const char* path, const char* mode)
+static surf_action_t storage_action_open(void *storage, const char* mount, const char* path, const char* mode)
{
XBT_DEBUG("\tOpen file '%s'",path);
char *storage_type_id = xbt_lib_get_or_null(
surf_file_t file = xbt_new0(s_surf_file_t,1);
file->name = xbt_strdup(path);
file->content = content;
+ file->storage = mount;
surf_action_t action = storage_action_execute(storage,0, OPEN);
action->file = (void *)file;
typedef struct surf_file {
char *name;
surf_stat_t content;
+ const char* storage;
} s_surf_file_t;
typedef struct storage {
return st;
}
-static surf_action_t ws_action_open(void *workstation, const char* storage, const char* path, const char* mode)
+static surf_action_t ws_action_open(void *workstation, const char* mount, const char* path, const char* mode)
{
- storage_t st = find_storage_on_mount_list(workstation, storage);
+ storage_t st = find_storage_on_mount_list(workstation, mount);
XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
- return model->extension.storage.open(st, path, mode);
+ return model->extension.storage.open(st, mount, path, mode);
}
-static surf_action_t ws_action_close(void *workstation, const char* storage, surf_file_t fp)
+static surf_action_t ws_action_close(void *workstation, surf_file_t fp)
{
- storage_t st = find_storage_on_mount_list(workstation, storage);
+ storage_t st = find_storage_on_mount_list(workstation, fp->storage);
XBT_DEBUG("CLOSE on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
return model->extension.storage.close(st, fp);
}
-static surf_action_t ws_action_read(void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
- storage_t st = find_storage_on_mount_list(workstation, storage);
+ storage_t st = find_storage_on_mount_list(workstation, stream->storage);
XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
return model->extension.storage.read(st, ptr, size, nmemb, stream);
}
-static surf_action_t ws_action_write(void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
{
- storage_t st = find_storage_on_mount_list(workstation, storage);
+ storage_t st = find_storage_on_mount_list(workstation, stream->storage);
XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
return model->extension.storage.write(st, ptr, size, nmemb, stream);
}
-static surf_action_t ws_action_stat(void *workstation, const char* storage, surf_file_t stream)
+static surf_action_t ws_action_stat(void *workstation, surf_file_t stream)
{
- storage_t st = find_storage_on_mount_list(workstation, storage);
+ storage_t st = find_storage_on_mount_list(workstation, stream->storage);
XBT_DEBUG("STAT on disk '%s'",st->generic_resource.name);
surf_model_t model = st->generic_resource.model;
return model->extension.storage.stat(st, stream);