]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
rrd_open: Ignore EINVAL from posix_fallocate() 1085/head
authorNiclas Zeising <zeising@daemonic.se>
Sun, 14 Jun 2020 09:31:33 +0000 (11:31 +0200)
committerNiclas Zeising <zeising@daemonic.se>
Sun, 14 Jun 2020 09:39:15 +0000 (11:39 +0200)
ZFS on FreeBSD (at least) does not support posix_fallocate(),
returning EINVAL instead.  Ignore this error and continue normally.
Without this change, it is not possible to resize rrd files on ZFS.

This fixes #1082

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
src/rrd_open.c

index d8005fe4be47f5b246e5c3076891d43a67a75959..00dfb8caa5f1ab4ea23a5243a24866e14304cf5f 100644 (file)
@@ -363,7 +363,13 @@ rrd_file_t *rrd_open(
          */
         int       fret =
             posix_fallocate(rrd_simple_file->fd, 0, newfile_size);
-        if (fret) {
+        /* ZFS (on FreeBSD) does not support posix_fallocate(), always returning
+         * EINVAL.  Ignore this error and continue anyway.
+         * Without this, resize isn't possible on ZFS filesystems.
+         */
+        if (fret == EINVAL) {
+            /* DO NOTHING */
+        } else if (fret) {
             rrd_set_error("posix_fallocate '%s': %s", file_name,
                           rrd_strerror(fret));
             goto out_close;