Merge pull request #39 from jyvet/mpiio-access

Implement an access function for MPIIO backend
master
Glenn K. Lockwood 2018-03-02 09:59:03 -08:00 committed by GitHub
commit c40317f75d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 9 deletions

View File

@ -41,23 +41,49 @@ static void MPIIO_Close(void *, IOR_param_t *);
static void MPIIO_Delete(char *, IOR_param_t *); static void MPIIO_Delete(char *, IOR_param_t *);
static void MPIIO_SetVersion(IOR_param_t *); static void MPIIO_SetVersion(IOR_param_t *);
static void MPIIO_Fsync(void *, 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 ***************************/ /************************** D E C L A R A T I O N S ***************************/
ior_aiori_t mpiio_aiori = { ior_aiori_t mpiio_aiori = {
"MPIIO", .name = "MPIIO",
MPIIO_Create, .create = MPIIO_Create,
MPIIO_Open, .open = MPIIO_Open,
MPIIO_Xfer, .xfer = MPIIO_Xfer,
MPIIO_Close, .close = MPIIO_Close,
MPIIO_Delete, .delete = MPIIO_Delete,
MPIIO_SetVersion, .set_version = MPIIO_SetVersion,
MPIIO_Fsync, .fsync = MPIIO_Fsync,
MPIIO_GetFileSize .get_file_size = MPIIO_GetFileSize,
.access = MPIIO_Access,
}; };
/***************************** F U N C T I O N S ******************************/ /***************************** 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. * Create and open a file through the MPIIO interface.
*/ */