root/ompi/mca/io/romio321/romio/adio/ad_pfs/ad_pfs_fcntl.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PFS_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_pfs.h"
   9 #include "adio_extern.h"
  10 
  11 void ADIOI_PFS_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
  12                      int *error_code)
  13 {
  14     int i, err;
  15     int iomod, np_total, np_comm;
  16     static char myname[] = "ADIOI_PFS_FCNTL";
  17 
  18     switch(flag) {
  19     case ADIO_FCNTL_GET_FSIZE:
  20         if (!(fd->atomicity)) {
  21           /* in M_ASYNC mode, all processes are not aware of changes 
  22              in file size (although the manual says otherwise). Therefore, 
  23              temporarily change to M_UNIX and then change 
  24              back to M_ASYNC.*/ 
  25             MPI_Comm_size(MPI_COMM_WORLD, &np_total);
  26             MPI_Comm_size(fd->comm, &np_comm);
  27             if (np_total == np_comm) {
  28                 err = _setiomode(fd->fd_sys, M_UNIX);
  29                 err = _setiomode(fd->fd_sys, M_ASYNC);
  30             }
  31             /* else it is M_UNIX anyway, so no problem */
  32         }
  33         fcntl_struct->fsize = lseek(fd->fd_sys, 0, SEEK_END);
  34         if (fd->fp_sys_posn != -1) 
  35             lseek(fd->fd_sys, fd->fp_sys_posn, SEEK_SET);
  36         *error_code = MPI_SUCCESS;
  37         break;
  38 
  39     case ADIO_FCNTL_SET_DISKSPACE:
  40         err = _lsize(fd->fd_sys, fcntl_struct->diskspace, SEEK_SET);
  41         if (err == -1) {
  42             *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  43                                                MPIR_ERR_RECOVERABLE, myname,
  44                                                __LINE__, MPI_ERR_IO, "**io",
  45                                                "**io %s", strerror(errno));
  46         }
  47         else *error_code = MPI_SUCCESS;
  48         break;
  49 
  50     case ADIO_FCNTL_SET_ATOMICITY:
  51         MPI_Comm_size(MPI_COMM_WORLD, &np_total);
  52         MPI_Comm_size(fd->comm, &np_comm);
  53         if (np_total == np_comm) {
  54             iomod = (fcntl_struct->atomicity == 0) ? M_ASYNC : M_UNIX;
  55             err = _setiomode(fd->fd_sys, iomod);
  56         }
  57         /* else can't do anything because setiomode is global. but
  58            the file will have been opened with M_UNIX anyway, because
  59            gopen is also global. */
  60 
  61         fd->atomicity = (fcntl_struct->atomicity == 0) ? 0 : 1;
  62         if (err == -1) {
  63             /* --BEGIN ERROR HANDLING-- */
  64             *error_code = MPIO_Err_create_code(MPI_SUCCESS,
  65                                                MPIR_ERR_RECOVERABLE, myname,
  66                                                __LINE__, MPI_ERR_IO, "**io",
  67                                                "**io %s", strerror(errno));
  68             /* --END ERROR HANDLING-- */
  69         }
  70         else *error_code = MPI_SUCCESS;
  71         break;
  72 
  73     default:
  74         /* --BEGIN ERROR HANDLING-- */
  75         *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPI_ERR_RECOVERABLE,
  76                                            myname, __LINE__, MPI_ERR_ARG,
  77                                            "**flag", "**flag %d", flag);
  78         return;
  79         /* --END ERROR HANDLING-- */
  80     }
  81 }

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