dovecot-2.2: lib-fs: Fixes to posix backend's FS_OPEN_MODE_CREAT...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Mar 27 13:40:01 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/0b4a0361f1aa
changeset: 17176:0b4a0361f1aa
user: Timo Sirainen <tss at iki.fi>
date: Thu Mar 27 15:39:33 2014 +0200
description:
lib-fs: Fixes to posix backend's FS_OPEN_MODE_CREATE_UNIQUE_128 handling.
diffstat:
src/lib-fs/fs-posix.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diffs (54 lines):
diff -r 7ccee18b5085 -r 0b4a0361f1aa src/lib-fs/fs-posix.c
--- a/src/lib-fs/fs-posix.c Thu Mar 27 14:37:10 2014 +0100
+++ b/src/lib-fs/fs-posix.c Thu Mar 27 15:39:33 2014 +0200
@@ -183,12 +183,8 @@
i_assert(file->temp_path == NULL);
- if (file->open_mode == FS_OPEN_MODE_CREATE_UNIQUE_128) {
- str_append(str, file->file.path);
- str_append_c(str, '/');
- } else if ((slash = strrchr(file->file.path, '/')) != NULL) {
+ if ((slash = strrchr(file->file.path, '/')) != NULL)
str_append_n(str, file->file.path, slash - file->file.path + 1);
- }
str_append(str, fs->temp_file_prefix);
fd = safe_mkstemp_hostpid(str, fs->mode, (uid_t)-1, (gid_t)-1);
@@ -243,10 +239,17 @@
enum fs_open_mode mode, enum fs_open_flags flags)
{
struct posix_fs_file *file;
+ guid_128_t guid;
file = i_new(struct posix_fs_file, 1);
file->file.fs = _fs;
- file->file.path = i_strdup(path);
+ if (mode != FS_OPEN_MODE_CREATE_UNIQUE_128)
+ file->file.path = i_strdup(path);
+ else {
+ guid_128_generate(guid);
+ file->file.path = i_strdup_printf("%s/%s", path,
+ guid_128_to_string(guid));
+ }
file->open_mode = mode;
file->open_flags = flags;
file->fd = -1;
@@ -377,17 +380,6 @@
switch (file->open_mode) {
case FS_OPEN_MODE_CREATE_UNIQUE_128:
- T_BEGIN {
- guid_128_t guid;
- char *path;
-
- guid_128_generate(guid);
- path = i_strdup_printf("%s/%s", file->file.path,
- guid_128_to_string(guid));
- i_free(file->file.path);
- file->file.path = path;
- } T_END;
- /* fall through */
case FS_OPEN_MODE_CREATE:
if ((ret = link(file->temp_path, file->file.path)) < 0) {
fs_set_error(file->file.fs, "link(%s, %s) failed: %m",
More information about the dovecot-cvs
mailing list