]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Use [io]_stream_get_error() insted of %m
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 12:49:08 +0000 (15:49 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 18 May 2016 12:21:30 +0000 (15:21 +0300)
33 files changed:
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

index c9e1450f0ba8eb24fc811d8297327553f042a47c..4a6569610513790bc06779c6cdebd22a1c1e3f6c 100644 (file)
@@ -180,7 +180,8 @@ do_auth_continue(struct auth_request *auth_request,
                          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;
index b578d272b6cd79088ffc93b4f1b78f903a986bd7..f80cac1f9e084475b939b81be1a5ed6cf5caa905 100644 (file)
@@ -139,7 +139,8 @@ static void passwd_file_iterate_next(struct userdb_iterate_context *_ctx)
                        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;
                }
        }
index a727658efd796b0532880c1cc35efb48833cf383..2beb3270735a93f3466680da13e3e28b50b0b513 100644 (file)
@@ -2051,9 +2051,10 @@ void director_connection_send(struct director_connection *conn,
        } 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);
                }
index 76accd25661c02f71f96c653aa099c5e14ff6076..383a62c4a3fc3c6c0e8d899d45cc38f7a850c878 100644 (file)
@@ -60,11 +60,12 @@ static void director_connect(struct director_context *ctx)
        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);
                }
@@ -79,8 +80,10 @@ static void director_connect(struct director_context *ctx)
 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);
        }
 }
index 36b9fd85f4b47311584407d743d143bb15969398..2a4b33d887860cbfce105f60dbfa96b5ab46ddfa 100644 (file)
@@ -80,8 +80,10 @@ static void penalty_lookup(struct penalty_context *ctx)
                        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);
 }
index 6459a6c0f9f091775ebe494f3967573db70f6036..390572b530fd49385935a30c81c795ecb17d3a0d 100644 (file)
@@ -48,9 +48,10 @@ static void replicator_connect(struct replicator_context *ctx)
        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_connect(struct replicator_context *ctx)
 
 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);
 }
 
index 81e6f25623b07e62e8bf37bbf7d771b900c15354..54201ed78a83e12d168fc7c3b0ae3b69c1083f54 100644 (file)
@@ -111,7 +111,7 @@ static void stats_dump(const char *path, const char *cmd)
                } 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 @@ static void stats_read(struct top_context *ctx)
                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);
 }
 
index 3b75b9a9a69c824c8e90e9822a7a5ca761ce0cf8..d0f3b0f5d737a8cf52be7bb1b8ede4e08dba8b70 100644 (file)
@@ -169,8 +169,10 @@ void who_lookup(struct who_context *ctx, who_callback_t *callback)
                                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);
 }
index 957d4dd42d3b6c0c68661b9de0515a3e8cb43d35..10c964afb9dfdd093dc7d136b1a0e519dfada84f 100644 (file)
@@ -122,8 +122,8 @@ static void server_input(struct client *client)
 
        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");
index a138417e20657fb95301e3995c996c51e07cc4eb..b3ceab510f8aa1a2ee9f5d53257c7f5708b85ba3 100644 (file)
@@ -413,7 +413,8 @@ static int auth_master_run_cmd_pre(struct auth_master_connection *conn,
        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;
index 528d49a6714c3557520db8647260f28ea88d041e..8453a3a61f41a742211d275a710df25e8fac37c7 100644 (file)
@@ -453,9 +453,10 @@ int auth_server_connection_connect(struct auth_server_connection *conn)
                                     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;
        }
 
index f8379364740244e45a409c89d9821a208b59a364..0c721d2f121a76c9f6df4b0b438e885a2c9c82d9 100644 (file)
@@ -142,8 +142,8 @@ void http_server_response_set_payload(struct http_server_response *resp,
        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 @@ int http_server_response_send_more(struct http_server_response *resp,
        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 @@ static int http_server_response_send_real(struct http_server_response *resp,
        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;
        }
index 4f5de33d09912006e2b1303385492591b17b922a..549eaf45f1e1eb9666608893a62f3d50f00f139a 100644 (file)
@@ -1017,8 +1017,8 @@ static int mail_index_strmap_recreate(struct mail_index_strmap_view *view)
        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);
index 0e458d06ae044d385dd42e496f910c0d6c1de637..9cf1757325b6d164ca119ce98e8468993a1af349 100644 (file)
@@ -317,7 +317,8 @@ void duplicate_flush(struct duplicate_context *ctx)
        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;
index 5c91e7d72c8d91e4da82f9e82abe54d715ddb0e9..4d16a4ea12f1526b3675d1b7b00cc27a2e2b9379 100644 (file)
@@ -603,8 +603,8 @@ static void lmtp_client_input(struct lmtp_client *client)
                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) {
index 28bb1eb3b224a7b6c1515b187de7bd1f0a1b4999..131766ef038dd4ee812dccb072be87489fe0175e 100644 (file)
@@ -265,14 +265,14 @@ smtp_client_send_flush(struct smtp_client *smtp_client,
        }
 
        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;
        }
 
index 553b21b041ea57a0bdddf1f47ee981ade82626a9..eff41ff5780ae946d7bbc7ee4188bc1a24a73d1b 100644 (file)
@@ -113,7 +113,8 @@ static void anvil_input(struct anvil_client *client)
                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);
index b05ecb29008398bc6b81cc381ab741918850cda8..271adfe27822f27d6f3b7a213a01e2f6988ad5f8 100644 (file)
@@ -116,7 +116,7 @@ static int master_instance_list_refresh(struct master_instance_list *list)
                        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 @@ master_instance_list_write(struct master_instance_list *list,
                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);
index 5d02c2b80b405322d398f64bd695110685390ecc..4a25f6592cc5c7f9a65b0f6a6db125da81ee2b2c 100644 (file)
@@ -327,7 +327,8 @@ config_read_reply_header(struct istream *istream, const char *path, pool_t pool,
                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;
        }
index 0131521ef01e8d72eaf6cabbd8b0e0cc7ed79d2c..f2a7e9b4d94e2f19e2710c443deeaf3c679d97bb 100644 (file)
@@ -151,7 +151,8 @@ static int cydir_save_flush(struct cydir_save_context *ctx, const char *path)
        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;
        }
 
index a8911412cce92bfa5f168cdd1524a8046c88f957..fc566a84306c4563fb6cadfc7a4ef9be2c7be968 100644 (file)
@@ -78,7 +78,8 @@ mdbox_file_read_metadata_hdr(struct dbox_file *file,
                        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;
        }
 
@@ -191,7 +192,6 @@ mdbox_purge_save_msg(struct mdbox_purge_context *ctx, struct dbox_file *file,
        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);
@@ -207,19 +207,19 @@ mdbox_purge_save_msg(struct mdbox_purge_context *ctx, struct dbox_file *file,
 
        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) {
index 4cdaaf2aa794ee8cdadce3e7b19e4b533c8fa1e2..47622b9fed34a9d593407b15d1522139e84c81de 100644 (file)
@@ -323,20 +323,15 @@ int sdbox_file_move(struct dbox_file *file, bool alt_path)
 
        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);
 
index ff9e23b228d34e9aabc0b229055e3d7d6d722a1b..b8a6919b5f0284eabb3f291579438a810772617e 100644 (file)
@@ -274,7 +274,8 @@ int imapc_save_finish(struct mail_save_context *_ctx)
                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;
                }
index 5ec3efd042df49fd4ac27e3a58e885e2c988d25d..4b7abd9129d32ecddac007df284dcebae5f0cf58 100644 (file)
@@ -196,10 +196,9 @@ static int save_check_write_error(struct mail_storage *storage,
        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;
 }
index 8999737a9d02cce02d3df95bfdcc15b0e4c59bd4..f20fd76afbfc14028b75fc5f9fb0248beaf0cf08 100644 (file)
@@ -524,7 +524,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
 {
        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;
@@ -539,7 +539,8 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
        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;
        }
@@ -570,6 +571,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
                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 &&
@@ -613,13 +615,12 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
                /* 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);
index eb89aa558d428052ed118e5b7d1763e1371ed993..b0208f2672e1f6a883b5bc4e5bc1ae649eea394f 100644 (file)
@@ -832,9 +832,9 @@ maildir_uidlist_update_read(struct maildir_uidlist *uidlist,
                 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 @@ static int maildir_uidlist_write_fd(struct maildir_uidlist *uidlist, int fd,
        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;
        }
index fe54a19cdf1c8ba1924adba1e6d58c54118e8a1f..4e6afbf85c12167699ea915ec2d326818a45686b 100644 (file)
@@ -133,8 +133,9 @@ int json_parser_deinit(struct json_parser **_parser, const char **error_r)
                /* 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) {
index 28764171b075eab00f54567b696d1521d5c3c4dc..6e3fd226d98842da24fe7f95b1357f18502d293e 100644 (file)
@@ -279,7 +279,8 @@ acl_backend_vfile_acllist_try_rebuild(struct acl_backend_vfile *backend)
        }
 
        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)
index ecd2dea99db0ff0c7227b697ea0b21b398221c8f..0c2ebadee075bfdcec12bab877618d020f88ea47 100644 (file)
@@ -159,7 +159,8 @@ acl_backend_vfile_update_write(struct acl_object *aclobj,
        }
        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);
index 188a41cbaaa3344a2bcce30d546cb9dc3a9c3ce8..db8048a5df7b2c92d640bcb48e927d638f406d99 100644 (file)
@@ -393,7 +393,8 @@ acl_backend_vfile_read(struct acl_object *aclobj, bool global, const char *path,
                        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) {
index 0861f21b0c88ac7f1cb94bf4ad3e087b5bb6c757..b3d8fa301b8387259cc024c2e28ef96560a5dcb1 100644 (file)
@@ -1680,7 +1680,8 @@ static int squat_trie_write(struct squat_trie_build_context *ctx)
                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);
index 92bc86fa4690a273b8863678f8c68e4e31cc8759..1b7fb1cad19dc43b49610f1c2e9d8e1ed5999161 100644 (file)
@@ -861,7 +861,8 @@ int squat_uidlist_build_finish(struct squat_uidlist_build_context *ctx)
        }
 
        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 @@ int squat_uidlist_rebuild_finish(struct squat_uidlist_rebuild_context *ctx,
                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",
index cf94ba12bb0925fdd4b6ab03eddfb6e8e6e02c78..667d66ac7feb9259699e78a211a26c7c06d0c04c 100644 (file)
@@ -424,7 +424,8 @@ fts_expunge_log_read_failure(struct fts_expunge_log_read_ctx *ctx,
 
        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;