Skip to content

Commit 42ccd38

Browse files
authored
Merge pull request #9784 from edgargabriel/topic/sharedfp-sm-init
sharedfp_sm_file_component_query: add file open to ensure correct ope…
2 parents b74c84f + d8464d2 commit 42ccd38

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ompi/mca/sharedfp/sm/sharedfp_sm.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2013 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2021 University of Houston. All rights reserved.
1313
* Copyright (c) 2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
@@ -94,6 +94,29 @@ struct mca_sharedfp_base_module_1_0_0_t * mca_sharedfp_sm_component_file_query(o
9494
return NULL;
9595
}
9696
}
97+
98+
99+
/* Check that we can actually open the required file */
100+
char *filename_basename = basename((char*)fh->f_filename);
101+
char *sm_filename;
102+
int comm_cid = -1;
103+
int pid = ompi_comm_rank (comm);
104+
105+
asprintf(&sm_filename, "%s/%s_cid-%d-%d.sm", ompi_process_info.job_session_dir,
106+
filename_basename, comm_cid, pid);
107+
108+
int sm_fd = open(sm_filename, O_RDWR | O_CREAT,
109+
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
110+
if ( sm_fd == -1){
111+
/*error opening file*/
112+
opal_output(0,"mca_sharedfp_sm_component_file_query: Error, unable to open file for mmap: %s\n",sm_filename);
113+
free(sm_filename);
114+
return NULL;
115+
}
116+
close (sm_fd);
117+
unlink(sm_filename);
118+
free (sm_filename);
119+
97120
/* This module can run */
98121
*priority = mca_sharedfp_sm_priority;
99122
return &sm;

0 commit comments

Comments
 (0)