1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "fs-api-private.h"
#include "ostream.h"
struct wrapper_fs_iter {
struct fs_iter iter;
struct fs_iter *parent;
};
enum fs_properties fs_wrapper_get_properties(struct fs *fs)
{
return fs_get_properties(fs->parent);
}
void fs_wrapper_file_close(struct fs_file *file)
{
fs_file_close(file->parent);
}
const char *fs_wrapper_file_get_path(struct fs_file *file)
{
return fs_file_path(file->parent);
}
void fs_wrapper_set_async_callback(struct fs_file *file,
fs_file_async_callback_t *callback,
void *context)
{
fs_file_set_async_callback(file->parent, *callback, context);
}
void fs_wrapper_wait_async(struct fs *fs)
{
fs_wait_async(fs->parent);
}
void fs_wrapper_set_metadata(struct fs_file *file, const char *key,
const char *value)
{
fs_set_metadata(file->parent, key, value);
}
int fs_wrapper_get_metadata(struct fs_file *file,
enum fs_get_metadata_flags flags,
const ARRAY_TYPE(fs_metadata) **metadata_r)
{
return fs_get_metadata_full(file->parent, flags, metadata_r);
}
bool fs_wrapper_prefetch(struct fs_file *file, uoff_t length)
{
return fs_prefetch(file->parent, length);
}
ssize_t fs_wrapper_read(struct fs_file *file, void *buf, size_t size)
{
return fs_read(file->parent, buf, size);
}
struct istream *
fs_wrapper_read_stream(struct fs_file *file, size_t max_buffer_size)
{
return fs_read_stream(file->parent, max_buffer_size);
}
int fs_wrapper_write(struct fs_file *file, const void *data, size_t size)
{
return fs_write(file->parent, data, size);
}
void fs_wrapper_write_stream(struct fs_file *file)
{
i_assert(file->output == NULL);
file->output = fs_write_stream(file->parent);
}
int fs_wrapper_write_stream_finish(struct fs_file *file, bool success)
{
if (file->output == NULL)
return fs_write_stream_finish_async(file->parent);
if (!success) {
fs_write_stream_abort_parent(file, &file->output);
return -1;
}
return fs_write_stream_finish(file->parent, &file->output);
}
int fs_wrapper_lock(struct fs_file *file, unsigned int secs,
struct fs_lock **lock_r)
{
return fs_lock(file->parent, secs, lock_r);
}
void fs_wrapper_unlock(struct fs_lock *_lock ATTR_UNUSED)
{
i_unreached();
}
int fs_wrapper_exists(struct fs_file *file)
{
return fs_exists(file->parent);
}
int fs_wrapper_stat(struct fs_file *file, struct stat *st_r)
{
return fs_stat(file->parent, st_r);
}
int fs_wrapper_get_nlinks(struct fs_file *file, nlink_t *nlinks_r)
{
return fs_get_nlinks(file->parent, nlinks_r);
}
int fs_wrapper_copy(struct fs_file *src, struct fs_file *dest)
{
if (src != NULL)
return fs_copy(src->parent, dest->parent);
else
return fs_copy_finish_async(dest->parent);
}
int fs_wrapper_rename(struct fs_file *src, struct fs_file *dest)
{
return fs_rename(src->parent, dest->parent);
}
int fs_wrapper_delete(struct fs_file *file)
{
return fs_delete(file->parent);
}
struct fs_iter *fs_wrapper_iter_alloc(void)
{
struct wrapper_fs_iter *iter = i_new(struct wrapper_fs_iter, 1);
return &iter->iter;
}
void fs_wrapper_iter_init(struct fs_iter *_iter, const char *path,
enum fs_iter_flags flags)
{
struct wrapper_fs_iter *iter = (struct wrapper_fs_iter *)_iter;
iter->parent = fs_iter_init_parent(_iter, path, flags);
}
const char *fs_wrapper_iter_next(struct fs_iter *_iter)
{
struct wrapper_fs_iter *iter = (struct wrapper_fs_iter *)_iter;
const char *fname;
iter->parent->async_callback = _iter->async_callback;
iter->parent->async_context = _iter->async_context;
fname = fs_iter_next(iter->parent);
_iter->async_have_more = iter->parent->async_have_more;
return fname;
}
int fs_wrapper_iter_deinit(struct fs_iter *_iter)
{
struct wrapper_fs_iter *iter = (struct wrapper_fs_iter *)_iter;
const char *error;
int ret;
if ((ret = fs_iter_deinit(&iter->parent, &error)) < 0)
fs_set_error_errno(_iter->event, "%s", error);
return ret;
}
|