From ec4656ceb7707c85a2228f23d88aae20798e4755 Mon Sep 17 00:00:00 2001 From: suter Date: Thu, 6 Jun 2013 19:05:56 +0200 Subject: [PATCH] fp => fd (for file descriptor) --- examples/msg/io/file.c | 3 ++- include/msg/msg.h | 2 +- src/include/surf/surf.h | 2 +- src/msg/msg_io.c | 12 ++++++------ src/surf/storage.c | 12 ++++++------ src/surf/workstation.c | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index 6a6cc805a9..3fca676679 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -56,7 +56,8 @@ int host(int argc, char *argv[]) XBT_INFO("\tHave written %zu on %s",write,file->name); read = MSG_file_read(ptr,110000,sizeof(char*),file); // Read for 110KB - XBT_INFO("\tHave read %zu on %s",read,file->name); + XBT_INFO("\tHave read %zu on %s (of size %zu)",read,file->name, + MSG_file_get_size(file)); XBT_INFO("\tClose file '%s'",file->name); MSG_file_close(file); diff --git a/include/msg/msg.h b/include/msg/msg.h index 2ab76ca341..3654b07558 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -74,7 +74,7 @@ XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void); 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_close(msg_file_t fd); XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd); XBT_PUBLIC(int) MSG_file_unlink(msg_file_t fd); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index e4e6b168ed..025acee757 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -226,7 +226,7 @@ typedef struct surf_network_model_extension_public { typedef struct surf_storage_model_extension_public { 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(*close) (void *storage, surf_file_t fd); surf_action_t(*read) (void *storage, void* ptr, double 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, surf_file_t stream); diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 09188a355c..a61f4b1d9f 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -76,15 +76,15 @@ msg_file_t MSG_file_open(const char* mount, const char* path, const char* mode) /** \ingroup msg_file_management * \brief Close the file * - * \param fp is the file to close + * \param fd is the file to close * \return 0 on success or 1 on error */ -int MSG_file_close(msg_file_t fp) +int MSG_file_close(msg_file_t fd) { - int res = simcall_file_close(fp->simdata->smx_file); - free(fp->name); - xbt_free(fp->simdata); - xbt_free(fp); + int res = simcall_file_close(fd->simdata->smx_file); + free(fd->name); + xbt_free(fd->simdata); + xbt_free(fd); return res; } diff --git a/src/surf/storage.c b/src/surf/storage.c index c503a22fe5..271bb0b47e 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -124,22 +124,22 @@ static surf_action_t storage_action_open(void *storage, const char* mount, const return action; } -static surf_action_t storage_action_close(void *storage, surf_file_t fp) +static surf_action_t storage_action_close(void *storage, surf_file_t fd) { - char *filename = fp->name; - XBT_DEBUG("\tClose file '%s' size '%zu'",filename,fp->size); + char *filename = fd->name; + XBT_DEBUG("\tClose file '%s' size '%zu'",filename,fd->size); // unref write actions from storage surf_action_storage_t write_action; unsigned int i; xbt_dynar_foreach(((storage_t)storage)->write_actions,i,write_action) { - if ((write_action->generic_lmm_action.generic_action.file) == fp) { + if ((write_action->generic_lmm_action.generic_action.file) == fd) { xbt_dynar_cursor_rm(((storage_t)storage)->write_actions, &i); storage_action_unref((surf_action_t) write_action); } } - free(fp->name); - xbt_free(fp); + free(fd->name); + xbt_free(fd); surf_action_t action = storage_action_execute(storage,0, CLOSE); return action; } diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 4d45d1c1e8..bcb2578664 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -334,12 +334,12 @@ static surf_action_t ws_action_open(void *workstation, const char* mount, const return model->extension.storage.open(st, mount, path, mode); } -static surf_action_t ws_action_close(void *workstation, surf_file_t fp) +static surf_action_t ws_action_close(void *workstation, surf_file_t fd) { - storage_t st = find_storage_on_mount_list(workstation, fp->storage); + storage_t st = find_storage_on_mount_list(workstation, fd->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); + return model->extension.storage.close(st, fd); } static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream) -- 2.20.1