]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Improved fs_write_*() error messages.
authorTimo Sirainen <tss@iki.fi>
Sun, 22 Sep 2013 01:41:50 +0000 (04:41 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 22 Sep 2013 01:41:50 +0000 (04:41 +0300)
src/lib-fs/fs-posix.c
src/lib-fs/fs-sis-queue.c
src/lib-fs/fs-sis.c

index 92c3ca6b43d1c88700333cfed55df962f3588382..00d70dc4ab09e277b53f47dd9e2c75b14028e1b9 100644 (file)
@@ -47,6 +47,7 @@ struct posix_fs_file {
 
        bool seek_to_beginning;
        bool success;
+       bool open_failed;
 };
 
 struct posix_fs_lock {
@@ -462,7 +463,9 @@ static void fs_posix_write_stream(struct fs_file *_file)
                file->write_buf = buffer_create_dynamic(default_pool, 1024*32);
                _file->output = o_stream_create_buffer(file->write_buf);
        } else if (file->fd == -1 && fs_posix_open(file) < 0) {
-               _file->output = o_stream_create_error(errno);
+               _file->output = o_stream_create_error_str(errno, "%s",
+                       fs_file_last_error(_file));
+               file->open_failed = TRUE;
        } else {
                _file->output = o_stream_create_fd_file(file->fd,
                                                        (uoff_t)-1, FALSE);
@@ -475,9 +478,12 @@ static int fs_posix_write_stream_finish(struct fs_file *_file, bool success)
        struct posix_fs_file *file = (struct posix_fs_file *)_file;
        int ret = success ? 0 : -1;
 
-       if (o_stream_nfinish(_file->output) < 0) {
-               fs_set_error(_file->fs, "write(%s) failed: %m",
-                            o_stream_get_name(_file->output));
+       if (file->open_failed)
+               ret = -1;
+       else if (o_stream_nfinish(_file->output) < 0) {
+               fs_set_error(_file->fs, "write(%s) failed: %s",
+                            o_stream_get_name(_file->output),
+                            o_stream_get_error(_file->output));
                ret = -1;
        }
        o_stream_destroy(&_file->output);
index 914403eb2406d68c979a46a7b0aeab689a62be5b..ef79d55f1890c78c405c52a696b65dd578453b5c 100644 (file)
@@ -234,10 +234,12 @@ static void fs_sis_queue_write_stream(struct fs_file *_file)
 
        i_assert(_file->output == NULL);
 
-       if (file->super == NULL)
-               _file->output = o_stream_create_error(EINVAL);
-       else
+       if (file->super == NULL) {
+               _file->output = o_stream_create_error_str(EINVAL, "%s",
+                                               fs_file_last_error(_file));
+       } else {
                _file->output = fs_write_stream(file->super);
+       }
        o_stream_set_name(_file->output, _file->path);
 }
 
index 14f0920a416b7278681d66541d380413ca7d1d30..aa95cdcff8d907d61c51705efa757704ca635ea9 100644 (file)
@@ -354,9 +354,10 @@ static void fs_sis_write_stream(struct fs_file *_file)
 
        i_assert(_file->output == NULL);
 
-       if (file->super == NULL)
-               _file->output = o_stream_create_error(EINVAL);
-       else {
+       if (file->super == NULL) {
+               _file->output = o_stream_create_error_str(EINVAL, "%s",
+                                               fs_file_last_error(_file));
+       } else {
                file->fs_output = fs_write_stream(file->super);
                if (file->hash_input == NULL)
                        _file->output = file->fs_output;