1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

config_file: remove unused code

config_file_read() is only used for regular files, not devices.
This commit is contained in:
David Teigland 2024-07-02 16:24:12 -05:00
parent 76bd678ce3
commit 57e9083c90
3 changed files with 29 additions and 34 deletions

View File

@ -265,7 +265,7 @@ struct dm_config_tree *config_file_open_and_read(const char *config_file,
} }
log_very_verbose("Loading config file: %s", config_file); log_very_verbose("Loading config file: %s", config_file);
if (!config_file_read(cft)) { if (!config_file_read_from_file(cft)) {
log_error("Failed to load config file %s", config_file); log_error("Failed to load config file %s", config_file);
goto bad; goto bad;
} }
@ -589,7 +589,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
return r; return r;
} }
int config_file_read(struct dm_config_tree *cft) int config_file_read_from_file(struct dm_config_tree *cft)
{ {
const char *filename = NULL; const char *filename = NULL;
struct config_source *cs = dm_config_get_custom(cft); struct config_source *cs = dm_config_get_custom(cft);
@ -597,7 +597,6 @@ int config_file_read(struct dm_config_tree *cft)
struct stat info; struct stat info;
struct device fake_dev = { 0 }; struct device fake_dev = { 0 };
struct dm_str_list *alias; struct dm_str_list *alias;
int free_fake = 0;
int fd; int fd;
int r; int r;
@ -610,10 +609,12 @@ int config_file_read(struct dm_config_tree *cft)
cf = cs->source.file; cf = cs->source.file;
if (cf->dev)
return_0;
/* fixme: get rid of fake dev and just /* fixme: get rid of fake dev and just
add separate code paths for files */ add separate code paths for files */
if (!cf->dev) {
if (!(alias = zalloc(sizeof(*alias)))) if (!(alias = zalloc(sizeof(*alias))))
return_0; return_0;
if (!(alias->str = strdup(filename))) { if (!(alias->str = strdup(filename))) {
@ -631,21 +632,15 @@ int config_file_read(struct dm_config_tree *cft)
return_0; return_0;
} }
fake_dev.fd = fd; fake_dev.fd = fd;
free_fake = 1;
cf->dev = &fake_dev; cf->dev = &fake_dev;
}
r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0, 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);
if (free_fake) {
free((void*)alias->str); free((void*)alias->str);
free((void*)alias); free((void*)alias);
close(fd); close(fd);
} else {
if (!dev_close(cf->dev))
stack;
}
cf->dev = NULL; cf->dev = NULL;
return r; return r;

View File

@ -244,7 +244,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
off_t offset, size_t size, off_t offset2, size_t size2, off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum, 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 config_file_read(struct dm_config_tree *cft); 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 dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source,
struct cmd_context *cmd); struct cmd_context *cmd);
int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec, int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec,

View File

@ -67,7 +67,7 @@ int text_read_metadata_summary(const struct format_type *fmt,
goto out; goto out;
} }
} else { } else {
if (!config_file_read(cft)) { if (!config_file_read_from_file(cft)) {
log_warn("WARNING: invalid metadata text from file."); log_warn("WARNING: invalid metadata text from file.");
goto out; goto out;
} }
@ -161,7 +161,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
goto out; goto out;
} }
} else { } else {
if (!config_file_read(cft)) { if (!config_file_read_from_file(cft)) {
log_warn("WARNING: couldn't read volume group metadata from file."); log_warn("WARNING: couldn't read volume group metadata from file.");
goto out; goto out;
} }