Skip to contentSkip to conversation

lib/ext2fs: add some msg for io error

PATCH Superseded zhanchengbin 1 participant 1 message Feb 23, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/ext2fs: add some msg for io error

Add msgs to show whether there is eio in fsck process, when write and fsync methods fail.

---
 lib/ext2fs/unix_io.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
lib/ext2fs/unix_io.c +11 -3
index 3171c736..d0ab3689 100644
@@ -1265,12 +1265,17 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
 		return errno;
 
 	actual = write(data->dev, buf, size);
+
 	if (actual < 0)
-		return errno;
+		retval = errno;
 	if (actual != size)
-		return EXT2_ET_SHORT_WRITE;
+		retval = EXT2_ET_SHORT_WRITE;
 
 	return 0;
+
+	fprintf(stderr, "%s unix_write_byte error, error %d\n",
+			channel->name, errno);
+	return retval;
 }
 
 /*
@@ -1289,8 +1294,11 @@ static errcode_t unix_flush(io_channel channel)
 	retval = flush_cached_blocks(channel, data, 0);
 #endif
 #ifdef HAVE_FSYNC
-	if (!retval && fsync(data->dev) != 0)
+	if (!retval && fsync(data->dev) != 0) {
+		fprintf(stderr, "%s flush error, error %d\n",
+				channel->name, errno);
 		return errno;
+	}
 #endif
 	return retval;
 }
Signature · 1 line
2.31.1