1
1

common/ompio: return correct error code for improper access

return MPI_ERR_ACCESS if the user tries to read from  a file
that was opened using MPI_MODE_WRONLY

return MPI_ERR_READ_ONLY if the user tries to write a file
that was opened using MPI_MODE_RDONLY

Signed-off-by: Edgar Gabriel <egabriel@central.uh.edu>
Этот коммит содержится в:
Edgar Gabriel 2018-10-11 14:41:58 -05:00
родитель c65dda6f5f
Коммит 425a71799e
2 изменённых файлов: 25 добавлений и 5 удалений

Просмотреть файл

@ -77,6 +77,12 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
int i = 0; /* index into the decoded iovec of the buffer */
int j = 0; /* index into the file vie iovec */
if (fh->f_amode & MPI_MODE_WRONLY){
// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n");
ret = MPI_ERR_ACCESS;
return ret;
}
if ( 0 == count ) {
if ( MPI_STATUS_IGNORE != status ) {
status->_ucount = 0;
@ -84,11 +90,6 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
return ret;
}
if (fh->f_amode & MPI_MODE_WRONLY){
printf("Improper use of FILE Mode, Using WRONLY for Read!\n");
ret = OMPI_ERROR;
return ret;
}
#if OPAL_CUDA_SUPPORT
int is_gpu, is_managed;
@ -226,6 +227,12 @@ int mca_common_ompio_file_iread (ompio_file_t *fh,
mca_ompio_request_t *ompio_req=NULL;
size_t spc=0;
if (fh->f_amode & MPI_MODE_WRONLY){
// opal_output(10, "Improper use of FILE Mode, Using WRONLY for Read!\n");
ret = MPI_ERR_ACCESS;
return ret;
}
mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_READ);
if ( 0 == count ) {

Просмотреть файл

@ -58,6 +58,13 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
int i = 0; /* index into the decoded iovec of the buffer */
int j = 0; /* index into the file view iovec */
if (fh->f_amode & MPI_MODE_RDONLY){
// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n");
ret = MPI_ERR_READ_ONLY;
return ret;
}
if ( 0 == count ) {
if ( MPI_STATUS_IGNORE != status ) {
status->_ucount = 0;
@ -194,6 +201,12 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh,
mca_ompio_request_t *ompio_req=NULL;
size_t spc=0;
if (fh->f_amode & MPI_MODE_RDONLY){
// opal_output(10, "Improper use of FILE Mode, Using RDONLY for write!\n");
ret = MPI_ERR_READ_ONLY;
return ret;
}
mca_common_ompio_request_alloc ( &ompio_req, MCA_OMPIO_REQUEST_WRITE);
if ( 0 == count ) {