00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009
00010 #ifdef HAVE_UNISTD_H
00011 #include <unistd.h>
00012 #endif
00013
00014 void ADIOI_GEN_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
00015 int *error_code)
00016 {
00017 static char myname[] = "ADIOI_GEN_FCNTL";
00018
00019 switch(flag) {
00020 case ADIO_FCNTL_GET_FSIZE:
00021 #ifdef ADIOI_MPE_LOGGING
00022 MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
00023 #endif
00024 fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END);
00025 #ifdef ADIOI_MPE_LOGGING
00026 MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
00027 #endif
00028 if (fd->fp_sys_posn != -1) {
00029 #ifdef ADIOI_MPE_LOGGING
00030 MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
00031 #endif
00032 lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
00033 #ifdef ADIOI_MPE_LOGGING
00034 MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
00035 #endif
00036 }
00037 if (fcntl_struct->fsize == -1) {
00038 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00039 MPIR_ERR_RECOVERABLE, myname,
00040 __LINE__, MPI_ERR_IO, "**io",
00041 "**io %s", strerror(errno));
00042 }
00043 else *error_code = MPI_SUCCESS;
00044 break;
00045
00046 case ADIO_FCNTL_SET_DISKSPACE:
00047 ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
00048 break;
00049
00050 case ADIO_FCNTL_SET_ATOMICITY:
00051 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00052 *error_code = MPI_SUCCESS;
00053 break;
00054
00055
00056 default:
00057 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00058 MPIR_ERR_RECOVERABLE,
00059 myname, __LINE__,
00060 MPI_ERR_ARG,
00061 "**flag", "**flag %d", flag);
00062
00063 }
00064 }