dovecot-2.0: fs-sis: If a super fs function fails, copy the erro...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Oct 2 14:33:55 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/ed1b7a4f225f
changeset: 12236:ed1b7a4f225f
user: Timo Sirainen <tss at iki.fi>
date: Fri Jul 30 15:58:12 2010 +0100
description:
fs-sis: If a super fs function fails, copy the error message to sis fs.
diffstat:
src/lib-fs/fs-sis.c | 78 +++++++++++++++++++++++++++++++++------
1 files changed, 66 insertions(+), 12 deletions(-)
diffs (178 lines):
diff -r 8e511be90b4b -r ed1b7a4f225f src/lib-fs/fs-sis.c
--- a/src/lib-fs/fs-sis.c Thu Jul 22 20:01:55 2010 +0100
+++ b/src/lib-fs/fs-sis.c Fri Jul 30 15:58:12 2010 +0100
@@ -27,6 +27,18 @@
struct sha1_ctxt existing_hash;
};
+static void fs_sis_copy_error(struct sis_fs *fs)
+{
+ fs_set_error(&fs->fs, "%s", fs_last_error(fs->super));
+}
+
+static void fs_sis_file_copy_error(struct sis_fs_file *file)
+{
+ struct sis_fs *fs = (struct sis_fs *)file->file.fs;
+
+ fs_sis_copy_error(fs);
+}
+
static struct fs *
fs_sis_init(const char *args, const struct fs_settings *set)
{
@@ -95,8 +107,10 @@
return -1;
}
- if (fs_open(fs->super, path, mode | flags, &super) < 0)
+ if (fs_open(fs->super, path, mode | flags, &super) < 0) {
+ fs_sis_copy_error(fs);
return -1;
+ }
switch (mode) {
case FS_OPEN_MODE_RDONLY:
@@ -153,8 +167,11 @@
static ssize_t fs_sis_read(struct fs_file *_file, void *buf, size_t size)
{
struct sis_fs_file *file = (struct sis_fs_file *)_file;
+ ssize_t ret;
- return fs_read(file->super, buf, size);
+ if ((ret = fs_read(file->super, buf, size)) < 0)
+ fs_sis_file_copy_error(file);
+ return ret;
}
static struct istream *
@@ -269,8 +286,10 @@
return 0;
}
- if (fs_write(file->super, data, size) < 0)
+ if (fs_write(file->super, data, size) < 0) {
+ fs_sis_file_copy_error(file);
return -1;
+ }
T_BEGIN {
fs_sis_replace_hash_file(file);
} T_END;
@@ -299,6 +318,7 @@
if (!success) {
fs_write_stream_abort(file->super, &file->fs_output);
+ fs_sis_file_copy_error(file);
return -1;
}
@@ -311,8 +331,10 @@
}
}
- if (fs_write_stream_finish(file->super, &file->fs_output) < 0)
+ if (fs_write_stream_finish(file->super, &file->fs_output) < 0) {
+ fs_sis_file_copy_error(file);
return -1;
+ }
T_BEGIN {
fs_sis_replace_hash_file(file);
} T_END;
@@ -324,7 +346,11 @@
{
struct sis_fs_file *file = (struct sis_fs_file *)_file;
- return fs_lock(file->super, secs, lock_r);
+ if (fs_lock(file->super, secs, lock_r) < 0) {
+ fs_sis_file_copy_error(file);
+ return -1;
+ }
+ return 0;
}
static void fs_sis_unlock(struct fs_lock *_lock ATTR_UNUSED)
@@ -336,35 +362,55 @@
{
struct sis_fs_file *file = (struct sis_fs_file *)_file;
- return fs_fdatasync(file->super);
+ if (fs_fdatasync(file->super) < 0) {
+ fs_sis_file_copy_error(file);
+ return -1;
+ }
+ return 0;
}
static int fs_sis_exists(struct fs *_fs, const char *path)
{
struct sis_fs *fs = (struct sis_fs *)_fs;
- return fs_exists(fs->super, path);
+ if (fs_exists(fs->super, path) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
static int fs_sis_stat(struct fs *_fs, const char *path, struct stat *st_r)
{
struct sis_fs *fs = (struct sis_fs *)_fs;
- return fs_stat(fs->super, path, st_r);
+ if (fs_stat(fs->super, path, st_r) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
static int fs_sis_link(struct fs *_fs, const char *src, const char *dest)
{
struct sis_fs *fs = (struct sis_fs *)_fs;
- return fs_link(fs->super, src, dest);
+ if (fs_link(fs->super, src, dest) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
static int fs_sis_rename(struct fs *_fs, const char *src, const char *dest)
{
struct sis_fs *fs = (struct sis_fs *)_fs;
- return fs_rename(fs->super, src, dest);
+ if (fs_rename(fs->super, src, dest) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
static void fs_sis_try_unlink_hash_file(struct sis_fs *fs, const char *path)
@@ -399,14 +445,22 @@
T_BEGIN {
fs_sis_try_unlink_hash_file(fs, path);
} T_END;
- return fs_unlink(fs->super, path);
+ if (fs_unlink(fs->super, path) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
static int fs_sis_rmdir(struct fs *_fs, const char *path)
{
struct sis_fs *fs = (struct sis_fs *)_fs;
- return fs_rmdir(fs->super, path);
+ if (fs_rmdir(fs->super, path) < 0) {
+ fs_sis_copy_error(fs);
+ return -1;
+ }
+ return 0;
}
struct fs fs_class_sis = {
More information about the dovecot-cvs
mailing list