cursor/os-compatibility: move resizing into a separate function

Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
This commit is contained in:
Jan Beich 2020-02-16 05:54:33 +00:00
parent 3a3dd0820d
commit 230885ebb4
3 changed files with 25 additions and 28 deletions

View file

@ -83,17 +83,7 @@ err_free:
static int
shm_pool_resize(struct shm_pool *pool, int size)
{
#ifdef HAVE_POSIX_FALLOCATE
/*
* Filesystems that do support fallocate will return EINVAL or
* EOPNOTSUPP. In this case we need to fall back to ftruncate
*/
errno = posix_fallocate(pool->fd, 0, size);
if (errno != 0 && errno != EINVAL && errno != EOPNOTSUPP)
return 0;
#endif
if (ftruncate(pool->fd, size) < 0)
if (os_resize_anonymous_file(pool->fd, size) < 0)
return 0;
wl_shm_pool_resize(pool->pool, size);