]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs: Remove support for legacy_init() from fs drivers
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 24 Aug 2023 22:11:53 +0000 (18:11 -0400)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:01 +0000 (10:40 +0200)
src/lib-fs/fs-dict.c
src/lib-fs/fs-metawrap.c
src/lib-fs/fs-posix.c
src/lib-fs/fs-randomfail.c
src/lib-fs/fs-sis-queue.c
src/lib-fs/fs-sis.c
src/lib-fs/fs-test.c

index 415b816f3c2bd0b72430d19b56a40f96d15293cd..f29696ec9d9e7a8980e0a36ef3cb71c87ad9bac2 100644 (file)
@@ -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,
index f7b8bcf02d02e31f2ec9e1071757b5bb2cc9ed23..8d0084e5c7d784e5c5b91773127f3dc333a657fb 100644 (file)
@@ -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,
index 27f9498a23a83479e2583747eb24e2b9bafe665e..4097151bb5cfd9bd7ee9a13abc4112424d02ac79 100644 (file)
@@ -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,
index 8379c49a1ebe3f93d76be44a0922d0dbd891ff0d..7030d9b285a579939014c8c8ea0e23f3517127aa 100644 (file)
@@ -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,
index 4f1dd303c081a4683240ba30b4e07ec36fc36302..304e96aa142092a8a0423b909e59a29030d38344 100644 (file)
@@ -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;
-
-       /* <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);
@@ -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,
index 00d14e9297baaca5705701c20e26aa48d65ddca2..b125d0028c484b87edda268f2f87c9fffcfadb9a 100644 (file)
@@ -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,
index 807329b2b9a66113605bc49c0a9d66156e3f0544..4e3be5e119ec37637b62d8013ba15b7d8f2b1f5e 100644 (file)
@@ -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,