This source file includes following definitions.
- ADIOI_HFS_Open
1
2
3
4
5
6
7
8 #include "ad_hfs.h"
9
10 #ifndef HAVE_LSEEK64
11 #define lseek64 lseek
12 #endif
13
14 void ADIOI_HFS_Open(ADIO_File fd, int *error_code)
15 {
16 int perm, old_mask, amode;
17 #ifndef PRINT_ERR_MSG
18 static char myname[] = "ADIOI_HFS_OPEN";
19 #endif
20
21 if (fd->perm == ADIO_PERM_NULL) {
22 old_mask = umask(022);
23 umask(old_mask);
24 perm = old_mask ^ 0666;
25 }
26 else perm = fd->perm;
27
28 amode = 0;
29 if (fd->access_mode & ADIO_CREATE)
30 amode = amode | O_CREAT;
31 if (fd->access_mode & ADIO_RDONLY)
32 amode = amode | O_RDONLY;
33 if (fd->access_mode & ADIO_WRONLY)
34 amode = amode | O_WRONLY;
35 if (fd->access_mode & ADIO_RDWR)
36 amode = amode | O_RDWR;
37 if (fd->access_mode & ADIO_EXCL)
38 amode = amode | O_EXCL;
39
40 fd->fd_sys = open64(fd->filename, amode, perm);
41 fd->fd_direct = -1;
42
43 if ((fd->fd_sys != -1) && (fd->access_mode & ADIO_APPEND)) {
44 fd->fp_ind = lseek64(fd->fd_sys, 0, SEEK_END);
45 #ifdef HPUX
46 fd->fp_sys_posn = fd->fp_ind;
47 #endif
48 }
49
50 #ifdef SPPUX
51 fd->fp_sys_posn = -1;
52 #endif
53
54 if (fd->fd_sys == -1 ) {
55 #ifdef MPICH
56 *error_code = MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io",
57 "**io %s", strerror(errno));
58 #elif defined(PRINT_ERR_MSG)
59 *error_code = MPI_ERR_UNKNOWN;
60 #else
61 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
62 myname, "I/O Error", "%s", strerror(errno));
63 ADIOI_Error(ADIO_FILE_NULL, *error_code, myname);
64 #endif
65 }
66 else *error_code = MPI_SUCCESS;
67 }