00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_sfs.h"
00009 #include "adio_extern.h"
00010
00011 void ADIOI_SFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
00012 {
00013 int i, ntimes, len;
00014 ADIO_Offset curr_fsize, alloc_size, size, done;
00015 ADIO_Status status;
00016 char *buf;
00017 #ifndef PRINT_ERR_MSG
00018 static char myname[] = "ADIOI_SFS_FCNTL";
00019 #endif
00020
00021 switch(flag) {
00022 case ADIO_FCNTL_GET_FSIZE:
00023
00024
00025
00026
00027
00028
00029 fsync(fd->fd_sys);
00030 MPI_Barrier(fd->comm);
00031 fsync(fd->fd_sys);
00032
00033 fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END);
00034 if (fd->fp_sys_posn != -1)
00035 llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
00036 if (fcntl_struct->fsize == -1) {
00037 #ifdef MPICH2
00038 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
00039 "**io %s", strerror(errno));
00040 #elif defined(PRINT_ERR_MSG)
00041 *error_code = MPI_ERR_UNKNOWN;
00042 #else
00043 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00044 myname, "I/O Error", "%s", strerror(errno));
00045 ADIOI_Error(fd, *error_code, myname);
00046 #endif
00047 }
00048 else *error_code = MPI_SUCCESS;
00049 break;
00050
00051 case ADIO_FCNTL_SET_DISKSPACE:
00052 ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
00053 break;
00054
00055 case ADIO_FCNTL_SET_ATOMICITY:
00056 fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
00057 *error_code = MPI_SUCCESS;
00058 break;
00059
00060 default:
00061 FPRINTF(stderr, "Unknown flag passed to ADIOI_SFS_Fcntl\n");
00062 MPI_Abort(MPI_COMM_WORLD, 1);
00063 }
00064 }