/* ******************************** File ************************************ */
typedef struct simdata_file *simdata_file_t;
+typedef struct s_file_info {
+ size_t size;
+ char* mount_point;
+ char* storageId;
+ char* storage_type;
+ char* content_type;
+} s_file_info_t, *msg_file_info_t;
+
typedef struct msg_file {
char *fullname; /**< @brief file full name (path+name)*/
simdata_file_t simdata; /**< @brief simulator data */
void *data; /**< @brief user data */
+ msg_file_info_t info;
} s_msg_file_t;
/** @brief File datatype.
XBT_PUBLIC(xbt_dict_t) MSG_file_ls(const char *mount, const char *path);
XBT_PUBLIC(size_t) MSG_storage_get_free_size(msg_storage_t sd);
+XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd);
/************************** 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(int) simcall_file_unlink(smx_file_t fd);
XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
XBT_PUBLIC(size_t) simcall_file_get_size(smx_file_t fd);
+XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
XBT_PUBLIC(size_t) simcall_storage_get_free_size (smx_storage_t storage);
/************************** AS router **********************************/
XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
int(*unlink) (void *workstation, surf_file_t fd);
surf_action_t(*ls) (void *workstation, const char* mount, const char *path);
size_t (*get_size) (void *workstation, surf_file_t fd);
+ xbt_dynar_t (*get_info) (void *workstation, surf_file_t fd);
int (*link_shared) (const void *link);
xbt_dict_t(*get_properties) (const void *resource);
*/
/********************************* File **************************************/
-
+void __MSG_file_get_info(msg_file_t fd){
+ xbt_dynar_t info = simcall_file_get_info(fd->simdata->smx_file);
+ fd->info->content_type = xbt_dynar_pop_as(info, char *);
+ fd->info->storage_type = xbt_dynar_pop_as(info, char *);
+ fd->info->storageId = xbt_dynar_pop_as(info, char *);
+ fd->info->mount_point = xbt_dynar_pop_as(info, char *);
+ fd->info->size = xbt_dynar_pop_as(info, size_t);
+
+ xbt_dynar_free_container(&info);
+}
/** \ingroup msg_file_management
* \brief Display information related to a file descriptor
*
*/
void MSG_file_dump (msg_file_t fd){
- THROW_UNIMPLEMENTED;
+// THROW_UNIMPLEMENTED;
/* Update the cached information first */
-// fd->info = __MSG_file_get_info(fd);
-// XBT_INFO("File Descriptor information:\n\t\tFull name: '%s'"
-// "\n\t\tSize: %zu\n\t\tMount point: '%s'\n\t\t Storage Id: '%s'"
-// "\n\t\t Content Type: '%s'", fd->fullname, fd->info->size, NULL,NULL,NULL);
-// fd->info->mount_point, fd->info->storageId, fd->info->content_type);
+ __MSG_file_get_info(fd);
+ XBT_INFO("File Descriptor information:\n\t\tFull name: '%s'"
+ "\n\t\tSize: %zu\n\t\tMount point: '%s'\n\t\tStorage Id: '%s'"
+ "\n\t\tStorage Type: '%s'\n\t\tContent Type: '%s'",
+ fd->fullname, fd->info->size, fd->info->mount_point, fd->info->storageId,
+ fd->info->storage_type, fd->info->content_type);
}
/** \ingroup msg_file_management
msg_file_t file = xbt_new(s_msg_file_t,1);
file->fullname = xbt_strdup(fullname);
file->simdata = xbt_new0(s_simdata_file_t,1);
+ file->info = xbt_new0(s_file_info_t,1);
file->simdata->smx_file = simcall_file_open(mount, fullname);
return file;
}
int res = simcall_file_close(fd->simdata->smx_file);
free(fd->fullname);
xbt_free(fd->simdata);
+ xbt_free(fd->info);
xbt_free(fd);
return res;
}
fd->surf_file);
}
+xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd)
+{
+ return SIMIX_file_get_info(simcall->issuer, fd);
+}
+
+xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd)
+{
+ smx_host_t host = process->smx_host;
+ return surf_workstation_model->extension.workstation.get_info(host,
+ fd->surf_file);
+}
+
size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage)
{
return SIMIX_storage_get_free_size(simcall->issuer, storage);
void SIMIX_pre_file_ls(smx_simcall_t simcall,
const char* mount, const char* path);
size_t SIMIX_pre_file_get_size(smx_simcall_t simcall, smx_file_t fd);
+xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd);
smx_action_t SIMIX_file_read(smx_process_t process, size_t size,
smx_file_t fd);
smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount,
const char *path);
size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
+xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, smx_storage_t storage);
size_t SIMIX_storage_get_free_size(smx_process_t process, smx_storage_t storage);
ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITH_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
ACTION(SIMCALL_FILE_LS, file_ls, WITHOUT_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(mount), TSTRING(path)) sep \
ACTION(SIMCALL_FILE_GET_SIZE, file_get_size, WITH_ANSWER, TSIZE(result), TSPEC(fd, smx_file_t)) sep \
+ACTION(SIMCALL_FILE_GET_INFO, file_get_info, WITH_ANSWER, TSPEC(result, xbt_dynar_t), TSPEC(fd, smx_file_t)) sep \
ACTION(SIMCALL_STORAGE_GET_FREE_SIZE, storage_get_free_size, WITH_ANSWER, TSIZE(result), TSPEC(storage, smx_storage_t)) sep \
ACTION(SIMCALL_ASR_GET_PROPERTIES, asr_get_properties, WITH_ANSWER, TSPEC(result, xbt_dict_t), TSTRING(name)) sep
return simcall_BODY_file_get_size(fd);
}
+/**
+ * \ingroup simix_file_management
+ *
+ */
+xbt_dynar_t simcall_file_get_info(smx_file_t fd)
+{
+ return simcall_BODY_file_get_info(fd);
+}
+
/**
* \ingroup simix_storage_management
* \brief Return the free size on a given storage element.
char *name;
} s_mount_t, *mount_t;
-typedef struct s_file_info {
- size_t size;
- char* mount_point;
- char* storageId;
- char* content_type;
-} s_file_info_t, *surf_file_info_t;
-
typedef struct surf_file {
char *name;
char *mount;
size_t size;
- surf_file_info_t info;
} s_surf_file_t;
typedef struct surf_storage {
return fd->size;
}
+static xbt_dynar_t ws_file_get_info(void *workstation, surf_file_t fd)
+{
+ storage_t st = find_storage_on_mount_list(workstation, fd->mount);
+ xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
+ xbt_dynar_push_as(info, void *, &(fd->size));
+ xbt_dynar_push_as(info, void *, fd->mount);
+ xbt_dynar_push_as(info, void *, st->generic_resource.name);
+ xbt_dynar_push_as(info, void *, st->type_id);
+ xbt_dynar_push_as(info, void *, st->content_type);
+
+ return info;
+}
+
static size_t ws_storage_get_free_size(void *workstation, surf_storage_t storage)
{
return storage->size - storage->used_size;
surf_workstation_model->extension.workstation.unlink = ws_file_unlink;
surf_workstation_model->extension.workstation.ls = ws_action_ls;
surf_workstation_model->extension.workstation.get_size = ws_file_get_size;
+ surf_workstation_model->extension.workstation.get_info = ws_file_get_info;
surf_workstation_model->extension.workstation.get_free_size = ws_storage_get_free_size;
surf_workstation_model->extension.workstation.get_storage_list = ws_get_storage_list;
}