root/ompi/mca/io/romio321/romio/adio/common/error.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_Error
  2. ADIOI_Err_create_code

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "adio.h"
   9 #include "adio_extern.h"
  10 
  11 /* NOTE: THIS FUNCTION IS DEPRECATED AND ONLY EXISTS HERE BECAUSE
  12  * SOME DEPRECATED ADIO IMPLEMENTATIONS STILL CALL IT (SFS, HFS, PIOFS).
  13  */
  14 int ADIOI_Error(ADIO_File fd, int error_code, char *string)
  15 {
  16     char buf[MPI_MAX_ERROR_STRING];
  17     int myrank, result_len; 
  18     MPI_Errhandler err_handler;
  19 
  20     if (fd == ADIO_FILE_NULL) err_handler = ADIOI_DFLT_ERR_HANDLER;
  21     else err_handler = fd->err_handler;
  22 
  23     MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  24     if (err_handler == MPI_ERRORS_ARE_FATAL) {
  25         MPI_Error_string(error_code, buf, &result_len);
  26         FPRINTF(stderr, "[%d] - %s : %s\n", myrank, string, buf);
  27         MPI_Abort(MPI_COMM_WORLD, 1);
  28     }
  29     else if (err_handler != MPI_ERRORS_RETURN) {
  30         /* MPI_File_call_errorhandler(fd, error_code); */
  31 
  32         FPRINTF(stderr, "Only MPI_ERRORS_RETURN and MPI_ERRORS_ARE_FATAL are currently supported as error handlers for files\n");
  33         MPI_Abort(MPI_COMM_WORLD, 1);
  34     }
  35 
  36     return error_code;
  37 }
  38 /* Check for special error codes for those MPI error
  39    classes that relate to particular problems.
  40    Returns an MPI error code corresponding to "my_errno", for function "myname"
  41  * and the given file, "filename".  */
  42 int ADIOI_Err_create_code(const char *myname, const char *filename, int my_errno)
  43 {
  44     int error_code = MPI_SUCCESS;
  45     if(!my_errno) return MPI_SUCCESS;
  46 
  47     /* --BEGIN ERROR HANDLING-- */
  48     switch(my_errno) {
  49         case EACCES:
  50             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  51                                               MPIR_ERR_RECOVERABLE, myname,
  52                                               __LINE__, MPI_ERR_ACCESS,
  53                                               "**fileaccess",
  54                                               "**fileaccess %s",
  55                                               filename );
  56             break;
  57         case ENAMETOOLONG:
  58             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  59                                               MPIR_ERR_RECOVERABLE, myname,
  60                                               __LINE__, MPI_ERR_BAD_FILE,
  61                                               "**filenamelong",
  62                                               "**filenamelong %s %d",
  63                                               filename,
  64                                               strlen(filename));
  65             break;
  66         case ENOENT:
  67             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  68                                               MPIR_ERR_RECOVERABLE, myname,
  69                                               __LINE__, MPI_ERR_NO_SUCH_FILE,
  70                                               "**filenoexist",
  71                                               "**filenoexist %s",
  72                                               filename);
  73             break;
  74         case EISDIR:
  75             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  76                                               MPIR_ERR_RECOVERABLE,
  77                                               myname, __LINE__,
  78                                               MPI_ERR_BAD_FILE,
  79                                               "**filenamedir",
  80                                               "**filenamedir %s",
  81                                               filename);
  82             break;
  83         case EROFS:
  84             /* Read only file or file system and write access requested */
  85             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  86                                               MPIR_ERR_RECOVERABLE, myname,
  87                                               __LINE__, MPI_ERR_READ_ONLY,
  88                                               "**ioneedrd", 0 );
  89             break;
  90         case EEXIST:
  91             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  92                                               MPIR_ERR_RECOVERABLE, myname,
  93                                               __LINE__, MPI_ERR_FILE_EXISTS,
  94                                               "**fileexist", 0);
  95             break;
  96         case ENOTDIR:
  97         case ELOOP:
  98             error_code = MPIO_Err_create_code(MPI_SUCCESS,
  99                                                MPIR_ERR_RECOVERABLE,
 100                                                myname, __LINE__,
 101                                                MPI_ERR_BAD_FILE,
 102                                                "**filenamedir",
 103                                                "**filenamedir %s",
 104                                                filename);
 105             break;
 106         case ENOSPC:
 107             error_code = MPIO_Err_create_code(MPI_SUCCESS,
 108                     MPIR_ERR_RECOVERABLE, myname, __LINE__,
 109                     MPI_ERR_NO_SPACE,
 110                     "**filenospace", 0);
 111             break;
 112         case EDQUOT:
 113             error_code = MPIO_Err_create_code(MPI_SUCCESS,
 114                     MPIR_ERR_RECOVERABLE, myname, __LINE__,
 115                     MPI_ERR_QUOTA,
 116                     "**filequota", 0);
 117             break;
 118         default:
 119             error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
 120                                               myname, __LINE__, MPI_ERR_IO, "**io",
 121                                               "**io %s", strerror(my_errno));
 122             break;
 123     }
 124     /* --END ERROR HANDLING-- */
 125 
 126     return error_code;
 127 }

/* [<][>][^][v][top][bottom][index][help] */