From effafa8fc8d0b1326bd9f7061763f9f974dfaa5a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 2 May 2024 20:52:40 +0200 Subject: [PATCH] const: _ops text handler Making sure these structures ends in '.data.rel.ro' section. (instead of plain '.data' section). --- lib/format_text/format-text.c | 11 ++++------- lib/format_text/layout.h | 4 ++-- lib/metadata/metadata-exported.h | 3 +-- lib/metadata/metadata.h | 3 +-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 6bacc1d44..1fcb51875 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1958,7 +1958,7 @@ static void _text_destroy(struct format_type *fmt) free(fmt); } -static struct metadata_area_ops _metadata_text_file_ops = { +static const struct metadata_area_ops _metadata_text_file_ops = { .vg_read = _vg_read_file, .vg_read_precommit = _vg_read_precommit_file, .vg_write = _vg_write_file, @@ -1966,14 +1966,14 @@ static struct metadata_area_ops _metadata_text_file_ops = { .vg_commit = _vg_commit_file }; -static struct metadata_area_ops _metadata_text_file_backup_ops = { +static const struct metadata_area_ops _metadata_text_file_backup_ops = { .vg_read = _vg_read_file, .vg_write = _vg_write_file, .vg_remove = _vg_remove_file, .vg_commit = _vg_commit_file_backup }; -static struct metadata_area_ops _metadata_text_raw_ops = { +static const struct metadata_area_ops _metadata_text_raw_ops = { .vg_read = _vg_read_raw, .vg_read_precommit = _vg_read_precommit_raw, .vg_write = _vg_write_raw, @@ -2571,7 +2571,7 @@ static struct format_instance *_text_create_text_instance(const struct format_ty return fid; } -static struct format_handler _text_handler = { +static const struct format_handler _text_handler = { .pv_initialise = _text_pv_initialise, .pv_setup = _text_pv_setup, .pv_add_metadata_area = _text_pv_add_metadata_area, @@ -2618,9 +2618,6 @@ struct format_type *create_text_format(struct cmd_context *cmd) mda_lists->raw_ops = &_metadata_text_raw_ops; fmt->private = (void *) mda_lists; - dm_list_init(&fmt->mda_ops); - dm_list_add(&fmt->mda_ops, &_metadata_text_raw_ops.list); - if (!(fmt->labeller = text_labeller_create(fmt))) { log_error("Couldn't create text label handler."); goto bad; diff --git a/lib/format_text/layout.h b/lib/format_text/layout.h index df7ed3a78..d3b4e6119 100644 --- a/lib/format_text/layout.h +++ b/lib/format_text/layout.h @@ -85,8 +85,8 @@ struct mda_header *raw_read_mda_header(const struct format_type *fmt, uint32_t *bad_fields); struct mda_lists { - struct metadata_area_ops *file_ops; - struct metadata_area_ops *raw_ops; + const struct metadata_area_ops *file_ops; + const struct metadata_area_ops *raw_ops; }; struct mda_context { diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index af9c3864b..f894aca26 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -372,8 +372,7 @@ struct labeller; struct format_type { struct dm_list list; struct cmd_context *cmd; - struct format_handler *ops; - struct dm_list mda_ops; /* List of permissible mda ops. */ + const struct format_handler *ops; struct labeller *labeller; const char *name; const char *alias; diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 3d470207f..f93cd263d 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -73,7 +73,6 @@ struct cached_vg_fmtdata; /* Per-format per-metadata area operations */ struct metadata_area_ops { - struct dm_list list; struct volume_group *(*vg_read) (struct cmd_context *cmd, struct format_instance * fi, const char *vg_name, @@ -183,7 +182,7 @@ struct metadata_area_ops { struct metadata_area { struct dm_list list; - struct metadata_area_ops *ops; + const struct metadata_area_ops *ops; void *metadata_locn; uint32_t status; uint64_t header_start; /* mda_header.start */