From: suter Date: Tue, 11 Jun 2013 08:28:09 +0000 (+0200) Subject: get rid of "mode" parameter in the open file function. It wasn't used X-Git-Tag: v3_9_90~289 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8b1bc235e2747a7705c534c0fdcb0bc1bb8fb499 get rid of "mode" parameter in the open file function. It wasn't used anyway. --- diff --git a/examples/msg/io/file.c b/examples/msg/io/file.c index 3fca676679..bcd2d94223 100644 --- a/examples/msg/io/file.c +++ b/examples/msg/io/file.c @@ -38,13 +38,13 @@ int host(int argc, char *argv[]) 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")) - file = MSG_file_open(mount,FILENAME2,"rw"); + file = MSG_file_open(mount,FILENAME2); 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")) - 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); diff --git a/examples/msg/io/file_unlink.c b/examples/msg/io/file_unlink.c index e4ddfbf77d..60dcadc25f 100644 --- a/examples/msg/io/file_unlink.c +++ b/examples/msg/io/file_unlink.c @@ -36,7 +36,7 @@ int host(int argc, char *argv[]) // 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); @@ -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); - 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 diff --git a/include/msg/msg.h b/include/msg/msg.h index 3654b07558..3a342b76e7 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -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); -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); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index c968eeb0dc..434aef513e 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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, - double max_duration); + double max_duration); 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); diff --git a/src/bindings/java/jmsg_file.c b/src/bindings/java/jmsg_file.c index 9266483085..bf16d306ac 100644 --- a/src/bindings/java/jmsg_file.c +++ b/src/bindings/java/jmsg_file.c @@ -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 -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 *mode = (*env)->GetStringUTFChars(env, jmode, 0); 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); - (*env)->ReleaseStringUTFChars(env, jmode, mode); } JNIEXPORT jlong JNICALL Java_org_simgrid_msg_File_read(JNIEnv *env, jobject jfile, jlong jsize, jlong jnmemb) { diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index b2a69d2f96..cd77c27d33 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -225,7 +225,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(*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); @@ -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 */ - 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); diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 61d6f09fdb..5049e0f136 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -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 - * 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" @@ -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 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 */ -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); - file->simdata->smx_file = simcall_file_open(mount, path, mode); + file->simdata->smx_file = simcall_file_open(mount, path); return file; } diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index eb4eac7597..5106fcf248 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -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, - 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; } -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; @@ -118,7 +119,8 @@ smx_action_t SIMIX_file_open(smx_process_t process ,const char* mount, const cha #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); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 1da45b6f29..6bc9f9f7cb 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -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, - 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); -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_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); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index f527d9febc..e901819bdd 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -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_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 \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 5765041fd7..7cff1776c8 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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 */ -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); } /** diff --git a/src/surf/storage.c b/src/surf/storage.c index 242e5af81b..8d18f31d88 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -98,7 +98,8 @@ static surf_action_t storage_action_unlink(void *storage, surf_file_t stream) 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; diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 245b68454e..7d7c93b293 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -326,12 +326,13 @@ static storage_t find_storage_on_mount_list(void *workstation,const char* storag 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; - 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)