From: Ulrich Drepper Date: Mon, 8 Aug 2005 20:42:33 +0000 (+0000) Subject: * nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate. X-Git-Tag: upstream/2.30~16500 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f54a329a28050846c0475b45f8bf131f66eab996;p=external%2Fglibc.git * nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate. * nscd/connections.c (nscd_init): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 489320e..10e1378 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-08 Ulrich Drepper + + * nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate. + * nscd/connections.c (nscd_init): Likewise. + 2005-08-08 Jakub Jelinek * stdio-common/fxprintf.c: Include libioP.h. diff --git a/nscd/connections.c b/nscd/connections.c index 808ea33..7ead3fd 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 a1108f3..823eda1 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -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) {