fs-metawrap.c revision 41843bdb6cd96d761a18bab5d5825f344d02420c
/* Copyright (c) 2013-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "strescape.h"
#include "istream.h"
#include "istream-private.h"
#include "istream-concat.h"
#include "istream-metawrap.h"
#include "ostream.h"
#include "ostream-metawrap.h"
#include "iostream-temp.h"
#include "fs-api-private.h"
#define MAX_METADATA_LINE_LEN 8192
struct metawrap_fs {
bool wrap_metadata;
};
struct metawrap_fs_file {
struct metawrap_fs *fs;
enum fs_open_mode open_mode;
bool metadata_read;
struct ostream *super_output;
struct ostream *temp_output;
};
struct metawrap_fs_iter {
};
static struct fs *fs_metawrap_alloc(void)
{
struct metawrap_fs *fs;
}
static int
struct fs_settings *set)
{
if (*args == '\0') {
return -1;
}
if (parent_args == NULL) {
parent_name = args;
parent_args = "";
} else {
parent_args++;
}
return -1;
}
return 0;
}
{
}
{
enum fs_properties props;
if (fs->wrap_metadata) {
/* we don't have a quick stat() to see the file's size,
because of the metadata header */
props &= ~FS_PROPERTY_STAT;
/* Copying can copy the whole metadata. */
}
return props;
}
static struct fs_file *
{
struct metawrap_fs_file *file;
/* avoid unnecessarily creating two seekable streams */
(flags & FS_OPEN_FLAG_ASYNC) == 0) {
/* use async stream for super, so fs_read_stream() won't create
another seekable stream unneededly */
} else {
}
}
{
}
{
}
{
}
static void
void *context)
{
}
{
}
static void
const char *value)
{
else {
}
}
static int
{
char c;
if (!file->metadata_read) {
return -1;
}
return 0;
}
{
else
}
{
}
static void
{
return;
}
T_BEGIN {
} T_END;
}
static struct istream *
{
}
}
{
}
static void
{
const struct fs_metadata *metadata;
strlen(FS_METADATA_INTERNAL_PREFIX)) == 0)
continue;
}
}
static void fs_metawrap_write_metadata(void *context)
{
if (ret < 0)
else
}
{
} else {
file->temp_output =
}
}
static struct istream *
{
else
i_stream_unref(&inputs[0]);
return input2;
}
{
int ret;
else
}
if (!success) {
return -1;
}
/* no metawrap */
}
/* finishing up */
}
/* finish writing the temporary file */
if (file->metadata_changed_since_write) {
/* we'll need to recreate the metadata. do this by creating a
new istream combining the new metadata header and the
old body. */
}
else if (input->stream_errno != 0) {
ret = -1;
} else {
ret = -1;
}
return ret;
}
static int
{
}
{
i_unreached();
}
{
}
{
return -1;
}
if (ret == 0) {
return -1;
}
return -1;
}
return 0;
}
{
else
}
}
{
}
{
}
static struct fs_iter *
enum fs_iter_flags flags)
{
struct metawrap_fs_iter *iter;
}
{
const char *fname;
return fname;
}
{
int ret;
return ret;
}
const struct fs fs_class_metawrap = {
.name = "metawrap",
.v = {
}
};