From 0cd546312a2ed54d5396def19fad787725a36b97 Mon Sep 17 00:00:00 2001 From: "resver@gmail.com" Date: Fri, 23 Aug 2013 05:56:00 +0000 Subject: [PATCH] Fixed return codes from exfat_close() and exfat_fsync(): return -EIO on error instead of 1. Also do fsync() after ublio_fsync(): ublio_fsync() does not flush changes to the disk, just writes them. git-svn-id: http://exfat.googlecode.com/svn/trunk@382 60bc1c72-a15a-11de-b98f-4500b42dc123 --- libexfat/io.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/libexfat/io.c b/libexfat/io.c index c9fde95..d365be4 100644 --- a/libexfat/io.c +++ b/libexfat/io.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef __APPLE__ #include #endif @@ -210,32 +211,41 @@ struct exfat_dev* exfat_open(const char* spec, enum exfat_mode mode) int exfat_close(struct exfat_dev* dev) { + int rc = 0; + #ifdef USE_UBLIO if (ublio_close(dev->ufh) != 0) + { exfat_error("failed to close ublio"); + rc = -EIO; + } #endif if (close(dev->fd) != 0) { - free(dev); exfat_error("failed to close device"); - return 1; + rc = -EIO; } free(dev); - return 0; + return rc; } int exfat_fsync(struct exfat_dev* dev) { + int rc = 0; + #ifdef USE_UBLIO if (ublio_fsync(dev->ufh) != 0) -#else - if (fsync(dev->fd) != 0) + { + exfat_error("ublio fsync failed"); + rc = -EIO; + } #endif + if (fsync(dev->fd) != 0) { exfat_error("fsync failed"); - return 1; + rc = -EIO; } - return 0; + return rc; } enum exfat_mode exfat_get_mode(const struct exfat_dev* dev) -- 2.11.0