From 779903418aea237a06889573e8d2f9a0b25bd720 Mon Sep 17 00:00:00 2001 From: szaka Date: Fri, 8 Jun 2007 21:35:33 +0000 Subject: [PATCH] ntfs_device_unix_io_close(), ntfs_device_unix_io_sync(): log all errors --- libntfs-3g/unix_io.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libntfs-3g/unix_io.c b/libntfs-3g/unix_io.c index 78a09207..75aebcec 100644 --- a/libntfs-3g/unix_io.c +++ b/libntfs-3g/unix_io.c @@ -151,21 +151,25 @@ static int ntfs_device_unix_io_close(struct ntfs_device *dev) if (!NDevOpen(dev)) { errno = EBADF; + ntfs_log_perror("Device %s is not open", dev->d_name); return -1; } if (NDevDirty(dev)) - fsync(DEV_FD(dev)); - /* Release exclusive (mandatory) lock on the whole device. */ + if (fsync(DEV_FD(dev))) { + ntfs_log_perror("Failed to fsync device %s", dev->d_name); + return -1; + } + memset(&flk, 0, sizeof(flk)); flk.l_type = F_UNLCK; flk.l_whence = SEEK_SET; flk.l_start = flk.l_len = 0LL; if (fcntl(DEV_FD(dev), F_SETLK, &flk)) - ntfs_log_perror("ntfs_device_unix_io_close: Warning: Could not " - "unlock %s", dev->d_name); - /* Close the file descriptor and clear our open flag. */ - if (close(DEV_FD(dev))) + ntfs_log_perror("Could not unlock %s", dev->d_name); + if (close(DEV_FD(dev))) { + ntfs_log_perror("Failed to close device %s", dev->d_name); return -1; + } NDevClearOpen(dev); free(dev->d_private); dev->d_private = NULL; @@ -274,13 +278,16 @@ static s64 ntfs_device_unix_io_pwrite(struct ntfs_device *dev, const void *buf, */ static int ntfs_device_unix_io_sync(struct ntfs_device *dev) { + int res = 0; + if (!NDevReadOnly(dev)) { - int res = fsync(DEV_FD(dev)); - if (!res) + res = fsync(DEV_FD(dev)); + if (res) + ntfs_log_perror("Failed to sync device %s", dev->d_name); + else NDevClearDirty(dev); - return res; } - return 0; + return res; } /**