diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index ae7de20..2fec74f 100755 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -41,23 +41,49 @@ 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 ***************************/ ior_aiori_t mpiio_aiori = { - "MPIIO", - MPIIO_Create, - MPIIO_Open, - MPIIO_Xfer, - MPIIO_Close, - MPIIO_Delete, - MPIIO_SetVersion, - MPIIO_Fsync, - MPIIO_GetFileSize + .name = "MPIIO", + .create = MPIIO_Create, + .open = MPIIO_Open, + .xfer = MPIIO_Xfer, + .close = MPIIO_Close, + .delete = MPIIO_Delete, + .set_version = MPIIO_SetVersion, + .fsync = MPIIO_Fsync, + .get_file_size = MPIIO_GetFileSize, + .access = MPIIO_Access, }; /***************************** 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. */