git » libjio » commit 7b27277

jtrans_rollback(): Check if ftruncate() fails

author Alberto Bertogli
2009-02-27 15:18:28 UTC
committer Alberto Bertogli
2009-03-02 00:41:21 UTC
parent 58faf056fff9f3306faabc99ab24c557ccded737

jtrans_rollback(): Check if ftruncate() fails

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

trans.c +5 -2

diff --git a/trans.c b/trans.c
index a39e63e..ba30674 100644
--- a/trans.c
+++ b/trans.c
@@ -490,8 +490,11 @@ ssize_t jtrans_rollback(struct jtrans *ts)
 		 * if for some reason, after the previous transacton, we have
 		 * extended the file further, this will cut it back to what it
 		 * was; read the docs for more detail */
-		if (op->plen < op->len)
-			ftruncate(ts->fs->fd, op->offset + op->plen);
+		if (op->plen < op->len) {
+			rv = ftruncate(ts->fs->fd, op->offset + op->plen);
+			if (rv != 0)
+				goto exit;
+		}
 
 		/* manually add the operation to the new transaction */
 		curop = malloc(sizeof(struct joper));