00001
00002
00003
00004
00005
00006
00007 #include "ad_zoidfs.h"
00008 #include "ad_zoidfs_common.h"
00009 #include <unistd.h>
00010 #include <sys/types.h>
00011
00012
00013
00014 int ADIOI_ZOIDFS_Initialized = MPI_KEYVAL_INVALID;
00015
00016 void ADIOI_ZOIDFS_End(int *error_code)
00017 {
00018 int ret;
00019 static char myname[] = "ADIOI_ZOIDFS_END";
00020
00021 ret = zoidfs_finalize();
00022
00023
00024 if (ret != 0 ) {
00025 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00026 MPIR_ERR_RECOVERABLE,
00027 myname, __LINE__,
00028 ADIOI_ZOIDFS_error_convert(ret),
00029 "Error in zoidfs_finalize", 0);
00030 return;
00031 }
00032
00033
00034 *error_code = MPI_SUCCESS;
00035 }
00036
00037 int ADIOI_ZOIDFS_End_call(MPI_Comm comm, int keyval,
00038 void *attribute_val, void *extra_state)
00039 {
00040 int error_code;
00041 ADIOI_ZOIDFS_End(&error_code);
00042 MPI_Keyval_free(&keyval);
00043 return error_code;
00044 }
00045
00046 void ADIOI_ZOIDFS_Init(int rank, int *error_code )
00047 {
00048 int ret;
00049 static char myname[] = "ADIOI_ZOIDFS_INIT";
00050
00051
00052 if (ADIOI_ZOIDFS_Initialized != MPI_KEYVAL_INVALID) {
00053 *error_code = MPI_SUCCESS;
00054 return;
00055 }
00056
00057 ret = zoidfs_init();
00058 if (ret < 0 ) {
00059 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00060 MPIR_ERR_RECOVERABLE,
00061 myname, __LINE__,
00062 ADIOI_ZOIDFS_error_convert(ret),
00063 "Error in zoidfs_init",
00064 0);
00065 return;
00066 }
00067
00068 MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_ZOIDFS_End_call,
00069 &ADIOI_ZOIDFS_Initialized, (void *)0);
00070
00071
00072 MPI_Attr_put(MPI_COMM_SELF, ADIOI_ZOIDFS_Initialized, (void *)0);
00073 }
00074
00075 void ADIOI_ZOIDFS_makeattribs(zoidfs_sattr_t * attribs)
00076 {
00077 memset(attribs, 0, sizeof(zoidfs_sattr_t));
00078
00079 attribs->mask = ZOIDFS_ATTR_MODE;
00080 attribs->mode = 0644;
00081 }
00082
00083 int ADIOI_ZOIDFS_error_convert(int error)
00084 {
00085 switch (error)
00086 {
00087 case ZFSERR_PERM:
00088 case ZFSERR_ACCES:
00089 return MPI_ERR_ACCESS;
00090 case ZFSERR_NOENT:
00091 case ZFSERR_NXIO:
00092 case ZFSERR_NODEV:
00093 return MPI_ERR_NO_SUCH_FILE;
00094 case ZFSERR_IO:
00095 return MPI_ERR_IO;
00096 case ZFSERR_EXIST:
00097 return MPI_ERR_FILE_EXISTS;
00098 case ZFSERR_NOTDIR:
00099 case ZFSERR_ISDIR:
00100 case ZFSERR_NAMETOOLONG:
00101 return MPI_ERR_BAD_FILE;
00102 case ZFSERR_INVAL:
00103 case ZFSERR_STALE:
00104 return MPI_ERR_FILE;
00105 case ZFSERR_FBIG:
00106 case ZFSERR_NOSPC:
00107 return MPI_ERR_NO_SPACE;
00108 case ZFSERR_ROFS:
00109 return MPI_ERR_READ_ONLY;
00110 case ZFSERR_NOTIMPL:
00111 return MPI_ERR_UNSUPPORTED_OPERATION;
00112 case ZFSERR_DQUOT:
00113 return MPI_ERR_QUOTA;
00114
00115
00116
00117 case ZFSERR_NOMEM:
00118 return MPI_ERR_INTERN;
00119 default:
00120 return MPI_UNDEFINED;
00121 }
00122 }
00123
00124
00125
00126