Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fp => fd (for file descriptor)
authorsuter <frederic.suter@cc.in2p3.fr>
Thu, 6 Jun 2013 17:05:56 +0000 (19:05 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Thu, 6 Jun 2013 17:05:56 +0000 (19:05 +0200)
examples/msg/io/file.c
include/msg/msg.h
src/include/surf/surf.h
src/msg/msg_io.c
src/surf/storage.c
src/surf/workstation.c

index 6a6cc80..3fca676 100644 (file)
@@ -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);
index 2ab76ca..3654b07 100644 (file)
@@ -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);
index e4e6b16..025acee 100644 (file)
@@ -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);
index 09188a3..a61f4b1 100644 (file)
@@ -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;
 }
 
index c503a22..271bb0b 100644 (file)
@@ -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;
 }
index 4d45d1c..bcb2578 100644 (file)
@@ -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)