[PATCH] iohelper: Don't report errors on special FDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some FDs may not implement fdatasync() functionality, e.g.
pipes or stdout. In that case EINVAL or EROFS is returned.
We don't want to fail then nor report any error.

Reported-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
---

I know that those two 'if-s' can be joined together but it just looks weird to me.

 src/util/iohelper.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index 860e14a..b8c91aa 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -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 like stdout or pipes */
+            virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
+            goto cleanup;
+        }
     }
 
     ret = 0;
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]