return ret <= 0 ? -1 : 0;
}
-static int
-fs_dict_init_legacy(struct fs *_fs, const char *args,
- const struct fs_parameters *params, const char **error_r)
-{
- struct dict_fs *fs = (struct dict_fs *)_fs;
- struct dict_legacy_settings dict_set;
- const char *p, *encoding_str, *error;
-
- p = strchr(args, ':');
- if (p == NULL) {
- *error_r = "':' missing in args";
- return -1;
- }
- encoding_str = t_strdup_until(args, p++);
- if (fs_dict_value_encoding_parse(encoding_str, &fs->encoding, error_r) < 0)
- return -1;
-
- i_zero(&dict_set);
- dict_set.base_dir = params->base_dir;
- dict_set.event_parent = _fs->event;
-
- if (dict_init_legacy(p, &dict_set, &fs->dict, &error) < 0) {
- *error_r = t_strdup_printf("dict_init(%s) failed: %s",
- args, error);
- return -1;
- }
- return 0;
-}
-
static void fs_dict_free(struct fs *_fs)
{
struct dict_fs *fs = (struct dict_fs *)_fs;
.v = {
.alloc = fs_dict_alloc,
.init = fs_dict_init,
- .legacy_init = fs_dict_init_legacy,
.deinit = NULL,
.free = fs_dict_free,
.get_properties = fs_dict_get_properties,
return 0;
}
-static int
-fs_metawrap_legacy_init(struct fs *_fs, const char *args,
- const struct fs_parameters *params,
- const char **error_r)
-{
- struct metawrap_fs *fs = METAWRAP_FS(_fs);
- const char *parent_name, *parent_args;
-
- if (*args == '\0') {
- *error_r = "Parent filesystem not given as parameter";
- return -1;
- }
-
- parent_args = strchr(args, ':');
- if (parent_args == NULL) {
- parent_name = args;
- parent_args = "";
- } else {
- parent_name = t_strdup_until(args, parent_args);
- parent_args++;
- }
- if (fs_legacy_init(parent_name, parent_args, _fs->event, params,
- &_fs->parent, error_r) < 0)
- return -1;
- if ((fs_get_properties(_fs->parent) & FS_PROPERTY_METADATA) == 0)
- fs->wrap_metadata = TRUE;
- return 0;
-}
-
static void fs_metawrap_free(struct fs *_fs)
{
struct metawrap_fs *fs = METAWRAP_FS(_fs);
.v = {
.alloc = fs_metawrap_alloc,
.init = fs_metawrap_init,
- .legacy_init = fs_metawrap_legacy_init,
.deinit = NULL,
.free = fs_metawrap_free,
.get_properties = fs_metawrap_get_properties,
return 0;
}
-static int
-fs_posix_legacy_init(struct fs *_fs, const char *args,
- const struct fs_parameters *params, const char **error_r)
-{
- struct posix_fs *fs = container_of(_fs, struct posix_fs, fs);
- const char *value, *const *tmp;
-
- fs_posix_init_common(fs, params);
-
- pool_t pool = pool_alloconly_create("fs_posix_settings", 128);
- struct fs_posix_settings *set =
- settings_defaults_dup(pool, &fs_posix_setting_parser_info);
- set->parsed_lock_method = FS_POSIX_LOCK_METHOD_FLOCK;
- fs->set = set;
-
- tmp = t_strsplit_spaces(args, ":");
- for (; *tmp != NULL; tmp++) {
- const char *arg = *tmp;
-
- if (strcmp(arg, "lock=flock") == 0)
- set->parsed_lock_method = FS_POSIX_LOCK_METHOD_FLOCK;
- else if (strcmp(arg, "lock=dotlock") == 0)
- set->parsed_lock_method = FS_POSIX_LOCK_METHOD_DOTLOCK;
- else if (str_begins(arg, "prefix=", &value))
- set->fs_posix_prefix = p_strdup(pool, value);
- else if (strcmp(arg, "dirs") == 0)
- set->fs_posix_autodelete_empty_directories = FALSE;
- else if (strcmp(arg, "no-fsync") == 0)
- set->fs_posix_fsync = FALSE;
- else if (strcmp(arg, "accurate-mtime") == 0)
- set->fs_posix_accurate_mtime = TRUE;
- else if (str_begins(arg, "mode=", &value)) {
- unsigned int mode;
- if (str_to_uint_oct(value, &mode) < 0) {
- *error_r = t_strdup_printf("Invalid mode value: %s", value);
- return -1;
- }
- set->fs_posix_mode = mode & 0666;
- if (set->fs_posix_mode == 0) {
- *error_r = t_strdup_printf("Invalid mode: %s", value);
- return -1;
- }
- } else {
- *error_r = t_strdup_printf("Unknown arg '%s'", arg);
- return -1;
- }
- }
- return 0;
-}
-
static void fs_posix_free(struct fs *_fs)
{
struct posix_fs *fs = container_of(_fs, struct posix_fs, fs);
.v = {
.alloc = fs_posix_alloc,
.init = fs_posix_init,
- .legacy_init = fs_posix_legacy_init,
.deinit = NULL,
.free = fs_posix_free,
.get_properties = fs_posix_get_properties,
return -1;
}
-static int fs_randomfail_parse_params(struct randomfail_fs *fs,
- const char *params, const char **error_r)
-{
- const char *const *tmp;
-
- for (tmp = t_strsplit_spaces(params, ","); *tmp != NULL; tmp++) {
- const char *key = *tmp;
- const char *value = strchr(key, '=');
-
- if (value == NULL) {
- *error_r = "Missing '='";
- return -1;
- }
- key = t_strdup_until(key, value++);
- if (fs_randomfail_op_add(fs, key, value, error_r) < 0)
- return -1;
- }
- return 0;
-}
-
static int
fs_randomfail_init(struct fs *_fs, const struct fs_parameters *params,
const char **error_r)
return fs_init_parent(_fs, params, error_r);
}
-static int
-fs_randomfail_legacy_init(struct fs *_fs, const char *args,
- const struct fs_parameters *params,
- const char **error_r)
-{
- struct randomfail_fs *fs = RANDOMFAIL_FS(_fs);
- const char *p, *parent_name, *parent_args, *error;
-
- p = strchr(args, ':');
- if (p == NULL) {
- *error_r = "Randomfail parameters missing";
- return -1;
- }
- if (fs_randomfail_parse_params(fs, t_strdup_until(args, p++), &error) < 0) {
- *error_r = t_strdup_printf(
- "Invalid randomfail parameters: %s", error);
- return -1;
- }
- args = p;
-
- if (*args == '\0') {
- *error_r = "Parent filesystem not given as parameter";
- return -1;
- }
-
- parent_args = strchr(args, ':');
- if (parent_args == NULL) {
- parent_name = args;
- parent_args = "";
- } else {
- parent_name = t_strdup_until(args, parent_args);
- parent_args++;
- }
- if (fs_legacy_init(parent_name, parent_args, _fs->event, params,
- &_fs->parent, error_r) < 0)
- return -1;
- return 0;
-}
-
static void fs_randomfail_free(struct fs *_fs)
{
struct randomfail_fs *fs = RANDOMFAIL_FS(_fs);
.v = {
.alloc = fs_randomfail_alloc,
.init = fs_randomfail_init,
- .legacy_init = fs_randomfail_legacy_init,
.deinit = NULL,
.free = fs_randomfail_free,
.get_properties = fs_randomfail_get_properties,
return fs_init_parent(_fs, params, error_r);
}
-static int
-fs_sis_queue_legacy_init(struct fs *_fs, const char *args,
- const struct fs_parameters *params, const char **error_r)
-{
- struct sis_queue_fs *fs = SISQUEUE_FS(_fs);
- const char *p, *parent_name, *parent_args;
-
- /* <queue_dir>:<parent fs>[:<args>] */
-
- p = strchr(args, ':');
- if (p == NULL || p[1] == '\0') {
- *error_r = "Parent filesystem not given as parameter";
- return -1;
- }
-
- fs->queue_dir = i_strdup_until(args, p);
- parent_name = p + 1;
-
- parent_args = strchr(parent_name, ':');
- if (parent_args == NULL)
- parent_args = "";
- else
- parent_name = t_strdup_until(parent_name, parent_args++);
- if (fs_legacy_init(parent_name, parent_args, _fs->event, params,
- &_fs->parent, error_r) < 0)
- return -1;
- return 0;
-}
-
static void fs_sis_queue_free(struct fs *_fs)
{
struct sis_queue_fs *fs = SISQUEUE_FS(_fs);
.v = {
.alloc = fs_sis_queue_alloc,
.init = fs_sis_queue_init,
- .legacy_init = fs_sis_queue_legacy_init,
.deinit = NULL,
.free = fs_sis_queue_free,
.get_properties = fs_wrapper_get_properties,
return 0;
}
-static int
-fs_sis_legacy_init(struct fs *_fs, const char *args,
- const struct fs_parameters *params, const char **error_r)
-{
- enum fs_properties props;
- const char *parent_name, *parent_args;
-
- if (*args == '\0') {
- *error_r = "Parent filesystem not given as parameter";
- return -1;
- }
-
- parent_args = strchr(args, ':');
- if (parent_args == NULL) {
- parent_name = args;
- parent_args = "";
- } else {
- parent_name = t_strdup_until(args, parent_args);
- parent_args++;
- }
- if (fs_legacy_init(parent_name, parent_args, _fs->event, params,
- &_fs->parent, error_r) < 0)
- return -1;
- props = fs_get_properties(_fs->parent);
- if ((props & FS_SIS_REQUIRED_PROPS) != FS_SIS_REQUIRED_PROPS) {
- *error_r = t_strdup_printf("%s backend can't be used with SIS",
- parent_name);
- return -1;
- }
- return 0;
-}
-
static void fs_sis_free(struct fs *_fs)
{
struct sis_fs *fs = SIS_FS(_fs);
.v = {
.alloc = fs_sis_alloc,
.init = fs_sis_init,
- .legacy_init = fs_sis_legacy_init,
.deinit = NULL,
.free = fs_sis_free,
.get_properties = fs_wrapper_get_properties,
return 0;
}
-static int
-fs_test_legacy_init(struct fs *_fs ATTR_UNUSED, const char *args ATTR_UNUSED,
- const struct fs_parameters *params ATTR_UNUSED,
- const char **error_r ATTR_UNUSED)
-{
- return 0;
-}
-
static void fs_test_free(struct fs *_fs)
{
struct test_fs *fs = (struct test_fs *)_fs;
.v = {
.alloc = fs_test_alloc,
.init = fs_test_init,
- .legacy_init = fs_test_legacy_init,
.deinit = NULL,
.free = fs_test_free,
.get_properties = fs_test_get_properties,