From 98504523009232432d9ddc78a302d7bc84de5b4a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 17 Oct 2024 23:11:16 +0200 Subject: [PATCH] config: use dm_config_parse_only_section --- lib/config/config.c | 9 ++++++--- lib/config/config.h | 2 +- lib/format_text/import.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/config/config.c b/lib/config/config.c index 9f4fb77a7..fb5039813 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -483,7 +483,7 @@ int override_config_tree_from_profile(struct cmd_context *cmd, int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason, off_t offset, size_t size, off_t offset2, size_t size2, checksum_fn_t checksum_fn, uint32_t checksum, - int checksum_only, int no_dup_node_check) + int checksum_only, int no_dup_node_check, int only_pv_summary) { char namebuf[NAME_LEN + 1] __attribute__((aligned(8))); int namelen = 0; @@ -573,7 +573,10 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r if (!checksum_only) { fe = fb + size + size2; if (no_dup_node_check) { - if (!dm_config_parse_without_dup_node_check(cft, fb, fe)) + if (only_pv_summary) { + if (!dm_config_parse_only_section(cft, fb, fe, "physical_volumes")) + goto_out; + } else if (!dm_config_parse_without_dup_node_check(cft, fb, fe)) goto_out; } else { if (!dm_config_parse(cft, fb, fe)) @@ -635,7 +638,7 @@ int config_file_read_from_file(struct dm_config_tree *cft) cf->dev = &fake_dev; r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0, - (checksum_fn_t) NULL, 0, 0, 0); + (checksum_fn_t) NULL, 0, 0, 0, 0); free((void*)alias->str); free((void*)alias); diff --git a/lib/config/config.h b/lib/config/config.h index 550763da5..5cf17649a 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -243,7 +243,7 @@ struct dm_config_tree *config_open(config_source_t source, const char *filename, int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_reason_t reason, off_t offset, size_t size, off_t offset2, size_t size2, checksum_fn_t checksum_fn, uint32_t checksum, - int skip_parse, int no_dup_node_check); + int skip_parse, int no_dup_node_check, int only_pv_summary); int config_file_read_from_file(struct dm_config_tree *cft); struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source, struct cmd_context *cmd); diff --git a/lib/format_text/import.c b/lib/format_text/import.c index fa0a6c2fd..0ab9c1ab0 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -61,7 +61,7 @@ int text_read_metadata_summary(const struct format_type *fmt, if (!config_file_read_fd(cft, dev, reason, offset, size, offset2, size2, checksum_fn, vgsummary->mda_checksum, - checksum_only, 1)) { + checksum_only, 1, 1)) { log_warn("WARNING: invalid metadata text from %s at %llu.", dev_name(dev), (unsigned long long)offset); goto out; @@ -156,7 +156,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid, if (!config_file_read_fd(cft, dev, MDA_CONTENT_REASON(primary_mda), offset, size, offset2, size2, checksum_fn, checksum, - skip_parse, 1)) { + skip_parse, 1, 0)) { log_warn("WARNING: couldn't read volume group metadata from %s.", dev_name(dev)); goto out; }