diff options
author | Igor Mikhailov (imichail) <imichail@cisco.com> | 2018-02-05 12:09:36 -0800 |
---|---|---|
committer | John Lo <loj@cisco.com> | 2018-02-08 01:04:18 +0000 |
commit | 67d782514941a68ea47934379e2d96050c9b2001 (patch) | |
tree | 164e0c72a979e9ec1124c9ed6872c649395d9dfb | |
parent | 0eacf49ffaaeb94f00aea71b8106aed80804d327 (diff) |
Provide page-aligned length to ftruncate.
For some files such as hugepages files, ftruncate() fails with the error
"Invalid argument" if the 'length' parameter is not on a page boundary.
Change-Id: I42a9cde98707da15e3c5d1653046e2277fc7a424
Signed-off-by: Igor Mikhailov (imichail) <imichail@cisco.com>
(cherry picked from commit 7d25415a9384d4c3d786d0c1ae5c0fcff3112acd)
-rw-r--r-- | src/vppinfra/linux/mem.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c index 2d8f593d2b6..0bc08787baa 100644 --- a/src/vppinfra/linux/mem.c +++ b/src/vppinfra/linux/mem.c @@ -167,7 +167,7 @@ clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a) } if (fd != -1) - if ((ftruncate (fd, a->size)) == -1) + if ((ftruncate (fd, n_pages * (1 << log2_page_size))) == -1) { err = clib_error_return_unix (0, "ftruncate"); goto error; |