dovecot-2.2: lib-index: Added path parameter to mail_index_creat...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 7 16:07:50 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/0a34975b2dcc
changeset: 17904:0a34975b2dcc
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 07 19:04:36 2014 +0300
description:
lib-index: Added path parameter to mail_index_create_tmp_file()
This allows using it for creating any kind of a new index file with proper
file permissions.
Some of the old code should probably be changed to use this. Maybe even move
this function to public mail-index.h
diffstat:
src/lib-index/mail-index-private.h | 3 ++-
src/lib-index/mail-index-write.c | 2 +-
src/lib-index/mail-index.c | 5 +++--
3 files changed, 6 insertions(+), 4 deletions(-)
diffs (47 lines):
diff -r bd55bdba0e75 -r 0a34975b2dcc src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h Tue Oct 07 18:58:01 2014 +0300
+++ b/src/lib-index/mail-index-private.h Tue Oct 07 19:04:36 2014 +0300
@@ -259,7 +259,8 @@
void mail_index_unregister_sync_lost_handler(struct mail_index *index,
mail_index_sync_lost_handler_t *cb);
-int mail_index_create_tmp_file(struct mail_index *index, const char **path_r);
+int mail_index_create_tmp_file(struct mail_index *index,
+ const char *path_prefix, const char **path_r);
int mail_index_try_open_only(struct mail_index *index);
void mail_index_close_file(struct mail_index *index);
diff -r bd55bdba0e75 -r 0a34975b2dcc src/lib-index/mail-index-write.c
--- a/src/lib-index/mail-index-write.c Tue Oct 07 18:58:01 2014 +0300
+++ b/src/lib-index/mail-index-write.c Tue Oct 07 19:04:36 2014 +0300
@@ -68,7 +68,7 @@
i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
i_assert(map->hdr.indexid == index->indexid);
- fd = mail_index_create_tmp_file(index, &path);
+ fd = mail_index_create_tmp_file(index, index->filepath, &path);
if (fd == -1)
return -1;
diff -r bd55bdba0e75 -r 0a34975b2dcc src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c Tue Oct 07 18:58:01 2014 +0300
+++ b/src/lib-index/mail-index.c Tue Oct 07 19:04:36 2014 +0300
@@ -438,7 +438,8 @@
return ret;
}
-int mail_index_create_tmp_file(struct mail_index *index, const char **path_r)
+int mail_index_create_tmp_file(struct mail_index *index,
+ const char *path_prefix, const char **path_r)
{
mode_t old_mask;
const char *path;
@@ -446,7 +447,7 @@
i_assert(!MAIL_INDEX_IS_IN_MEMORY(index));
- path = *path_r = t_strconcat(index->filepath, ".tmp", NULL);
+ path = *path_r = t_strconcat(path_prefix, ".tmp", NULL);
old_mask = umask(0);
fd = open(path, O_RDWR|O_CREAT|O_EXCL, index->mode);
umask(old_mask);
More information about the dovecot-cvs
mailing list