/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "md5.h"
#include "sha2.h"
#include "hash-method.h"
#include "hex-binary.h"
#include "istream.h"
#include "ostream.h"
#include "iostream-ssl.h"
#include "fs-api.h"
#include "doveadm.h"
#include "doveadm-print.h"
#include <stdio.h>
#include <unistd.h>
{
i_fatal("fs_init: Add -- if you have - in arguments");
}
static struct fs *
{
const char *error;
if (own_arg_count > 0) {
} else {
if (*argc <= 2)
}
*argc += 2;
*argv += 2;
return fs;
}
{
const unsigned char *data;
}
doveadm_print_stream("", 0);
} else if (input->stream_errno != 0) {
}
}
{
int c;
switch (c) {
case 'h':
i_fatal("Invalid -h parameter: Hash not in hex");
break;
default:
}
}
;
if ((props & FS_PROPERTY_WRITE_HASH_MD5) == 0)
i_fatal("fs backend doesn't support MD5 hashes");
if ((props & FS_PROPERTY_WRITE_HASH_SHA256) == 0)
i_fatal("fs backend doesn't support SHA256 hashes");
}
i_error("fs_write_stream_finish() failed: %s",
}
}
{
fs_last_error(fs));
} else {
i_error("fs_copy(%s, %s) failed: %s",
}
}
{
doveadm_print_formatted_set_format("%{path} size=%{size}");
doveadm_print_header_simple("path");
} else {
i_error("fs_stat(%s) failed: %s",
}
}
{
const struct fs_metadata *m;
doveadm_print_formatted_set_format("%{key}=%{value}\n");
doveadm_print_header_simple("key");
doveadm_print_header_simple("value");
doveadm_print(m->key);
doveadm_print(m->value);
}
} else {
i_error("fs_stat(%s) failed: %s",
}
}
struct fs_delete_ctx {
const char *path_prefix;
unsigned int files_count;
};
{
unsigned int i;
int ret = 0;
for (i = 0; i < ctx->files_count; i++) {
;
if (ret == 0)
ret = 1;
ret = -1;
} else {
i_error("fs_delete(%s) failed: %s",
ret = -1;
}
}
return ret;
}
const char *fname)
{
unsigned int i;
int ret;
for (i = 0; i < ctx->files_count; i++) {
continue;
break;
}
return -1;
if (ret > 0)
}
return 0;
}
{
unsigned int i;
}
for (i = 0; i < ctx->files_count; i++) {
}
}
static void
const char *path_prefix)
{
int ret;
/* delete subdirs first. all fs backends can't handle recursive
lookups, so save the list first. */
/* append "/" so that if FS_PROPERTY_DIRECTORIES is set,
we'll include the "/" suffix in the filename when deleting
it. */
}
if (fs_iter_deinit(&iter) < 0) {
i_error("fs_iter_deinit(%s) failed: %s",
}
} T_END;
/* delete files. again because we're doing this asynchronously finish
the iteration first. */
/* we need to explicitly delete also the directories */
} else {
}
}
if (fs_iter_deinit(&iter) < 0) {
i_error("fs_iter_deinit(%s) failed: %s",
}
T_BEGIN {
} T_END;
if (ret < 0)
break;
}
}
unsigned int async_count)
{
/* delete the root itself */
i_error("fs_delete(%s) failed: %s",
}
}
}
static void
{
unsigned int i;
}
unsigned int async_count)
{
unsigned int i;
int ret;
T_BEGIN {
} T_END;
if (ret < 0)
break;
}
}
{
unsigned int async_count = 0;
int c;
switch (c) {
case 'R':
break;
case 'n':
break;
default:
}
}
if (recursive)
else
}
{
const char *fname;
doveadm_print_formatted_set_format("%{path}\n");
doveadm_print_header_simple("path");
}
if (fs_iter_deinit(&iter) < 0) {
i_error("fs_iter_deinit(%s) failed: %s",
}
}
{
}
{
}
{
.name = "fs get",
.old_cmd = cmd_fs_get,
.usage = "<fs-driver> <fs-args> <path>",
},
{
.name = "fs put",
.old_cmd = cmd_fs_put,
.usage = "[-h <hash>] <fs-driver> <fs-args> <input path> <path>",
},
{
.name = "fs copy",
.old_cmd = cmd_fs_copy,
.usage = "<fs-driver> <fs-args> <source path> <dest path>",
},
{
.name = "fs stat",
.old_cmd = cmd_fs_stat,
.usage = "<fs-driver> <fs-args> <path>",
},
{
.name = "fs metadata",
.usage = "<fs-driver> <fs-args> <path>",
},
{
.name = "fs delete",
.old_cmd = cmd_fs_delete,
.usage = "[-R] [-n <count>] <fs-driver> <fs-args> <path> [<path> ...]",
},
{
.name = "fs iter",
.old_cmd = cmd_fs_iter,
.usage = "<fs-driver> <fs-args> <path>",
},
{
.name = "fs iter-dirs",
.usage = "<fs-driver> <fs-args> <path>",
}
};
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_fs); i++) {
help_ver2(&doveadm_cmd_fs[i]);
}
i_unreached();
}
void doveadm_register_fs_commands(void)
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_fs); i++)
}