diff options
author | David Zafman <david.zafman@inktank.com> | 2013-09-27 16:25:36 -0700 |
---|---|---|
committer | David Zafman <david.zafman@inktank.com> | 2013-09-27 16:25:36 -0700 |
commit | 14d4862048be0262bf838cc38465c77a78ea494e (patch) | |
tree | e48ea6ee591c373185a96ab443f9a03b05ea442c | |
parent | 4d54c73b7013b772005e9677f629ed2c8c12c6f2 (diff) | |
download | ceph-14d4862048be0262bf838cc38465c77a78ea494e.tar.gz |
Review changes to be squashedwip-6422
Fix error handling (Discovered this myself)
Add check for the last fsync error
-rw-r--r-- | src/common/safe_io.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/common/safe_io.c b/src/common/safe_io.c index 5880bc1bc75..e3e40ff989e 100644 --- a/src/common/safe_io.c +++ b/src/common/safe_io.c @@ -145,26 +145,29 @@ int safe_write_file(const char *base, const char *file, } ret = fsync(fd); + if (ret < 0) ret = -errno; TEMP_FAILURE_RETRY(close(fd)); - if (ret) { + if (ret < 0) { unlink(tmp); return ret; } ret = rename(tmp, fn); - if (ret) { + if (ret < 0) { + ret = -errno; unlink(tmp); return ret; } fd = open(base, O_RDONLY); if (fd < 0) { - ret = errno; - return -ret; + ret = -errno; + return ret; } - fsync(fd); + ret = fsync(fd); + if (ret < 0) ret = -errno; TEMP_FAILURE_RETRY(close(fd)); - return 0; + return ret; } int safe_read_file(const char *base, const char *file, |