bool metadata_changed_since_write;
};
+#define METAWRAP_FS(ptr) container_of((ptr), struct metawrap_fs, fs)
+#define METAWRAP_FILE(ptr) container_of((ptr), struct metawrap_fs_file, file)
+
static struct fs *fs_metawrap_alloc(void)
{
struct metawrap_fs *fs;
fs_metawrap_init(struct fs *_fs, const char *args,
const struct fs_settings *set, const char **error_r)
{
- struct metawrap_fs *fs = (struct metawrap_fs *)_fs;
+ struct metawrap_fs *fs = METAWRAP_FS(_fs);
const char *parent_name, *parent_args;
if (*args == '\0') {
static void fs_metawrap_free(struct fs *_fs)
{
- struct metawrap_fs *fs = (struct metawrap_fs *)_fs;
+ struct metawrap_fs *fs = METAWRAP_FS(_fs);
fs_deinit(&_fs->parent);
i_free(fs);
static enum fs_properties fs_metawrap_get_properties(struct fs *_fs)
{
- const struct metawrap_fs *fs = (const struct metawrap_fs *)_fs;
+ const struct metawrap_fs *fs = METAWRAP_FS(_fs);
enum fs_properties props;
props = fs_get_properties(_fs->parent);
fs_metawrap_file_init(struct fs_file *_file, const char *path,
enum fs_open_mode mode, enum fs_open_flags flags)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
- struct metawrap_fs *fs = (struct metawrap_fs *)_file->fs;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
+ struct metawrap_fs *fs = METAWRAP_FS(_file->fs);
file->file.path = i_strdup(path);
file->fs = fs;
static void fs_metawrap_file_deinit(struct fs_file *_file)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
if (file->super_read != _file->parent)
fs_file_deinit(&file->super_read);
static void fs_metawrap_file_close(struct fs_file *_file)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
i_stream_unref(&file->input);
fs_file_close(file->super_read);
fs_metawrap_set_metadata(struct fs_file *_file, const char *key,
const char *value)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
if (!file->fs->wrap_metadata ||
strcmp(key, FS_METADATA_WRITE_FNAME) == 0)
enum fs_get_metadata_flags flags,
const ARRAY_TYPE(fs_metadata) **metadata_r)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
ssize_t ret;
char c;
static bool fs_metawrap_prefetch(struct fs_file *_file, uoff_t length)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
if (!file->fs->wrap_metadata)
return fs_prefetch(_file->parent, length);
static ssize_t fs_metawrap_read(struct fs_file *_file, void *buf, size_t size)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
if (!file->fs->wrap_metadata)
return fs_read(_file->parent, buf, size);
static int fs_metawrap_write(struct fs_file *_file, const void *data, size_t size)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
if (!file->fs->wrap_metadata)
return fs_write(_file->parent, data, size);
static int fs_metawrap_write_stream_finish(struct fs_file *_file, bool success)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
struct istream *input;
int ret;
static int fs_metawrap_stat(struct fs_file *_file, struct stat *st_r)
{
- struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
+ struct metawrap_fs_file *file = METAWRAP_FILE(_file);
struct istream *input;
uoff_t input_size;
ssize_t ret;
static int fs_metawrap_copy(struct fs_file *_src, struct fs_file *_dest)
{
- struct metawrap_fs_file *dest = (struct metawrap_fs_file *)_dest;
+ struct metawrap_fs_file *dest = METAWRAP_FILE(_dest);
if (!dest->fs->wrap_metadata || !_dest->metadata_changed)
return fs_wrapper_copy(_src, _dest);