root/ompi/mca/io/romio321/romio/adio/ad_hfs/ad_hfs_fcntl.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_HFS_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_hfs.h"
   9 #include "adio_extern.h"
  10 
  11 #ifndef HAVE_LSEEK64
  12 #define lseek64 lseek
  13 #endif
  14 void ADIOI_HFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct, int *error_code)
  15 {
  16     int  i, ntimes, err;
  17     ADIO_Offset curr_fsize, alloc_size, size, len, done;
  18     ADIO_Status status;
  19     char *buf;
  20 #ifndef PRINT_ERR_MSG
  21     static char myname[] = "ADIOI_HFS_FCNTL";
  22 #endif
  23 
  24     switch(flag) {
  25     case ADIO_FCNTL_GET_FSIZE:
  26         fcntl_struct->fsize = lseek64(fd->fd_sys, 0, SEEK_END);
  27 #ifdef HPUX
  28         if (fd->fp_sys_posn != -1) 
  29              lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  30 /* not required in SPPUX since there we use pread/pwrite */
  31 #endif
  32         if (fcntl_struct->fsize == -1) {
  33 #ifdef MPICH
  34             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", 
  35                 "**io %s", strerror(errno));
  36 #elif defined(PRINT_ERR_MSG)
  37                 *error_code = MPI_ERR_UNKNOWN;
  38 #else /* MPICH-1 */
  39                 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  40                                 myname, "I/O Error", "%s", strerror(errno));
  41                 ADIOI_Error(fd, *error_code, myname);       
  42 #endif
  43         }
  44         else *error_code = MPI_SUCCESS;
  45         break;
  46 
  47     case ADIO_FCNTL_SET_DISKSPACE:
  48         /* will be called by one process only */
  49 
  50 #ifdef HPUX
  51         err = prealloc64(fd->fd_sys, fcntl_struct->diskspace);
  52         /* prealloc64 works only if file is of zero length */
  53         if (err && (errno != ENOTEMPTY)) {
  54 #ifdef MPICH
  55             *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", 
  56                 "**io %s", strerror(errno));
  57 #elif defined(PRINT_ERR_MSG)
  58             *error_code = MPI_ERR_UNKNOWN;
  59 #else
  60             *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  61                               myname, "I/O Error", "%s", strerror(errno));
  62             ADIOI_Error(fd, *error_code, myname);
  63 #endif
  64             return;
  65         }
  66         if (err && (errno == ENOTEMPTY)) {
  67 #endif
  68 
  69 #ifdef SPPUX
  70         /* SPPUX has no prealloc64. therefore, use prealloc
  71            if size < (2GB - 1), otherwise use long method. */
  72         if (fcntl_struct->diskspace <= 2147483647) {
  73             err = prealloc(fd->fd_sys, (off_t) fcntl_struct->diskspace);
  74             if (err && (errno != ENOTEMPTY)) {
  75 #ifdef MPICH
  76                 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  77                     "**io %s", strerror(errno));
  78 #elif defined(PRINT_ERR_MSG)
  79                 *error_code = MPI_ERR_UNKNOWN;
  80 #else
  81                 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  82                               myname, "I/O Error", "%s", strerror(errno));
  83                 ADIOI_Error(fd, *error_code, myname);
  84 #endif
  85                 return;
  86             }
  87         }    
  88 
  89         if ((fcntl_struct->diskspace > 2147483647) || 
  90             (err && (errno == ENOTEMPTY))) {
  91 #endif
  92                 ADIOI_GEN_Prealloc(fd,fcntl_struct->diskspace, error_code);
  93             }
  94             ADIOI_Free(buf);
  95 #ifdef HPUX
  96             if (fd->fp_sys_posn != -1) 
  97                 lseek64(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  98             /* not required in SPPUX since there we use pread/pwrite */
  99 #endif
 100         }
 101         *error_code = MPI_SUCCESS;
 102         break;
 103 
 104     case ADIO_FCNTL_SET_ATOMICITY:
 105         fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
 106         *error_code = MPI_SUCCESS;
 107         break;
 108 
 109     default:
 110         FPRINTF(stderr, "Unknown flag passed to ADIOI_HFS_Fcntl\n");
 111         MPI_Abort(MPI_COMM_WORLD, 1);
 112     }
 113 }

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