@@ -46,43 +46,16 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm,
4646 struct opal_info_t * info ,
4747 ompio_file_t * fh )
4848{
49- int amode ;
50- int old_mask , perm ;
49+ int perm , amode ;
5150 int ret = OMPI_SUCCESS ;
5251
53- if (fh -> f_perm == OMPIO_PERM_NULL ) {
54- old_mask = umask (022 );
55- umask (old_mask );
56- perm = old_mask ^ 0666 ;
57- }
58- else {
59- perm = fh -> f_perm ;
60- }
61-
62- amode = 0 ;
63-
64- if (access_mode & MPI_MODE_RDONLY ) {
65- amode = amode | O_RDONLY ;
66- }
67- if (access_mode & MPI_MODE_WRONLY ) {
68- amode = amode | O_WRONLY ;
69- }
70- if (access_mode & MPI_MODE_RDWR ) {
71- amode = amode | O_RDWR ;
72- }
52+ perm = mca_fs_base_get_file_perm (fh );
53+ amode = mca_fs_base_get_file_amode (fh -> f_rank , access_mode );
7354
7455 if (OMPIO_ROOT == fh -> f_rank ) {
75- if (access_mode & MPI_MODE_CREATE ) {
76- amode = amode | O_CREAT ;
77- }
78- if (access_mode & MPI_MODE_EXCL ) {
79- amode = amode | O_EXCL ;
80- }
81-
8256 fh -> fd = open (filename , amode , perm );
83-
8457 if ( 0 > fh -> fd ) {
85- ret = mca_fs_gpfs_file_get_mpi_err (errno );
58+ ret = mca_fs_base_get_mpi_err (errno );
8659 }
8760 }
8861
@@ -92,10 +65,10 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm,
9265 return ret ;
9366 }
9467
95- if ( OMPIO_ROOT != fh -> f_rank ) {
68+ if (OMPIO_ROOT != fh -> f_rank ) {
9669 fh -> fd = open (filename , amode , perm );
9770 if ( 0 > fh -> fd ) {
98- return mca_fs_gpfs_file_get_mpi_err (errno );
71+ return mca_fs_base_get_mpi_err (errno );
9972 }
10073 }
10174
@@ -104,69 +77,3 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm,
10477
10578 return OMPI_SUCCESS ;
10679}
107-
108- int
109- mca_fs_gpfs_file_get_amode (ompi_file_t * fh ,
110- int * amode )
111- {
112- mca_common_ompio_data_t * data ;
113-
114- data = (mca_common_ompio_data_t * ) fh -> f_io_selected_data ;
115-
116- * amode = data -> ompio_fh .f_amode ;
117-
118- return OMPI_SUCCESS ;
119- }
120-
121- //CN: Is mca_fs_gpfs_file_seek needed at all. Not used anywhere!
122- int
123- mca_fs_gpfs_file_seek (ompi_file_t * fh , OMPI_MPI_OFFSET_TYPE off , int whence ) {
124- //DEBUG: fprintf(stderr, "GPFS FILE SEEK!");
125- int ret = OMPI_SUCCESS ;
126- mca_common_ompio_data_t * data ;
127- OMPI_MPI_OFFSET_TYPE offset , temp_offset ;
128-
129- data = (mca_common_ompio_data_t * ) fh -> f_io_selected_data ;
130-
131- offset = off * data -> ompio_fh .f_etype_size ;
132-
133- switch (whence ) {
134- case MPI_SEEK_SET :
135- if (offset < 0 ) {
136- return OMPI_ERROR ;
137- }
138- break ;
139- case MPI_SEEK_CUR :
140- offset += data -> ompio_fh .f_position_in_file_view ;
141- offset += data -> ompio_fh .f_disp ;
142- if (offset < 0 ) {
143- return OMPI_ERROR ;
144- }
145- break ;
146- case MPI_SEEK_END :
147- ret = data -> ompio_fh .f_fs -> fs_file_get_size (& data -> ompio_fh ,
148- & temp_offset );
149- offset += temp_offset ;
150- if (offset < 0 || OMPI_SUCCESS != ret ) {
151- return OMPI_ERROR ;
152- }
153- break ;
154- default :
155- return OMPI_ERROR ;
156- }
157-
158- ret = mca_common_ompio_set_explicit_offset (& data -> ompio_fh , offset
159- / data -> ompio_fh .f_etype_size );
160- return ret ;
161- }
162-
163- int mca_fs_gpfs_file_get_position (ompi_file_t * fh , OMPI_MPI_OFFSET_TYPE * offset ) {
164- mca_common_ompio_data_t * data ;
165-
166- data = (mca_common_ompio_data_t * ) fh -> f_io_selected_data ;
167-
168- * offset = data -> ompio_fh .f_position_in_file_view
169- / data -> ompio_fh .f_etype_size ;
170-
171- return OMPI_SUCCESS ;
172- }
0 commit comments