pmalloc: fix shared mappings

Change-Id: I6782544d5ee0a66b1a027874b23574416093ca92
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index a881a65..46ccd7f 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -290,7 +290,7 @@
       return 0;
     }
 
-  mmap_flags = MAP_FIXED | MAP_ANONYMOUS;
+  mmap_flags = MAP_FIXED;
 
   if ((pm->flags & CLIB_PMALLOC_F_NO_PAGEMAP) == 0)
     mmap_flags |= MAP_LOCKED;
@@ -307,10 +307,12 @@
 	pm->error = clib_mem_create_fd ((char *) a->name, &a->fd);
       if (a->fd == -1)
 	goto error;
+      if ((ftruncate (a->fd, size)) == -1)
+	goto error;
     }
   else
     {
-      mmap_flags |= MAP_PRIVATE;
+      mmap_flags |= MAP_PRIVATE | MAP_ANONYMOUS;
       a->fd = -1;
     }