From: Timo Sirainen Date: Mon, 30 Mar 2020 14:17:11 +0000 (+0300) Subject: lib-index: Add mail_cache_map_all() X-Git-Tag: 2.3.11.2~443 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd27250accbc8f5aa39d7b9c1736a9542a1c8747;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Add mail_cache_map_all() --- diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index 70d9ca82ee..b757490d84 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -244,8 +244,12 @@ mail_cache_transaction_lookup_rec(struct mail_cache_transaction_ctx *ctx, unsigned int seq, unsigned int *trans_next_idx); +/* Return data from the specified position in the cache file. Returns 1 if + successful, 0 if offset/size points outside the cache file, -1 if error. */ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size, const void **data_r); +/* Map the whole cache file into memory. Returns 0 if ok, -1 if error. */ +int mail_cache_map_all(struct mail_cache *cache); void mail_cache_file_close(struct mail_cache *cache); int mail_cache_reopen(struct mail_cache *cache); diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 0e464143a2..81e2b7b5c4 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -520,6 +520,15 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size, cache->mmap_base, FALSE); } +int mail_cache_map_all(struct mail_cache *cache) +{ + const void *data; + + int ret = mail_cache_map(cache, 0, 0, &data); + i_assert(ret != 0); + return ret < 0 ? -1 : 0; +} + int mail_cache_open_and_verify(struct mail_cache *cache) { int ret;