Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
prepare MSG_file_rcopy()
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 25 Mar 2014 10:39:35 +0000 (11:39 +0100)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 25 Mar 2014 10:39:35 +0000 (11:39 +0100)
16 files changed:
include/msg/msg.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/simcalls.in
src/simix/simcalls_generated_args_getter_setter.h
src/simix/simcalls_generated_body.c
src/simix/simcalls_generated_case.c
src/simix/simcalls_generated_enum.h
src/simix/simcalls_generated_res_getter_setter.h
src/simix/simcalls_generated_string.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_user.c
src/surf/surf_c_bindings.cpp
src/surf/workstation_interface.hpp

index f7f04a3..a625c26 100644 (file)
@@ -97,6 +97,7 @@ XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd);
 XBT_PUBLIC(void) __MSG_file_priv_free(msg_file_priv_t priv);
 XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t storage);
 XBT_PUBLIC(msg_error_t) MSG_file_move(msg_file_t fd, const char* fullpath);
+XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
 /************************** Storage handling ***********************************/
 XBT_PUBLIC(msg_host_t) MSG_get_storage_by_name(const char *name);
 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
index fb02698..6b68336 100644 (file)
@@ -499,6 +499,7 @@ XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
 XBT_PUBLIC(sg_size_t) simcall_file_tell(smx_file_t fd);
 XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_size_t offset, int origin);
 XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
+XBT_PUBLIC(int) simcall_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath);
 /*****************************   Storage   **********************************/
 XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (const char* name);
 XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (const char* name);
index c388006..16da53a 100644 (file)
@@ -701,7 +701,6 @@ XBT_PUBLIC(size_t) surf_workstation_file_tell(surf_resource_t workstation, surf_
  * @param workstation The surf workstation
  * @param fd The file descriptor
  * @param fullpath The new full path
- * @param origin Position used as a reference for the offset
  *
  * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
  */
@@ -722,6 +721,18 @@ XBT_PUBLIC(int) surf_workstation_file_move(surf_resource_t workstation, surf_fil
  */
 XBT_PUBLIC(int) surf_workstation_file_seek(surf_resource_t workstation, surf_file_t fd, sg_size_t offset, int origin);
 
+/**
+ * @brief Copy a file to another location on a remote host.
+ * @details [long description]
+ *
+ * @param workstation The surf workstation
+ * @param fd The file descriptor
+ * @param host_dest The workstation destination
+ * @param fullpath The new full path
+ *
+ * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
+ */
+XBT_PUBLIC(int) surf_workstation_file_rcopy(surf_resource_t workstation, surf_file_t fd, surf_resource_t host_dest, const char* fullpath);
 
 /**
  * @brief [brief description]
index fbaf853..0b88c8a 100644 (file)
@@ -253,6 +253,22 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath)
   return simcall_file_move(priv->simdata->smx_file, fullpath);
 }
 
+/**
+ * \ingroup msg_file_management
+ * \brief Move a file to another location on a remote host.
+ * \param fd : the file to move
+ * \param host : the remote host where the file has to be moved
+ * \param fullpath : the complete path destination on the remote host
+ * \return If successful, the function returns MSG_OK. Otherwise, it returns
+ * MSG_TASK_CANCELED.
+ */
+msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath)
+{
+  msg_file_priv_t file_priv = MSG_file_priv(file);
+  return simcall_file_rcopy(file_priv->simdata->smx_file, host, fullpath);
+}
+
+
 /**
  * \brief Destroys a file (internal call only)
  */
index 9c7a7db..f22c444 100644 (file)
@@ -119,6 +119,7 @@ file_tell True (sg_size_t) (fd, void*, smx_file_t)
 file_seek True (int) (fd, void*, smx_file_t) (offset, sg_size_t) (origin, int)
 file_get_info True (void*, xbt_dynar_t) (fd, void*, smx_file_t)
 file_move True (int) (fd, void*, smx_file_t) (fullpath, const char*)
+file_rcopy True (int) (fd, void*, smx_file_t) (host, void*, smx_host_t) (fullpath, const char*)
 storage_get_free_size True (sg_size_t) (name, const char*)
 storage_get_used_size True (sg_size_t) (name, const char*)
 storage_get_properties True (void*, xbt_dict_t) (storage, void*, smx_storage_t)
index 55ba148..1e1c421 100644 (file)
@@ -1154,6 +1154,24 @@ static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall
 static inline void simcall_file_move__set__fullpath(smx_simcall_t simcall, const char* arg){
     simcall->args[1].cc = arg;
 }
+static inline smx_file_t simcall_file_rcopy__get__fd(smx_simcall_t simcall){
+  return (smx_file_t) simcall->args[0].dp;
+}
+static inline void simcall_file_rcopy__set__fd(smx_simcall_t simcall, void* arg){
+    simcall->args[0].dp = arg;
+}
+static inline smx_host_t simcall_file_rcopy__get__host(smx_simcall_t simcall){
+  return (smx_host_t) simcall->args[1].dp;
+}
+static inline void simcall_file_rcopy__set__host(smx_simcall_t simcall, void* arg){
+    simcall->args[1].dp = arg;
+}
+static inline const char* simcall_file_rcopy__get__fullpath(smx_simcall_t simcall){
+  return  simcall->args[2].cc;
+}
+static inline void simcall_file_rcopy__set__fullpath(smx_simcall_t simcall, const char* arg){
+    simcall->args[2].cc = arg;
+}
 static inline const char* simcall_storage_get_free_size__get__name(smx_simcall_t simcall){
   return  simcall->args[0].cc;
 }
index 5e2bf9e..885dc4b 100644 (file)
     }    
     return self->simcall.result.i;
   }
+  inline static int simcall_BODY_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath) {
+    smx_process_t self = SIMIX_process_self();
+    self->simcall.call = SIMCALL_FILE_RCOPY;
+    memset(&self->simcall.result, 0, sizeof(self->simcall.result));
+    memset(self->simcall.args, 0, sizeof(self->simcall.args));
+    self->simcall.args[0].dp = (void*) fd;
+    self->simcall.args[1].dp = (void*) host;
+    self->simcall.args[2].cc = (const char*) fullpath;
+    if (self != simix_global->maestro_process) {
+      XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
+                SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
+      SIMIX_process_yield(self);
+    } else {
+      SIMIX_simcall_pre(&self->simcall, 0);
+    }    
+    return self->simcall.result.i;
+  }
   inline static sg_size_t simcall_BODY_storage_get_free_size(const char* name) {
     smx_process_t self = SIMIX_process_self();
     self->simcall.call = SIMCALL_STORAGE_GET_FREE_SIZE;
index 6d7bc91..bf5a699 100644 (file)
@@ -551,6 +551,11 @@ case SIMCALL_FILE_MOVE:
       SIMIX_simcall_answer(simcall);
       break;  
 
+case SIMCALL_FILE_RCOPY:
+      simcall->result.i = SIMIX_pre_file_rcopy(simcall , (smx_file_t) simcall->args[0].dp, (smx_host_t) simcall->args[1].dp,  simcall->args[2].cc);
+      SIMIX_simcall_answer(simcall);
+      break;  
+
 case SIMCALL_STORAGE_GET_FREE_SIZE:
       simcall->result.sgsz = SIMIX_pre_storage_get_free_size(simcall ,  simcall->args[0].cc);
       SIMIX_simcall_answer(simcall);
index 448c05a..5130bb2 100644 (file)
@@ -118,6 +118,7 @@ SIMCALL_FILE_TELL,
 SIMCALL_FILE_SEEK,
 SIMCALL_FILE_GET_INFO,
 SIMCALL_FILE_MOVE,
+SIMCALL_FILE_RCOPY,
 SIMCALL_STORAGE_GET_FREE_SIZE,
 SIMCALL_STORAGE_GET_USED_SIZE,
 SIMCALL_STORAGE_GET_PROPERTIES,
index 052b1f4..d339060 100644 (file)
@@ -491,6 +491,12 @@ static inline int simcall_file_move__get__result(smx_simcall_t simcall){
 static inline void simcall_file_move__set__result(smx_simcall_t simcall, int result){
     simcall->result.i = result;
 }
+static inline int simcall_file_rcopy__get__result(smx_simcall_t simcall){
+  return  simcall->result.i;
+}
+static inline void simcall_file_rcopy__set__result(smx_simcall_t simcall, int result){
+    simcall->result.i = result;
+}
 static inline sg_size_t simcall_storage_get_free_size__get__result(smx_simcall_t simcall){
   return  simcall->result.sgsz;
 }
index 0f14211..8ef57be 100644 (file)
 [SIMCALL_FILE_SEEK] = "SIMCALL_FILE_SEEK",
 [SIMCALL_FILE_GET_INFO] = "SIMCALL_FILE_GET_INFO",
 [SIMCALL_FILE_MOVE] = "SIMCALL_FILE_MOVE",
+[SIMCALL_FILE_RCOPY] = "SIMCALL_FILE_RCOPY",
 [SIMCALL_STORAGE_GET_FREE_SIZE] = "SIMCALL_STORAGE_GET_FREE_SIZE",
 [SIMCALL_STORAGE_GET_USED_SIZE] = "SIMCALL_STORAGE_GET_USED_SIZE",
 [SIMCALL_STORAGE_GET_PROPERTIES] = "SIMCALL_STORAGE_GET_PROPERTIES",
index 25c87cf..b4dc9b8 100644 (file)
@@ -301,6 +301,17 @@ int SIMIX_file_move(smx_process_t process, smx_file_t file, const char* fullpath
   return  surf_workstation_file_move(host, file->surf_file, fullpath);
 }
 
+int SIMIX_pre_file_rcopy(smx_simcall_t simcall, smx_file_t fd, smx_host_t host, const char* fullpath)
+{
+  return SIMIX_file_rcopy(simcall->issuer, fd, host, fullpath);
+}
+
+int SIMIX_file_rcopy(smx_process_t process, smx_file_t file, smx_host_t host_dest, const char* fullpath)
+{
+  smx_host_t host = process->smx_host;
+  return  surf_workstation_file_rcopy(host, file->surf_file, host_dest, fullpath);
+}
+
 sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall, const char* name)
 {
   return SIMIX_storage_get_free_size(simcall->issuer, name);
index 8a3c38d..15e2624 100644 (file)
@@ -34,6 +34,7 @@ sg_size_t SIMIX_pre_file_tell(smx_simcall_t simcall, smx_file_t fd);
 xbt_dynar_t SIMIX_pre_file_get_info(smx_simcall_t simcall, smx_file_t fd);
 int SIMIX_pre_file_seek(smx_simcall_t simcall, smx_file_t fd, sg_size_t offset, int origin);
 int SIMIX_pre_file_move(smx_simcall_t simcall, smx_file_t fd, const char* fullpath);
+int SIMIX_pre_file_rcopy(smx_simcall_t simcall, smx_file_t fd, smx_host_t dest, const char* fullpath);
 smx_action_t SIMIX_file_read(smx_process_t process, smx_file_t fd, sg_size_t size);
 smx_action_t SIMIX_file_write(smx_process_t process, smx_file_t fd, sg_size_t size);
 smx_action_t SIMIX_file_open(smx_process_t process, const char* fullpath);
@@ -46,6 +47,7 @@ sg_size_t SIMIX_file_tell(smx_process_t process, smx_file_t fd);
 xbt_dynar_t SIMIX_file_get_info(smx_process_t process, smx_file_t fd);
 int SIMIX_file_seek(smx_process_t process, smx_file_t fd, sg_size_t offset, int origin);
 int SIMIX_file_move(smx_process_t process, smx_file_t fd, const char* fullpath);
+int SIMIX_file_rcopy(smx_process_t process, smx_file_t fd, smx_host_t dest, const char* fullpath);
 
 sg_size_t SIMIX_pre_storage_get_free_size(smx_simcall_t simcall,const char* name);
 sg_size_t SIMIX_storage_get_free_size(smx_process_t process,const char* name);
index d4ecd2f..43085e4 100644 (file)
@@ -1410,6 +1410,16 @@ int simcall_file_move(smx_file_t fd, const char* fullpath)
   return simcall_BODY_file_move(fd, fullpath);
 }
 
+/**
+ * \ingroup simix_file_management
+ * \brief Copy a file to another location on a remote host.
+ *
+ */
+int simcall_file_rcopy(smx_file_t fd, smx_host_t host, const char* fullpath)
+{
+  return simcall_BODY_file_rcopy(fd, host, fullpath);
+}
+
 /**
  * \ingroup simix_storage_management
  * \brief Returns the free space size on a given storage element.
index 82e93b1..b34f4ee 100644 (file)
@@ -412,6 +412,10 @@ int surf_workstation_file_move(surf_resource_t workstation, surf_file_t fd, cons
   return get_casted_workstation(workstation)->fileMove(fd, fullpath);
 }
 
+int surf_workstation_file_rcopy(surf_resource_t workstation, surf_file_t fd, surf_resource_t host_dest, const char* fullpath){
+  return get_casted_workstation(workstation)->fileRcopy(fd, host_dest, fullpath);
+}
+
 xbt_dynar_t surf_workstation_get_vms(surf_resource_t resource){
   return get_casted_workstation(resource)->getVms();
 }
index 473b044..c472d37 100644 (file)
@@ -380,6 +380,17 @@ public:
    */
   virtual int fileMove(surf_file_t fd, const char* fullpath);
 
+  /**
+   * @brief Copy a file to another location on a remote host.
+   * @details [long description]
+   *
+   * @param fd The file descriptor
+   * @param host_dest The worstation destination
+   * @param fullpath The new full path
+   * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
+   */
+  virtual int fileRcopy(surf_file_t fd, surf_resource_t host_dest, const char* fullpath);
+
   xbt_dynar_t p_storage;
   RoutingEdgePtr p_netElm;
   CpuPtr p_cpu;