[Sheepdog] [PATCH] sheep: check return value of write() in __start_recovery()

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun Jan 2 13:27:02 CET 2011


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/store.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/sheep/store.c b/sheep/store.c
index a989d0a..ad37afc 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -1602,7 +1602,12 @@ static void __start_recovery(struct work *work, int idx)
 		eprintf("failed to open %s, %s, %m\n", tmp_path, strerror(errno));
 		goto fail;
 	}
-	write(fd, rw->buf, sizeof(uint64_t) * rw->count);
+	ret = write(fd, rw->buf, sizeof(uint64_t) * rw->count);
+	if (ret != sizeof(uint64_t) * rw->count) {
+		eprintf("failed to write to %s, %m\n", tmp_path);
+		close(fd);
+		goto fail;
+	}
 	close(fd);
 
 	dprintf("rename %s to %s\n", tmp_path, path);
-- 
1.5.6.5




More information about the sheepdog mailing list