diff options
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/connections.c | 2 | ||||
-rw-r--r-- | nscd/mem.c | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/nscd/connections.c b/nscd/connections.c index 808ea33adb..7ead3fd5e7 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -638,7 +638,7 @@ cannot create read-only descriptor for \"%s\"; no mmap"), if ((TEMP_FAILURE_RETRY (write (fd, &head, sizeof (head))) != sizeof (head)) - || ftruncate (fd, total) != 0 + || posix_fallocate (fd, 0, total) != 0 || (mem = mmap (NULL, total, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { diff --git a/nscd/mem.c b/nscd/mem.c index a1108f3143..823eda1019 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -21,6 +21,7 @@ #include <assert.h> #include <errno.h> #include <error.h> +#include <fcntl.h> #include <inttypes.h> #include <libintl.h> #include <limits.h> @@ -488,7 +489,8 @@ mempool_alloc (struct database_dyn *db, size_t len) + db->head->module * sizeof (ref_t) + new_data_size); - if ((!db->mmap_used || ftruncate (db->wr_fd, newtotal) != 0) + if ((!db->mmap_used + || posix_fallocate (db->wr_fd, oldtotal, newtotal) != 0) /* Try to resize the mapping. Note: no MREMAP_MAYMOVE. */ && mremap (db->head, oldtotal, newtotal, 0) == 0) { |