/************************** File handling ***********************************/
-XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream);
-XBT_PUBLIC(m_file_t) MSG_file_open(const char* path, const char* mode);
-XBT_PUBLIC(int) MSG_file_close(m_file_t fp);
-XBT_PUBLIC(int) MSG_file_stat(int fd, void* buf);
+XBT_PUBLIC(size_t) MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream);
+XBT_PUBLIC(size_t) MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream);
+XBT_PUBLIC(m_file_t) MSG_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(int) MSG_file_close(const char* storage, m_file_t fp);
+XBT_PUBLIC(int) MSG_file_stat(const char* storage, int fd, void* 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(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* path, const char* mode);
-XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
-XBT_PUBLIC(int) simcall_file_stat(int fd, void* buf);
+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(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, int fd, void* buf);
SG_END_DECL()
#endif /* _SIMIX_SIMIX_H */
*/
typedef struct surf_storage_model_extension_public {
- surf_action_t(*open) (void *workstation, const char* path, const char* mode);
- 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, int fd, void* buf);
- void* (*create_resource) (const char* id, const char* model,
- const char* content, xbt_dict_t properties);
+ surf_action_t(*open) (void *storage, 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);
+ surf_action_t(*stat) (void *storage, int fd, void* buf);
+ void* (*create_resource) (const char* id, const char* model,const char* type_id,
+ const char* content, xbt_dict_t storage_properties);
} s_surf_model_extension_storage_t;
/** \brief Workstation model extension public
double amount, double rate);
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* path, const char* mode);
- 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, int fd, void* buf);
+ 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, int fd, void* buf);
int (*link_shared) (const void *link);
xbt_dict_t(*get_properties) (const void *resource);
void* (*link_create_resource) (const char *name,
static inline void *surf_network_resource_by_name(const char *name){
return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
}
+static inline void *surf_storage_resource_by_name(const char *name){
+ return xbt_lib_get_or_null(storage_lib, name, SURF_STORAGE_LEVEL);
+}
typedef struct surf_resource {
surf_model_t model;
typedef struct s_storage_type {
char *model;
char *content;
- xbt_dict_t properties;
char *type_id;
+ xbt_dict_t properties;
} s_storage_type_t, *storage_type_t;
typedef struct s_mount {
- char *type_id;
+ char *id;
char *name;
} s_mount_t, *mount_t;
// FILE
-size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream)
+size_t MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream)
{
- return simcall_file_read(ptr, size, nmemb, (smx_file_t)stream);
+ return simcall_file_read(storage, ptr, size, nmemb, (smx_file_t)stream);
}
-size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream)
+size_t MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream)
{
- return simcall_file_write(ptr, size, nmemb, (smx_file_t)stream);
+ return simcall_file_write(storage, ptr, size, nmemb, (smx_file_t)stream);
}
-m_file_t MSG_file_open(const char* path, const char* mode)
+m_file_t MSG_file_open(const char* storage, const char* path, const char* mode)
{
- return (m_file_t) simcall_file_open(path, mode);
+ return (m_file_t) simcall_file_open(storage, path, mode);
}
-int MSG_file_close(m_file_t fp)
+int MSG_file_close(const char* storage, m_file_t fp)
{
- return simcall_file_close((smx_file_t)fp);
+ return simcall_file_close(storage, (smx_file_t)fp);
}
-int MSG_file_stat(int fd, void* buf)
+int MSG_file_stat(const char* storage, int fd, void* buf)
{
- return simcall_file_stat(fd, buf);
+ return simcall_file_stat(storage, fd, buf);
}
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, void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+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 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, ptr, size, nmemb, (surf_file_t)stream),
+ action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, storage, ptr, size, nmemb, (surf_file_t)stream),
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 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 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, ptr, size, nmemb, (surf_file_t)stream);
+ action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, storage, ptr, size, nmemb, (surf_file_t)stream);
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.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* path, const char* mode)
+smx_action_t SIMIX_file_open(smx_process_t process ,const char* storage, 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, path, mode);
+ action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, storage, 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, smx_file_t fp)
+smx_action_t SIMIX_file_close(smx_process_t process ,const char* storage, 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, (surf_file_t)fp);
+ action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, storage, (surf_file_t)fp);
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, int fd, void* buf)
+smx_action_t SIMIX_file_stat(smx_process_t process ,const char* storage, int fd, void* 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, fd, buf);
+ action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, storage, fd, buf);
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, 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* path, const char* mode);
-smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp);
-smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf);
+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_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, int fd, void* 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* 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;
int fd;
//Next should be struct stat* buf
void* buf;
return simcall->sem_get_capacity.result;
}
-size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_read(const char* storage, 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 void* ptr, size_t size, size_t nmemb, smx_file_t stream)
+size_t simcall_file_write(const char* storage, 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* path, const char* mode)
+smx_file_t simcall_file_open(const char* storage, 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.path = path;
simcall->file_open.mode = mode;
SIMIX_simcall_push(simcall->issuer);
return simcall->file_open.result;
}
-int simcall_file_close(smx_file_t fp)
+int simcall_file_close(const char* storage, 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(int fd, void* buf)
+int simcall_file_stat(const char* storage, int fd, void* buf)
{
smx_simcall_t simcall = SIMIX_simcall_mine();
simcall->call = SIMCALL_FILE_STAT;
+ simcall->file_stat.storage = storage;
simcall->file_stat.fd = fd;
simcall->file_stat.buf = buf;
SIMIX_simcall_push(simcall->issuer);