summaryrefslogtreecommitdiff
path: root/libhfcommon
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2018-02-02 12:56:08 +0100
committerRobert Swiecki <robert@swiecki.net>2018-02-02 12:56:08 +0100
commit2d1631a8df63926b2f862764e1f9e81ba378e959 (patch)
treef4fbe56bc0a608f8f29ecf7c049042828d7c40a7 /libhfcommon
parent0fba3482ee3154cdf72337859147af50d44d95d1 (diff)
downloadhonggfuzz-2d1631a8df63926b2f862764e1f9e81ba378e959.tar.gz
libhfcommon/files: use a name when mapping shared memore regions
Diffstat (limited to 'libhfcommon')
-rw-r--r--libhfcommon/files.c6
-rw-r--r--libhfcommon/files.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/libhfcommon/files.c b/libhfcommon/files.c
index f3f070e5..e26dc68c 100644
--- a/libhfcommon/files.c
+++ b/libhfcommon/files.c
@@ -390,7 +390,7 @@ uint8_t* files_mapFileShared(const char* fileName, off_t* fileSz, int* fd) {
return buf;
}
-void* files_mapSharedMem(size_t sz, int* fd, const char* dir) {
+void* files_mapSharedMem(size_t sz, int* fd, const char* name, const char* dir) {
*fd = -1;
#if defined(_HF_ARCH_LINUX)
@@ -406,14 +406,14 @@ void* files_mapSharedMem(size_t sz, int* fd, const char* dir) {
#endif /* !defined(__NR_memfd_create) */
#if defined(__NR_memfd_create)
- *fd = syscall(__NR_memfd_create, "honggfuzz", (uintptr_t)MFD_CLOEXEC);
+ *fd = syscall(__NR_memfd_create, name, (uintptr_t)MFD_CLOEXEC);
#endif /* defined__NR_memfd_create) */
#endif /* defined(_HF_ARCH_LINUX) */
if (*fd == -1) {
char template[PATH_MAX];
- snprintf(template, sizeof(template), "%s/hfuzz.XXXXXX", dir);
+ snprintf(template, sizeof(template), "%s/%s.XXXXXX", dir, name);
if ((*fd = mkostemp(template, O_CLOEXEC)) == -1) {
PLOG_W("mkstemp('%s')", template);
return NULL;
diff --git a/libhfcommon/files.h b/libhfcommon/files.h
index 4ee28559..7a92858a 100644
--- a/libhfcommon/files.h
+++ b/libhfcommon/files.h
@@ -62,7 +62,7 @@ extern uint8_t* files_mapFile(const char* fileName, off_t* fileSz, int* fd, bool
extern uint8_t* files_mapFileShared(const char* fileName, off_t* fileSz, int* fd);
-extern void* files_mapSharedMem(size_t sz, int* fd, const char* dir);
+extern void* files_mapSharedMem(size_t sz, int* fd, const char* name, const char* dir);
extern bool files_readPidFromFile(const char* fileName, pid_t* pidPtr);