/*
* Memory helpers
*/
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include "fio.h"
#ifndef FIO_NO_HAVE_SHM_H
}
if (td->o.mmapfile) {
+ if (access(td->o.mmapfile, F_OK) == 0)
+ td->flags |= TD_F_MMAP_KEEP;
+
td->mmapfd = open(td->o.mmapfile, O_RDWR|O_CREAT, 0644);
if (td->mmapfd < 0) {
td->orig_buffer = NULL;
if (td->mmapfd != 1 && td->mmapfd != -1) {
close(td->mmapfd);
- if (td->o.mmapfile)
+ if (td->o.mmapfile && !(td->flags & TD_F_MMAP_KEEP))
unlink(td->o.mmapfile);
}
if (td->o.mmapfile) {
if (td->mmapfd != -1)
close(td->mmapfd);
- unlink(td->o.mmapfile);
+ if (!(td->flags & TD_F_MMAP_KEEP))
+ unlink(td->o.mmapfile);
free(td->o.mmapfile);
}
}