root/ompi/mca/io/romio321/romio/adio/ad_piofs/ad_piofs_fcntl.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PIOFS_Fcntl

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "ad_piofs.h"
   9 #include "adio_extern.h"
  10 
  11 void ADIOI_PIOFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
  12 {
  13     MPI_Datatype copy_etype, copy_filetype;
  14     int i, ntimes, err;
  15     ADIO_Offset curr_fsize, alloc_size, size, len, done;
  16     ADIO_Status status;
  17     char *buf;
  18     piofs_change_view_t *piofs_change_view;
  19 #ifndef PRINT_ERR_MSG
  20     static char myname[] = "ADIOI_PIOFS_FCNTL";
  21 #endif
  22 
  23     switch(flag) {
  24     case ADIO_FCNTL_GET_FSIZE:
  25         fcntl_struct->fsize = llseek(fd->fd_sys, 0, SEEK_END);
  26         if (fd->fp_sys_posn != -1) 
  27              llseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  28         if (fcntl_struct->fsize == -1) {
  29 #ifdef MPICH
  30             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  31                 "**io %s", strerror(errno));
  32 #elif defined(PRINT_ERR_MSG)
  33             *error_code =  MPI_ERR_UNKNOWN;
  34 #else /* MPICH-1 */
  35             *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  36                               myname, "I/O Error", "%s", strerror(errno));
  37             ADIOI_Error(fd, *error_code, myname);           
  38 #endif
  39         }
  40         else *error_code = MPI_SUCCESS;
  41         break;
  42 
  43     case ADIO_FCNTL_SET_DISKSPACE:
  44         ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
  45         break;
  46 
  47     case ADIO_FCNTL_SET_ATOMICITY:
  48         piofs_change_view = (piofs_change_view_t *) 
  49                                  ADIOI_Malloc(sizeof(piofs_change_view_t));
  50         piofs_change_view->Vbs = piofs_change_view->Vn = 
  51              piofs_change_view->Hbs = piofs_change_view->Hn = 1;
  52         piofs_change_view->subfile = 0;
  53         piofs_change_view->flags = (fcntl_struct->atomicity == 0) 
  54                              ? (ACTIVE | NORMAL) : (ACTIVE | CAUTIOUS);
  55         err = piofsioctl(fd->fd_sys, PIOFS_CHANGE_VIEW, piofs_change_view);
  56         ADIOI_Free(piofs_change_view);
  57         fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
  58         if (err == -1) {
  59 #ifdef MPICH
  60             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  61                 "**io %s", strerror(errno));
  62 #elif defined(PRINT_ERR_MSG)
  63             *error_code =  MPI_ERR_UNKNOWN;
  64 #else /* MPICH-1 */
  65             *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  66                               myname, "I/O Error", "%s", strerror(errno));
  67             ADIOI_Error(fd, *error_code, myname);           
  68 #endif
  69         }
  70         else *error_code = MPI_SUCCESS;
  71         break;
  72 
  73     default:
  74         FPRINTF(stderr, "Unknown flag passed to ADIOI_PIOFS_Fcntl\n");
  75         MPI_Abort(MPI_COMM_WORLD, 1);
  76     }
  77 }

/* [<][>][^][v][top][bottom][index][help] */