expose MPIIO access and delete calls

master
Shane Snyder 2018-04-25 17:32:16 -05:00
parent d7fc07163e
commit 60243e0277
2 changed files with 28 additions and 27 deletions

View File

@ -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;
}

View File

@ -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 */