Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of "mode" parameter in the open file function. It wasn't used
authorsuter <frederic.suter@cc.in2p3.fr>
Tue, 11 Jun 2013 08:28:09 +0000 (10:28 +0200)
committersuter <frederic.suter@cc.in2p3.fr>
Tue, 11 Jun 2013 09:05:08 +0000 (11:05 +0200)
anyway.

13 files changed:
examples/msg/io/file.c
examples/msg/io/file_unlink.c
include/msg/msg.h
include/simgrid/simix.h
src/bindings/java/jmsg_file.c
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/storage.c
src/surf/workstation.c

index 3fca676..bcd2d94 100644 (file)
@@ -38,13 +38,13 @@ int host(int argc, char *argv[])
   size_t read,write;
 
   if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
   size_t read,write;
 
   if(!strcmp(MSG_process_get_name(MSG_process_self()),"0"))
-    file = MSG_file_open(mount,FILENAME1,"rw");
+    file = MSG_file_open(mount,FILENAME1);
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"1"))
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"1"))
-    file = MSG_file_open(mount,FILENAME2,"rw");
+    file = MSG_file_open(mount,FILENAME2);
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"2"))
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"2"))
-    file = MSG_file_open(mount,FILENAME3,"rw");
+    file = MSG_file_open(mount,FILENAME3);
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"3"))
   else if(!strcmp(MSG_process_get_name(MSG_process_self()),"3"))
-    file = MSG_file_open(mount,FILENAME4,"rw");
+    file = MSG_file_open(mount,FILENAME4);
   else xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
 
   XBT_INFO("\tOpen file '%s'",file->name);
   else xbt_die("FILENAME NOT DEFINED %s",MSG_process_get_name(MSG_process_self()));
 
   XBT_INFO("\tOpen file '%s'",file->name);
index e4ddfbf..60dcadc 100644 (file)
@@ -36,7 +36,7 @@ int host(int argc, char *argv[])
 
   // First open
   XBT_INFO("\tOpen file '%s'",FILENAME1);
 
   // First open
   XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(mount,FILENAME1,"rw");
+  file = MSG_file_open(mount,FILENAME1);
 
   // Unlink the file
   XBT_INFO("\tUnlink file '%s'",file->name);
 
   // Unlink the file
   XBT_INFO("\tUnlink file '%s'",file->name);
@@ -44,7 +44,7 @@ int host(int argc, char *argv[])
 
   // Re Open the file wich is in fact created
   XBT_INFO("\tOpen file '%s'",FILENAME1);
 
   // Re Open the file wich is in fact created
   XBT_INFO("\tOpen file '%s'",FILENAME1);
-  file = MSG_file_open(mount,FILENAME1,"rw");
+  file = MSG_file_open(mount,FILENAME1);
 
   // Write into the new file
   write = MSG_file_write(ptr,100000,sizeof(char*),file);  // Write for 100Ko
 
   // Write into the new file
   write = MSG_file_write(ptr,100000,sizeof(char*),file);  // Write for 100Ko
index 3654b07..3a342b7 100644 (file)
@@ -73,7 +73,7 @@ XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
 /************************** File handling ***********************************/
 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);
 /************************** File handling ***********************************/
 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(msg_file_t) MSG_file_open(const char* mount, const char* path);
 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_close(msg_file_t fd);
 XBT_PUBLIC(size_t) MSG_file_get_size(msg_file_t fd);
 
index c968eeb..434aef5 100644 (file)
@@ -457,12 +457,14 @@ XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
 XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
 XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
-                                           double max_duration);
+                                             double max_duration);
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
-XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
+XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb,
+                                     smx_file_t stream);
+XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size,
+                                      size_t nmemb, smx_file_t stream);
+XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
 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(int) simcall_file_close(smx_file_t fd);
 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
 XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
index 9266483..bf16d30 100644 (file)
@@ -24,18 +24,16 @@ Java_org_simgrid_msg_File_nativeInit(JNIEnv *env, jclass cls) {
   xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
 }
 JNIEXPORT void JNICALL
   xbt_assert((jfile_field_bind != NULL), "Can't find \"bind\" field in File class.");
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath, jobject jmode) {
+Java_org_simgrid_msg_File_open(JNIEnv *env, jobject jfile, jobject jstorage, jobject jpath) {
   const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
   const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
   const char *storage = (*env)->GetStringUTFChars(env, jstorage, 0);
   const char *path = (*env)->GetStringUTFChars(env, jpath, 0);
-  const char *mode = (*env)->GetStringUTFChars(env, jmode, 0);
   msg_file_t file;
 
   msg_file_t file;
 
-  file = MSG_file_open(storage, path, mode);
+  file = MSG_file_open(storage, path);
   jfile_bind(env, jfile, file);
 
   (*env)->ReleaseStringUTFChars(env, jstorage, storage);
   (*env)->ReleaseStringUTFChars(env, jpath, path);
   jfile_bind(env, jfile, file);
 
   (*env)->ReleaseStringUTFChars(env, jstorage, storage);
   (*env)->ReleaseStringUTFChars(env, jpath, path);
-  (*env)->ReleaseStringUTFChars(env, jmode, mode);
 }
 JNIEXPORT jlong JNICALL
 Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
 }
 JNIEXPORT jlong JNICALL
 Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) {
index b2a69d2..cd77c27 100644 (file)
@@ -225,7 +225,7 @@ typedef struct surf_network_model_extension_public {
  */
 
 typedef struct surf_storage_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(*open) (void *storage, const char* mount, const char* path);
   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(*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);
@@ -260,7 +260,7 @@ typedef struct surf_workstation_model_extension_public {
                                           double rate);
   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
                                           double rate);
   double (*get_link_bandwidth) (const void *link);                                         /**< Return the current bandwidth of a network link */
   double (*get_link_latency) (const void *link);                                           /**< Return the current latency of a network link */
-  surf_action_t(*open) (void *workstation, const char* storage, const char* path, const char* mode);
+  surf_action_t(*open) (void *workstation, const char* storage, const char* path);
   surf_action_t(*close) (void *workstation, surf_file_t fd);
   surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*close) (void *workstation, surf_file_t fd);
   surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream);
   surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream);
index 61d6f09..5049e0f 100644 (file)
@@ -1,8 +1,8 @@
-/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. The SimGrid Team.
- * All rights reserved.                                                                  */
+/* Copyright (c) 2004 - 2013. The SimGrid Team.
+ * All rights reserved.                                                       */
 
 /* This program is free software; you can redistribute it and/or modify it
 
 /* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package.              */
+ * under the terms of the license (GNU LGPL) which comes with this package.   */
 
 #include "msg_private.h"
 #include "xbt/log.h"
 
 #include "msg_private.h"
 #include "xbt/log.h"
@@ -52,24 +52,15 @@ size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, msg_file_t str
  *
  * \param mount is the mount point where find the file is located
  * \param path is the file location on the storage
  *
  * \param mount is the mount point where find the file is located
  * \param path is the file location on the storage
- * \param mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.):
- *      r      Open text file for reading.  The stream is positioned at the beginning of the file.
- *      r+     Open for reading and writing.  The stream is positioned at the beginning of the file.
- *      w      Truncate file to zero length or create text file for writing.  The stream is positioned at the beginning of the file.
- *      w+     Open for reading and writing.  The file is created if it does not exist, otherwise it is truncated.  The stream is positioned at the
- *             beginning of the file.
- *      a      Open for appending (writing at end of file).  The file is created if it does not exist.  The stream is positioned at the end of the file.
- *      a+     Open for reading and appending (writing at end of file).  The file is created if it does not exist.  The initial file position for  reading
- *             is at the beginning of the file, but output is always appended to the end of the file.
  *
  * \return An #msg_file_t associated to the file
  */
  *
  * \return An #msg_file_t associated to the file
  */
-msg_file_t MSG_file_open(const char* mount, const char* path, const char* mode)
+msg_file_t MSG_file_open(const char* mount, const char* path)
 {
   msg_file_t file = xbt_new(s_msg_file_t,1);
   file->name = strdup(path);
   file->simdata = xbt_new0(s_simdata_file_t,1);
 {
   msg_file_t file = xbt_new(s_msg_file_t,1);
   file->name = strdup(path);
   file->simdata = xbt_new0(s_simdata_file_t,1);
-  file->simdata->smx_file = simcall_file_open(mount, path, mode);
+  file->simdata->smx_file = simcall_file_open(mount, path);
   return file;
 }
 
   return file;
 }
 
index eb4eac7..5106fcf 100644 (file)
@@ -91,14 +91,15 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz
 
 //SIMIX FILE OPEN
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
 
 //SIMIX FILE OPEN
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
-                        const char* path, const char* mode)
+                         const char* path)
 {
 {
-  smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path, mode);
+  smx_action_t action = SIMIX_file_open(simcall->issuer, mount, path);
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
   xbt_fifo_push(action->simcalls, simcall);
   simcall->issuer->waiting_action = action;
 }
 
-smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const char* path, const char* mode)
+smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount,
+                             const char* path)
 {
   smx_action_t action;
   smx_host_t host = process->smx_host;
 {
   smx_action_t action;
   smx_host_t host = process->smx_host;
@@ -118,7 +119,8 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const cha
 #endif
 
   action->io.host = host;
 #endif
 
   action->io.host = host;
-  action->io.surf_io = surf_workstation_model->extension.workstation.open(host, mount, path, mode);
+  action->io.surf_io =
+      surf_workstation_model->extension.workstation.open(host, mount, path);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
 
   surf_workstation_model->action_data_set(action->io.surf_io, action);
   XBT_DEBUG("Create io action %p", action);
index 1da45b6..6bc9f9f 100644 (file)
@@ -15,19 +15,23 @@ void SIMIX_pre_file_read(smx_simcall_t simcall, void *ptr, size_t size,
 void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
                          size_t nmemb, smx_file_t strea);
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
 void SIMIX_pre_file_write(smx_simcall_t simcall, const void *ptr, size_t size,
                          size_t nmemb, smx_file_t strea);
 void SIMIX_pre_file_open(smx_simcall_t simcall, const char* mount,
-                        const char* path, const char* mode);
+                        const char* path);
 void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
 void SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
 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);
 
 void SIMIX_pre_file_close(smx_simcall_t simcall, smx_file_t fd);
 void SIMIX_pre_file_unlink(smx_simcall_t simcall, smx_file_t fd);
 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);
 
-smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
-smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path, const char* mode);
+smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size,
+                             size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr,
+                              size_t size, size_t nmemb, smx_file_t stream);
+smx_action_t SIMIX_file_open(smx_process_t process, const char* storage,
+                             const char* path);
 smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd);
 smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
 smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fd);
 smx_action_t SIMIX_file_unlink(smx_process_t process, smx_file_t fd);
-smx_action_t SIMIX_file_ls(smx_process_t process, const char *mount, const char *path);
+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);
 
 void SIMIX_post_io(smx_action_t action);
 size_t SIMIX_file_get_size(smx_process_t process, smx_file_t fd);
 
 void SIMIX_post_io(smx_action_t action);
index f527d9f..e901819 100644 (file)
@@ -341,7 +341,7 @@ ACTION(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem_acquire_timeout, WITHOUT_ANSWER, TVOID(r
 ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
 ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
 ACTION(SIMCALL_SEM_GET_CAPACITY, sem_get_capacity, WITH_ANSWER, TINT(result), TSPEC(sem, smx_sem_t)) sep \
 ACTION(SIMCALL_FILE_READ, file_read, WITHOUT_ANSWER, TDOUBLE(result), TPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_WRITE, file_write, WITHOUT_ANSWER, TSIZE(result), TCPTR(ptr), TSIZE(size), TSIZE(nmemb), TSPEC(stream, smx_file_t)) sep \
-ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path), TSTRING(mode)) sep \
+ACTION(SIMCALL_FILE_OPEN, file_open, WITHOUT_ANSWER, TSPEC(result, smx_file_t), TSTRING(mount), TSTRING(path)) sep \
 ACTION(SIMCALL_FILE_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITHOUT_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_CLOSE, file_close, WITHOUT_ANSWER, TINT(result), TSPEC(fd, smx_file_t)) sep \
 ACTION(SIMCALL_FILE_UNLINK, file_unlink, WITHOUT_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 \
index 5765041..7cff177 100644 (file)
@@ -1109,9 +1109,9 @@ size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t
  * \ingroup simix_file_management
  * \brief
  */
  * \ingroup simix_file_management
  * \brief
  */
-smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
+smx_file_t simcall_file_open(const char* mount, const char* path)
 {
 {
-  return simcall_BODY_file_open(mount, path, mode);
+  return simcall_BODY_file_open(mount, path);
 }
 
 /**
 }
 
 /**
index 242e5af..8d18f31 100644 (file)
@@ -98,7 +98,8 @@ static surf_action_t storage_action_unlink(void *storage, surf_file_t stream)
   return action;
 }
 
   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;
 {
   XBT_DEBUG("\tOpen file '%s'",path);
   xbt_dict_t content_dict = ((storage_t)storage)->content;
index 245b684..7d7c93b 100644 (file)
@@ -326,12 +326,13 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* storag
   return st;
 }
 
   return st;
 }
 
-static surf_action_t ws_action_open(void *workstation, const char* mount, const char* path, const char* mode)
+static surf_action_t ws_action_open(void *workstation, const char* mount,
+                                    const char* path)
 {
   storage_t st = find_storage_on_mount_list(workstation, mount);
   XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
   surf_model_t model = st->generic_resource.model;
 {
   storage_t st = find_storage_on_mount_list(workstation, mount);
   XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
   surf_model_t model = st->generic_resource.model;
-  return model->extension.storage.open(st, mount, path, mode);
+  return model->extension.storage.open(st, mount, path);
 }
 
 static surf_action_t ws_action_close(void *workstation, surf_file_t fd)
 }
 
 static surf_action_t ws_action_close(void *workstation, surf_file_t fd)