]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
iohelper: Don't report errors on special FDs
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 5 Nov 2012 14:42:53 +0000 (15:42 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 5 Nov 2012 15:55:42 +0000 (16:55 +0100)
Some FDs may not implement fdatasync() functionality,
e.g.  pipes. In that case EINVAL or EROFS is returned.
We don't want to fail then nor report any error.

Reported-by: Christophe Fergeau <cfergeau@redhat.com>
src/util/iohelper.c

index 860e14a98f6c6c5b5330b8c9ebd96b5985dcb2ab..a9c8b4cefa4c96c38f32c6c2f0980e6f0dc6eb78 100644 (file)
@@ -181,8 +181,11 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
 
     /* Ensure all data is written */
     if (fdatasync(fdout) < 0) {
-        virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
-        goto cleanup;
+        if (errno != EINVAL && errno != EROFS) {
+            /* fdatasync() may fail on some special FDs, e.g. pipes */
+            virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
+            goto cleanup;
+        }
     }
 
     ret = 0;