Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaning step: uniform naming (stream to fd) + some cuts at 80
[simgrid.git] / src / surf / storage.c
index 271bb0b..1e8c2a4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. The SimGrid Team.
+/* Copyright (c) 2004 - 2013. The SimGrid Team.
  * All rights reserved.                                                                 */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -81,30 +81,25 @@ static surf_action_t storage_action_ls(void *storage, const char* path)
   return action;
 }
 
-static surf_action_t storage_action_get_size(void *storage, surf_file_t stream)
-{
-  surf_action_t action = storage_action_execute(storage,0,GET_SIZE);
-  return action;
-}
-
-static surf_action_t storage_action_unlink(void *storage, surf_file_t stream)
+static surf_action_t storage_action_unlink(void *storage, surf_file_t fd)
 {
   surf_action_t action = storage_action_execute(storage,0, UNLINK);
 
   // Add memory to storage
-  ((storage_t)storage)->used_size -= stream->size;
+  ((storage_t)storage)->used_size -= fd->size;
 
   // Remove the file from storage
   xbt_dict_t content_dict = ((storage_t)storage)->content;
-  xbt_dict_remove(content_dict,stream->name);
+  xbt_dict_remove(content_dict,fd->name);
 
-  free(stream->name);
-  xbt_free(stream);
+  free(fd->name);
+  xbt_free(fd);
 
   return action;
 }
 
-static surf_action_t storage_action_open(void *storage, const char* mount, const char* path, const char* mode)
+static surf_action_t storage_action_open(void *storage, const char* mount,
+                                         const char* path)
 {
   XBT_DEBUG("\tOpen file '%s'",path);
   xbt_dict_t content_dict = ((storage_t)storage)->content;
@@ -144,21 +139,24 @@ static surf_action_t storage_action_close(void *storage, surf_file_t fd)
   return action;
 }
 
-static surf_action_t storage_action_read(void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_read(void *storage, void* ptr, double size,
+                                         size_t nmemb, surf_file_t fd)
 {
-  if(size > stream->size)
-    size = stream->size;
+  if(size > fd->size)
+    size = fd->size;
   surf_action_t action = storage_action_execute(storage,size,READ);
   return action;
 }
 
-static surf_action_t storage_action_write(void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
+static surf_action_t storage_action_write(void *storage, const void* ptr,
+                                          size_t size, size_t nmemb,
+                                          surf_file_t fd)
 {
-  char *filename = stream->name;
-  XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,stream->size);
+  char *filename = fd->name;
+  XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
 
   surf_action_t action = storage_action_execute(storage,size,WRITE);
-  action->file = stream;
+  action->file = fd;
 
   // If the storage is full
   if(((storage_t)storage)->used_size==((storage_t)storage)->size) {
@@ -195,7 +193,6 @@ static surf_action_t storage_action_execute (void *storage, double size, e_surf_
   case STAT:
   case UNLINK:
   case LS:
-  case GET_SIZE:
     break;
   case READ:
     lmm_expand(storage_maxmin_system, STORAGE->constraint_read,
@@ -501,7 +498,6 @@ static void surf_storage_model_init_internal(void)
   surf_storage_model->extension.storage.write = storage_action_write;
   surf_storage_model->extension.storage.unlink = storage_action_unlink;
   surf_storage_model->extension.storage.ls = storage_action_ls;
-  surf_storage_model->extension.storage.get_size = storage_action_get_size;
 
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);