From d9e664e60bd7fab62db0f1d838efd1d7bfd4d367 Mon Sep 17 00:00:00 2001 From: Pierre Veyre Date: Thu, 26 Sep 2013 08:56:41 +0200 Subject: [PATCH] Fix MSG_storage_get_content function --- include/simgrid/simix.h | 1 + src/include/surf/surf.h | 2 +- src/msg/msg_host.c | 2 +- src/msg/msg_io.c | 4 +++- src/simix/smx_smurf_private.h | 1 + src/simix/smx_user.c | 11 +++++++++++ src/surf/storage.c | 9 +++++---- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 272829ed84..22bda35a09 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -496,6 +496,7 @@ 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); +XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage); XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host); /************************** AS router **********************************/ XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 49c1000180..5e767d2487 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -238,7 +238,7 @@ typedef struct surf_storage_model_extension_public { 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 *storage); - xbt_dict_t(*get_content) (const void *storage); + xbt_dict_t(*get_content) (void *storage); } s_surf_model_extension_storage_t; /** \ingroup SURF_models diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index a03efa9e9d..c5440ab9cd 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -364,7 +364,7 @@ xbt_dynar_t MSG_host_get_storage_content(msg_host_t host) xbt_dynar_t storage_list = simcall_host_get_storage_list(host); xbt_dynar_foreach(storage_list, i, storage_name){ storage = xbt_lib_get_elm_or_null(storage_lib,storage_name); - xbt_dict_t content = SIMIX_storage_get_content(storage); + xbt_dict_t content = simcall_storage_get_content(storage); xbt_dynar_push(contents, &content); } return contents; diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 99ac05b5e4..9612fb7e8c 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -316,8 +316,10 @@ void *MSG_storage_get_data(msg_storage_t storage) * * \brief Returns the content (file list) of a #msg_storage_t. * \param storage a storage + * \return The content of this storage element as a dict (full path file => size) */ xbt_dict_t MSG_storage_get_content(msg_storage_t storage) { - return SIMIX_storage_get_content(storage); + return SIMIX_storage_get_content(storage); + //return (simcall_storage_get_properties(storage)); } diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 2176f1ff7c..bbca42fd1f 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -360,6 +360,7 @@ ACTION(SIMCALL_FILE_GET_INFO, file_get_info, WITH_ANSWER, TSPEC(result, xbt_dyna ACTION(SIMCALL_STORAGE_GET_FREE_SIZE, storage_get_free_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) sep \ ACTION(SIMCALL_STORAGE_GET_USED_SIZE, storage_get_used_size, WITH_ANSWER, TSIZE(result), TSTRING(name)) sep \ ACTION(SIMCALL_STORAGE_GET_PROPERTIES, storage_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(storage, smx_storage_t)) sep \ +ACTION(SIMCALL_STORAGE_GET_CONTENT, storage_get_content, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSPEC(storage, smx_storage_t)) sep \ ACTION(SIMCALL_ASR_GET_PROPERTIES, asr_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(name)) sep /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index fb1e54f398..d45a92d44c 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1311,6 +1311,17 @@ xbt_dict_t simcall_storage_get_properties(smx_storage_t storage) return simcall_BODY_storage_get_properties(storage); } +/** + * \ingroup simix_storage_management + * \brief Returns a dict containing the content of a storage element. + * + * \param storage A storage element + * \return The content of this storage element as a dict (full path file => size) + */ +xbt_dict_t simcall_storage_get_content(smx_storage_t storage) +{ + return simcall_BODY_storage_get_content(storage); +} #ifdef HAVE_MC diff --git a/src/surf/storage.c b/src/surf/storage.c index 087913b5b2..14da9abd48 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -197,16 +197,17 @@ static xbt_dict_t storage_get_properties(const void *storage) return surf_resource_properties(surf_storage_resource_priv(storage)); } -static xbt_dict_t storage_get_content(const void *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); */ + /*surf_action_t action = storage_action_execute(storage,0, LS);*/ + + void *st = surf_storage_resource_priv(storage); 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_foreach(((storage_t)st)->content, cursor, file, size){ xbt_dict_set(content_dict,file,&size,NULL); } return content_dict; -- 2.20.1