[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-2.2 3/3] block/raw-posix: Catch fsync() errors
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH for-2.2 3/3] block/raw-posix: Catch fsync() errors |
Date: |
Tue, 18 Nov 2014 11:23:06 +0100 |
fsync() may fail, and that case should be handled.
Reported-by: László Érsek <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/raw-posix.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index f67fb11..666cdec 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1460,7 +1460,12 @@ static int raw_create(const char *filename, QemuOpts
*opts, Error **errp)
left -= result;
}
if (result >= 0) {
- fsync(fd);
+ result = fsync(fd);
+ if (result < 0) {
+ result = -errno;
+ error_setg_errno(errp, -result,
+ "Could not flush new file to disk");
+ }
}
g_free(buf);
break;
--
1.9.3