lib_atexit(fs_class_deinit_modules);
}
+static struct event *fs_create_event(struct fs *fs, struct event *parent)
+{
+ struct event *event;
+
+ event = event_create(parent);
+ event_set_append_log_prefix(event,
+ t_strdup_printf("fs-%s: ", fs->name));
+ return event;
+}
+
int fs_init(const char *driver, const char *args,
const struct fs_settings *set,
struct fs **fs_r, const char **error_r)
}
if (fs_alloc(fs_class, args, set, fs_r, error_r) < 0)
return -1;
+ (*fs_r)->event = fs_create_event(*fs_r, set->event);
temp_file_prefix = set->temp_file_prefix != NULL ?
set->temp_file_prefix : ".temp.dovecot";
}
i_assert(fs->files == NULL);
+ event_unref(&fs->event);
i_free(fs->username);
i_free(fs->session_id);
i_free(fs->temp_path_prefix);
}
struct fs_file *fs_file_init(struct fs *fs, const char *path, int mode_flags)
+{
+ return fs_file_init_with_event(fs, fs->event, path, mode_flags);
+}
+
+struct fs_file *fs_file_init_with_event(struct fs *fs, struct event *event,
+ const char *path, int mode_flags)
{
struct fs_file *file;
file = fs->v.file_alloc();
file->fs = fs;
file->flags = mode_flags & ~FS_OPEN_MODE_MASK;
+ file->event = fs_create_event(fs, event);
fs->v.file_init(file, path, mode_flags & FS_OPEN_MODE_MASK,
mode_flags & ~FS_OPEN_MODE_MASK);
} T_END;
+
fs->files_open_count++;
DLLIST_PREPEND(&fs->files, file);
void fs_file_deinit(struct fs_file **_file)
{
struct fs_file *file = *_file;
+ struct event *event = file->event;
pool_t metadata_pool = file->metadata_pool;
i_assert(file->fs->files_open_count > 0);
file->fs->v.file_deinit(file);
} T_END;
+ event_unref(&event);
if (metadata_pool != NULL)
pool_unref(&metadata_pool);
}
return file->fs;
}
+struct event *fs_file_event(struct fs_file *file)
+{
+ return file->event;
+}
+
static void ATTR_FORMAT(2, 0)
fs_set_verror(struct fs *fs, const char *fmt, va_list args)
{
struct fs_iter *
fs_iter_init(struct fs *fs, const char *path, enum fs_iter_flags flags)
+{
+ return fs_iter_init_with_event(fs, fs->event, path, flags);
+}
+
+struct fs_iter *
+fs_iter_init_with_event(struct fs *fs, struct event *event,
+ const char *path, enum fs_iter_flags flags)
{
struct fs_iter *iter;
struct timeval now = ioloop_timeval;
iter = fs->v.iter_alloc();
iter->fs = fs;
iter->flags = flags;
+ iter->event = fs_create_event(fs, event);
fs->v.iter_init(iter, path, flags);
} T_END;
iter->start_time = now;
int fs_iter_deinit(struct fs_iter **_iter)
{
struct fs_iter *iter = *_iter;
+ struct event *event = iter->event;
int ret;
*_iter = NULL;
} else T_BEGIN {
ret = iter->fs->v.iter_deinit(iter);
} T_END;
+ event_unref(&event);
return ret;
}
va_start(args, fmt);
fs_set_verror(fs, fmt, args);
- i_error("fs-%s: %s", fs->name, fs_last_error(fs));
+ e_error(fs->event, "%s", fs_last_error(fs));
va_end(args);
}
struct fs_file *
fs_file_init_parent(struct fs_file *parent, const char *path, int mode_flags)
{
- return fs_file_init(parent->fs->parent, path, mode_flags);
+ return fs_file_init_with_event(parent->fs->parent, parent->event,
+ path, mode_flags);
}
struct fs_iter *
fs_iter_init_parent(struct fs_iter *parent,
const char *path, enum fs_iter_flags flags)
{
- return fs_iter_init(parent->fs->parent, path, flags);
+ return fs_iter_init_with_event(parent->fs->parent, parent->event,
+ path, flags);
}
them. */
struct dns_client *dns_client;
+ /* Parent event to use, unless overridden by
+ fs_file_init_with_event() */
+ struct event *event;
+
/* Enable debugging */
bool debug;
/* Enable timing statistics */
const char *fs_get_root_driver(struct fs *fs);
struct fs_file *fs_file_init(struct fs *fs, const char *path, int mode_flags);
+struct fs_file *fs_file_init_with_event(struct fs *fs, struct event *event,
+ const char *path, int mode_flags);
void fs_file_deinit(struct fs_file **file);
/* If the file has an input streams open, close them. */
const char *fs_file_path(struct fs_file *file);
/* Returns the file's fs. */
struct fs *fs_file_fs(struct fs_file *file);
+/* Returns the file's event. */
+struct event *fs_file_event(struct fs_file *file);
/* Return the error message for the last failed operation. */
const char *fs_last_error(struct fs *fs);
nonexistent directory. */
struct fs_iter *
fs_iter_init(struct fs *fs, const char *path, enum fs_iter_flags flags);
+struct fs_iter *
+fs_iter_init_with_event(struct fs *fs, struct event *event,
+ const char *path, enum fs_iter_flags flags);
/* Returns 0 if ok, -1 if iteration failed. */
int fs_iter_deinit(struct fs_iter **iter);
/* Returns the next filename. */