This source file includes following definitions.
- ADIOI_PVFS2_End
- ADIOI_PVFS2_End_call
- ADIOI_PVFS2_Init
- ADIOI_PVFS2_makeattribs
- ADIOI_PVFS2_makecredentials
- ADIOI_PVFS2_error_convert
1
2
3
4
5
6
7 #include "ad_pvfs2.h"
8 #include "ad_pvfs2_common.h"
9 #include <unistd.h>
10 #include <sys/types.h>
11 #include <time.h>
12 #include <stdlib.h>
13
14
15
16
17 int ADIOI_PVFS2_Initialized = MPI_KEYVAL_INVALID;
18
19 void ADIOI_PVFS2_End(int *error_code)
20 {
21 int ret;
22 static char myname[] = "ADIOI_PVFS2_END";
23
24 ret = PVFS_sys_finalize();
25
26
27 if (ret != 0 ) {
28 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
29 MPIR_ERR_RECOVERABLE,
30 myname, __LINE__,
31 ADIOI_PVFS2_error_convert(ret),
32 "Error in PVFS_sys_finalize", 0);
33 return;
34 }
35
36
37 *error_code = MPI_SUCCESS;
38 }
39
40 int ADIOI_PVFS2_End_call(MPI_Comm comm, int keyval,
41 void *attribute_val, void *extra_state)
42 {
43 int error_code;
44 ADIOI_PVFS2_End(&error_code);
45 MPI_Keyval_free(&keyval);
46 return error_code;
47 }
48
49 void ADIOI_PVFS2_Init(int *error_code )
50 {
51 int ret;
52 static char myname[] = "ADIOI_PVFS2_INIT";
53 char * ncache_timeout;
54
55
56 if (ADIOI_PVFS2_Initialized != MPI_KEYVAL_INVALID) {
57 *error_code = MPI_SUCCESS;
58 return;
59 }
60
61
62
63
64 ncache_timeout = getenv("PVFS2_NCACHE_TIMEOUT");
65 if (ncache_timeout == NULL )
66 setenv("PVFS2_NCACHE_TIMEOUT", "0", 1);
67
68 ret = PVFS_util_init_defaults();
69 if (ret < 0 ) {
70 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
71 MPIR_ERR_RECOVERABLE,
72 myname, __LINE__,
73 ADIOI_PVFS2_error_convert(ret),
74 "Error in PVFS_util_init_defaults",
75 0);
76 PVFS_perror("PVFS_util_init_defaults", ret);
77
78 return;
79 }
80
81 MPI_Keyval_create(MPI_NULL_COPY_FN, ADIOI_PVFS2_End_call,
82 &ADIOI_PVFS2_Initialized, (void *)0);
83
84
85 MPI_Attr_put(MPI_COMM_SELF, ADIOI_PVFS2_Initialized, (void *)0);
86 }
87
88 void ADIOI_PVFS2_makeattribs(PVFS_sys_attr * attribs)
89 {
90 memset(attribs, 0, sizeof(PVFS_sys_attr));
91
92 attribs->owner = geteuid();
93 attribs->group = getegid();
94 attribs->perms = 0644;
95 attribs->mask = PVFS_ATTR_SYS_ALL_SETABLE;
96 attribs->atime = time(NULL);
97 attribs->mtime = attribs->atime;
98 attribs->ctime = attribs->atime;
99 }
100
101
102 void ADIOI_PVFS2_makecredentials(PVFS_credentials * credentials)
103 {
104 memset(credentials, 0, sizeof(PVFS_credentials));
105
106 PVFS_util_gen_credentials(credentials);
107 }
108
109 int ADIOI_PVFS2_error_convert(int pvfs_error)
110 {
111 switch(pvfs_error)
112 {
113 case PVFS_EPERM:
114 case PVFS_EACCES:
115 return MPI_ERR_ACCESS;
116 case PVFS_ENOENT:
117 case PVFS_ENXIO:
118 case PVFS_ENODEV:
119 return MPI_ERR_NO_SUCH_FILE;
120 case PVFS_EIO:
121 return MPI_ERR_IO;
122 case PVFS_EEXIST:
123 return MPI_ERR_FILE_EXISTS;
124 case PVFS_ENOTDIR:
125 case PVFS_EISDIR:
126 case PVFS_ENAMETOOLONG:
127 return MPI_ERR_BAD_FILE;
128 case PVFS_EINVAL:
129 return MPI_ERR_FILE;
130 case PVFS_EFBIG:
131 case PVFS_ENOSPC:
132 return MPI_ERR_NO_SPACE;
133 case PVFS_EROFS:
134 return MPI_ERR_READ_ONLY;
135 case PVFS_ENOSYS:
136 return MPI_ERR_UNSUPPORTED_OPERATION;
137
138 case EDQUOT:
139 return MPI_ERR_QUOTA;
140 case PVFS_ENOMEM:
141 return MPI_ERR_INTERN;
142 default:
143 return MPI_UNDEFINED;
144 }
145
146 }
147
148
149
150