From 60243e02778a95bab65ef1ab318ee2ed3f096882 Mon Sep 17 00:00:00 2001 From: Shane Snyder Date: Wed, 25 Apr 2018 17:32:16 -0500 Subject: [PATCH] expose MPIIO access and delete calls --- src/aiori-MPIIO.c | 52 +++++++++++++++++++++++------------------------ src/aiori.h | 3 +++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index 2fec74f..ac766ff 100755 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -38,10 +38,8 @@ static void *MPIIO_Open(char *, IOR_param_t *); static IOR_offset_t MPIIO_Xfer(int, void *, IOR_size_t *, IOR_offset_t, IOR_param_t *); static void MPIIO_Close(void *, IOR_param_t *); -static void MPIIO_Delete(char *, IOR_param_t *); static void MPIIO_SetVersion(IOR_param_t *); static void MPIIO_Fsync(void *, IOR_param_t *); -static int MPIIO_Access(const char *, int, IOR_param_t *); /************************** D E C L A R A T I O N S ***************************/ @@ -60,30 +58,6 @@ ior_aiori_t mpiio_aiori = { /***************************** F U N C T I O N S ******************************/ -/* - * Try to access a file through the MPIIO interface. - */ -static int MPIIO_Access(const char *path, int mode, IOR_param_t *param) -{ - MPI_File fd; - int mpi_mode = MPI_MODE_UNIQUE_OPEN; - - if ((mode & W_OK) && (mode & R_OK)) - mpi_mode |= MPI_MODE_RDWR; - else if (mode & W_OK) - mpi_mode |= MPI_MODE_WRONLY; - else - mpi_mode |= MPI_MODE_RDONLY; - - int ret = MPI_File_open(MPI_COMM_SELF, path, mpi_mode, - MPI_INFO_NULL, &fd); - - if (!ret) - MPI_File_close(&fd); - - return ret; -} - /* * Create and open a file through the MPIIO interface. */ @@ -396,7 +370,7 @@ static void MPIIO_Close(void *fd, IOR_param_t * param) /* * Delete a file through the MPIIO interface. */ -static void MPIIO_Delete(char *testFileName, IOR_param_t * param) +void MPIIO_Delete(char *testFileName, IOR_param_t * param) { MPI_CHECK(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL), "cannot delete file"); @@ -495,3 +469,27 @@ IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, return (aggFileSizeFromStat); } + +/* + * Try to access a file through the MPIIO interface. + */ +int MPIIO_Access(const char *path, int mode, IOR_param_t *param) +{ + MPI_File fd; + int mpi_mode = MPI_MODE_UNIQUE_OPEN; + + if ((mode & W_OK) && (mode & R_OK)) + mpi_mode |= MPI_MODE_RDWR; + else if (mode & W_OK) + mpi_mode |= MPI_MODE_WRONLY; + else + mpi_mode |= MPI_MODE_RDONLY; + + int ret = MPI_File_open(MPI_COMM_SELF, path, mpi_mode, + MPI_INFO_NULL, &fd); + + if (!ret) + MPI_File_close(&fd); + + return ret; +} diff --git a/src/aiori.h b/src/aiori.h index 49b8c62..a54bd59 100755 --- a/src/aiori.h +++ b/src/aiori.h @@ -99,7 +99,10 @@ int aiori_posix_rmdir (const char *path, IOR_param_t * param); int aiori_posix_access (const char *path, int mode, IOR_param_t * param); int aiori_posix_stat (const char *path, struct stat *buf, IOR_param_t * param); +/* NOTE: these 3 MPI-IO functions are exported for reuse by HDF5/PNetCDF */ +void MPIIO_Delete(char *testFileName, IOR_param_t * param); IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); +int MPIIO_Access(const char *, int, IOR_param_t *); #endif /* not _AIORI_H */