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