summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/linux/mem.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 1b3694b1af4..8b2fd14d210 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -359,11 +359,20 @@ legacy_memfd_create (u8 * name)
clib_mem_main_t *mm = &clib_mem_main;
int fd = -1;
char *mount_dir;
+ u8 *temp;
u8 *filename;
+ /*
+ * Since mkdtemp will modify template string "/tmp/hugepage_mount.XXXXXX",
+ * it must not be a string constant, but should be declared as
+ * a character array.
+ */
+ temp = format (0, "/tmp/hugepage_mount.XXXXXX%c", 0);
+
/* create mount directory */
- if ((mount_dir = mkdtemp ("/tmp/hugepage_mount.XXXXXX")) == 0)
+ if ((mount_dir = mkdtemp ((char *) temp)) == 0)
{
+ vec_free (temp);
vec_reset_length (mm->error);
mm->error = clib_error_return_unix (mm->error, "mkdtemp");
return CLIB_MEM_ERROR;
@@ -371,6 +380,7 @@ legacy_memfd_create (u8 * name)
if (mount ("none", mount_dir, "hugetlbfs", 0, NULL))
{
+ vec_free (temp);
rmdir ((char *) mount_dir);
vec_reset_length (mm->error);
mm->error = clib_error_return_unix (mm->error, "mount");
@@ -388,6 +398,7 @@ legacy_memfd_create (u8 * name)
umount2 ((char *) mount_dir, MNT_DETACH);
rmdir ((char *) mount_dir);
vec_free (filename);
+ vec_free (temp);
return fd;
}
@@ -403,6 +414,8 @@ clib_mem_vm_create_fd (clib_mem_page_sz_t log2_page_size, char *fmt, ...)
if (log2_page_size == mm->log2_page_sz)
log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT;
+ else if (log2_page_size == mm->log2_default_hugepage_sz)
+ log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT_HUGE;
switch (log2_page_size)
{