00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_piofs.h"
00009 #include "adio_extern.h"
00010
00011 void ADIOI_PIOFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
00012 {
00013 MPI_Datatype copy_etype, copy_filetype;
00014 int i, ntimes, err;
00015 ADIO_Offset curr_fsize, alloc_size, size, len, done;
00016 ADIO_Status status;
00017 char *buf;
00018 piofs_change_view_t *piofs_change_view;
00019 #ifndef PRINT_ERR_MSG
00020 static char myname[] = "ADIOI_PIOFS_FCNTL";
00021 #endif
00022
00023 switch(flag) {
00024 case ADIO_FCNTL_GET_FSIZE:
00025 fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END);
00026 if (fd->fp_sys_posn != -1)
00027 llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
00028 if (fcntl_struct->fsize == -1) {
00029 #ifdef MPICH2
00030 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
00031 "**io %s", strerror(errno));
00032 #elif defined(PRINT_ERR_MSG)
00033 *error_code = MPI_ERR_UNKNOWN;
00034 #else
00035 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00036 myname, "I/O Error", "%s", strerror(errno));
00037 ADIOI_Error(fd, *error_code, myname);
00038 #endif
00039 }
00040 else *error_code = MPI_SUCCESS;
00041 break;
00042
00043 case ADIO_FCNTL_SET_DISKSPACE:
00044 ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
00045 break;
00046
00047 case ADIO_FCNTL_SET_ATOMICITY:
00048 piofs_change_view = (piofs_change_view_t *)
00049 ADIOI_Malloc(sizeof(piofs_change_view_t));
00050 piofs_change_view->Vbs = piofs_change_view->Vn =
00051 piofs_change_view->Hbs = piofs_change_view->Hn = 1;
00052 piofs_change_view->subfile = 0;
00053 piofs_change_view->flags = (fcntl_struct->atomicity == 0)
00054 ? (ACTIVE | NORMAL) : (ACTIVE | CAUTIOUS);
00055 err = piofsioctl(fd->fd_sys, PIOFS_CHANGE_VIEW, piofs_change_view);
00056 ADIOI_Free(piofs_change_view);
00057 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00058 if (err == -1) {
00059 #ifdef MPICH2
00060 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
00061 "**io %s", strerror(errno));
00062 #elif defined(PRINT_ERR_MSG)
00063 *error_code = MPI_ERR_UNKNOWN;
00064 #else
00065 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00066 myname, "I/O Error", "%s", strerror(errno));
00067 ADIOI_Error(fd, *error_code, myname);
00068 #endif
00069 }
00070 else *error_code = MPI_SUCCESS;
00071 break;
00072
00073 default:
00074 FPRINTF(stderr, "Unknown flag passed to ADIOI_PIOFS_Fcntl\n");
00075 MPI_Abort(MPI_COMM_WORLD, 1);
00076 }
00077 }