Mercurial > dovecot > core-2.2
changeset 19587:999368a35f8f
lib-fs: Added default implementations for fs_iter_*(), fs_copy() and fs_stat()
The backends can now leave them as NULL, and the callers will get an error
that they're not supported.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 18 Jan 2016 14:59:50 +0200 |
parents | f9d75e6e1618 |
children | 3ad2efd7e247 |
files | src/lib-fs/fs-api.c |
diffstat | 1 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-fs/fs-api.c Mon Jan 18 14:57:45 2016 +0200 +++ b/src/lib-fs/fs-api.c Mon Jan 18 14:59:50 2016 +0200 @@ -716,8 +716,6 @@ return ret; } - - int fs_lock(struct fs_file *file, unsigned int secs, struct fs_lock **lock_r) { int ret; @@ -764,6 +762,11 @@ { int ret; + if (file->fs->v.stat == NULL) { + fs_set_error(file->fs, "fs_stat() not supported"); + return -1; + } + if (!file->read_or_prefetch_counted && !file->lookup_metadata_counted && !file->stat_counted) { file->stat_counted = TRUE; @@ -834,6 +837,11 @@ i_assert(src->fs == dest->fs); + if (src->fs->v.copy == NULL) { + fs_set_error(src->fs, "fs_copy() not supported"); + return -1; + } + dest->fs->stats.copy_count++; fs_file_timing_start(dest, FS_OP_COPY); T_BEGIN { @@ -904,7 +912,10 @@ if (gettimeofday(&now, NULL) < 0) i_fatal("gettimeofday() failed: %m"); } - T_BEGIN { + if (fs->v.iter_init == NULL) { + iter = i_new(struct fs_iter, 1); + iter->fs = fs; + } else T_BEGIN { iter = fs->v.iter_init(fs, path, flags); } T_END; iter->start_time = now; @@ -919,7 +930,12 @@ *_iter = NULL; DLLIST_REMOVE(&iter->fs->iters, iter); - T_BEGIN { + + if (iter->fs->v.iter_deinit == NULL) { + fs_set_error(iter->fs, "FS teration not supported"); + i_free(iter); + ret = -1; + } else T_BEGIN { ret = iter->fs->v.iter_deinit(iter); } T_END; return ret; @@ -929,6 +945,8 @@ { const char *ret; + if (iter->fs->v.iter_next == NULL) + return NULL; T_BEGIN { ret = iter->fs->v.iter_next(iter); } T_END;