doveadm-fs.c revision ca096c557fac1cf87dd5f129c202b2c1d990ff59
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainenstatic void fs_cmd_help(doveadm_command_t *cmd);
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainenstatic void cmd_fs_delete(int argc, char *argv[]);
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainenstatic struct fs *
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainencmd_fs_init(int *argc, char **argv[], int own_arg_count, doveadm_command_t *cmd)
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen ssl_set.ca_dir = doveadm_settings->ssl_client_ca_dir;
9b7eeffb5752b500ac62ba1fd01c4a8c4ada14e9Timo Sirainen ssl_set.ca_file = doveadm_settings->ssl_client_ca_file;
b565a6a7a66fb9f224d00c06a950e3c1c585c18eTimo Sirainen if (fs_init((*argv)[1], (*argv)[2], &fs_set, &fs, &error) < 0)
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen const unsigned char *data;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen fs = cmd_fs_init(&argc, &argv, 1, cmd_fs_get);
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen file = fs_file_init(fs, argv[0], FS_OPEN_MODE_READONLY);
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) {
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_error("%s doesn't exist", fs_file_path(file));
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_error("read(%s) failed: %m", fs_file_path(file));
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen fs = cmd_fs_init(&argc, &argv, 2, cmd_fs_put);
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainen file = fs_file_init(fs, dest_path, FS_OPEN_MODE_REPLACE);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen input = i_stream_create_file(src_path, IO_BLOCK_SIZE);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen if ((ret = o_stream_send_istream(output, input)) < 0) {
03f5c621d06d6b6d77a145196c9633a7aa64dc78Timo Sirainen if (fs_write_stream_finish(file, &output) < 0) {
03f5c621d06d6b6d77a145196c9633a7aa64dc78Timo Sirainen i_error("fs_write_stream_finish() failed: %s",
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenstatic void cmd_fs_copy(int argc, char *argv[])
} T_END;
} T_END;
const char *fname;
i_unreached();
void doveadm_register_fs_commands(void)