MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / openSharedFile

Function openSharedFile

src/plugin/pid/pid.cpp:229–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229static int
230openSharedFile(string const& name, int flags)
231{
232 int fd;
233 int errno_bkp;
234
235 // try to create, truncate & open file
236
237 dmtcp::string dir = jalib::Filesystem::DirName(name);
238
239 JTRACE("shared file dir:")(dir);
240 jalib::Filesystem::mkdir_r(dir, 0755);
241
242 if ((fd = open(name.c_str(), O_EXCL | O_CREAT | O_TRUNC | flags, 0600)) >=
243 0) {
244 return fd;
245 }
246 errno_bkp = errno;
247
248 if ((fd < 0) && (errno_bkp == EEXIST)) {
249 errno = 0;
250 if ((fd = open(name.c_str(), flags, 0600)) >= 0) {
251 return fd;
252 }
253 }
254
255 // unable to create & open OR open
256 JASSERT(false)(name)(strerror(errno)).Text("Cannot open file");
257 return -1;
258}
259
260static void
261pidVirt_PostRestart()

Callers 1

pidVirt_PostRestartFunction · 0.85

Calls 1

openFunction · 0.50

Tested by

no test coverage detected