root/ompi/mca/io/romio321/romio/adio/ad_sfs/ad_sfs_open.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_SFS_Open

   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_sfs.h"
   9 
  10 void ADIOI_SFS_Open(ADIO_File fd, int *error_code)
  11 {
  12     int perm, old_mask, amode;
  13 #ifndef PRINT_ERR_MSG
  14     static char myname[] = "ADIOI_SFS_OPEN";
  15 #endif
  16 
  17     if (fd->perm == ADIO_PERM_NULL) {
  18         old_mask = umask(022);
  19         umask(old_mask);
  20         perm = old_mask ^ 0666;
  21     }
  22     else perm = fd->perm;
  23 
  24     amode = 0;
  25     if (fd->access_mode & ADIO_CREATE)
  26         amode = amode | O_CREAT;
  27     if (fd->access_mode & ADIO_RDONLY)
  28         amode = amode | O_RDONLY;
  29     if (fd->access_mode & ADIO_WRONLY)
  30         amode = amode | O_WRONLY;
  31     if (fd->access_mode & ADIO_RDWR)
  32         amode = amode | O_RDWR;
  33     if (fd->access_mode & ADIO_EXCL)
  34         amode = amode | O_EXCL;
  35 
  36     fd->fd_sys = open(fd->filename, amode, perm);
  37     fd->fd_direct = -1;
  38 
  39     if ((fd->fd_sys != -1) && (fd->access_mode & ADIO_APPEND)) {
  40         fd->fp_ind = llseek(fd->fd_sys, 0, SEEK_END);
  41         fd->fp_sys_posn = fd->fp_ind;
  42     }
  43 
  44     if (fd->fd_sys == -1) {
  45 #ifdef MPICH
  46         *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
  47             "**io %s", strerror(errno));
  48 #elif defined(PRINT_ERR_MSG)
  49         *error_code = MPI_ERR_UNKNOWN;
  50 #else /* MPICH-1 */
  51         *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
  52                               myname, "I/O Error", "%s", strerror(errno));
  53         ADIOI_Error(ADIO_FILE_NULL, *error_code, myname);           
  54 #endif
  55     }
  56     else *error_code = MPI_SUCCESS;
  57 }

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