summaryrefslogtreecommitdiffstats
path: root/cursor
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2020-02-15 15:16:51 +0000
committerJan Beich <jbeich@FreeBSD.org>2020-02-23 20:42:54 +0000
commit3a3dd0820de331d560af954bf9d786c1256ec577 (patch)
treedb4bb25920f1d2e7633d24e7828a81fdc638cb75 /cursor
parentcursor: posix_fallocate may fail with EINVAL if not supported (diff)
downloadwayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar.gz
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar.bz2
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar.lz
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar.xz
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.tar.zst
wayland-3a3dd0820de331d560af954bf9d786c1256ec577.zip
cursor: ignore posix_fallocate in shm_pool_resize if not supported by FS
Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
Diffstat (limited to 'cursor')
-rw-r--r--cursor/wayland-cursor.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index d40c5c8..ca5be8d 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -83,15 +83,19 @@ err_free:
static int
shm_pool_resize(struct shm_pool *pool, int size)
{
- if (ftruncate(pool->fd, size) < 0)
- return 0;
-
#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)
+ if (errno != 0 && errno != EINVAL && errno != EOPNOTSUPP)
return 0;
#endif
+ if (ftruncate(pool->fd, size) < 0)
+ return 0;
+
wl_shm_pool_resize(pool->pool, size);
munmap(pool->data, pool->size);