XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void);
XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data);
XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
+XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
/************************** AS Router handling ************************************/
XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
XBT_PUBLIC(xbt_dict_t) MSG_as_router_get_properties(const char* asr);
XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
+XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
/************************** AS router **********************************/
XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
surf_action_t(*write) (void *storage, size_t size, surf_file_t fd);
surf_action_t(*stat) (void *storage, surf_file_t fd);
surf_action_t(*ls) (void *storage, const char *path);
- xbt_dict_t(*get_properties) (const void *resource);
+ xbt_dict_t(*get_properties) (const void *storage);
+ xbt_dict_t(*get_content) (void *storage);
} s_surf_model_extension_storage_t;
/** \ingroup SURF_models
static inline void *surf_workstation_resource_priv(const void *host){
return xbt_lib_get_level((void *)host, SURF_WKS_LEVEL);
}
-static inline void *surf_storage_resource_priv(const void *host){
- return xbt_lib_get_level((void *)host, SURF_STORAGE_LEVEL);
+static inline void *surf_storage_resource_priv(const void *storage){
+ return xbt_lib_get_level((void *)storage, SURF_STORAGE_LEVEL);
}
static inline void *surf_cpu_resource_by_name(const char *name) {
*
* \brief Returns the user data of a #msg_storage_t.
*
- * This functions checks whether \a storage is a valid pointer or not and return
+ * This functions checks whether \a storage is a valid pointer or not and returns
the user data associated to \a storage if it is possible.
*/
void *MSG_storage_get_data(msg_storage_t storage)
return SIMIX_storage_get_data(storage);
}
+/** \ingroup msg_storage_management
+ *
+ * \brief Returns the content (file list) of a #msg_storage_t.
+ * \param storage a storage
+ */
+xbt_dict_t MSG_storage_get_content(msg_storage_t storage){
+
+ return SIMIX_storage_get_content(storage);
+}
void* SIMIX_pre_storage_get_data(smx_simcall_t simcall,smx_storage_t storage){
return SIMIX_storage_get_data(storage);
}
+
void* SIMIX_storage_get_data(smx_storage_t storage){
xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
return SIMIX_storage_priv(storage)->data;
}
+xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage){
+ return SIMIX_storage_get_content(storage);
+}
+
+xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage){
+ xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
+ return surf_storage_model->extension.storage.get_content(storage);
+}
+
void SIMIX_post_io(smx_action_t action)
{
xbt_fifo_item_t i;
void SIMIX_pre_storage_set_data(smx_simcall_t, smx_storage_t, void*);
void* SIMIX_pre_storage_get_data(smx_simcall_t, smx_storage_t);
+xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage);
+xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage);
+
void SIMIX_post_io(smx_action_t action);
void SIMIX_io_destroy(smx_action_t action);
void SIMIX_io_finish(smx_action_t action);
return surf_resource_properties(surf_storage_resource_priv(storage));
}
+static xbt_dict_t storage_get_content(void *storage)
+{
+ /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
+ /* surf_action_t action = storage_action_execute(storage,0, LS); */
+ xbt_dict_t content_dict = xbt_dict_new();
+
+ xbt_dict_cursor_t cursor = NULL;
+ char *file;
+ size_t size;
+
+ xbt_dict_foreach(((storage_t)storage)->content,cursor,file,size)
+ xbt_dict_set(content_dict,file,&size,NULL);
+
+ return content_dict;
+}
+
static void* storage_create_resource(const char* id, const char* model,
const char* type_id, const char* content_name, const char* content_type, xbt_dict_t properties){
storage_t storage = NULL;
surf_storage_model->extension.storage.read = storage_action_read;
surf_storage_model->extension.storage.write = storage_action_write;
surf_storage_model->extension.storage.ls = storage_action_ls;
-
surf_storage_model->extension.storage.get_properties = storage_get_properties;
+ surf_storage_model->extension.storage.get_content = storage_get_content;
if (!storage_maxmin_system) {
storage_maxmin_system = lmm_system_new(storage_selective_update);