changeset 20264:0fd0fb05e2b3

global: Use [io]_stream_get_error() insted of %m
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 16 May 2016 15:49:08 +0300
parents b85badda00af
children 2e9253743a09
files src/auth/mech-winbind.c src/auth/userdb-passwd-file.c src/director/director-connection.c src/doveadm/doveadm-director.c src/doveadm/doveadm-penalty.c src/doveadm/doveadm-replicator.c src/doveadm/doveadm-stats.c src/doveadm/doveadm-who.c src/doveadm/doveadm-zlib.c src/lib-auth/auth-master.c src/lib-auth/auth-server-connection.c src/lib-http/http-server-response.c src/lib-index/mail-index-strmap.c src/lib-lda/duplicate.c src/lib-lda/lmtp-client.c src/lib-lda/smtp-client.c src/lib-master/anvil-client.c src/lib-master/master-instance.c src/lib-master/master-service-settings.c src/lib-storage/index/cydir/cydir-save.c src/lib-storage/index/dbox-multi/mdbox-purge.c src/lib-storage/index/dbox-single/sdbox-file.c src/lib-storage/index/imapc/imapc-save.c src/lib-storage/index/index-attachment.c src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-uidlist.c src/lib/json-parser.c src/plugins/acl/acl-backend-vfile-acllist.c src/plugins/acl/acl-backend-vfile-update.c src/plugins/acl/acl-backend-vfile.c src/plugins/fts-squat/squat-trie.c src/plugins/fts-squat/squat-uidlist.c src/plugins/fts/fts-expunge-log.c
diffstat 33 files changed, 123 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/mech-winbind.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/auth/mech-winbind.c	Mon May 16 15:49:08 2016 +0300
@@ -180,7 +180,8 @@
 			  str_data(str), str_len(str)) < 0 ||
 	    o_stream_flush(request->winbind->out_pipe) < 0) {
 		auth_request_log_error(auth_request, AUTH_SUBSYS_MECH,
-				       "write(out_pipe) failed: %m");
+			"write(out_pipe) failed: %s",
+			o_stream_get_error(request->winbind->out_pipe));
 		return HR_RESTART;
 	}
 	request->continued = FALSE;
--- a/src/auth/userdb-passwd-file.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/auth/userdb-passwd-file.c	Mon May 16 15:49:08 2016 +0300
@@ -139,7 +139,8 @@
 			break;
 		}
 		if (line == NULL && ctx->input->stream_errno != 0) {
-			i_error("read(%s) failed: %m", ctx->path);
+			i_error("read(%s) failed: %s", ctx->path,
+				i_stream_get_error(ctx->input));
 			_ctx->failed = TRUE;
 		}
 	}
--- a/src/director/director-connection.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/director/director-connection.c	Mon May 16 15:49:08 2016 +0300
@@ -2051,9 +2051,10 @@
 	} T_END;
 	ret = o_stream_send(conn->output, data, len);
 	if (ret != (off_t)len) {
-		if (ret < 0)
-			i_error("director(%s): write() failed: %m", conn->name);
-		else {
+		if (ret < 0) {
+			i_error("director(%s): write() failed: %s", conn->name,
+				o_stream_get_error(conn->output));
+		} else {
 			i_error("director(%s): Output buffer full, "
 				"disconnecting", conn->name);
 		}
--- a/src/doveadm/doveadm-director.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-director.c	Mon May 16 15:49:08 2016 +0300
@@ -66,11 +66,12 @@
 	line = i_stream_read_next_line(ctx->input);
 	alarm(0);
 	if (line == NULL) {
-		if (ctx->input->stream_errno != 0)
-			i_fatal("read(%s) failed: %m", ctx->socket_path);
-		else if (ctx->input->eof)
+		if (ctx->input->stream_errno != 0) {
+			i_fatal("read(%s) failed: %s", ctx->socket_path,
+				i_stream_get_error(ctx->input));
+		} else if (ctx->input->eof) {
 			i_fatal("%s disconnected", ctx->socket_path);
-		else {
+		} else {
 			i_fatal("read(%s) timed out (is director configured?)",
 				ctx->socket_path);
 		}
@@ -85,8 +86,10 @@
 static void director_disconnect(struct director_context *ctx)
 {
 	if (ctx->input != NULL) {
-		if (ctx->input->stream_errno != 0)
-			i_fatal("read(%s) failed: %m", ctx->socket_path);
+		if (ctx->input->stream_errno != 0) {
+			i_fatal("read(%s) failed: %s", ctx->socket_path,
+				i_stream_get_error(ctx->input));
+		}
 		i_stream_destroy(&ctx->input);
 	}
 }
--- a/src/doveadm/doveadm-penalty.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-penalty.c	Mon May 16 15:49:08 2016 +0300
@@ -80,8 +80,10 @@
 			penalty_print_line(ctx, &penalty_line);
 		} T_END;
 	}
-	if (input->stream_errno != 0)
-		i_fatal("read(%s) failed: %m", ctx->anvil_path);
+	if (input->stream_errno != 0) {
+		i_fatal("read(%s) failed: %s", ctx->anvil_path,
+			i_stream_get_error(input));
+	}
 
 	i_stream_destroy(&input);
 }
--- a/src/doveadm/doveadm-replicator.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-replicator.c	Mon May 16 15:49:08 2016 +0300
@@ -48,9 +48,10 @@
 	line = i_stream_read_next_line(ctx->input);
 	alarm(0);
 	if (line == NULL) {
-		if (ctx->input->stream_errno != 0)
-			i_fatal("read(%s) failed: %m", ctx->socket_path);
-		else if (ctx->input->eof)
+		if (ctx->input->stream_errno != 0) {
+			i_fatal("read(%s) failed: %s", ctx->socket_path,
+				i_stream_get_error(ctx->input));
+		} else if (ctx->input->eof)
 			i_fatal("%s disconnected", ctx->socket_path);
 		else
 			i_fatal("read(%s) timed out", ctx->socket_path);
@@ -64,8 +65,10 @@
 
 static void replicator_disconnect(struct replicator_context *ctx)
 {
-	if (ctx->input->stream_errno != 0)
-		i_fatal("read(%s) failed: %m", ctx->socket_path);
+	if (ctx->input->stream_errno != 0) {
+		i_fatal("read(%s) failed: %s", ctx->socket_path,
+			i_stream_get_error(ctx->input));
+	}
 	i_stream_destroy(&ctx->input);
 }
 
--- a/src/doveadm/doveadm-stats.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-stats.c	Mon May 16 15:49:08 2016 +0300
@@ -111,7 +111,7 @@
 		} while (args != NULL);
 	}
 	if (input->stream_errno != 0)
-		i_fatal("read(%s) failed: %m", path);
+		i_fatal("read(%s) failed: %s", path, i_stream_get_error(input));
 	i_stream_destroy(&input);
 }
 
@@ -194,8 +194,10 @@
 		hash_table_insert(ctx->sessions, line->id, line);
 	}
 
-	if (ctx->input->stream_errno != 0)
-		i_fatal("read(%s) failed: %m", ctx->path);
+	if (ctx->input->stream_errno != 0) {
+		i_fatal("read(%s) failed: %s", ctx->path,
+			i_stream_get_error(ctx->input));
+	}
 	i_fatal("read(%s): unexpected EOF", ctx->path);
 }
 
--- a/src/doveadm/doveadm-who.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-who.c	Mon May 16 15:49:08 2016 +0300
@@ -169,8 +169,10 @@
 				callback(ctx, &who_line);
 		} T_END;
 	}
-	if (input->stream_errno != 0)
-		i_fatal("read(%s) failed: %m", ctx->anvil_path);
+	if (input->stream_errno != 0) {
+		i_fatal("read(%s) failed: %s", ctx->anvil_path,
+			i_stream_get_error(input));
+	}
 
 	i_stream_destroy(&input);
 }
--- a/src/doveadm/doveadm-zlib.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/doveadm/doveadm-zlib.c	Mon May 16 15:49:08 2016 +0300
@@ -122,8 +122,8 @@
 
 	if (i_stream_read(client->input) == -1) {
 		if (client->input->stream_errno != 0) {
-			errno = client->input->stream_errno;
-			i_fatal("read(server) failed: %m");
+			i_fatal("read(server) failed: %s",
+				i_stream_get_error(client->input));
 		}
 
 		i_info("Server disconnected");
--- a/src/lib-auth/auth-master.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-auth/auth-master.c	Mon May 16 15:49:08 2016 +0300
@@ -413,7 +413,8 @@
 	o_stream_uncork(conn->output);
 
 	if (o_stream_nfinish(conn->output) < 0) {
-		i_error("write(auth socket) failed: %m");
+		i_error("write(auth socket) failed: %s",
+			o_stream_get_error(conn->output));
 		auth_master_unset_io(conn);
 		auth_connection_close(conn);
 		return -1;
--- a/src/lib-auth/auth-server-connection.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-auth/auth-server-connection.c	Mon May 16 15:49:08 2016 +0300
@@ -453,9 +453,10 @@
                                     AUTH_CLIENT_PROTOCOL_MINOR_VERSION,
 				    conn->client->client_pid);
 	if (o_stream_send_str(conn->output, handshake) < 0) {
-		i_warning("Error sending handshake to auth server: %m");
+		i_warning("Error sending handshake to auth server: %s",
+			  o_stream_get_error(conn->output));
 		auth_server_connection_disconnect(conn,
-			strerror(conn->output->last_failed_errno));
+			o_stream_get_error(conn->output));
 		return -1;
 	}
 
--- a/src/lib-http/http-server-response.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-http/http-server-response.c	Mon May 16 15:49:08 2016 +0300
@@ -142,8 +142,8 @@
 	resp->payload_input = input;
 	if ((ret = i_stream_get_size(input, TRUE, &resp->payload_size)) <= 0) {
 		if (ret < 0) {
-			i_error("i_stream_get_size(%s) failed: %m",
-				i_stream_get_name(input));
+			i_error("i_stream_get_size(%s) failed: %s",
+				i_stream_get_name(input), i_stream_get_error(input));
 		}
 		resp->payload_size = 0;
 		resp->payload_chunked = TRUE;
@@ -500,16 +500,16 @@
 	if (resp->payload_input->stream_errno != 0) {
 		/* we're in the middle of sending a response, so the connection
 		   will also have to be aborted */
-		errno = resp->payload_input->stream_errno;
-		*error_r = t_strdup_printf("read(%s) failed: %m",
-					   i_stream_get_name(resp->payload_input));
+		*error_r = t_strdup_printf("read(%s) failed: %s",
+			i_stream_get_name(resp->payload_input),
+			i_stream_get_error(resp->payload_input));
 		ret = -1;
 	} else if (output->stream_errno != 0) {
 		/* failed to send response */
-		errno = output->stream_errno;
-		if (errno != EPIPE && errno != ECONNRESET) {
-			*error_r = t_strdup_printf("write(%s) failed: %m",
-					   o_stream_get_name(output));
+		if (output->stream_errno != EPIPE &&
+		    output->stream_errno != ECONNRESET) {
+			*error_r = t_strdup_printf("write(%s) failed: %s",
+				o_stream_get_name(output), o_stream_get_error(output));
 		}
 		ret = -1;
 	} else {
@@ -646,9 +646,10 @@
 	o_stream_ref(output);
 	o_stream_cork(output);
 	if (o_stream_sendv(output, iov, N_ELEMENTS(iov)) < 0) {
-		if (errno != EPIPE && errno != ECONNRESET) {
-			*error_r = t_strdup_printf("write(%s) failed: %m",
-					   o_stream_get_name(output));
+		if (output->stream_errno != EPIPE &&
+		    output->stream_errno != ECONNRESET) {
+			*error_r = t_strdup_printf("write(%s) failed: %s",
+				o_stream_get_name(output), o_stream_get_error(output));
 		}
 		ret = -1;
 	}
--- a/src/lib-index/mail-index-strmap.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-index/mail-index-strmap.c	Mon May 16 15:49:08 2016 +0300
@@ -1018,8 +1018,8 @@
 	o_stream_cork(output);
 	mail_index_strmap_recreate_write(view, output);
 	if (o_stream_nfinish(output) < 0) {
-		mail_index_set_error(strmap->index,
-				     "write(%s) failed: %m", temp_path);
+		mail_index_set_error(strmap->index, "write(%s) failed: %s",
+				     temp_path, o_stream_get_error(output));
 		ret = -1;
 	}
 	o_stream_destroy(&output);
--- a/src/lib-lda/duplicate.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-lda/duplicate.c	Mon May 16 15:49:08 2016 +0300
@@ -318,7 +318,8 @@
 	hash_table_iterate_deinit(&iter);
 
 	if (o_stream_nfinish(output) < 0) {
-		i_error("write(%s) failed: %m", file->path);
+		i_error("write(%s) failed: %s", file->path,
+			o_stream_get_error(output));
 		o_stream_unref(&output);
 		duplicate_file_free(&ctx->file);
 		return;
--- a/src/lib-lda/lmtp-client.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-lda/lmtp-client.c	Mon May 16 15:49:08 2016 +0300
@@ -604,8 +604,8 @@
 		lmtp_client_fail(client,
 				 "501 5.5.4 Command reply line too long");
 	} else if (client->input->stream_errno != 0) {
-		errno = client->input->stream_errno;
-		i_error("lmtp client: read() failed: %m");
+		i_error("lmtp client: read() failed: %s",
+			i_stream_get_error(client->input));
 		lmtp_client_fail(client, ERRSTR_TEMP_REMOTE_FAILURE
 				 " (read failure)");
 	} else if (client->input->eof) {
--- a/src/lib-lda/smtp-client.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-lda/smtp-client.c	Mon May 16 15:49:08 2016 +0300
@@ -265,14 +265,14 @@
 	}
 
 	if (o_stream_nfinish(smtp_client->output) < 0) {
-		*error_r = t_strdup_printf("write(%s) failed: %m",
-					   smtp_client->temp_path);
+		*error_r = t_strdup_printf("write(%s) failed: %s",
+			smtp_client->temp_path, o_stream_get_error(smtp_client->output));
 		return -1;
 	}
 
 	if (o_stream_seek(smtp_client->output, 0) < 0) {
-		*error_r = t_strdup_printf("lseek(%s) failed: %m",
-					   smtp_client->temp_path);
+		*error_r = t_strdup_printf("lseek(%s) failed: %s",
+			smtp_client->temp_path, o_stream_get_error(smtp_client->output));
 		return -1;
 	}
 
--- a/src/lib-master/anvil-client.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-master/anvil-client.c	Mon May 16 15:49:08 2016 +0300
@@ -113,7 +113,8 @@
 		aqueue_delete_tail(client->queries);
 	}
 	if (client->input->stream_errno != 0) {
-		i_error("read(%s) failed: %m", client->path);
+		i_error("read(%s) failed: %s", client->path,
+			i_stream_get_error(client->input));
 		anvil_reconnect(client);
 	} else if (client->input->eof) {
 		i_error("read(%s) failed: EOF", client->path);
--- a/src/lib-master/master-instance.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-master/master-instance.c	Mon May 16 15:49:08 2016 +0300
@@ -116,7 +116,7 @@
 			i_error("Invalid line in %s: %s", list->path, line);
 	} T_END;
 	if (input->stream_errno != 0) {
-		i_error("read(%s) failed: %m", line);
+		i_error("read(%s) failed: %s", line, i_stream_get_error(input));
 		ret = -1;
 	}
 	i_stream_destroy(&input);
@@ -147,7 +147,7 @@
 		o_stream_nsend(output, str_data(str), str_len(str));
 	}
 	if (o_stream_nfinish(output) < 0) {
-		i_error("write(%s) failed: %m", path);
+		i_error("write(%s) failed: %s", path, o_stream_get_error(output));
 		ret = -1;
 	}
 	o_stream_destroy(&output);
--- a/src/lib-master/master-service-settings.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-master/master-service-settings.c	Mon May 16 15:49:08 2016 +0300
@@ -327,7 +327,8 @@
 		if (ret == 0)
 			return 1;
 		*error_r = istream->stream_errno != 0 ?
-			t_strdup_printf("read(%s) failed: %m", path) :
+			t_strdup_printf("read(%s) failed: %s", path,
+					i_stream_get_error(istream)) :
 			t_strdup_printf("read(%s) failed: EOF", path);
 		return -1;
 	}
--- a/src/lib-storage/index/cydir/cydir-save.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/cydir/cydir-save.c	Mon May 16 15:49:08 2016 +0300
@@ -162,7 +162,8 @@
 	int ret = 0;
 
 	if (o_stream_nfinish(ctx->ctx.data.output) < 0) {
-		mail_storage_set_critical(storage, "write(%s) failed: %m", path);
+		mail_storage_set_critical(storage, "write(%s) failed: %s", path,
+			o_stream_get_error(ctx->ctx.data.output));
 		ret = -1;
 	}
 
--- a/src/lib-storage/index/dbox-multi/mdbox-purge.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c	Mon May 16 15:49:08 2016 +0300
@@ -78,7 +78,8 @@
 			return 0;
 		}
 		mail_storage_set_critical(&file->storage->storage,
-			"read(%s) failed: %m", file->cur_path);
+			"read(%s) failed: %s", file->cur_path,
+			i_stream_get_error(file->input));
 		return -1;
 	}
 
@@ -192,7 +193,6 @@
 	enum mdbox_map_append_flags append_flags;
 	uoff_t msg_size;
 	off_t ret;
-	int read_errno;
 
 	if (ctx->append_ctx == NULL)
 		ctx->append_ctx = mdbox_map_append_begin(ctx->atomic);
@@ -208,19 +208,19 @@
 
 	input = i_stream_create_limit(file->input, msg_size);
 	ret = o_stream_send_istream(output, input);
-	read_errno = input->stream_errno;
-	i_stream_unref(&input);
-
-	if (read_errno != 0) {
-		errno = read_errno;
+	if (input->stream_errno != 0) {
 		mail_storage_set_critical(&file->storage->storage,
-			"read(%s) failed: %m", file->cur_path);
+			"read(%s) failed: %s", file->cur_path,
+			i_stream_get_error(input));
+		i_stream_unref(&input);
 		return -1;
 	}
+	i_stream_unref(&input);
 	if (o_stream_nfinish(output) < 0) {
 		mail_storage_set_critical(&file->storage->storage,
-					  "write(%s) failed: %m",
-					  out_file_append->file->cur_path);
+					  "write(%s) failed: %s",
+					  out_file_append->file->cur_path,
+					  o_stream_get_error(output));
 		return -1;
 	}
 	if (ret != (off_t)msg_size) {
--- a/src/lib-storage/index/dbox-single/sdbox-file.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-file.c	Mon May 16 15:49:08 2016 +0300
@@ -328,20 +328,15 @@
 
 	output = o_stream_create_fd_file(out_fd, 0, FALSE);
 	i_stream_seek(file->input, 0);
-	while ((ret = o_stream_send_istream(output, file->input)) > 0) ;
+	ret = o_stream_send_istream(output, file->input) > 0 ? 0 : -1;
 	if (o_stream_nfinish(output) < 0) {
-		mail_storage_set_critical(storage, "write(%s) failed: %m",
-					  temp_path);
+		mail_storage_set_critical(storage, "write(%s) failed: %s",
+			temp_path, o_stream_get_error(output));
 		ret = -1;
 	} else if (file->input->stream_errno != 0) {
-		errno = file->input->stream_errno;
-		dbox_file_set_syscall_error(file, "ftruncate()");
+		mail_storage_set_critical(storage, "read(%s) failed: %s",
+			temp_path, i_stream_get_error(file->input));
 		ret = -1;
-	} else if (ret < 0) {
-		mail_storage_set_critical(storage,
-			"o_stream_send_istream(%s, %s) "
-			"failed with unknown error",
-			temp_path, file->cur_path);
 	}
 	o_stream_unref(&output);
 
--- a/src/lib-storage/index/imapc/imapc-save.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/imapc/imapc-save.c	Mon May 16 15:49:08 2016 +0300
@@ -280,7 +280,8 @@
 		if (o_stream_nfinish(_ctx->data.output) < 0) {
 			if (!mail_storage_set_error_from_errno(storage)) {
 				mail_storage_set_critical(storage,
-					"write(%s) failed: %m", ctx->temp_path);
+					"write(%s) failed: %s", ctx->temp_path,
+					o_stream_get_error(_ctx->data.output));
 			}
 			ctx->failed = TRUE;
 		}
--- a/src/lib-storage/index/index-attachment.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/index-attachment.c	Mon May 16 15:49:08 2016 +0300
@@ -196,10 +196,9 @@
 	if (output->last_failed_errno == 0)
 		return 0;
 
-	errno = output->last_failed_errno;
 	if (!mail_storage_set_error_from_errno(storage)) {
-		mail_storage_set_critical(storage, "write(%s) failed: %m",
-					  o_stream_get_name(output));
+		mail_storage_set_critical(storage, "write(%s) failed: %s",
+			o_stream_get_name(output), o_stream_get_error(output));
 	}
 	return -1;
 }
--- a/src/lib-storage/index/maildir/maildir-save.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/maildir/maildir-save.c	Mon May 16 15:49:08 2016 +0300
@@ -536,7 +536,7 @@
 {
 	struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx;
 	struct mail_storage *storage = &ctx->mbox->storage->storage;
-	const char *path;
+	const char *path, *output_errstr;
 	off_t real_size;
 	uoff_t size;
 	int output_errno;
@@ -551,7 +551,8 @@
 	if (!ctx->failed && o_stream_nfinish(_ctx->data.output) < 0) {
 		if (!mail_storage_set_error_from_errno(storage)) {
 			mail_storage_set_critical(storage,
-				"write(%s) failed: %m", path);
+				"write(%s) failed: %s", path,
+				o_stream_get_error(_ctx->data.output));
 		}
 		ctx->failed = TRUE;
 	}
@@ -582,6 +583,7 @@
 		ctx->file_last->vsize = (uoff_t)-1;
 
 	output_errno = _ctx->data.output->last_failed_errno;
+	output_errstr = t_strdup(o_stream_get_error(_ctx->data.output));
 	o_stream_destroy(&_ctx->data.output);
 
 	if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER &&
@@ -625,13 +627,12 @@
 		/* delete the tmp file */
 		i_unlink_if_exists(path);
 
-		errno = output_errno;
-		if (ENOQUOTA(errno)) {
+		if (ENOQUOTA(output_errno)) {
 			mail_storage_set_error(storage,
 				MAIL_ERROR_NOQUOTA, MAIL_ERRSTR_NO_QUOTA);
-		} else if (errno != 0) {
+		} else if (output_errno != 0) {
 			mail_storage_set_critical(storage,
-				"write(%s) failed: %m", path);
+				"write(%s) failed: %s", path, output_errstr);
 		}
 
 		maildir_save_remove_last_filename(ctx);
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Mon May 16 15:49:08 2016 +0300
@@ -832,9 +832,9 @@
                 if (input->stream_errno == ESTALE && try_retry)
 			*retry_r = TRUE;
 		else {
-			errno = input->stream_errno;
 			mail_storage_set_critical(storage,
-				"read(%s) failed: %m", uidlist->path);
+				"read(%s) failed: %s", uidlist->path,
+				i_stream_get_error(input));
 		}
 		uidlist->last_read_offset = 0;
 	}
@@ -1312,7 +1312,8 @@
 	maildir_uidlist_iter_deinit(&iter);
 
 	if (o_stream_nfinish(output) < 0) {
-		mail_storage_set_critical(storage, "write(%s) failed: %m", path);
+		mail_storage_set_critical(storage, "write(%s) failed: %s", path,
+					  o_stream_get_error(output));
 		o_stream_unref(&output);
 		return -1;
 	}
--- a/src/lib/json-parser.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/lib/json-parser.c	Mon May 16 15:49:08 2016 +0300
@@ -133,8 +133,9 @@
 		/* actual parser error */
 		*error_r = parser->error;
 	} else if (parser->input->stream_errno != 0) {
-		*error_r = t_strdup_printf("read(%s) failed: %m",
-					   i_stream_get_name(parser->input));
+		*error_r = t_strdup_printf("read(%s) failed: %s",
+					   i_stream_get_name(parser->input),
+					   i_stream_get_error(parser->input));
 	} else if (parser->data == parser->end &&
 		   !i_stream_have_bytes_left(parser->input) &&
 		   parser->state != JSON_STATE_DONE) {
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Mon May 16 15:49:08 2016 +0300
@@ -279,7 +279,8 @@
 	}
 
 	if (o_stream_nfinish(output) < 0) {
-		i_error("write(%s) failed: %m", str_c(path));
+		i_error("write(%s) failed: %s", str_c(path),
+			o_stream_get_error(output));
 		ret = -1;
 	}
 	if (mailbox_list_iter_deinit(&iter) < 0)
--- a/src/plugins/acl/acl-backend-vfile-update.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/acl/acl-backend-vfile-update.c	Mon May 16 15:49:08 2016 +0300
@@ -159,7 +159,8 @@
 	}
 	str_free(&str);
 	if (o_stream_nfinish(output) < 0) {
-		i_error("write(%s) failed: %m", path);
+		i_error("write(%s) failed: %s", path,
+			o_stream_get_error(output));
 		ret = -1;
 	}
 	o_stream_destroy(&output);
--- a/src/plugins/acl/acl-backend-vfile.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/acl/acl-backend-vfile.c	Mon May 16 15:49:08 2016 +0300
@@ -393,7 +393,8 @@
 			ret = 0;
 		else {
 			ret = -1;
-			i_error("read(%s) failed: %m", path);
+			i_error("read(%s) failed: %s", path,
+				i_stream_get_error(input));
 		}
 	} else {
 		if (fstat(fd, &st) < 0) {
--- a/src/plugins/fts-squat/squat-trie.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/fts-squat/squat-trie.c	Mon May 16 15:49:08 2016 +0300
@@ -1680,7 +1680,8 @@
 		o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
 	}
 	if (o_stream_nfinish(output) < 0) {
-		i_error("write() to %s failed: %m", path);
+		i_error("write(%s) failed: %s", path,
+			o_stream_get_error(output));
 		ret = -1;
 	}
 	o_stream_destroy(&output);
--- a/src/plugins/fts-squat/squat-uidlist.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/fts-squat/squat-uidlist.c	Mon May 16 15:49:08 2016 +0300
@@ -861,7 +861,8 @@
 	}
 
 	if (o_stream_nfinish(ctx->output) < 0) {
-		i_error("write() to %s failed: %m", ctx->uidlist->path);
+		i_error("write() to %s failed: %s", ctx->uidlist->path,
+			o_stream_get_error(ctx->output));
 		return -1;
 	}
 	return 0;
@@ -1064,7 +1065,8 @@
 		if (ctx->uidlist->corrupted)
 			ret = -1;
 		else if (o_stream_nfinish(ctx->output) < 0) {
-			i_error("write() to %s failed: %m", temp_path);
+			i_error("write(%s) failed: %s", temp_path,
+				o_stream_get_error(ctx->output));
 			ret = -1;
 		} else if (rename(temp_path, ctx->uidlist->path) < 0) {
 			i_error("rename(%s, %s) failed: %m",
--- a/src/plugins/fts/fts-expunge-log.c	Tue May 10 20:37:55 2016 +0200
+++ b/src/plugins/fts/fts-expunge-log.c	Mon May 16 15:49:08 2016 +0300
@@ -424,7 +424,8 @@
 
 	if (ctx->input->stream_errno != 0) {
 		ctx->failed = TRUE;
-		i_error("read(%s) failed: %m", ctx->log->path);
+		i_error("read(%s) failed: %s", ctx->log->path,
+			i_stream_get_error(ctx->input));
 	} else {
 		size = i_stream_get_data_size(ctx->input);
 		ctx->corrupted = TRUE;