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