From: Liu Bo Date: Thu, 9 Nov 2017 17:35:20 +0000 (-0600) Subject: xfs_io: report io error for pwrite -W and -w X-Git-Tag: v4.14.0-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74919c4e745affbc386744925945e838bfaed7b7;p=thirdparty%2Fxfsprogs-dev.git xfs_io: report io error for pwrite -W and -w When IO error occurs, xfs_io -c "pwrite -W/w" doesn't report errors while xfs_io -c "pwrite" -c "fsync" does. This changes "pwrite -W/w" to report errors when it should. Signed-off-by: Liu Bo Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/io/pwrite.c b/io/pwrite.c index 1c5dfca1e..71bccccfd 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -379,10 +379,18 @@ pwrite_f( } if (c < 0) goto done; - if (Wflag) - fsync(file->fd); - if (wflag) - fdatasync(file->fd); + if (Wflag) { + if (fsync(file->fd) < 0) { + perror("fsync"); + goto done; + } + } + if (wflag) { + if (fdatasync(file->fd) < 0) { + perror("fdatasync"); + goto done; + } + } if (qflag) goto done; gettimeofday(&t2, NULL);