cursor: posix_fallocate may fail with EINVAL if not supported
authorJan Beich <jbeich@FreeBSD.org>
Sat, 15 Feb 2020 15:15:00 +0000 (15:15 +0000)
committerJan Beich <jbeich@FreeBSD.org>
Sun, 23 Feb 2020 20:42:54 +0000 (20:42 +0000)
ZFS on FreeBSD >= 12.0 returns EINVAL, see
https://svnweb.freebsd.org/changeset/base/325320

Signed-off-by: Jan Beich <jbeich@FreeBSD.org>
cursor/os-compatibility.c

index 6f5b39f..002bb5c 100644 (file)
@@ -157,13 +157,13 @@ os_create_anonymous_file(off_t size)
 
 #ifdef HAVE_POSIX_FALLOCATE
        /* 
-        * Filesystems that do support fallocate will return EOPNOTSUPP.
-        * In this case we need to fall back to ftruncate
+        * Filesystems that do support fallocate will return EINVAL or
+        * EOPNOTSUPP. In this case we need to fall back to ftruncate
         */
        ret = posix_fallocate(fd, 0, size);
        if (ret == 0) {
                return fd;
-       } else if (ret != EOPNOTSUPP) {
+       } else if (ret != EINVAL && ret != EOPNOTSUPP) {
                close(fd);
                errno = ret;
                return -1;