From: Timo Sirainen Date: Thu, 24 Aug 2023 22:11:53 +0000 (-0400) Subject: lib-fs: Remove support for legacy_init() from fs drivers X-Git-Tag: 2.4.0~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dd17e21528cdf00b191afa484ceb2fb923f29c7;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Remove support for legacy_init() from fs drivers --- diff --git a/src/lib-fs/fs-dict.c b/src/lib-fs/fs-dict.c index 415b816f3c..f29696ec9d 100644 --- a/src/lib-fs/fs-dict.c +++ b/src/lib-fs/fs-dict.c @@ -117,35 +117,6 @@ fs_dict_init(struct fs *_fs, const struct fs_parameters *params ATTR_UNUSED, 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; @@ -401,7 +372,6 @@ const struct fs fs_class_dict = { .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, diff --git a/src/lib-fs/fs-metawrap.c b/src/lib-fs/fs-metawrap.c index f7b8bcf02d..8d0084e5c7 100644 --- a/src/lib-fs/fs-metawrap.c +++ b/src/lib-fs/fs-metawrap.c @@ -57,35 +57,6 @@ fs_metawrap_init(struct fs *_fs, const struct fs_parameters *params, 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); @@ -513,7 +484,6 @@ const struct fs fs_class_metawrap = { .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, diff --git a/src/lib-fs/fs-posix.c b/src/lib-fs/fs-posix.c index 27f9498a23..4097151bb5 100644 --- a/src/lib-fs/fs-posix.c +++ b/src/lib-fs/fs-posix.c @@ -156,56 +156,6 @@ fs_posix_init(struct fs *_fs, const struct fs_parameters *params, 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); @@ -1070,7 +1020,6 @@ const struct fs fs_class_posix = { .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, diff --git a/src/lib-fs/fs-randomfail.c b/src/lib-fs/fs-randomfail.c index 8379c49a1e..7030d9b285 100644 --- a/src/lib-fs/fs-randomfail.c +++ b/src/lib-fs/fs-randomfail.c @@ -177,26 +177,6 @@ fs_randomfail_op_add(struct randomfail_fs *fs, const char *key, 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) @@ -221,45 +201,6 @@ fs_randomfail_init(struct fs *_fs, const struct fs_parameters *params, 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); @@ -583,7 +524,6 @@ const struct fs fs_class_randomfail = { .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, diff --git a/src/lib-fs/fs-sis-queue.c b/src/lib-fs/fs-sis-queue.c index 4f1dd303c0..304e96aa14 100644 --- a/src/lib-fs/fs-sis-queue.c +++ b/src/lib-fs/fs-sis-queue.c @@ -72,35 +72,6 @@ fs_sis_queue_init(struct fs *_fs, const struct fs_parameters *params, 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; - - /* :[:] */ - - 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); @@ -218,7 +189,6 @@ const struct fs fs_class_sis_queue = { .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, diff --git a/src/lib-fs/fs-sis.c b/src/lib-fs/fs-sis.c index 00d14e9297..b125d0028c 100644 --- a/src/lib-fs/fs-sis.c +++ b/src/lib-fs/fs-sis.c @@ -58,38 +58,6 @@ fs_sis_init(struct fs *_fs, const struct fs_parameters *params, 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); @@ -274,7 +242,6 @@ const struct fs fs_class_sis = { .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, diff --git a/src/lib-fs/fs-test.c b/src/lib-fs/fs-test.c index 807329b2b9..4e3be5e119 100644 --- a/src/lib-fs/fs-test.c +++ b/src/lib-fs/fs-test.c @@ -24,14 +24,6 @@ fs_test_init(struct fs *_fs ATTR_UNUSED, 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; @@ -416,7 +408,6 @@ const struct fs fs_class_test = { .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,